editorconfig-checker
Advanced tools
| some Readme with trailing whitespace - spaces | ||
| some Readme with trailing whitespace - tabs |
@@ -66,2 +66,25 @@ 'use strict'; | ||
| expect((0, _validationProcessor2.default)(filePath, editorconfig).length).toEqual(1); | ||
| }); | ||
| test('should return 0 if the false line is disabled', function () { | ||
| var filePath = process.cwd() + '/Build/TestFiles/DisablingRules/disable.js'; | ||
| var editorconfig = { | ||
| end_of_line: 'lf', // eslint-disable-line camelcase | ||
| indent_style: 'tab' // eslint-disable-line camelcase | ||
| }; | ||
| expect((0, _validationProcessor2.default)(filePath, editorconfig).length).toEqual(0); | ||
| }); | ||
| test('should return 0 if the false line is disabled and inside a HTML comment', function () { | ||
| var filePath = process.cwd() + '/Build/TestFiles/DisablingRules/disable.html'; | ||
| var editorconfig = { | ||
| end_of_line: 'lf', // eslint-disable-line camelcase | ||
| indent_style: 'space', // eslint-disable-line camelcase | ||
| indent_size: 4 // eslint-disable-line camelcase | ||
| }; | ||
| expect((0, _validationProcessor2.default)(filePath, editorconfig).length).toEqual(0); | ||
| }); |
@@ -42,2 +42,7 @@ 'use strict'; | ||
| var isLineDisabled = function isLineDisabled(line) { | ||
| return (/editorconfig-disable-line/.test(line) | ||
| ); | ||
| }; | ||
| if (editorconfig.end_of_line) { | ||
@@ -51,5 +56,7 @@ fileContentArray = fileContent.split((0, _lineEndingUtils2.default)(editorconfig.end_of_line)); | ||
| lineNumber++; | ||
| errors.push((0, _tabValidator2.default)(line, lineNumber, editorconfig)); | ||
| errors.push((0, _spaceValidator2.default)(line, lineNumber, editorconfig)); | ||
| errors.push((0, _trailingWhitespaceValidator2.default)(line, lineNumber, editorconfig)); | ||
| if (!isLineDisabled(line)) { | ||
| errors.push((0, _tabValidator2.default)(line, lineNumber, editorconfig)); | ||
| errors.push((0, _spaceValidator2.default)(line, lineNumber, editorconfig)); | ||
| errors.push((0, _trailingWhitespaceValidator2.default)(line, lineNumber, editorconfig)); | ||
| } | ||
| }); | ||
@@ -56,0 +63,0 @@ |
+1
-1
| { | ||
| "name": "editorconfig-checker", | ||
| "version": "1.1.5", | ||
| "version": "1.2.0", | ||
| "description": "", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
+12
-0
@@ -135,3 +135,15 @@ # editorconfig-checker | ||
| ### Disabling single lines | ||
| It is possible to disable single lines with placing a comment - or theoretically | ||
| any other string which includes `editorconfig-disable-line` on that line. | ||
| It is planned in future releases to also have the possibility to disable single | ||
| rules and also blocks of codes. | ||
| Example as it is working now: | ||
| ``` | ||
| const x = 'this constant is indented false' // editorconfig-disable-line | ||
| ``` | ||
| ## Default ignores: | ||
@@ -138,0 +150,0 @@ |
@@ -59,1 +59,24 @@ import validateFile from './validation-processor'; // eslint-disable-line no-unused-vars | ||
| }); | ||
| test(`should return 0 if the false line is disabled`, () => { | ||
| const filePath = `${process.cwd()}/Build/TestFiles/DisablingRules/disable.js`; | ||
| const editorconfig = { | ||
| end_of_line: 'lf', // eslint-disable-line camelcase | ||
| indent_style: 'tab' // eslint-disable-line camelcase | ||
| }; | ||
| expect(validateFile(filePath, editorconfig).length).toEqual(0); | ||
| }); | ||
| test(`should return 0 if the false line is disabled and inside a HTML comment`, () => { | ||
| const filePath = `${process.cwd()}/Build/TestFiles/DisablingRules/disable.html`; | ||
| const editorconfig = { | ||
| end_of_line: 'lf', // eslint-disable-line camelcase | ||
| indent_style: 'space', // eslint-disable-line camelcase | ||
| indent_size: 4 // eslint-disable-line camelcase | ||
| }; | ||
| expect(validateFile(filePath, editorconfig).length).toEqual(0); | ||
| }); |
@@ -16,2 +16,6 @@ import fs from 'fs'; | ||
| const isLineDisabled = line => { | ||
| return /editorconfig-disable-line/.test(line); | ||
| }; | ||
| if (editorconfig.end_of_line) { | ||
@@ -25,5 +29,7 @@ fileContentArray = fileContent.split(getEndOfLineChar(editorconfig.end_of_line)); | ||
| lineNumber++; | ||
| errors.push(validateTab(line, lineNumber, editorconfig)); | ||
| errors.push(validateSpaces(line, lineNumber, editorconfig)); | ||
| errors.push(validateTrailingWhitespace(line, lineNumber, editorconfig)); | ||
| if (!isLineDisabled(line)) { | ||
| errors.push(validateTab(line, lineNumber, editorconfig)); | ||
| errors.push(validateSpaces(line, lineNumber, editorconfig)); | ||
| errors.push(validateTrailingWhitespace(line, lineNumber, editorconfig)); | ||
| } | ||
| }); | ||
@@ -30,0 +36,0 @@ |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
99497
2.48%54
1.89%2366
1.94%185
6.94%