Skip to content
This repository was archived by the owner on Sep 28, 2020. It is now read-only.

Commit d4e5df6

Browse files
committed
Changed: a file that should be ignored doesn't trigger a warning
Close #44
1 parent 4345151 commit d4e5df6

File tree

4 files changed

+50
-36
lines changed

4 files changed

+50
-36
lines changed

Diff for: CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# 0.13.0 - 2015-06-14
2+
3+
- Changed: a file that should be ignored doesn't trigger a warning
4+
([#44](https://github.com/MoOx/eslint-loader/issues/44))
5+
16
# 0.12.0 - 2015-06-04
27

38
- Changed: upgrade to eslint 0.22.x

Diff for: index.js

+43-34
Original file line numberDiff line numberDiff line change
@@ -26,47 +26,56 @@ function lint(input, config, webpack, callback) {
2626
var res = engine.executeOnText(input, resourcePath)
2727
// executeOnText ensure we will have res.results[0] only
2828

29-
// quiet filter done now
30-
// eslint allow rules to be specified in the input between comments
31-
// so we can found warnings defined in the input itself
32-
if (res.warningCount && config.quiet) {
33-
res.warningCount = 0
34-
res.results[0].warningCount = 0
35-
res.results[0].messages = res.results[0].messages.filter(function(message) {
36-
return message.severity !== 1
37-
})
38-
}
29+
// skip ignored file warning
30+
if (!(
31+
res.warningCount === 1 &&
32+
res.results[0].messages[0] &&
33+
res.results[0].messages[0].message &&
34+
res.results[0].messages[0].message.indexOf(".eslintignore") > -1 &&
35+
res.results[0].messages[0].message.indexOf("--no-ignore") > -1
36+
)) {
37+
// quiet filter done now
38+
// eslint allow rules to be specified in the input between comments
39+
// so we can found warnings defined in the input itself
40+
if (res.warningCount && config.quiet) {
41+
res.warningCount = 0
42+
res.results[0].warningCount = 0
43+
res.results[0].messages = res.results[0].messages.filter(function(message) {
44+
return message.severity !== 1
45+
})
46+
}
3947

40-
if (res.errorCount || res.warningCount) {
41-
// add filename for each results so formatter can have relevant filename
42-
res.results.forEach(function(r) {
43-
r.filePath = webpack.resourcePath
44-
})
45-
var messages = config.formatter(res.results)
48+
if (res.errorCount || res.warningCount) {
49+
// add filename for each results so formatter can have relevant filename
50+
res.results.forEach(function(r) {
51+
r.filePath = webpack.resourcePath
52+
})
53+
var messages = config.formatter(res.results)
4654

47-
// default behavior: emit error only if we have errors
48-
var emitter = res.errorCount ? webpack.emitError : webpack.emitWarning
55+
// default behavior: emit error only if we have errors
56+
var emitter = res.errorCount ? webpack.emitError : webpack.emitWarning
4957

50-
// force emitError or emitWarning if user want this
51-
if (config.emitError) {
52-
emitter = webpack.emitError
53-
}
54-
else if (config.emitWarning) {
55-
emitter = webpack.emitWarning
56-
}
58+
// force emitError or emitWarning if user want this
59+
if (config.emitError) {
60+
emitter = webpack.emitError
61+
}
62+
else if (config.emitWarning) {
63+
emitter = webpack.emitWarning
64+
}
5765

58-
if (emitter) {
59-
emitter(messages)
60-
if (config.failOnError && res.errorCount) {
61-
throw new Error("Module failed because of a eslint error.")
66+
if (emitter) {
67+
emitter(messages)
68+
if (config.failOnError && res.errorCount) {
69+
throw new Error("Module failed because of a eslint error.")
70+
}
71+
else if (config.failOnWarning && res.warningCount) {
72+
throw new Error("Module failed because of a eslint warning.")
73+
}
6274
}
63-
else if (config.failOnWarning && res.warningCount) {
64-
throw new Error("Module failed because of a eslint warning.")
75+
else {
76+
throw new Error("Your module system doesn't support emitWarning. Update available? \n" + messages)
6577
}
6678
}
67-
else {
68-
throw new Error("Your module system doesn't support emitWarning. Update available? \n" + messages)
69-
}
7079
}
7180

7281
if (callback) {

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "eslint-loader",
3-
"version": "0.12.0",
3+
"version": "0.13.0",
44
"description": "eslint loader (for webpack)",
55
"keywords": [
66
"lint",

Diff for: test/eslintignore.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ test("eslint-loader ignores files present in .eslintignore", function(t) {
1818
function(err, stats) {
1919
if (err) {throw err}
2020

21-
t.ok(stats.hasWarnings(), "an ignored file gives a warning")
21+
t.notOk(stats.hasWarnings(), "an ignored doesn't give a warning")
2222
t.end()
2323
})
2424
})

0 commit comments

Comments
 (0)