Skip to content

Commit b5561e4

Browse files
TylerVigariosindresorhus
andauthoredMay 3, 2024··
Target ESLint 9 (#357)
Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
1 parent 990f069 commit b5561e4

33 files changed

+111
-98
lines changed
 

‎.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
strategy:
1414
fail-fast: false
1515
matrix:
16-
node-version: [^14.17, ^16.4]
16+
node-version: [^18.18]
1717
steps:
1818
- uses: actions/checkout@v3
1919
- uses: actions/setup-node@v3

‎docs/rules/assertion-arguments.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Enforce passing correct arguments to assertions (`ava/assertion-arguments`)
22

3-
💼 This rule is enabled in the `recommended` [config](https://github.com/avajs/eslint-plugin-ava#recommended-config).
3+
💼 This rule is enabled in the following [configs](https://github.com/avajs/eslint-plugin-ava#recommended-config): `flat/recommended`, ✅ `recommended`.
44

55
🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
66

‎docs/rules/hooks-order.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Enforce test hook ordering (`ava/hooks-order`)
22

3-
💼 This rule is enabled in the `recommended` [config](https://github.com/avajs/eslint-plugin-ava#recommended-config).
3+
💼 This rule is enabled in the following [configs](https://github.com/avajs/eslint-plugin-ava#recommended-config): `flat/recommended`, ✅ `recommended`.
44

55
🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
66

‎docs/rules/max-asserts.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Enforce a limit on the number of assertions in a test (`ava/max-asserts`)
22

3-
🚫 This rule is _disabled_ in the `recommended` [config](https://github.com/avajs/eslint-plugin-ava#recommended-config).
3+
🚫 This rule is _disabled_ in the following [configs](https://github.com/avajs/eslint-plugin-ava#recommended-config): `flat/recommended`, ✅ `recommended`.
44

55
<!-- end auto-generated rule header -->
66

‎docs/rules/no-async-fn-without-await.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Ensure that async tests use `await` (`ava/no-async-fn-without-await`)
22

3-
💼 This rule is enabled in the `recommended` [config](https://github.com/avajs/eslint-plugin-ava#recommended-config).
3+
💼 This rule is enabled in the following [configs](https://github.com/avajs/eslint-plugin-ava#recommended-config): `flat/recommended`, ✅ `recommended`.
44

55
<!-- end auto-generated rule header -->
66

‎docs/rules/no-duplicate-modifiers.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Ensure tests do not have duplicate modifiers (`ava/no-duplicate-modifiers`)
22

3-
💼 This rule is enabled in the `recommended` [config](https://github.com/avajs/eslint-plugin-ava#recommended-config).
3+
💼 This rule is enabled in the following [configs](https://github.com/avajs/eslint-plugin-ava#recommended-config): `flat/recommended`, ✅ `recommended`.
44

55
<!-- end auto-generated rule header -->
66

‎docs/rules/no-identical-title.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Ensure no tests have the same title (`ava/no-identical-title`)
22

3-
💼 This rule is enabled in the `recommended` [config](https://github.com/avajs/eslint-plugin-ava#recommended-config).
3+
💼 This rule is enabled in the following [configs](https://github.com/avajs/eslint-plugin-ava#recommended-config): `flat/recommended`, ✅ `recommended`.
44

55
<!-- end auto-generated rule header -->
66

‎docs/rules/no-ignored-test-files.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Ensure no tests are written in ignored files (`ava/no-ignored-test-files`)
22

3-
💼 This rule is enabled in the `recommended` [config](https://github.com/avajs/eslint-plugin-ava#recommended-config).
3+
💼 This rule is enabled in the following [configs](https://github.com/avajs/eslint-plugin-ava#recommended-config): `flat/recommended`, ✅ `recommended`.
44

55
<!-- end auto-generated rule header -->
66

‎docs/rules/no-import-test-files.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Ensure no test files are imported anywhere (`ava/no-import-test-files`)
22

3-
💼 This rule is enabled in the `recommended` [config](https://github.com/avajs/eslint-plugin-ava#recommended-config).
3+
💼 This rule is enabled in the following [configs](https://github.com/avajs/eslint-plugin-ava#recommended-config): `flat/recommended`, ✅ `recommended`.
44

55
<!-- end auto-generated rule header -->
66

‎docs/rules/no-incorrect-deep-equal.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Disallow using `deepEqual` with primitives (`ava/no-incorrect-deep-equal`)
22

3-
💼 This rule is enabled in the `recommended` [config](https://github.com/avajs/eslint-plugin-ava#recommended-config).
3+
💼 This rule is enabled in the following [configs](https://github.com/avajs/eslint-plugin-ava#recommended-config): `flat/recommended`, ✅ `recommended`.
44

55
🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
66

‎docs/rules/no-inline-assertions.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Ensure assertions are not called from inline arrow functions (`ava/no-inline-assertions`)
22

3-
💼 This rule is enabled in the `recommended` [config](https://github.com/avajs/eslint-plugin-ava#recommended-config).
3+
💼 This rule is enabled in the following [configs](https://github.com/avajs/eslint-plugin-ava#recommended-config): `flat/recommended`, ✅ `recommended`.
44

55
🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
66

‎docs/rules/no-nested-tests.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Ensure no tests are nested (`ava/no-nested-tests`)
22

3-
💼 This rule is enabled in the `recommended` [config](https://github.com/avajs/eslint-plugin-ava#recommended-config).
3+
💼 This rule is enabled in the following [configs](https://github.com/avajs/eslint-plugin-ava#recommended-config): `flat/recommended`, ✅ `recommended`.
44

55
<!-- end auto-generated rule header -->
66

‎docs/rules/no-only-test.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Ensure no `test.only()` are present (`ava/no-only-test`)
22

3-
💼 This rule is enabled in the `recommended` [config](https://github.com/avajs/eslint-plugin-ava#recommended-config).
3+
💼 This rule is enabled in the following [configs](https://github.com/avajs/eslint-plugin-ava#recommended-config): `flat/recommended`, ✅ `recommended`.
44

5-
🔧💡 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).
5+
🔧💡 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions).
66

77
<!-- end auto-generated rule header -->
88

‎docs/rules/no-skip-assert.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Ensure no assertions are skipped (`ava/no-skip-assert`)
22

3-
💼 This rule is enabled in the `recommended` [config](https://github.com/avajs/eslint-plugin-ava#recommended-config).
3+
💼 This rule is enabled in the following [configs](https://github.com/avajs/eslint-plugin-ava#recommended-config): `flat/recommended`, ✅ `recommended`.
44

55
<!-- end auto-generated rule header -->
66

‎docs/rules/no-skip-test.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Ensure no tests are skipped (`ava/no-skip-test`)
22

3-
💼 This rule is enabled in the `recommended` [config](https://github.com/avajs/eslint-plugin-ava#recommended-config).
3+
💼 This rule is enabled in the following [configs](https://github.com/avajs/eslint-plugin-ava#recommended-config): `flat/recommended`, ✅ `recommended`.
44

5-
🔧💡 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).
5+
🔧💡 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions).
66

77
<!-- end auto-generated rule header -->
88

‎docs/rules/no-todo-implementation.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Ensure `test.todo()` is not given an implementation function (`ava/no-todo-implementation`)
22

3-
💼 This rule is enabled in the `recommended` [config](https://github.com/avajs/eslint-plugin-ava#recommended-config).
3+
💼 This rule is enabled in the following [configs](https://github.com/avajs/eslint-plugin-ava#recommended-config): `flat/recommended`, ✅ `recommended`.
44

55
<!-- end auto-generated rule header -->
66

‎docs/rules/no-todo-test.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Ensure no `test.todo()` is used (`ava/no-todo-test`)
22

3-
⚠️ This rule _warns_ in the `recommended` [config](https://github.com/avajs/eslint-plugin-ava#recommended-config).
3+
⚠️ This rule _warns_ in the following [configs](https://github.com/avajs/eslint-plugin-ava#recommended-config): `flat/recommended`, ✅ `recommended`.
44

55
<!-- end auto-generated rule header -->
66

‎docs/rules/no-unknown-modifiers.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Disallow the use of unknown test modifiers (`ava/no-unknown-modifiers`)
22

3-
💼 This rule is enabled in the `recommended` [config](https://github.com/avajs/eslint-plugin-ava#recommended-config).
3+
💼 This rule is enabled in the following [configs](https://github.com/avajs/eslint-plugin-ava#recommended-config): `flat/recommended`, ✅ `recommended`.
44

55
<!-- end auto-generated rule header -->
66

‎docs/rules/prefer-async-await.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Prefer using async/await instead of returning a Promise (`ava/prefer-async-await`)
22

3-
💼 This rule is enabled in the `recommended` [config](https://github.com/avajs/eslint-plugin-ava#recommended-config).
3+
💼 This rule is enabled in the following [configs](https://github.com/avajs/eslint-plugin-ava#recommended-config): `flat/recommended`, ✅ `recommended`.
44

55
<!-- end auto-generated rule header -->
66

‎docs/rules/prefer-power-assert.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Enforce the use of the asserts that have no [power-assert](https://github.com/power-assert-js/power-assert) alternative (`ava/prefer-power-assert`)
22

3-
🚫 This rule is _disabled_ in the `recommended` [config](https://github.com/avajs/eslint-plugin-ava#recommended-config).
3+
🚫 This rule is _disabled_ in the following [configs](https://github.com/avajs/eslint-plugin-ava#recommended-config): `flat/recommended`, ✅ `recommended`.
44

55
<!-- end auto-generated rule header -->
66

‎docs/rules/prefer-t-regex.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Prefer using `t.regex()` to test regular expressions (`ava/prefer-t-regex`)
22

3-
💼 This rule is enabled in the `recommended` [config](https://github.com/avajs/eslint-plugin-ava#recommended-config).
3+
💼 This rule is enabled in the following [configs](https://github.com/avajs/eslint-plugin-ava#recommended-config): `flat/recommended`, ✅ `recommended`.
44

55
🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
66

‎docs/rules/test-title-format.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Ensure test titles have a certain format (`ava/test-title-format`)
22

3-
🚫 This rule is _disabled_ in the `recommended` [config](https://github.com/avajs/eslint-plugin-ava#recommended-config).
3+
🚫 This rule is _disabled_ in the following [configs](https://github.com/avajs/eslint-plugin-ava#recommended-config): `flat/recommended`, ✅ `recommended`.
44

55
<!-- end auto-generated rule header -->
66

‎docs/rules/test-title.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Ensure tests have a title (`ava/test-title`)
22

3-
💼 This rule is enabled in the `recommended` [config](https://github.com/avajs/eslint-plugin-ava#recommended-config).
3+
💼 This rule is enabled in the following [configs](https://github.com/avajs/eslint-plugin-ava#recommended-config): `flat/recommended`, ✅ `recommended`.
44

55
<!-- end auto-generated rule header -->
66

‎docs/rules/use-t-throws-async-well.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Ensure that `t.throwsAsync()` and `t.notThrowsAsync()` are awaited (`ava/use-t-throws-async-well`)
22

3-
💼 This rule is enabled in the `recommended` [config](https://github.com/avajs/eslint-plugin-ava#recommended-config).
3+
💼 This rule is enabled in the following [configs](https://github.com/avajs/eslint-plugin-ava#recommended-config): `flat/recommended`, ✅ `recommended`.
44

55
🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
66

‎docs/rules/use-t-well.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Disallow the incorrect use of `t` (`ava/use-t-well`)
22

3-
💼 This rule is enabled in the `recommended` [config](https://github.com/avajs/eslint-plugin-ava#recommended-config).
3+
💼 This rule is enabled in the following [configs](https://github.com/avajs/eslint-plugin-ava#recommended-config): `flat/recommended`, ✅ `recommended`.
44

55
🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
66

‎docs/rules/use-t.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Ensure test functions use `t` as their parameter (`ava/use-t`)
22

3-
💼 This rule is enabled in the `recommended` [config](https://github.com/avajs/eslint-plugin-ava#recommended-config).
3+
💼 This rule is enabled in the following [configs](https://github.com/avajs/eslint-plugin-ava#recommended-config): `flat/recommended`, ✅ `recommended`.
44

55
<!-- end auto-generated rule header -->
66

‎docs/rules/use-test.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Ensure that AVA is imported with `test` as the variable name (`ava/use-test`)
22

3-
💼 This rule is enabled in the `recommended` [config](https://github.com/avajs/eslint-plugin-ava#recommended-config).
3+
💼 This rule is enabled in the following [configs](https://github.com/avajs/eslint-plugin-ava#recommended-config): `flat/recommended`, ✅ `recommended`.
44

55
<!-- end auto-generated rule header -->
66

‎docs/rules/use-true-false.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Ensure that `t.true()`/`t.false()` are used instead of `t.truthy()`/`t.falsy()` (`ava/use-true-false`)
22

3-
💼 This rule is enabled in the `recommended` [config](https://github.com/avajs/eslint-plugin-ava#recommended-config).
3+
💼 This rule is enabled in the following [configs](https://github.com/avajs/eslint-plugin-ava#recommended-config): `flat/recommended`, ✅ `recommended`.
44

55
<!-- end auto-generated rule header -->
66

‎index.js

+42-30
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,39 @@
33
const path = require('path');
44
const importModules = require('import-modules');
55

6+
const rules = {
7+
'ava/assertion-arguments': 'error',
8+
'ava/hooks-order': 'error',
9+
'ava/max-asserts': [
10+
'off',
11+
5,
12+
],
13+
'ava/no-async-fn-without-await': 'error',
14+
'ava/no-duplicate-modifiers': 'error',
15+
'ava/no-identical-title': 'error',
16+
'ava/no-ignored-test-files': 'error',
17+
'ava/no-import-test-files': 'error',
18+
'ava/no-incorrect-deep-equal': 'error',
19+
'ava/no-inline-assertions': 'error',
20+
'ava/no-nested-tests': 'error',
21+
'ava/no-only-test': 'error',
22+
'ava/no-skip-assert': 'error',
23+
'ava/no-skip-test': 'error',
24+
'ava/no-todo-implementation': 'error',
25+
'ava/no-todo-test': 'warn',
26+
'ava/no-unknown-modifiers': 'error',
27+
'ava/prefer-async-await': 'error',
28+
'ava/prefer-power-assert': 'off',
29+
'ava/prefer-t-regex': 'error',
30+
'ava/test-title': 'error',
31+
'ava/test-title-format': 'off',
32+
'ava/use-t-well': 'error',
33+
'ava/use-t': 'error',
34+
'ava/use-t-throws-async-well': 'error',
35+
'ava/use-test': 'error',
36+
'ava/use-true-false': 'error',
37+
};
38+
639
module.exports = {
740
rules: importModules(path.resolve(__dirname, 'rules'), {camelize: false}),
841
configs: {
@@ -18,37 +51,16 @@ module.exports = {
1851
'ava',
1952
],
2053
rules: {
21-
'ava/assertion-arguments': 'error',
22-
'ava/hooks-order': 'error',
23-
'ava/max-asserts': [
24-
'off',
25-
5,
26-
],
27-
'ava/no-async-fn-without-await': 'error',
28-
'ava/no-duplicate-modifiers': 'error',
29-
'ava/no-identical-title': 'error',
30-
'ava/no-ignored-test-files': 'error',
31-
'ava/no-import-test-files': 'error',
32-
'ava/no-incorrect-deep-equal': 'error',
33-
'ava/no-inline-assertions': 'error',
34-
'ava/no-nested-tests': 'error',
35-
'ava/no-only-test': 'error',
36-
'ava/no-skip-assert': 'error',
37-
'ava/no-skip-test': 'error',
38-
'ava/no-todo-implementation': 'error',
39-
'ava/no-todo-test': 'warn',
40-
'ava/no-unknown-modifiers': 'error',
41-
'ava/prefer-async-await': 'error',
42-
'ava/prefer-power-assert': 'off',
43-
'ava/prefer-t-regex': 'error',
44-
'ava/test-title': 'error',
45-
'ava/test-title-format': 'off',
46-
'ava/use-t-well': 'error',
47-
'ava/use-t': 'error',
48-
'ava/use-t-throws-async-well': 'error',
49-
'ava/use-test': 'error',
50-
'ava/use-true-false': 'error',
54+
...rules,
5155
},
5256
},
57+
"flat/recommended": {
58+
plugins: {
59+
'ava': 'ava'
60+
},
61+
rules: {
62+
...rules
63+
}
64+
}
5365
},
5466
};

‎package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"license": "MIT",
66
"repository": "avajs/eslint-plugin-ava",
77
"engines": {
8-
"node": ">=14.17 <15 || >=16.4"
8+
"node": "^18.18 || >=20"
99
},
1010
"scripts": {
1111
"integration": "node ./test/integration/test.js",
@@ -63,7 +63,7 @@
6363
"xo": "^0.52.4"
6464
},
6565
"peerDependencies": {
66-
"eslint": ">=8.26.0"
66+
"eslint": ">=9"
6767
},
6868
"ava": {
6969
"files": [

‎readme.md

+31-31
Large diffs are not rendered by default.

‎rules/assertion-arguments.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ const create = context => {
282282
let lastArg = node.arguments[node.arguments.length - 1];
283283

284284
if (lastArg.type === 'Identifier') {
285-
const variable = findVariable(context.getScope(), lastArg);
285+
const variable = findVariable(context.sourceCode.getScope(node), lastArg);
286286
let value;
287287
for (const ref of variable.references) {
288288
value = ref.writeExpr ?? value;

‎rules/prefer-t-regex.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ const create = context => {
2020
]);
2121

2222
// Find the latest reference to the given identifier's name.
23-
const findReference = name => {
24-
const reference = context.getScope().references.find(reference => reference.identifier.name === name);
23+
const findReference = node => {
24+
const sourceCode = context.sourceCode;
25+
const reference = sourceCode.getScope(node).references.find(reference => reference.identifier.name === node.name);
2526

2627
if (reference?.resolved) {
2728
const definitions = reference.resolved.defs;
@@ -37,7 +38,7 @@ const create = context => {
3738
/*
3839
Recursively find the "origin" node of the given node.
3940
40-
Note: `context.getScope()` doesn't contain information about the outer scope so in most cases this function will only find the reference directly above the current scope. So the following code will only find the reference in this order: y -> x, and it will have no knowledge of the number `0`. (assuming we run this function on the identifier `y`)
41+
Note: `sourceCode.getScope()` doesn't contain information about the outer scope so in most cases this function will only find the reference directly above the current scope. So the following code will only find the reference in this order: y -> x, and it will have no knowledge of the number `0`. (assuming we run this function on the identifier `y`)
4142
4243
```
4344
const test = require('ava');
@@ -56,7 +57,7 @@ const create = context => {
5657
}
5758

5859
if (node.type === 'Identifier') {
59-
const reference = findReference(node.name);
60+
const reference = findReference(node);
6061

6162
if (reference?.init) {
6263
return findRootReference(reference.init);

0 commit comments

Comments
 (0)
Please sign in to comment.