Skip to content

Commit d7f203c

Browse files
authored
chore: migrate to ESLint v9 and update deps (#902)
- Migrate to ESLint flat config - Switch from `eslint-config-standard` to `neostandard` as the former does not support ESLint v9 and seems to be unmaintained. - Conform to the rules of the ESLint plugins/configs. - Update all dependencies to their latest versions.
1 parent 3cb5255 commit d7f203c

24 files changed

+76
-45
lines changed

.eslintignore

Lines changed: 0 additions & 5 deletions
This file was deleted.

.eslintrc

Lines changed: 0 additions & 17 deletions
This file was deleted.

bin/git-node.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,6 @@ Promise.all(commandFiles.map(importCommand)).then((commands) => {
2727
.epilogue(epilogue)
2828
.help('help')
2929
.parse();
30+
}).catch((err) => {
31+
throw err;
3032
});

components/git/metadata.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,5 +90,6 @@ export function handler(argv) {
9090
if (status === false) {
9191
throw new Error(IGNORE);
9292
}
93+
return undefined;
9394
}));
9495
}

eslint.config.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import globals from 'globals';
2+
import pluginJs from '@eslint/js';
3+
import neostandard from 'neostandard';
4+
import nodePlugin from 'eslint-plugin-n';
5+
import pluginPromise from 'eslint-plugin-promise';
6+
import importPlugin from 'eslint-plugin-import';
7+
8+
export default [
9+
pluginJs.configs.recommended,
10+
...neostandard(),
11+
nodePlugin.configs['flat/recommended'],
12+
pluginPromise.configs['flat/recommended'],
13+
importPlugin.flatConfigs.recommended,
14+
{
15+
ignores: [
16+
'**/.git',
17+
'**/.nyc_output',
18+
'coverage/',
19+
'node_modules/',
20+
'lib/wpt/templates/',
21+
],
22+
},
23+
{
24+
languageOptions: {
25+
globals: globals.node,
26+
sourceType: 'module',
27+
ecmaVersion: 'latest',
28+
},
29+
rules: {
30+
'@stylistic/semi': ['error', 'always'],
31+
'@stylistic/space-before-function-paren': ['error', 'never'],
32+
'@stylistic/no-multi-spaces': ['error', { ignoreEOLComments: true }],
33+
camelcase: 'off',
34+
'@stylistic/max-len': [
35+
2,
36+
100,
37+
4,
38+
{ ignoreRegExpLiterals: true, ignoreUrls: true },
39+
],
40+
'@stylistic/object-property-newline': 'off',
41+
'promise/always-return': ['error', { ignoreLastCallback: true }],
42+
'n/no-process-exit': 'off',
43+
'n/no-unsupported-features/node-builtins': 'off',
44+
},
45+
},
46+
];

lib/ci/build-types/health_build.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ class Health {
2020
formatAsMarkdown() {
2121
const { success, pending, aborted, failed, unstable, count } = this;
2222
const rate = `${(success / (count - pending - aborted) * 100).toFixed(2)}%`;
23-
// eslint-disable-next-line max-len
24-
let result = '| UTC Time | RUNNING | SUCCESS | UNSTABLE | ABORTED | FAILURE | Green Rate |\n';
25-
// eslint-disable-next-line max-len
26-
result += '| ---------------- | ------- | ------- | -------- | ------- | ------- | ---------- |\n';
23+
let result =
24+
'| UTC Time | RUNNING | SUCCESS | UNSTABLE | ABORTED | FAILURE | Green Rate |\n';
25+
result +=
26+
'| ---------------- | ------- | ------- | -------- | ------- | ------- | ---------- |\n';
2727
const time = new Date().toISOString().slice(0, 16).replace('T', ' ');
2828
result += `| ${time} | ${pad(pending, 7)} | ${pad(success, 8)}|`;
2929
result += ` ${pad(unstable, 8)} | ${pad(aborted, 7)} | ${pad(failed, 7)} |`;

lib/ci/build-types/test_build.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ export class TestBuild extends Job {
7676
return result;
7777
}
7878
}
79+
80+
return undefined;
7981
}
8082

