Skip to content

Commit

Permalink
chore: migrate to ESLint v9 and update deps
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
VoltrexKeyva committed Jan 26, 2025
1 parent 3cb5255 commit b982dae
Show file tree
Hide file tree
Showing 24 changed files with 74 additions and 45 deletions.
5 changes: 0 additions & 5 deletions .eslintignore

This file was deleted.

17 changes: 0 additions & 17 deletions .eslintrc

This file was deleted.

2 changes: 2 additions & 0 deletions bin/git-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,6 @@ Promise.all(commandFiles.map(importCommand)).then((commands) => {
.epilogue(epilogue)
.help('help')
.parse();
}).catch((err) => {
throw err;
});
1 change: 1 addition & 0 deletions components/git/metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,6 @@ export function handler(argv) {
if (status === false) {
throw new Error(IGNORE);
}
return undefined;
}));
}
44 changes: 44 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import globals from 'globals';
import pluginJs from '@eslint/js';
import neostandard from 'neostandard';
import nodePlugin from 'eslint-plugin-n';
import pluginPromise from 'eslint-plugin-promise';
import importPlugin from 'eslint-plugin-import';

export default [
pluginJs.configs.recommended,
...neostandard(),
nodePlugin.configs['flat/recommended'],
pluginPromise.configs['flat/recommended'],
importPlugin.flatConfigs.recommended,
{
ignores: [
'**/.git',
'**/.nyc_output',
'coverage',
'node_modules',
'lib/wpt/templates',
],
languageOptions: {
globals: globals.node,
sourceType: 'module',
ecmaVersion: 'latest',
},
rules: {
'@stylistic/semi': ['error', 'always'],
'@stylistic/space-before-function-paren': ['error', 'never'],
'@stylistic/no-multi-spaces': ['error', { ignoreEOLComments: true }],
camelcase: 'off',
'@stylistic/max-len': [
2,
100,
4,
{ ignoreRegExpLiterals: true, ignoreUrls: true },
],
'@stylistic/object-property-newline': 'off',
'promise/always-return': ['error', { ignoreLastCallback: true }],
'n/no-process-exit': 'off',
'n/no-unsupported-features/node-builtins': 'off',
},
},
];
8 changes: 4 additions & 4 deletions lib/ci/build-types/health_build.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ class Health {
formatAsMarkdown() {
const { success, pending, aborted, failed, unstable, count } = this;
const rate = `${(success / (count - pending - aborted) * 100).toFixed(2)}%`;
// eslint-disable-next-line max-len
let result = '| UTC Time | RUNNING | SUCCESS | UNSTABLE | ABORTED | FAILURE | Green Rate |\n';
// eslint-disable-next-line max-len
result += '| ---------------- | ------- | ------- | -------- | ------- | ------- | ---------- |\n';
let result =
'| UTC Time | RUNNING | SUCCESS | UNSTABLE | ABORTED | FAILURE | Green Rate |\n';
result +=
'| ---------------- | ------- | ------- | -------- | ------- | ------- | ---------- |\n';
const time = new Date().toISOString().slice(0, 16).replace('T', ' ');
result += `| ${time} | ${pad(pending, 7)} | ${pad(success, 8)}|`;
result += ` ${pad(unstable, 8)} | ${pad(aborted, 7)} | ${pad(failed, 7)} |`;
Expand Down
2 changes: 2 additions & 0 deletions lib/ci/build-types/test_build.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ export class TestBuild extends Job {
return result;
}
}

return undefined;
}

