diff --git a/Build/TestFiles/DisablingRules/disable-file.html b/Build/TestFiles/DisablingRules/disable-file.html
new file mode 100644
index 0000000..a45b17f
--- /dev/null
+++ b/Build/TestFiles/DisablingRules/disable-file.html
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+ stuff
+
+
diff --git a/Build/TestFiles/DisablingRules/disable-file.js b/Build/TestFiles/DisablingRules/disable-file.js
new file mode 100644
index 0000000..46336a5
--- /dev/null
+++ b/Build/TestFiles/DisablingRules/disable-file.js
@@ -0,0 +1,4 @@
+// editorconfig-disable-file
+const someFunc = () => {
+ return 'WRONG INDENDATION';
+};
diff --git a/Build/TestFiles/DisablingRules/disable.html b/Build/TestFiles/DisablingRules/disable-line.html
similarity index 100%
rename from Build/TestFiles/DisablingRules/disable.html
rename to Build/TestFiles/DisablingRules/disable-line.html
diff --git a/Build/TestFiles/DisablingRules/disable.js b/Build/TestFiles/DisablingRules/disable-line.js
similarity index 100%
rename from Build/TestFiles/DisablingRules/disable.js
rename to Build/TestFiles/DisablingRules/disable-line.js
diff --git a/README.md b/README.md
index 5e8425a..ae8e691 100644
--- a/README.md
+++ b/README.md
@@ -135,15 +135,28 @@ available options:
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
+ const x = 'this constant is indented false'; // editorconfig-disable-line
```
+### Disabling files
+
+It is possible to disable files with placing a comment - or theoretically
+any other string which includes `editorconfig-disable-file` on the *first line*.
+
+Example as it is working now:
+
+```
+// editorconfig-disable-file
+ const x = 'this constant is indented false';
+ ...
+ const y = 'everything is indented false';
+```
+
+
## Default ignores:
```
diff --git a/src/validation/validation-process.test.js b/src/validation/validation-process.test.js
index bb7feae..1e250f4 100644
--- a/src/validation/validation-process.test.js
+++ b/src/validation/validation-process.test.js
@@ -58,7 +58,7 @@ test(`should return an integer greater 0 for an invalid file`, () => {
});
test(`should return 0 if the false line is disabled`, () => {
- const filePath = `${process.cwd()}/Build/TestFiles/DisablingRules/disable.js`;
+ const filePath = `${process.cwd()}/Build/TestFiles/DisablingRules/disable-line.js`;
const editorconfig = {
end_of_line: 'lf', // eslint-disable-line camelcase
@@ -69,7 +69,30 @@ test(`should return 0 if the false line is disabled`, () => {
});
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 filePath = `${process.cwd()}/Build/TestFiles/DisablingRules/disable-line.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);
+});
+
+test(`should return 0 if the file is disabled`, () => {
+ const filePath = `${process.cwd()}/Build/TestFiles/DisablingRules/disable-file.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 file is disabled`, () => {
+ const filePath = `${process.cwd()}/Build/TestFiles/DisablingRules/disable-file.html`;
const editorconfig = {
end_of_line: 'lf', // eslint-disable-line camelcase
diff --git a/src/validation/validation-processor.js b/src/validation/validation-processor.js
index 411301c..ecfd83f 100644
--- a/src/validation/validation-processor.js
+++ b/src/validation/validation-processor.js
@@ -17,12 +17,20 @@ const validateFile = (filePath, editorconfig) => {
return /editorconfig-disable-line/.test(line);
};
+ const isFileDisabled = fileContentArray => {
+ return /editorconfig-disable-file/.test(fileContentArray[0]);
+ };
+
if (editorconfig.end_of_line) {
fileContentArray = fileContent.split(getEndOfLineChar(editorconfig.end_of_line));
} else {
fileContentArray = fileContent.split('\n');
}
+ if (isFileDisabled(fileContentArray)) {
+ return [];
+ }
+
fileContentArray.forEach((line, lineNumber) => {
lineNumber++;
if (!isLineDisabled(line)) {