diff --git a/src/Validator.js b/src/Validator.js index 5988561..b06821d 100644 --- a/src/Validator.js +++ b/src/Validator.js @@ -457,7 +457,7 @@ class Validator { * @private */ _validateNewlinesEOF() { - if (!this._settings.newline) { + if (this._settings.newline !== true) { return; } @@ -479,7 +479,7 @@ class Validator { * @private */ _validateTrailingspaces(line, index) { - if (this._settings.trailingspaces && typeof line === 'string') { + if (this._settings.trailingspaces === true && typeof line === 'string') { const matchSpaces = line.match(/\s*$/); // Is there a trailing whitespace? @@ -646,7 +646,7 @@ class Validator { * @private */ _validateEndOfLine() { - if (typeof this._settings.endOfLine === 'string') { + if (typeof this._settings.endOfLine === 'string' && this._settings.endOfLine !== 'unset') { const isEOL = (ch) => ch === '\r' || ch === '\n'; let desiredEOL = '\n'; diff --git a/src/Validator.test.js b/src/Validator.test.js index 3d22314..569f16d 100644 --- a/src/Validator.test.js +++ b/src/Validator.test.js @@ -416,6 +416,13 @@ describe('The validator', () => { }); }); + it('should pass when unset', () => { + const file = __fromFixtures('endofline.mixed.fixture'); + const validator = new Validator({endOfLine: 'unset'}); + validator.validate(file); + + expect(validator.getInvalidFiles()).toEqual({}); + }); }); describe('line feed', () => { @@ -939,6 +946,14 @@ describe('The validator', () => { }); }); + it('should pass when unset', () => { + const file = __fromFixtures('trailingspaces.invalid.fixture'); + const validator = new Validator({trailingspaces: 'unset'}); + validator.validate(file); + + const report = validator.getInvalidFiles() + expect(report).toEqual({}); + }); }); // Newline (at the end of file) @@ -993,6 +1008,14 @@ describe('The validator', () => { }); }); + it('should pass when unset', () => { + const file = __fromFixtures('newlines.endoffile.invalid.less.fixture'); + const validator = new Validator({newline: 'unset'}); + validator.validate(file); + + const report = validator.getInvalidFiles() + expect(report).toEqual({}); + }); }); // Newlines maximum