diff --git a/Build/Scripts/lint.sh b/Build/Scripts/lint.sh
index 7ba2a61..496637e 100755
--- a/Build/Scripts/lint.sh
+++ b/Build/Scripts/lint.sh
@@ -1,3 +1,3 @@
#!/usr/bin/env bash
-xo --ignore=Build/TestFiles/ValidationProcessor/*.js && yarn lint:self
+xo --ignore=Build/TestFiles/{ValidationProcessor,DisablingRules}/*.js && yarn lint:self
diff --git a/Build/TestFiles/DisablingRules/disable.html b/Build/TestFiles/DisablingRules/disable.html
new file mode 100644
index 0000000..f7b6bf1
--- /dev/null
+++ b/Build/TestFiles/DisablingRules/disable.html
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Build/TestFiles/DisablingRules/disable.js b/Build/TestFiles/DisablingRules/disable.js
new file mode 100644
index 0000000..e6eeab4
--- /dev/null
+++ b/Build/TestFiles/DisablingRules/disable.js
@@ -0,0 +1,3 @@
+const someFunc = () => {
+ return 'WRONG INDENDATION'; // editorconfig-disable-line
+};
diff --git a/README.md b/README.md
index ad589c7..ed29a99 100644
--- a/README.md
+++ b/README.md
@@ -132,6 +132,18 @@ available options:
will print all files which are checked to stdout
```
+### 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:
diff --git a/package.json b/package.json
index 07ce649..07667c3 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "editorconfig-checker",
- "version": "1.1.5",
+ "version": "1.2.0",
"description": "",
"main": "src/index.js",
"bin": {
diff --git a/src/validation/validation-process.test.js b/src/validation/validation-process.test.js
index aaa33c5..bb7feae 100644
--- a/src/validation/validation-process.test.js
+++ b/src/validation/validation-process.test.js
@@ -56,3 +56,26 @@ test(`should return an integer greater 0 for an invalid file`, () => {
expect(validateFile(filePath, editorconfig).length).toEqual(1);
});
+
+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);
+});
diff --git a/src/validation/validation-processor.js b/src/validation/validation-processor.js
index d6c4656..411301c 100644
--- a/src/validation/validation-processor.js
+++ b/src/validation/validation-processor.js
@@ -13,6 +13,10 @@ const validateFile = (filePath, editorconfig) => {
const fileContent = fs.readFileSync(filePath).toString();
let fileContentArray = [];
+ const isLineDisabled = line => {
+ return /editorconfig-disable-line/.test(line);
+ };
+
if (editorconfig.end_of_line) {
fileContentArray = fileContent.split(getEndOfLineChar(editorconfig.end_of_line));
} else {
@@ -21,9 +25,11 @@ const validateFile = (filePath, editorconfig) => {
fileContentArray.forEach((line, lineNumber) => {
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));
+ }
});
errors.push(validateEndOfLine(fileContent, editorconfig));
diff --git a/yarn.lock b/yarn.lock
index bddf94c..107d47b 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -5395,9 +5395,9 @@ xo-init@^0.7.0:
the-argv "^1.0.0"
write-pkg "^3.1.0"
-xo@^0.20.2:
- version "0.20.2"
- resolved "https://registry.yarnpkg.com/xo/-/xo-0.20.2.tgz#fcc6acdac5a14a6a788d448046a7a2fb01f57f4d"
+xo@^0.20.0:
+ version "0.20.3"
+ resolved "https://registry.yarnpkg.com/xo/-/xo-0.20.3.tgz#6fb1597b5e361fd561535bbf84cf97eefaac5d80"
dependencies:
arrify "^1.0.1"
debug "^3.1.0"