8183
get commit() {

lib/ci/ci_failure_parser.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,6 @@ const FAILURE_FILTERS = [{
204204
context: { index: 0, contextBefore: 0, contextAfter: 0 }
205205
}, {
206206
pattern:
207-
// eslint-disable-next-line max-len
208207
/error: Your local changes to the following files[\s\S]+Failed to merge in the changes./g,
209208
context: { index: 0, contextBefore: 0, contextAfter: 0 }
210209
}, {

lib/cli.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ export default class CLI {
8181
return defaultAnswer;
8282
}
8383

84+
// eslint-disable-next-line import/namespace -- Plugin can't validate computed reference here
8485
const answer = await inquirer[questionType]({
8586
message: question,
8687
default: defaultAnswer

lib/collaborators.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,13 @@ function parseCollaborators(readme, cli) {
105105

106106
// We also assume that TSC & TSC Emeriti are also listed as collaborators
107107
CONTACT_RE.lastIndex = tscIndex;
108-
// eslint-disable-next-line no-cond-assign
109108
while ((m = CONTACT_RE.exec(readme)) && CONTACT_RE.lastIndex < tscrIndex) {
110109
const login = m[1].toLowerCase();
111110
const user = new Collaborator(m[1], m[2], m[3], TSC);
112111
collaborators.set(login, user);
113112
}
114113

115114
CONTACT_RE.lastIndex = clIndex;
116-
// eslint-disable-next-line no-cond-assign
117115
while ((m = CONTACT_RE.exec(readme)) &&
118116
CONTACT_RE.lastIndex < cleIndex) {
119117
const login = m[1].toLowerCase();

lib/prepare_security.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ export default class PrepareSecurityRelease extends SecurityRelease {
5656
await this.closePRWithLabel('Security Release');
5757

5858
const updateFolder = await this.cli.prompt(
59-
// eslint-disable-next-line max-len
60-
`Would you like to update the next-security-release folder to ${vulnerabilityJSON.releaseDate}?`,
59+
`Would you like to update the next-security-release folder to ${
60+
vulnerabilityJSON.releaseDate}?`,
6161
{ defaultAnswer: true });
6262
if (updateFolder) {
6363
this.updateReleaseFolder(

lib/release/utils.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,10 @@ export function getStartLTSBlurb({ date, ltsCodename, versionComponents }) {
2121
const eol = eolDate.toLocaleString('en-US', dateFormat);
2222
const { major } = versionComponents;
2323
return [
24-
/* eslint-disable max-len */
2524
`This release marks the transition of Node.js ${major}.x into Long Term Support (LTS)`,
2625
`with the codename '${ltsCodename}'. The ${major}.x release line now moves into "Active LTS"`,
2726
`and will remain so until ${mainStart}. After that time, it will move into`,
2827
`"Maintenance" until end of life in ${eol}.`
29-
/* eslint-enable */
3028
].join('\n');
3129
}
3230

lib/team_info.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ TeamInfo.update = async function(cli, request, content) {
6767

6868
const blocks = new Map();
6969
let m;
70-
// eslint-disable-next-line no-cond-assign
7170
while ((m = RE.exec(content))) {
7271
const [, org, team] = m;
7372
const mapKey = key(org, team);

lib/update-v8/majorUpdate.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ function updateV8Deps() {
119119
path: v8Dep.repo
120120
})), newV8Version);
121121
if (deps.length === 0) return;
122-
/* eslint-disable no-await-in-loop */
123122
for (const dep of deps) {
124123
if (dep.gitignore) {
125124
if (typeof dep.gitignore === 'string') {
@@ -132,7 +131,6 @@ function updateV8Deps() {
132131
const thePath = path.join(ctx.nodeDir, 'deps/v8', dep.path);
133132
await fetchFromGit(thePath, repo, commit);
134133
}
135-
/* eslint-enable */
136134
}
137135
};
138136
}

lib/voting_session.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
getEditor, isGhAvailable
1111
} from './utils.js';
1212

13+
// eslint-disable-next-line import/no-unresolved
1314
import voteUsingGit from '@node-core/caritat/voteUsingGit';
1415
import * as yaml from 'js-yaml';
1516

@@ -97,7 +98,7 @@ export default class VotingSession extends Session {
9798
cp.stdin.end(share);
9899
const [code] = await Promise.race([
99100
once(cp, 'exit'),
100-
once(cp, 'error').then((er) => Promise.reject(er))
101+
once(cp, 'error').then((er) => { throw er; })
101102
]);
102103
if (code !== 0) throw new Error('failed', { cause: code });
103104
return Buffer.concat(await stdout);

package.json

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"@pkgjs/nv": "^0.2.2",
4141
"branch-diff": "^3.1.1",
4242
"chalk": "^5.4.1",
43-
"changelog-maker": "^4.3.1",
43+
"changelog-maker": "^4.3.2",
4444
"cheerio": "^1.0.0",
4545
"clipboardy": "^4.0.0",
4646
"core-validate-commit": "^4.1.0",
@@ -53,18 +53,21 @@
5353
"log-symbols": "^7.0.0",
5454
"ora": "^8.1.1",
5555
"replace-in-file": "^8.3.0",
56-
"undici": "^7.2.2",
56+
"semver": "^7.6.3",
57+
"undici": "^7.3.0",
5758
"which": "^5.0.0",
5859
"yargs": "^17.7.2"
5960
},
6061
"devDependencies": {
62+
"@eslint/js": "^9.19.0",
6163
"@reporters/github": "^1.7.2",
6264
"c8": "^10.1.3",
63-
"eslint": "^8.57.1",
64-
"eslint-config-standard": "^17.1.0",
65+
"eslint": "^9.19.0",
6566
"eslint-plugin-import": "^2.31.0",
66-
"eslint-plugin-n": "^16.6.2",
67-
"eslint-plugin-promise": "^6.6.0",
67+
"eslint-plugin-n": "^17.15.1",
68+
"eslint-plugin-promise": "^7.2.1",
69+
"globals": "^15.14.0",
70+
"neostandard": "^0.12.0",
6871
"sinon": "^19.0.2"
6972
}
7073
}

test/fixtures/release/expected-test-process-release.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'use strict';
22

3+
// eslint-disable-next-line n/no-missing-require
34
require('../common');
45

56
const assert = require('assert');

test/fixtures/release/original-test-process-release.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'use strict';
22

3+
// eslint-disable-next-line n/no-missing-require
34
require('../common');
45

56
const assert = require('assert');

test/unit/ci_start.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable import/no-named-as-default-member */
12
import { describe, it, before, afterEach } from 'node:test';
23
import assert from 'assert';
34

test/unit/pr_checker.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable import/no-named-as-default-member */
12
import { describe, it, before, after, afterEach } from 'node:test';
23
import assert from 'node:assert';
34

test/unit/pr_data.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable import/no-named-as-default-member */
12
import { describe, it } from 'node:test';
23
import assert from 'node:assert';
34

test/unit/prepare_release.test.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,10 @@ describe('prepare_release: utils.getLTSMaintenanceStartDate', () => {
3131
describe('prepare_release: utils.getStartLTSBlurb', () => {
3232
it('generates first LTS release text with correct dates', () => {
3333
const expected = [
34-
/* eslint-disable max-len */
3534
'This release marks the transition of Node.js 14.x into Long Term Support (LTS)',
3635
'with the codename \'Fermium\'. The 14.x release line now moves into "Active LTS"',
3736
'and will remain so until October 2021. After that time, it will move into',
3837
'"Maintenance" until end of life in April 2023.'
39-
/* eslint-enable max-len */
4038
].join('\n');
4139
const text = utils.getStartLTSBlurb({
4240
date: '2020-10-27',

test/unit/team_info.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable import/no-named-as-default-member */
12
import { describe, it, before, after } from 'node:test';
23
import assert from 'node:assert';
34

test/unit/wpt_updater.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable import/no-named-as-default-member */
12
import { describe, it, before, after } from 'node:test';
23
import assert from 'node:assert';
34
import TestCLI from '../fixtures/test_cli.js';

0 commit comments

Comments
 (0)