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

Utilize warnIgnored instead of filtering messages #915

Merged
merged 1 commit into from
May 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/worker-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ export function getCLIEngineOptions(type, config, rules, filePath, fileDir, give
const cliEngineConfig = {
rules,
ignore: !config.disableEslintIgnore,
warnIgnored: false,
fix: type === 'fix'
}

Expand Down
22 changes: 2 additions & 20 deletions src/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,6 @@ import isConfigAtHomeRoot from './is-config-at-home-root'

process.title = 'linter-eslint helper'

const ignoredMessages = [
// V1
'File ignored because of your .eslintignore file. Use --no-ignore to override.',
// V2
'File ignored because of a matching ignore pattern. Use --no-ignore to override.',
// V2.11.1
'File ignored because of a matching ignore pattern. Use "--no-ignore" to override.',
// supress warning that the current file is ignored by eslint by default
'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.',
]

function shouldBeReported(problem) {
return !ignoredMessages.includes(problem.message)
}

function lintJob({ cliEngineOptions, contents, eslint, filePath }) {
const cliEngine = new eslint.CLIEngine(cliEngineOptions)
return cliEngine.executeOnText(contents, filePath)
Expand All @@ -37,7 +19,7 @@ function fixJob({ cliEngineOptions, contents, eslint, filePath }) {

eslint.CLIEngine.outputFixes(report)

if (!report.results.length || !report.results[0].messages.filter(shouldBeReported).length) {
if (!report.results.length || !report.results[0].messages.length) {
return 'Linter-ESLint: Fix complete.'
}
return 'Linter-ESLint: Fix attempt complete, but linting errors remain.'
Expand Down Expand Up @@ -68,7 +50,7 @@ module.exports = async function () {
let response
if (type === 'lint') {
const report = lintJob({ cliEngineOptions, contents, eslint, filePath })
response = report.results.length ? report.results[0].messages.filter(shouldBeReported) : []
response = report.results.length ? report.results[0].messages : []
} else if (type === 'fix') {
response = fixJob({ cliEngineOptions, contents, eslint, filePath })
} else if (type === 'debug') {
Expand Down