Skip to content
This repository was archived by the owner on Aug 7, 2023. It is now read-only.

Commit b2c9f76

Browse files
Commit message ignored because of a matching ignore pattern
1 parent 8d366ca commit b2c9f76

File tree

3 files changed

+50
-11
lines changed

3 files changed

+50
-11
lines changed

lib/worker.js

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,20 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
2323

2424
process.title = 'linter-eslint helper';
2525

26+
const ignoredMessages = [
27+
// V1
28+
'File ignored because of your .eslintignore file. Use --no-ignore to override.',
29+
// V2
30+
'File ignored because of a matching ignore pattern. Use --no-ignore to override.',
31+
// V2.11.1
32+
'File ignored because of a matching ignore pattern. Use "--no-ignore" to override.',
33+
// supress warning that the current file is ignored by eslint by default
34+
'File ignored by default. Use a negated ignore pattern (like "--ignore-pattern \'!<relative' + '/path/to/filename>\'") to override.', 'File ignored by default. Use "--ignore-pattern \'!node_modules/*\'" to override.', 'File ignored by default. Use "--ignore-pattern \'!bower_components/*\'" to override.'];
35+
36+
function shouldBeReported(problem) {
37+
return !ignoredMessages.includes(problem.message);
38+
}
39+
2640
function lintJob(_ref) {
2741
let cliEngineOptions = _ref.cliEngineOptions,
2842
contents = _ref.contents,
@@ -36,15 +50,14 @@ function lintJob(_ref) {
3650

3751
function fixJob(_ref2) {
3852
let cliEngineOptions = _ref2.cliEngineOptions,
39-
contents = _ref2.contents,
4053
eslint = _ref2.eslint,
4154
filePath = _ref2.filePath;
4255

43-
const report = lintJob({ cliEngineOptions, contents, eslint, filePath });
56+
const report = lintJob({ cliEngineOptions, eslint, filePath });
4457

4558
eslint.CLIEngine.outputFixes(report);
4659

47-
if (!report.results.length || !report.results[0].messages.length) {
60+
if (!report.results.length || !report.results[0].messages.filter(shouldBeReported).length) {
4861
return 'Linter-ESLint: Fix complete.';
4962
}
5063
return 'Linter-ESLint: Fix attempt complete, but linting errors remain.';
@@ -74,9 +87,9 @@ function fixJob(_ref2) {
7487
job.response = [];
7588
} else if (type === 'lint') {
7689
const report = lintJob({ cliEngineOptions, contents, eslint, filePath });
77-
job.response = report.results.length ? report.results[0].messages : [];
90+
job.response = report.results.length ? report.results[0].messages.filter(shouldBeReported) : [];
7891
} else if (type === 'fix') {
79-
job.response = fixJob({ cliEngineOptions, contents, eslint, filePath });
92+
job.response = fixJob({ cliEngineOptions, eslint, filePath });
8093
} else if (type === 'debug') {
8194
const modulesDir = _path2.default.dirname((0, _atomLinter.findCached)(fileDir, 'node_modules/eslint') || '');
8295
job.response = Helpers.findESLintDirectory(modulesDir, config);

spec/linter-eslint-spec.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,13 +162,21 @@ describe('The eslint provider for Linter', () => {
162162
beforeEach(() => {
163163
atom.config.set('linter-eslint.disableEslintIgnore', false)
164164
})
165-
it('will not give warnings for the file', () => {
165+
it('will not give warnings when linting the file', () => {
166166
waitsForPromise(() =>
167167
atom.workspace.open(ignoredPath).then(editor =>
168168
lint(editor).then(messages => expect(messages.length).toBe(0))
169169
)
170170
)
171171
})
172+
173+
it('will not give warnings when autofixing the file', () => {
174+
waitsForPromise(() =>
175+
atom.workspace.open(ignoredPath).then(editor =>
176+
fix(editor).then(result => expect(result).toBe('Linter-ESLint: Fix complete.'))
177+
)
178+
)
179+
})
172180
})
173181

174182
describe('fixes errors', () => {

src/worker.js

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,24 @@ import { isConfigAtHomeRoot } from './is-config-at-home-root'
1010

1111
process.title = 'linter-eslint helper'
1212

13+
const ignoredMessages = [
14+
// V1
15+
'File ignored because of your .eslintignore file. Use --no-ignore to override.',
16+
// V2
17+
'File ignored because of a matching ignore pattern. Use --no-ignore to override.',
18+
// V2.11.1
19+
'File ignored because of a matching ignore pattern. Use "--no-ignore" to override.',
20+
// supress warning that the current file is ignored by eslint by default
21+
'File ignored by default. Use a negated ignore pattern (like "--ignore-pattern \'!<relative'
22+
+ '/path/to/filename>\'") to override.',
23+
'File ignored by default. Use "--ignore-pattern \'!node_modules/*\'" to override.',
24+
'File ignored by default. Use "--ignore-pattern \'!bower_components/*\'" to override.',
25+
]
26+
27+
function shouldBeReported(problem) {
28+
return !ignoredMessages.includes(problem.message)
29+
}
30+
1331
function lintJob({ cliEngineOptions, contents, eslint, filePath }) {
1432
const cliEngine = new eslint.CLIEngine(cliEngineOptions)
1533

@@ -18,12 +36,12 @@ function lintJob({ cliEngineOptions, contents, eslint, filePath }) {
1836
: cliEngine.executeOnFiles([filePath])
1937
}
2038

21-
function fixJob({ cliEngineOptions, contents, eslint, filePath }) {
22-
const report = lintJob({ cliEngineOptions, contents, eslint, filePath })
39+
function fixJob({ cliEngineOptions, eslint, filePath }) {
40+
const report = lintJob({ cliEngineOptions, eslint, filePath })
2341

2442
eslint.CLIEngine.outputFixes(report)
2543

26-
if (!report.results.length || !report.results[0].messages.length) {
44+
if (!report.results.length || !report.results[0].messages.filter(shouldBeReported).length) {
2745
return 'Linter-ESLint: Fix complete.'
2846
}
2947
return 'Linter-ESLint: Fix attempt complete, but linting errors remain.'
@@ -48,9 +66,9 @@ create().onRequest('job', ({ contents, type, config, filePath, projectPath, rule
4866
job.response = []
4967
} else if (type === 'lint') {
5068
const report = lintJob({ cliEngineOptions, contents, eslint, filePath })
51-
job.response = report.results.length ? report.results[0].messages : []
69+
job.response = report.results.length ? report.results[0].messages.filter(shouldBeReported) : []
5270
} else if (type === 'fix') {
53-
job.response = fixJob({ cliEngineOptions, contents, eslint, filePath })
71+
job.response = fixJob({ cliEngineOptions, eslint, filePath })
5472
} else if (type === 'debug') {
5573
const modulesDir = Path.dirname(findCached(fileDir, 'node_modules/eslint') || '')
5674
job.response = Helpers.findESLintDirectory(modulesDir, config)

0 commit comments

Comments
 (0)