Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ class Validator {
* @private
*/
_validateNewlinesEOF() {
if (!this._settings.newline) {
if (this._settings.newline !== true) {
return;
}

Expand All @@ -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?
Expand Down Expand Up @@ -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';
Expand Down
23 changes: 23 additions & 0 deletions src/Validator.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down