get commit() {
Expand Down
1 change: 0 additions & 1 deletion lib/ci/ci_failure_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@ const FAILURE_FILTERS = [{
context: { index: 0, contextBefore: 0, contextAfter: 0 }
}, {
pattern:
// eslint-disable-next-line max-len
/error: Your local changes to the following files[\s\S]+Failed to merge in the changes./g,
context: { index: 0, contextBefore: 0, contextAfter: 0 }
}, {
Expand Down
1 change: 1 addition & 0 deletions lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export default class CLI {
return defaultAnswer;
}

// eslint-disable-next-line import/namespace -- Plugin can't validate computed reference here

Check warning on line 84 in lib/cli.js

View check run for this annotation

Codecov / codecov/patch

lib/cli.js#L84

Added line #L84 was not covered by tests
const answer = await inquirer[questionType]({
message: question,
default: defaultAnswer
Expand Down
2 changes: 0 additions & 2 deletions lib/collaborators.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,13 @@ function parseCollaborators(readme, cli) {

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

CONTACT_RE.lastIndex = clIndex;
// eslint-disable-next-line no-cond-assign
while ((m = CONTACT_RE.exec(readme)) &&
CONTACT_RE.lastIndex < cleIndex) {
const login = m[1].toLowerCase();
Expand Down
4 changes: 2 additions & 2 deletions lib/prepare_security.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ export default class PrepareSecurityRelease extends SecurityRelease {
await this.closePRWithLabel('Security Release');

const updateFolder = await this.cli.prompt(
// eslint-disable-next-line max-len
`Would you like to update the next-security-release folder to ${vulnerabilityJSON.releaseDate}?`,
`Would you like to update the next-security-release folder to ${
vulnerabilityJSON.releaseDate}?`,
{ defaultAnswer: true });
if (updateFolder) {
this.updateReleaseFolder(
Expand Down
2 changes: 0 additions & 2 deletions lib/release/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,10 @@ export function getStartLTSBlurb({ date, ltsCodename, versionComponents }) {
const eol = eolDate.toLocaleString('en-US', dateFormat);
const { major } = versionComponents;
return [
/* eslint-disable max-len */
`This release marks the transition of Node.js ${major}.x into Long Term Support (LTS)`,
`with the codename '${ltsCodename}'. The ${major}.x release line now moves into "Active LTS"`,
`and will remain so until ${mainStart}. After that time, it will move into`,
`"Maintenance" until end of life in ${eol}.`
/* eslint-enable */
].join('\n');
}

Expand Down
1 change: 0 additions & 1 deletion lib/team_info.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ TeamInfo.update = async function(cli, request, content) {

const blocks = new Map();
let m;
// eslint-disable-next-line no-cond-assign
while ((m = RE.exec(content))) {
const [, org, team] = m;
const mapKey = key(org, team);
Expand Down
2 changes: 0 additions & 2 deletions lib/update-v8/majorUpdate.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ function updateV8Deps() {
path: v8Dep.repo
})), newV8Version);
if (deps.length === 0) return;
/* eslint-disable no-await-in-loop */
for (const dep of deps) {
if (dep.gitignore) {
if (typeof dep.gitignore === 'string') {
Expand All @@ -132,7 +131,6 @@ function updateV8Deps() {
const thePath = path.join(ctx.nodeDir, 'deps/v8', dep.path);
await fetchFromGit(thePath, repo, commit);
}
/* eslint-enable */
}
};
}
Expand Down
3 changes: 2 additions & 1 deletion lib/voting_session.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
getEditor, isGhAvailable
} from './utils.js';

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

Expand Down Expand Up @@ -97,7 +98,7 @@ export default class VotingSession extends Session {
cp.stdin.end(share);
const [code] = await Promise.race([
once(cp, 'exit'),
once(cp, 'error').then((er) => Promise.reject(er))
once(cp, 'error').then((er) => { throw er; })
]);
if (code !== 0) throw new Error('failed', { cause: code });
return Buffer.concat(await stdout);
Expand Down
15 changes: 9 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"@pkgjs/nv": "^0.2.2",
"branch-diff": "^3.1.1",
"chalk": "^5.4.1",
"changelog-maker": "^4.3.1",
"changelog-maker": "^4.3.2",
"cheerio": "^1.0.0",
"clipboardy": "^4.0.0",
"core-validate-commit": "^4.1.0",
Expand All @@ -53,18 +53,21 @@
"log-symbols": "^7.0.0",
"ora": "^8.1.1",
"replace-in-file": "^8.3.0",
"undici": "^7.2.2",
"semver": "^7.6.3",
"undici": "^7.3.0",
"which": "^5.0.0",
"yargs": "^17.7.2"
},
"devDependencies": {
"@eslint/js": "^9.19.0",
"@reporters/github": "^1.7.2",
"c8": "^10.1.3",
"eslint": "^8.57.1",
"eslint-config-standard": "^17.1.0",
"eslint": "^9.19.0",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-n": "^16.6.2",
"eslint-plugin-promise": "^6.6.0",
"eslint-plugin-n": "^17.15.1",
"eslint-plugin-promise": "^7.2.1",
"globals": "^15.14.0",
"neostandard": "^0.12.0",
"sinon": "^19.0.2"
}
}
1 change: 1 addition & 0 deletions test/fixtures/release/expected-test-process-release.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict';

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

const assert = require('assert');
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/release/original-test-process-release.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict';

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

const assert = require('assert');
Expand Down
1 change: 1 addition & 0 deletions test/unit/ci_start.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable import/no-named-as-default-member */
import { describe, it, before, afterEach } from 'node:test';
import assert from 'assert';

Expand Down
1 change: 1 addition & 0 deletions test/unit/pr_checker.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable import/no-named-as-default-member */
import { describe, it, before, after, afterEach } from 'node:test';
import assert from 'node:assert';

Expand Down
1 change: 1 addition & 0 deletions test/unit/pr_data.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable import/no-named-as-default-member */
import { describe, it } from 'node:test';
import assert from 'node:assert';

Expand Down
2 changes: 0 additions & 2 deletions test/unit/prepare_release.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,10 @@ describe('prepare_release: utils.getLTSMaintenanceStartDate', () => {
describe('prepare_release: utils.getStartLTSBlurb', () => {
it('generates first LTS release text with correct dates', () => {
const expected = [
/* eslint-disable max-len */
'This release marks the transition of Node.js 14.x into Long Term Support (LTS)',
'with the codename \'Fermium\'. The 14.x release line now moves into "Active LTS"',
'and will remain so until October 2021. After that time, it will move into',
'"Maintenance" until end of life in April 2023.'
/* eslint-enable max-len */
].join('\n');
const text = utils.getStartLTSBlurb({
date: '2020-10-27',
Expand Down
1 change: 1 addition & 0 deletions test/unit/team_info.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable import/no-named-as-default-member */
import { describe, it, before, after } from 'node:test';
import assert from 'node:assert';

Expand Down
1 change: 1 addition & 0 deletions test/unit/wpt_updater.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable import/no-named-as-default-member */
import { describe, it, before, after } from 'node:test';
import assert from 'node:assert';
import TestCLI from '../fixtures/test_cli.js';
Expand Down

0 comments on commit b982dae

Please sign in to comment.