diff --git a/.babelrc.json b/.babelrc.json index 68ca053f..6ca99f28 100644 --- a/.babelrc.json +++ b/.babelrc.json @@ -8,7 +8,7 @@ "@babel/preset-env", { "targets": { - "node": 16 + "node": 20 } } ] diff --git a/.github/workflows/feature.yaml b/.github/workflows/feature.yaml index d8e7b583..a58769f3 100644 --- a/.github/workflows/feature.yaml +++ b/.github/workflows/feature.yaml @@ -13,7 +13,7 @@ jobs: - name: setup node.js uses: actions/setup-node@v4 with: - node-version: '20' + node-version: '20.11.0' - run: pnpm install - run: pnpm build - run: pnpm lint @@ -40,8 +40,7 @@ jobs: fail-fast: false matrix: node_js_version: - - '18' - - '20' + - '20.11.0' - '22' build: runs-on: ubuntu-latest @@ -57,7 +56,7 @@ jobs: - name: setup node.js uses: actions/setup-node@v4 with: - node-version: '20' + node-version: '20.11.0' - run: pnpm install - run: pnpm build timeout-minutes: 10 diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index f10c5484..3ff1fc0f 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -14,7 +14,7 @@ jobs: - name: setup node.js uses: actions/setup-node@v4 with: - node-version: "20" + node-version: "22" - run: pnpm install - run: pnpm build - run: npx semantic-release diff --git a/package.json b/package.json index d09c122f..4aaa7945 100644 --- a/package.json +++ b/package.json @@ -71,7 +71,7 @@ "typescript-eslint": "^8.1.0" }, "engines": { - "node": ">=18" + "node": ">=20.11.0" }, "keywords": [ "eslint", diff --git a/src/bin/generateDocs.js b/src/bin/generateDocs.js index e5ec9e6e..f05cffdf 100644 --- a/src/bin/generateDocs.js +++ b/src/bin/generateDocs.js @@ -1,8 +1,7 @@ /** * This script is used to inline assertions into the README.md documents. */ -import path, {dirname} from 'path'; -import {fileURLToPath} from 'url'; +import path from 'path'; import fs from 'fs'; import decamelize from 'decamelize'; import Gitdown from 'gitdown'; @@ -10,7 +9,7 @@ import { glob, } from 'glob'; -const __dirname = dirname(fileURLToPath(import.meta.url)); +const __dirname = import.meta.dirname; /** * @param {string} code diff --git a/src/bin/generateRule.js b/src/bin/generateRule.js index 2fd8e1cd..8f0746f9 100644 --- a/src/bin/generateRule.js +++ b/src/bin/generateRule.js @@ -1,12 +1,11 @@ /* eslint-disable no-console -- CLI */ -import {fileURLToPath} from 'url'; import { existsSync, } from 'fs'; import fs from 'fs/promises'; import { - resolve, dirname, + resolve, } from 'path'; /** @@ -20,8 +19,6 @@ import { import camelCase from 'camelcase'; import open from 'open-editor'; -const __dirname = dirname(fileURLToPath(import.meta.url)); - // Todo: Would ideally have prompts, e.g., to ask for whether // type was problem/layout, etc. @@ -283,7 +280,7 @@ export default iterateJsdoc(({ */ // Set chdir as somehow still in operation from other test - process.chdir(resolve(__dirname, '../../')); + process.chdir(resolve(import.meta.dirname, '../../')); await open([ // Could even add editor line column numbers like `${rulePath}:1:1` ruleReadmePath, diff --git a/src/getJsdocProcessorPlugin.js b/src/getJsdocProcessorPlugin.js index ac44475e..4b5bf713 100644 --- a/src/getJsdocProcessorPlugin.js +++ b/src/getJsdocProcessorPlugin.js @@ -1,8 +1,7 @@ // Todo: Support TS by fenced block type import {readFileSync} from 'node:fs'; -import { dirname, join } from 'node:path'; -import { fileURLToPath } from 'node:url'; +import { join } from 'node:path'; import * as espree from 'espree'; import { getRegexFromString, @@ -15,11 +14,9 @@ import { parseComment, } from '@es-joy/jsdoccomment'; -const __dirname = dirname(fileURLToPath(import.meta.url)); - const {version} = JSON.parse( // @ts-expect-error `Buffer` is ok for `JSON.parse` - readFileSync(join(__dirname, '../package.json')) + readFileSync(join(import.meta.dirname, '../package.json')) ); // const zeroBasedLineIndexAdjust = -1; diff --git a/src/rules/checkValues.js b/src/rules/checkValues.js index 6b0b67a9..66f407e4 100644 --- a/src/rules/checkValues.js +++ b/src/rules/checkValues.js @@ -1,13 +1,8 @@ -import { dirname, join } from 'node:path'; -import { fileURLToPath } from 'node:url'; - import semver from 'semver'; import spdxExpressionParse from 'spdx-expression-parse'; import {parseImportsExports} from 'parse-imports-exports'; import iterateJsdoc from '../iterateJsdoc.js'; -const __dirname = dirname(fileURLToPath(import.meta.url)); - const allowedKinds = new Set([ 'class', 'constant', diff --git a/src/rules/noUndefinedTypes.js b/src/rules/noUndefinedTypes.js index a1992e70..d9103586 100644 --- a/src/rules/noUndefinedTypes.js +++ b/src/rules/noUndefinedTypes.js @@ -1,6 +1,3 @@ -import { dirname, join } from 'path'; -import { fileURLToPath } from 'url'; - import {parseImportsExports} from 'parse-imports-exports'; import { getJSDocComment, @@ -12,8 +9,6 @@ import iterateJsdoc, { parseComment, } from '../iterateJsdoc.js'; -const __dirname = dirname(fileURLToPath(import.meta.url)); - const extraTypes = [ 'null', 'undefined', 'void', 'string', 'boolean', 'object', 'function', 'symbol', diff --git a/test/rules/index.js b/test/rules/index.js index f15b892d..c8725b53 100644 --- a/test/rules/index.js +++ b/test/rules/index.js @@ -1,5 +1,4 @@ import config from '../../src/index.js'; -import {fileURLToPath} from 'url'; import camelCase from 'camelcase'; import { ESLint, @@ -10,7 +9,6 @@ import { } from 'fs'; import defaultsDeep from 'lodash.defaultsdeep'; import { - dirname, join, } from 'path'; import semver from 'semver'; @@ -21,13 +19,13 @@ import semver from 'semver'; * @property {import('eslint').RuleTester.InvalidTestCase[]} invalid */ -const __dirname = dirname(fileURLToPath(import.meta.url)); - const ruleTester = new RuleTester(); // eslint-disable-next-line complexity -- Temporary const main = async () => { - const ruleNames = JSON.parse(readFileSync(join(__dirname, './ruleNames.json'), 'utf8')); + const ruleNames = JSON.parse(readFileSync(join( + import.meta.dirname, './ruleNames.json' + ), 'utf8')); if (!config.rules) { throw new Error('TypeScript guard');