Skip to content

Commit 4613e82

Browse files
authored
test: test under ESLint v10 (#663)
Fixes #655. **Title:** chore: add ESLint 10 CI testing and remove deprecated `type` from test errors ## Summary - Removed the `type` property from RuleTester error objects across 21 test files (168 instances). ESLint 10 throws if `type` is present in invalid test case errors. This is backward-compatible with ESLint 8/9 since `type` was always optional. - Added a CI step to run unit tests against ESLint 10 on Node 20.x, following the same pattern used historically when adding ESLint 8 support. - Bumped `@typescript-eslint/parser` to 8.54.0 for ESLint 10 compatibility (`ScopeManager#addGlobals`). ## Test plan - All 1353 tests pass on both ESLint 9 and ESLint 10.
1 parent 6031514 commit 4613e82

33 files changed

+241
-791
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ jobs:
3030
- run: npm ci
3131
- run: npm run test:unit
3232

33+
- name: Test with ESLint v10
34+
if: matrix.node-version == '20.x'
35+
run: npm install --save-dev eslint@10 && npm run test:unit
36+
3337
- name: Coveralls
3438
uses: coverallsapp/github-action@v2
3539
with:

lib/rules/no-arrow-tests.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ module.exports = {
168168
* @returns {boolean}
169169
*/
170170
function isPropertyInModule(propertyNode) {
171-
return (
171+
return !!(
172172
propertyNode &&
173173
propertyNode.parent &&
174174
propertyNode.parent.type === "ObjectExpression" &&

lib/rules/no-assert-equal.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ module.exports = {
164164
* @returns {boolean}
165165
*/
166166
function isModuleHookCallback(propertyNode) {
167-
return (
167+
return !!(
168168
propertyNode.parent &&
169169
propertyNode.parent.type === "Property" &&
170170
utils.isModuleHookPropertyKey(propertyNode.parent.key) &&
@@ -240,7 +240,8 @@ module.exports = {
240240
/* istanbul ignore next: deprecated code paths only followed by old eslint versions */
241241
const scope = sourceCode.getScope
242242
? sourceCode.getScope(node)
243-
: context.getScope();
243+
: // @ts-expect-error -- removed in ESLint 10, but needed for ESLint 8 compat
244+
context.getScope();
244245

245246
const tracker = new ReferenceTracker(scope);
246247
const traceMap = { equal: { [ReferenceTracker.CALL]: true } };

lib/rules/no-conditional-assertions.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ module.exports = {
7676
* @param {import('eslint').Rule.Node} assertNode
7777
*/
7878
function checkAndReport(assertNode) {
79+
/** @type {import('eslint').Rule.Node | null} */
7980
let currentNode = assertNode;
8081

8182
while (
@@ -86,7 +87,7 @@ module.exports = {
8687
currentNode = currentNode.parent;
8788
}
8889

89-
if (CONDITIONAL_NODE_TYPES.has(currentNode.type)) {
90+
if (currentNode && CONDITIONAL_NODE_TYPES.has(currentNode.type)) {
9091
context.report({
9192
node: assertNode,
9293
messageId: "noAssertionInsideConditional",

lib/rules/no-global-assertions.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ module.exports = {
4040
/* istanbul ignore next: deprecated code paths only followed by old eslint versions */
4141
const scope = sourceCode.getScope
4242
? sourceCode.getScope(node)
43-
: context.getScope();
43+
: // @ts-expect-error -- removed in ESLint 10, but needed for ESLint 8 compat
44+
context.getScope();
4445

4546
const tracker = new ReferenceTracker(scope);
4647
/** @type {Record<string, { [ReferenceTracker.CALL]: boolean }>} */

lib/rules/no-global-expect.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ module.exports = {
3838
/* istanbul ignore next: deprecated code paths only followed by old eslint versions */
3939
const scope = sourceCode.getScope
4040
? sourceCode.getScope(node)
41-
: context.getScope();
41+
: // @ts-expect-error -- removed in ESLint 10, but needed for ESLint 8 compat
42+
context.getScope();
4243

4344
const tracker = new ReferenceTracker(scope);
4445
const traceMap = { expect: { [ReferenceTracker.CALL]: true } };

lib/rules/no-global-module-test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ module.exports = {
3838
/* istanbul ignore next: deprecated code paths only followed by old eslint versions */
3939
const scope = sourceCode.getScope
4040
? sourceCode.getScope(node)
41-
: context.getScope();
41+
: // @ts-expect-error -- removed in ESLint 10, but needed for ESLint 8 compat
42+
context.getScope();
4243

4344
const tracker = new ReferenceTracker(scope);
4445
const traceMap = {

lib/rules/no-global-stop-start.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ module.exports = {
4040
/* istanbul ignore next: deprecated code paths only followed by old eslint versions */
4141
const scope = sourceCode.getScope
4242
? sourceCode.getScope(node)
43-
: context.getScope();
43+
: // @ts-expect-error -- removed in ESLint 10, but needed for ESLint 8 compat
44+
context.getScope();
4445

4546
const tracker = new ReferenceTracker(scope);
4647
const traceMap = {

lib/rules/no-hooks-from-ancestor-modules.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ module.exports = {
4747
* @returns {boolean}
4848
*/
4949
function isInModuleCallbackBody(callExpressionNode) {
50-
return (
50+
return !!(
5151
callExpressionNode &&
5252
callExpressionNode.parent &&
5353
callExpressionNode.parent.type === "ExpressionStatement" &&

lib/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ exports.isModule = function (calleeNode) {
221221
* @returns {boolean}
222222
*/
223223
exports.isInModule = function (propertyNode) {
224-
return (
224+
return !!(
225225
propertyNode &&
226226
propertyNode.parent && // ObjectExpression
227227
propertyNode.parent.parent && // CallExpression?

0 commit comments

Comments
 (0)