Skip to content

Commit c1b55f6

Browse files
Use eslint.config.mts (#17573)
Co-authored-by: Nicolò Ribaudo <hello@nicr.dev>
1 parent d1e1bad commit c1b55f6

22 files changed

Lines changed: 305 additions & 231 deletions

File tree

Makefile.mjs

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

Makefile.source.mjs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,13 @@ target["clone-license"] = function () {
355355
*/
356356

357357
function eslint(...extraArgs) {
358-
const eslintArgs = ["--format", "codeframe", ...extraArgs.filter(Boolean)];
358+
const eslintArgs = [
359+
"--format",
360+
"codeframe",
361+
"--flag",
362+
"unstable_native_nodejs_ts_config",
363+
...extraArgs.filter(Boolean),
364+
];
359365

360366
const packagesPackages = readdirSync("packages").filter(n =>
361367
existsSync(`packages/${n}/package.json`)
Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1-
// @ts-check
2-
31
import babelParser from "@babel/eslint-parser/experimental-worker";
42
import globals from "globals";
53
import js from "@eslint/js";
4+
import { defineConfig } from "eslint/config";
65
// @ts-expect-error no types
76
import pluginImport from "eslint-plugin-import";
87
import pluginJest from "eslint-plugin-jest";
98
import pluginN from "eslint-plugin-n";
109
import configPrettier from "eslint-config-prettier";
1110
import pluginRegexp from "eslint-plugin-regexp";
1211
import pluginUnicorn from "eslint-plugin-unicorn";
12+
// @ts-expect-error no types
1313
import pluginBabelDevelopment from "@babel/eslint-plugin-development";
14+
// @ts-expect-error no types
1415
import pluginBabelDevelopmentInternal from "@babel/eslint-plugin-development-internal";
1516
import typescriptEslint from "typescript-eslint";
1617
import { commonJS } from "$repo-utils";
@@ -26,13 +27,13 @@ const testFiles = [
2627
"codemods/*/test/**/*.js",
2728
"eslint/*/test/**/*.js",
2829
];
29-
const sourceFiles = exts => [
30+
const sourceFiles = (exts: string) => [
3031
`packages/*/src/**/*.{${exts}}`,
3132
`codemods/*/src/**/*.{${exts}}`,
3233
`eslint/*/src/**/*.{${exts}}`,
3334
];
3435

35-
export default [
36+
export default defineConfig([
3637
{
3738
ignores: [
3839
"/lib",
@@ -127,11 +128,11 @@ export default [
127128
"unicorn/prefer-string-starts-ends-with": "error",
128129
},
129130
},
130-
...typescriptEslint.config({
131-
files: ["**/*.{ts,cts}"],
131+
...defineConfig({
132+
files: ["**/*.{ts,cts,mts}"],
132133
extends: [
133-
...typescriptEslint.configs.recommendedTypeChecked,
134-
...typescriptEslint.configs.stylisticTypeChecked,
134+
typescriptEslint.configs.recommendedTypeChecked,
135+
typescriptEslint.configs.stylisticTypeChecked,
135136
],
136137
languageOptions: {
137138
parser: typescriptEslint.parser,
@@ -440,4 +441,4 @@ export default [
440441
"@typescript-eslint/dot-notation": ["error", { allowKeywords: false }],
441442
},
442443
},
443-
];
444+
]);

package.json

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"test:runtime:node": "node test/runtime-integration/node.cjs"
2121
},
2222
"packageManager": "yarn@4.10.3",
23+
"_": "The dependency on minimatch (npm:is-odd@*) is to avoid hoisting of the real minimatch, which causes type issues",
2324
"devDependencies": {
2425
"$repo-utils": "link:./scripts/repo-utils",
2526
"@actions/github": "6.0.1",
@@ -38,7 +39,7 @@
3839
"@babel/preset-typescript": "8.0.0-beta.0",
3940
"@babel/runtime": "8.0.0-beta.0",
4041
"@cspotcode/source-map-support": "^0.8.1",
41-
"@eslint/js": "^9.22.0",
42+
"@eslint/js": "^9.38.0",
4243
"@rollup/plugin-babel": "^6.0.4",
4344
"@rollup/plugin-commonjs": "^25.0.7",
4445
"@rollup/plugin-json": "^6.1.0",
@@ -52,12 +53,12 @@
5253
"c8": "^10.0.0",
5354
"charcodes": "^0.2.0",
5455
"core-js": "^3.36.1",
55-
"eslint": "^9.22.0",
56-
"eslint-config-prettier": "^9.1.0",
56+
"eslint": "^9.38.0",
57+
"eslint-config-prettier": "^10.1.8",
5758
"eslint-formatter-codeframe": "^7.32.1",
5859
"eslint-import-resolver-node": "^0.3.9",
5960
"eslint-plugin-import": "^2.31.0",
60-
"eslint-plugin-jest": "^27.9.0",
61+
"eslint-plugin-jest": "^29.0.1",
6162
"eslint-plugin-n": "^17.10.3",
6263
"eslint-plugin-regexp": "^2.6.0",
6364
"eslint-plugin-unicorn": "^56.0.0",
@@ -74,6 +75,7 @@
7475
"json5": "^2.2.3",
7576
"lint-staged": "^15.2.7",
7677
"mergeiterator": "^1.4.4",
78+
"minimatch": "npm:is-odd@*",
7779
"picocolors": "^1.0.0",
7880
"pkg-pr-new": "^0.0.54",
7981
"prettier": "^3.5.2",
@@ -85,8 +87,8 @@
8587
"shelljs": "^0.8.5",
8688
"terser": "^5.43.1",
8789
"test262-stream": "^1.4.0",
88-
"typescript": "5.9.2",
89-
"typescript-eslint": "8.39.1"
90+
"typescript": "5.9.3",
91+
"typescript-eslint": "8.46.2"
9092
},
9193
"workspaces": [
9294
"codemods/*",
@@ -116,7 +118,7 @@
116118
"git add Makefile.mjs"
117119
],
118120
"*.{js,cjs,mjs,ts,cts,mts}": [
119-
"eslint --format=codeframe --cache --cache-strategy=content"
121+
"eslint --format=codeframe --cache --cache-strategy=content --flag unstable_native_nodejs_ts_config"
120122
],
121123
"*": [
122124
"prettier --write --ignore-unknown"

packages/babel-core/src/config/files/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ type indexType = typeof import("./index");
33

44
// Kind of gross, but essentially asserting that the exports of this module are the same as the
55
// exports of index-browser, since this file may be replaced at bundle time with index-browser.
6+
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
67
({}) as any as indexBrowserType as indexType;
78

89
export { findPackageData } from "./package.ts";

packages/babel-core/src/config/resolve-targets.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ type nodeType = typeof import("./resolve-targets");
33

44
// Kind of gross, but essentially asserting that the exports of this module are the same as the
55
// exports of index-browser, since this file may be replaced at bundle time with index-browser.
6+
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
67
({}) as any as browserType as nodeType;
78

89
import type { InputOptions } from "./validation/options.ts";

packages/babel-core/src/transform-file.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ type transformFileType = typeof import("./transform-file");
1212
// Kind of gross, but essentially asserting that the exports of this module are the same as the
1313
// exports of transform-file-browser, since this file may be replaced at bundle time with
1414
// transform-file-browser.
15+
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
1516
({}) as any as transformFileBrowserType as transformFileType;
1617

1718
const transformFileRunner = gensync(function* (

packages/babel-core/test/config-ts-integration-tsx.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const shouldSkip = semver.lt(process.version, "18.0.0");
2727
let unregister;
2828
beforeAll(async () => {
2929
// tsx/cjs/api is a defined sub-export
30-
// eslint-disable-next-line import/no-unresolved, import/extensions
30+
// eslint-disable-next-line import/extensions
3131
const tsx = require("tsx/cjs/api");
3232
// Provide a dummy tsconfig.json to avoid tsx resolving @babel/* from the `src` directory, where
3333
// undeclared globals such as the PACKAGE_JSON macro will break

packages/babel-generator/src/token-map.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export class TokenMap {
8383
// overhead in the simple case of having unique tokens per node.
8484
if (count > 1) {
8585
const cache = this._nodesOccurrencesCountCache.get(node);
86-
if (cache && cache.test === test && cache.count < count) {
86+
if (cache?.test === test && cache.count < count) {
8787
i = cache.i + 1;
8888
occurrenceCount -= cache.count + 1;
8989
}
@@ -143,8 +143,7 @@ export class TokenMap {
143143
if (
144144
(node.type === "ExportNamedDeclaration" ||
145145
node.type === "ExportDefaultDeclaration") &&
146-
node.declaration &&
147-
node.declaration.type === "ClassDeclaration"
146+
node.declaration?.type === "ClassDeclaration"
148147
) {
149148
// Exported class declarations can be not properly nested inside
150149
// the export declaration that contains them. For example, in

packages/babel-helper-replace-supers/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const unshadowSuperBindingVisitor = visitors.environmentVisitor<{
4545
Scopable(path, { refName }) {
4646
// https://github.com/Zzzen/babel/pull/1#pullrequestreview-564833183
4747
const binding = path.scope.getOwnBinding(refName);
48-
if (binding && binding.identifier.name === refName) {
48+
if (binding?.identifier.name === refName) {
4949
path.scope.rename(refName);
5050
}
5151
},

0 commit comments

Comments
 (0)