Skip to content

Commit bd8c4c6

Browse files
committed
Require Node.js 14 and ESLint 8
1 parent 33dbbc7 commit bd8c4c6

21 files changed

+46
-47
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,22 @@ jobs:
1313
strategy:
1414
fail-fast: false
1515
matrix:
16-
node-version: [^12.22, ^14.17, ^16.4]
16+
node-version: [^14.17, ^16.4]
1717
steps:
18-
- uses: actions/checkout@v2
19-
- uses: actions/setup-node@v2
18+
- uses: actions/checkout@v3
19+
- uses: actions/setup-node@v3
2020
with:
2121
node-version: ${{ matrix.node-version }}
2222
- run: npm install --no-audit
2323
- run: npm test
24-
- uses: codecov/codecov-action@v2
24+
- uses: codecov/codecov-action@v3
2525

2626
integration:
2727
name: Integration tests
2828
runs-on: ubuntu-latest
2929
steps:
30-
- uses: actions/checkout@v2
31-
- uses: actions/setup-node@v2
30+
- uses: actions/checkout@v3
31+
- uses: actions/setup-node@v3
3232
- run: npm install --no-audit
3333
- run: npm run integration
34-
- uses: codecov/codecov-action@v2
34+
- uses: codecov/codecov-action@v3

