Skip to content

Commit e7d9900

Browse files
committed
Fix: no-unused-disable false positive
1 parent b403abd commit e7d9900

File tree

2 files changed

+11
-15
lines changed

2 files changed

+11
-15
lines changed

lib/disabled-area.js

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,6 @@ function lte(a, b) {
2525
return a.line < b.line || (a.line === b.line && a.column <= b.column)
2626
}
2727

28-
/**
29-
* Checks `a` is less than `b`.
30-
*
31-
* @param {{line: number, column: number}} a - A location to compare.
32-
* @param {{line: number, column: number}} b - Another location to compare.
33-
* @returns {boolean} `true` if `a` is less than `b`.
34-
* @private
35-
*/
36-
function lt(a, b) {
37-
return a.line < b.line || (a.line === b.line && a.column < b.column)
38-
}
39-
4028
//------------------------------------------------------------------------------
4129
// Exports
4230
//------------------------------------------------------------------------------
@@ -182,9 +170,6 @@ module.exports = class DisabledArea {
182170
for (let i = this.areas.length - 1; i >= 0; --i) {
183171
const area = this.areas[i]
184172

185-
if (lt(location, area.start)) {
186-
break
187-
}
188173
if ((area.ruleId === null || area.ruleId === ruleId) &&
189174
lte(area.start, location) &&
190175
(area.end === null || lte(location, area.end))

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,17 @@ var a = b
5656
/*eslint-disable no-undef,no-unused-vars*/
5757
var a = b
5858
/*eslint-enable no-undef*/`,
59+
60+
`
61+
/*eslint no-shadow:error */
62+
var foo = 1
63+
function bar() {
64+
var foo = 2 //eslint-disable-line no-shadow
65+
}
66+
function baz() {
67+
var foo = 3 //eslint-disable-line no-shadow
68+
}
69+
`,
5970
],
6071
invalid: [
6172
{

0 commit comments

Comments
 (0)