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/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)) {