Skip to content

Commit 20f2c8b

Browse files
committed
chore: bump to Node 20.11.0+
BREAKING CHANGE: Requires Node 20.11.0+ Also: - refactor: use `import.meta.dirname`
1 parent 65b0dc0 commit 20f2c8b

File tree

10 files changed

+15
-33
lines changed

10 files changed

+15
-33
lines changed

.babelrc.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"@babel/preset-env",
99
{
1010
"targets": {
11-
"node": 16
11+
"node": 20
1212
}
1313
}
1414
]

.github/workflows/feature.yaml

+3-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
- name: setup node.js
1414
uses: actions/setup-node@v4
1515
with:
16-
node-version: '20'
16+
node-version: '20.11.0'
1717
- run: pnpm install
1818
- run: pnpm build
1919
- run: pnpm lint
@@ -40,8 +40,7 @@ jobs:
4040
fail-fast: false
4141
matrix:
4242
node_js_version:
43-
- '18'
44-
- '20'
43+
- '20.11.0'
4544
- '22'
4645
build:
4746
runs-on: ubuntu-latest
@@ -57,7 +56,7 @@ jobs:
5756
- name: setup node.js
5857
uses: actions/setup-node@v4
5958
with:
60-
node-version: '20'
59+
node-version: '20.11.0'
6160
- run: pnpm install
6261
- run: pnpm build
6362
timeout-minutes: 10

.github/workflows/main.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
- name: setup node.js
1515
uses: actions/setup-node@v4
1616
with:
17-
node-version: "20"
17+
node-version: "22"
1818
- run: pnpm install
1919
- run: pnpm build
2020
- run: npx semantic-release

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
"typescript-eslint": "^8.1.0"
7272
},
7373
"engines": {
74-
"node": ">=18"
74+
"node": ">=20.11.0"
7575
},
7676
"keywords": [
7777
"eslint",

src/bin/generateDocs.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
/**
22
* This script is used to inline assertions into the README.md documents.
33
*/
4-
import path, {dirname} from 'path';
5-
import {fileURLToPath} from 'url';
4+
import path from 'path';
65
import fs from 'fs';
76
import decamelize from 'decamelize';
87
import Gitdown from 'gitdown';
98
import {
109
glob,
1110
} from 'glob';
1211

13-
const __dirname = dirname(fileURLToPath(import.meta.url));
12+
const __dirname = import.meta.dirname;
1413

1514
/**
1615
* @param {string} code

src/bin/generateRule.js

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
/* eslint-disable no-console -- CLI */
22

3-
import {fileURLToPath} from 'url';
43
import {
54
existsSync,
65
} from 'fs';
76
import fs from 'fs/promises';
87
import {
9-
resolve, dirname,
8+
resolve,
109
} from 'path';
1110

1211
/**
@@ -20,8 +19,6 @@ import {
2019
import camelCase from 'camelcase';
2120
import open from 'open-editor';
2221

23-
const __dirname = dirname(fileURLToPath(import.meta.url));
24-
2522
// Todo: Would ideally have prompts, e.g., to ask for whether
2623
// type was problem/layout, etc.
2724

@@ -283,7 +280,7 @@ export default iterateJsdoc(({
283280
*/
284281

285282
// Set chdir as somehow still in operation from other test
286-
process.chdir(resolve(__dirname, '../../'));
283+
process.chdir(resolve(import.meta.dirname, '../../'));
287284
await open([
288285
// Could even add editor line column numbers like `${rulePath}:1:1`
289286
ruleReadmePath,

src/getJsdocProcessorPlugin.js

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
// Todo: Support TS by fenced block type
22

33
import {readFileSync} from 'node:fs';
4-
import { dirname, join } from 'node:path';
5-
import { fileURLToPath } from 'node:url';
4+
import { join } from 'node:path';
65
import * as espree from 'espree';
76
import {
87
getRegexFromString,
@@ -15,11 +14,9 @@ import {
1514
parseComment,
1615
} from '@es-joy/jsdoccomment';
1716

18-
const __dirname = dirname(fileURLToPath(import.meta.url));
19-
2017
const {version} = JSON.parse(
2118
// @ts-expect-error `Buffer` is ok for `JSON.parse`
22-
readFileSync(join(__dirname, '../package.json'))
19+
readFileSync(join(import.meta.dirname, '../package.json'))
2320
);
2421

2522
// const zeroBasedLineIndexAdjust = -1;

src/rules/checkValues.js

-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
1-
import { dirname, join } from 'node:path';
2-
import { fileURLToPath } from 'node:url';
3-
41
import semver from 'semver';
52
import spdxExpressionParse from 'spdx-expression-parse';
63
import {parseImportsExports} from 'parse-imports-exports';
74
import iterateJsdoc from '../iterateJsdoc.js';
85

9-
const __dirname = dirname(fileURLToPath(import.meta.url));
10-
116
const allowedKinds = new Set([
127
'class',
138
'constant',

src/rules/noUndefinedTypes.js

-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
import { dirname, join } from 'path';
2-
import { fileURLToPath } from 'url';
3-
41
import {parseImportsExports} from 'parse-imports-exports';
52
import {
63
getJSDocComment,
@@ -12,8 +9,6 @@ import iterateJsdoc, {
129
parseComment,
1310
} from '../iterateJsdoc.js';
1411

15-
const __dirname = dirname(fileURLToPath(import.meta.url));
16-
1712
const extraTypes = [
1813
'null', 'undefined', 'void', 'string', 'boolean', 'object',
1914
'function', 'symbol',

test/rules/index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ import semver from 'semver';
2121
* @property {import('eslint').RuleTester.InvalidTestCase[]} invalid
2222
*/
2323

24-
const __dirname = dirname(fileURLToPath(import.meta.url));
25-
2624
const ruleTester = new RuleTester();
2725

2826
// eslint-disable-next-line complexity -- Temporary
2927
const main = async () => {
30-
const ruleNames = JSON.parse(readFileSync(join(__dirname, './ruleNames.json'), 'utf8'));
28+
const ruleNames = JSON.parse(readFileSync(join(
29+
import.meta.dirname, './ruleNames.json'
30+
), 'utf8'));
3131

3232
if (!config.rules) {
3333
throw new Error('TypeScript guard');

0 commit comments

Comments
 (0)