create-ava-rule.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -188,36 +188,36 @@ module.exports = () => {
188188

189189
/* eslint quote-props: [2, "as-needed"] */
190190
const predefinedRules = {
191-
ImportDeclaration: node => {
191+
ImportDeclaration(node) {
192192
if (!isTestFile && avaImportDeclarationAsts.some(ast => isDeepStrictEqual(espurify(node), ast))) {
193193
isTestFile = true;
194194
}
195195
},
196-
VariableDeclarator: node => {
196+
VariableDeclarator(node) {
197197
if (!isTestFile && avaVariableDeclaratorAsts.some(ast => isDeepStrictEqual(espurify(node), ast))) {
198198
isTestFile = true;
199199
}
200200
},
201-
CallExpression: node => {
201+
CallExpression(node) {
202202
if (isTestFunctionCall(node.callee)) {
203203
// Entering test function
204204
currentTestNode = node;
205205
}
206206
},
207-
'CallExpression:exit': node => {
207+
'CallExpression:exit'(node) {
208208
if (currentTestNode === node) {
209209
// Leaving test function
210210
currentTestNode = undefined;
211211
}
212212
},
213-
'Program:exit': () => {
213+
'Program:exit'() {
214214
isTestFile = false;
215215
},
216216
};
217217

218218
return {
219219
hasTestModifier: mod => getTestModifierNames(currentTestNode).includes(mod),
220-
hasNoUtilityModifier: () => {
220+
hasNoUtilityModifier() {
221221
const modifiers = getTestModifierNames(currentTestNode);
222222
return !modifiers.includes('before')
223223
&& !modifiers.includes('beforeEach')

package.json

Lines changed: 5 additions & 5 deletions
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": ">=12.22 <13 || >=14.17 <15 || >=16.4"
8+
"node": ">=14.17 <15 || >=16.4"
99
},
1010
"scripts": {
1111
"test": "xo && c8 ava",
@@ -45,18 +45,18 @@
4545
"c8": "^7.7.3",
4646
"chalk": "^4.1.1",
4747
"del": "^6.0.0",
48-
"eslint": "^8.0.1",
48+
"eslint": "^8.26.0",
4949
"eslint-ava-rule-tester": "^4.0.0",
50-
"eslint-plugin-eslint-plugin": "^4.0.1",
50+
"eslint-plugin-eslint-plugin": "^5.0.6",
5151
"execa": "^5.1.1",
5252
"listr": "^0.14.3",
5353
"outdent": "^0.8.0",
5454
"pify": "^5.0.0",
5555
"tempy": "^1.0.1",
56-
"xo": "^0.46.4"
56+
"xo": "^0.52.4"
5757
},
5858
"peerDependencies": {
59-
"eslint": ">=7.22.0"
59+
"eslint": ">=8.26.0"
6060
},
6161
"ava": {
6262
"files": [

rules/assertion-arguments.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ function isString(node) {
211211

212212
const create = context => {
213213
const ava = createAvaRule();
214-
const options = context.options[0] || {};
214+
const options = context.options[0] ?? {};
215215
const enforcesMessage = Boolean(options.message);
216216
const shouldHaveMessage = options.message !== 'never';
217217

@@ -285,7 +285,7 @@ const create = context => {
285285
const variable = findVariable(context.getScope(), lastArg);
286286
let value;
287287
for (const ref of variable.references) {
288-
value = ref.writeExpr || value;
288+
value = ref.writeExpr ?? value;
289289
}
290290

291291
lastArg = value;

rules/hooks-order.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const buildOrders = names => {
2222
};
2323

2424
const buildMessage = (name, orders, visited) => {
25-
const checks = orders[name] || [];
25+
const checks = orders[name] ?? [];
2626

2727
for (const check of checks) {
2828
const nodeEarlier = visited[check];
@@ -90,7 +90,7 @@ const create = context => {
9090
const sourceCode = context.getSourceCode();
9191

9292
// TODO: Remove `.reduce()` usage.
93-
// eslint-disable-next-line unicorn/no-array-reduce, unicorn/prefer-object-from-entries
93+
// eslint-disable-next-line unicorn/no-array-reduce
9494
const selectors = checks.reduce((result, check) => {
9595
result[check.selector] = visitIf([
9696
ava.isInTestFile,
@@ -106,10 +106,10 @@ const create = context => {
106106
node,
107107
messageId: message.messageId,
108108
data: message.data,
109-
fix: fixer => {
109+
fix(fixer) {
110110
const tokensBetween = sourceCode.getTokensBetween(nodeEarlier.parent, node.parent);
111111

112-
if (tokensBetween && tokensBetween.length > 0) {
112+
if (tokensBetween?.length > 0) {
113113
return;
114114
}
115115

rules/max-asserts.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const create = context => {
1212
const ava = createAvaRule();
1313
// TODO: Convert options to object JSON Schema default works properly
1414
// https://github.com/avajs/eslint-plugin-ava/issues/260
15-
const maxAssertions = context.options[0] || MAX_ASSERTIONS_DEFAULT;
15+
const maxAssertions = context.options[0] ?? MAX_ASSERTIONS_DEFAULT;
1616
let assertionCount = 0;
1717
let nodeToReport;
1818

rules/no-async-fn-without-await.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const create = context => {
1515
}
1616
};
1717

18-
const isAsync = node => Boolean(node && node.async);
18+
const isAsync = node => Boolean(node?.async);
1919

2020
return ava.merge({
2121
CallExpression: visitIf([

rules/no-identical-title.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const create = context => {
5252

5353
usedTitleNodes.push(purify(titleNode));
5454
}),
55-
'Program:exit': () => {
55+
'Program:exit'() {
5656
usedTitleNodes = [];
5757
},
5858
});

rules/no-ignored-test-files.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const create = context => {
2222
])(() => {
2323
hasTestCall = true;
2424
}),
25-
'Program:exit': node => {
25+
'Program:exit'(node) {
2626
if (!hasTestCall) {
2727
return;
2828
}

rules/no-import-test-files.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ const create = context => {
4747
};
4848

4949
return {
50-
ImportDeclaration: node => {
50+
ImportDeclaration(node) {
5151
validateImportPath(node, node.source.value);
5252
},
53-
CallExpression: node => {
53+
CallExpression(node) {
5454
if (!(node.callee.type === 'Identifier' && node.callee.name === 'require')) {
5555
return;
5656
}

rules/prefer-t-regex.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const create = context => {
2323
const findReference = name => {
2424
const reference = context.getScope().references.find(reference => reference.identifier.name === name);
2525

26-
if (reference && reference.resolved) {
26+
if (reference?.resolved) {
2727
const definitions = reference.resolved.defs;
2828

2929
if (definitions.length === 0) {
@@ -54,7 +54,7 @@ const create = context => {
5454
if (node.type === 'Identifier') {
5555
const reference = findReference(node.name);
5656

57-
if (reference && reference.init) {
57+
if (reference?.init) {
5858
return findRootReference(reference.init);
5959
}
6060

@@ -86,7 +86,7 @@ const create = context => {
8686

8787
// Look up references in case it's a variable or RegExp declaration.
8888
const reference = findRootReference(lookup);
89-
return reference.regex || reference.name === 'RegExp';
89+
return reference.regex ?? reference.name === 'RegExp';
9090
};
9191

9292
const booleanHandler = node => {

rules/test-title-format.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const create = context => {
88
const ava = createAvaRule();
99

1010
let titleRegExp;
11-
if (context.options[0] && context.options[0].format) {
11+
if (context.options[0]?.format) {
1212
titleRegExp = new RegExp(context.options[0].format);
1313
} else {
1414
return {};

rules/use-t-well.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ const create = context => {
125125
context.report({
126126
node,
127127
message: 'Too many chained uses of `.skip`.',
128-
fix: fixer => {
128+
fix(fixer) {
129129
const chain = ['t', ...members.map(member => member.name).filter(name => name !== 'skip'), 'skip'];
130130
return fixer.replaceText(node, chain.join('.'));
131131
},
@@ -136,7 +136,7 @@ const create = context => {
136136
context.report({
137137
node,
138138
message: '`.skip` modifier should be the last in chain.',
139-
fix: fixer => {
139+
fix(fixer) {
140140
const chain = ['t', ...members.map(member => member.name).filter(name => name !== 'skip'), 'skip'];
141141
return fixer.replaceText(node, chain.join('.'));
142142
},

rules/use-t.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const create = context => {
2020
let implementationArg = node.arguments[index];
2121
if (ava.hasTestModifier('macro') && implementationArg.type === 'ObjectExpression') {
2222
const execProperty = implementationArg.properties.find(p => p.key.name === 'exec');
23-
implementationArg = execProperty && execProperty.value;
23+
implementationArg = execProperty?.value;
2424
}
2525

2626
if (!implementationArg || !implementationArg.params || implementationArg.params.length === 0) {

rules/use-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ const create = context => {
3131
const isTypeScript = ext === '.ts' || ext === '.tsx';
3232

3333
return {
34-
'ImportDeclaration[importKind!="type"]': node => {
34+
'ImportDeclaration[importKind!="type"]'(node) {
3535
if (node.source.value === 'ava') {
3636
const {name} = node.specifiers[0].local;
3737
if (name !== 'test' && (!isTypeScript || name !== 'anyTest')) {
3838
report(context, node);
3939
}
4040
}
4141
},
42-
VariableDeclarator: node => {
42+
VariableDeclarator(node) {
4343
if (node.init && isDeepStrictEqual(espurify(node.init), avaVariableDeclaratorInitAst)) {
4444
const {name} = node.id;
4545
if (name !== 'test' && (!isTypeScript || name !== 'anyTest')) {

test/create-ava-rule.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ const avaRuleTester = require('eslint-ava-rule-tester');
55
const createAvaRule = require('../create-ava-rule');
66

77
const rule = {
8-
create: context => {
8+
create(context) {
99
const ava = createAvaRule();
1010

1111
return ava.merge({
12-
'Program:exit': node => {
12+
'Program:exit'(node) {
1313
if (!ava.isInTestFile()) {
1414
context.report({node, message: 'not a test file'});
1515
}

test/integration/test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ const list = new Listr([
146146
},
147147
{
148148
title: 'Integration tests',
149-
task: () => {
149+
task() {
150150
const tests = new Listr({concurrent: true});
151151

152152
for (const [name] of packages) {

test/no-async-fn-without-await.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const ruleTesterOptions = [
2525
for (const options of ruleTesterOptions) {
2626
const ruleTester = avaRuleTester(test, options);
2727

28-
ruleTester.run(`no-async-fn-without-await - parser:${options.parser || 'default'}`, rule, {
28+
ruleTester.run(`no-async-fn-without-await - parser:${options.parser ?? 'default'}`, rule, {
2929
valid: [
3030
`${header}test(fn);`,
3131
`${header}test(t => {});`,

test/no-ignored-test-files.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const toPath = subPath => path.join(rootDir, subPath);
1919
const code = hasHeader => (hasHeader ? header : '') + 'test(t => { t.pass(); });';
2020

2121
util.loadAvaHelper = () => ({
22-
classifyFile: file => {
22+
classifyFile(file) {
2323
switch (file) {
2424
case toPath('lib/foo.test.js'):
2525
return {isHelper: false, isTest: true};

test/no-import-test-files.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const rootDir = path.dirname(__dirname);
1919
const toPath = subPath => path.join(rootDir, subPath);
2020

2121
util.loadAvaHelper = () => ({
22-
classifyImport: importPath => {
22+
classifyImport(importPath) {
2323
switch (importPath) {
2424
case toPath('lib/foo.test.js'):
2525
return {isHelper: false, isTest: true};

util.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,8 @@ exports.getMembers = getMembers;
8484

8585
const repoUrl = 'https://github.com/avajs/eslint-plugin-ava';
8686

87-
const getDocsUrl = (filename, commitHash) => {
87+
const getDocsUrl = (filename, commitHash = `v${pkg.version}`) => {
8888
const ruleName = path.basename(filename, '.js');
89-
commitHash = commitHash || `v${pkg.version}`;
9089
return `${repoUrl}/blob/${commitHash}/docs/rules/${ruleName}.md`;
9190
};
9291

0 commit comments

Comments
 (0)