Skip to content

Commit ed8a754

Browse files
authored
Merge pull request #3 from not-an-aardvark/support-eslint-4.4
Fix: support ESLint ^4.4.0
2 parents c6fb10f + 85fa282 commit ed8a754

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ node_js:
88

99
env:
1010
- ESLINT_VERSION=3
11+
- ESLINT_VERSION=4.3
1112
- ESLINT_VERSION=4
1213

1314
cache:

lib/rules/no-unused-disable.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,13 @@ module.exports = {
2828
},
2929

3030
create(context) {
31-
const originalReport = context.eslint.report
31+
const linter = context.eslint || context._linter
32+
const originalReport = linter.report
3233
const sourceCode = context.getSourceCode()
3334
const disabledArea = DisabledArea.get(sourceCode)
3435

3536
// Override `report` method to mark disabled-area as reported.
36-
context.eslint.report = function(ruleId, _severity, node, locationArg) {
37+
linter.report = function(ruleId, _severity, node, locationArg) {
3738
const location = (typeof locationArg === "string")
3839
? node.loc.start
3940
: locationArg.start || locationArg
@@ -64,14 +65,17 @@ module.exports = {
6465
}
6566

6667
// Restore
67-
context.eslint.report = originalReport
68+
linter.report = originalReport
6869
}
6970

7071
return {
7172
Program() {
7273
// Ensure that this listener is the last in `Program:exit` listeners
7374
// even if this rule was initialized before other rules.
74-
context.eslint.on("Program:exit", report)
75+
linter.on("Program:exit", report)
76+
},
77+
"Program:exit"() {
78+
// Ensure that at least one Program:exit listener exists so that the report listener will be called.
7579
},
7680
}
7781
},

tests/lib/rules/no-unused-disable.js

+13
Original file line numberDiff line numberDiff line change
@@ -313,5 +313,18 @@ var a = b
313313
},
314314
],
315315
},
316+
{
317+
code: "/* eslint new-parens:error*/ /*eslint-disable new-parens*/",
318+
errors: [
319+
{
320+
message: "'new-parens' rule is disabled but never reported.",
321+
line: 1,
322+
column: 47,
323+
endLine: 1,
324+
endColumn: 57,
325+
},
326+
],
327+
},
328+
316329
],
317330
})

0 commit comments

Comments
 (0)