Skip to content

Commit f985ba0

Browse files
authored
fix: address ci failures (#578)
* fix: fix type errors in rules * fix: address incompat between eslint-scope and eslint types * chore: update eslint packages * test: add console log to try and triage CI failures * chore: update typescript-eslint * test: correct projectService value * build: pin typescript-eslint
1 parent 61e59ca commit f985ba0

File tree

7 files changed

+569
-20
lines changed

7 files changed

+569
-20
lines changed

lib/rules/no-property-in-node.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { Rule } from 'eslint';
2+
import type { BinaryExpression } from 'estree';
23
import type { Type } from 'typescript';
34

45
const defaultTypedNodeSourceFileTesters = [
@@ -90,7 +91,7 @@ const rule: Rule.RuleModule = {
9091
];
9192

9293
return {
93-
'BinaryExpression[operator=in]'(node) {
94+
'BinaryExpression[operator=in]'(node: BinaryExpression) {
9495
// TODO: Switch this to ESLintUtils.getParserServices with typescript-eslint@>=6
9596
// https://github.com/eslint-community/eslint-plugin-eslint-plugin/issues/269
9697
const services = context.sourceCode.parserServices;

lib/rules/prefer-replace-text.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @author 薛定谔的猫<hh_2013@foxmail.com>
44
*/
55
import type { Rule } from 'eslint';
6-
import type { Identifier, Node } from 'estree';
6+
import type { CallExpression, Identifier, Node } from 'estree';
77

88
import type { FunctionInfo } from '../types.ts';
99
import {
@@ -70,17 +70,18 @@ const rule: Rule.RuleModule = {
7070
},
7171

7272
// Checks the replaceTextRange arguments.
73-
'CallExpression[arguments.length=2]'(node) {
73+
'CallExpression[arguments.length=2]'(node: CallExpression) {
7474
if (
7575
funcInfo.shouldCheck &&
7676
node.callee.type === 'MemberExpression' &&
77+
node.callee.property.type === 'Identifier' &&
7778
node.callee.property.name === 'replaceTextRange'
7879
) {
7980
const arg = node.arguments[0];
8081
const isIdenticalNodeRange =
8182
arg.type === 'ArrayExpression' &&
82-
arg.elements[0].type === 'MemberExpression' &&
83-
arg.elements[1].type === 'MemberExpression' &&
83+
arg.elements[0]?.type === 'MemberExpression' &&
84+
arg.elements[1]?.type === 'MemberExpression' &&
8485
sourceCode.getText(arg.elements[0].object) ===
8586
sourceCode.getText(arg.elements[1].object);
8687
if (isIdenticalNodeRange) {

package.json

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,27 +54,28 @@
5454
"@commitlint/types": "^19.8.1",
5555
"@eslint-community/eslint-plugin-eslint-comments": "^4.3.0",
5656
"@eslint/eslintrc": "^3.0.2",
57-
"@eslint/js": "^9.31.0",
57+
"@eslint/js": "^9.39.1",
5858
"@types/eslint-plugin-markdown": "^2.0.2",
59-
"@types/eslint-scope": "^8.3.0",
6059
"@types/espree": "^10.1.0",
60+
"@types/esrecurse": "^4.3.1",
6161
"@types/estraverse": "^5.1.7",
6262
"@types/estree": "^1.0.8",
6363
"@types/lodash": "^4.17.18",
6464
"@types/node": "^20.19.23",
65-
"@typescript-eslint/parser": "^8.39.0",
66-
"@typescript-eslint/utils": "^8.39.0",
65+
"@typescript-eslint/parser": "8.47.0",
66+
"@typescript-eslint/utils": "8.47.0",
6767
"@vitest/coverage-istanbul": "^3.2.4",
68-
"eslint": "^9.31.0",
68+
"eslint": "^9.39.1",
6969
"eslint-config-not-an-aardvark": "^2.1.0",
7070
"eslint-config-prettier": "^10.1.8",
7171
"eslint-doc-generator": "^2.2.2",
7272
"eslint-plugin-markdown": "^5.1.0",
7373
"eslint-plugin-n": "^17.21.0",
7474
"eslint-plugin-unicorn": "^56.0.1",
7575
"eslint-remote-tester": "^4.0.3",
76-
"eslint-scope": "^8.0.1",
77-
"espree": "^10.0.1",
76+
"eslint-scope": "^9.0.0",
77+
"eslint-visitor-keys": "^5.0.0",
78+
"espree": "^11.0.0",
7879
"husky": "^9.1.7",
7980
"jiti": "^2.5.1",
8081
"lodash": "^4.17.21",
@@ -84,7 +85,7 @@
8485
"prettier": "3.6.2",
8586
"tsdown": "^0.13.3",
8687
"typescript": "^5.9.2",
87-
"typescript-eslint": "^8.39.0",
88+
"typescript-eslint": "8.47.0",
8889
"vitest": "^3.2.4"
8990
},
9091
"peerDependencies": {

tests/lib/rules/no-property-in-node.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ const ruleTester = new RuleTester({
99
languageOptions: {
1010
parser,
1111
parserOptions: {
12-
projectService: {
13-
defaultProject: 'tsconfig.json',
14-
},
12+
projectService: true,
1513
tsconfigRootDir: path.join(dirname, '../fixtures'),
1614
},
1715
},

tests/lib/utils.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,10 @@ describe('utils', () => {
827827
if (typeof caseInfo === 'object' && caseInfo !== null) {
828828
// Object-style test case used when we need to specify additional information for this test case.
829829
assert.strictEqual(
830-
utils.getKeyName(caseInfo.getNode(ast), scopeManager.globalScope),
830+
utils.getKeyName(
831+
caseInfo.getNode(ast),
832+
scopeManager.globalScope ?? undefined,
833+
),
831834
caseInfo.result,
832835
);
833836

@@ -846,7 +849,7 @@ describe('utils', () => {
846849
assert.strictEqual(
847850
utils.getKeyName(
848851
expression.properties[0],
849-
scopeManager.globalScope,
852+
scopeManager.globalScope ?? undefined,
850853
),
851854
caseInfo,
852855
);

tsconfig.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@
1515
"forceConsistentCasingInFileNames": true,
1616
"rewriteRelativeImportExtensions": true,
1717
"paths": {
18-
"eslint-plugin-eslint-plugin": ["./lib/index.ts"]
18+
"eslint-plugin-eslint-plugin": ["./lib/index.ts"],
19+
"eslint-scope": ["./types/eslint-scope.d.ts"]
1920
},
20-
"types": ["eslint-scope", "espree", "estree", "lodash", "node"]
21+
"types": ["espree", "esrecurse", "estree", "lodash", "node"]
2122
},
2223
"include": ["lib/**/*", "tests/**/*", "types/**/*"]
2324
}

0 commit comments

Comments
 (0)