Skip to content

Commit

Permalink
feat: add support for eslint v9 (#478)
Browse files Browse the repository at this point in the history
  • Loading branch information
ota-meshi authored Jul 1, 2024
1 parent afbda82 commit 4dfc8a7
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ jobs:
node: [12.22.0, 12, 14.17.0, 14, 16.0.0, 16, 18, 20]
os: [ubuntu-latest]
include:
# ESLint v9
- eslint: 9
node: 20
os: ubuntu-latest
# On other platforms
- os: windows-latest
eslint: 8
Expand Down
31 changes: 28 additions & 3 deletions rules/no-multiple-resolved.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,22 @@ class CodePathInfo {
/** @type {Map<CodePathSegment, CodePathSegmentInfo>} */
this.segmentInfos = new Map()
this.resolvedCount = 0
/** @type {CodePathSegment[]} */
this.allSegments = []
/** @type {Set<CodePathSegment>} */
this.currentSegments = new Set()
}

/** @param {CodePathSegment} segment */
onSegmentEnter(segment) {
this.currentSegments.add(segment)
}

/** @param {CodePathSegment} segment */
onSegmentExit(segment) {
this.currentSegments.delete(segment)
}

getCurrentSegmentInfos() {
return this.path.currentSegments.map((segment) => {
return [...this.currentSegments].map((segment) => {
const info = this.segmentInfos.get(segment)
if (info) {
return info
Expand Down Expand Up @@ -434,6 +444,15 @@ module.exports = {
) {
lastThrowableExpression = node
},
/** @param {CodePathSegment} segment */
onCodePathSegmentStart(segment) {
codePathInfoStack[0].onSegmentEnter(segment)
},
/** @param {CodePathSegment} segment */
/* istanbul ignore next */ // It is not called in ESLint v7.
onUnreachableCodePathSegmentStart(segment) {
codePathInfoStack[0].onSegmentEnter(segment)
},
/**
* @param {CodePathSegment} segment
* @param {Node} node
Expand All @@ -453,6 +472,12 @@ module.exports = {
promiseCodePathContext.addResolvedTryBlockCodePathSegment(segment)
}
}
codePathInfoStack[0].onSegmentExit(segment)
},
/** @param {CodePathSegment} segment */
/* istanbul ignore next */ // It is not called in ESLint v7.
onUnreachableCodePathSegmentEnd(segment) {
codePathInfoStack[0].onSegmentExit(segment)
},
/** @type {Identifier} */
'CallExpression > Identifier.callee'(node) {
Expand Down

0 comments on commit 4dfc8a7

Please sign in to comment.