Skip to content

Commit bfb0830

Browse files
authored
build(benchmark): upgrade to ESLint 9 with flat config (microsoft#26412)
## Summary - Replace legacy `.eslintrc.cjs` with ESLint 9 `eslint.config.mts` flat config - Remove `@fluidframework/eslint-config-fluid` (not ESLint 9 compatible yet); added TODO to re-enable once v9 is released - Add required plugins directly: `typescript-eslint`, `eslint-plugin-import-x`, `eslint-plugin-unicorn`, `eslint-config-prettier`, `eslint-import-resolver-typescript`, and `jiti` - Upgrade `eslint` from `~8.57.0` to `~9.39.1` - Update `eslint-disable` comments from `import/` to `import-x/` prefix
1 parent 25005e2 commit bfb0830

File tree

6 files changed

+510
-1897
lines changed

6 files changed

+510
-1897
lines changed

tools/benchmark/.eslintrc.cjs

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

tools/benchmark/eslint.config.mts

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
/*!
2+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3+
* Licensed under the MIT License.
4+
*/
5+
6+
// TODO: Replace this local config with the shared @fluidframework/eslint-config-fluid
7+
// flat config once v9 is released. Example:
8+
// import { recommended } from "@fluidframework/eslint-config-fluid/flat.mts";
9+
// ...recommended,
10+
11+
import eslint from "@eslint/js";
12+
import eslintConfigPrettier from "eslint-config-prettier";
13+
import importPlugin from "eslint-plugin-import-x";
14+
import unicorn from "eslint-plugin-unicorn";
15+
import type { Linter } from "eslint";
16+
import tseslint from "typescript-eslint";
17+
18+
const config: Linter.Config[] = [
19+
// Base ESLint recommended rules
20+
eslint.configs.recommended,
21+
22+
// TypeScript ESLint recommended rules (type-checked)
23+
...tseslint.configs.recommendedTypeChecked,
24+
25+
// import-x plugin for import rules
26+
importPlugin.flatConfigs.recommended as Linter.Config,
27+
importPlugin.flatConfigs.typescript as Linter.Config,
28+
29+
// Unicorn plugin - register plugin so eslint-disable comments for unicorn rules are valid.
30+
// Only specific rules are enabled; the full recommended preset is not used due to a
31+
// compatibility issue between eslint-plugin-unicorn@54 and eslint@9.39 (expiring-todo-comments).
32+
{
33+
plugins: {
34+
unicorn,
35+
},
36+
rules: {
37+
"unicorn/prefer-module": "error",
38+
"unicorn/prefer-native-coercion-functions": "error",
39+
"unicorn/prefer-ternary": "error",
40+
"unicorn/no-negated-condition": "error",
41+
},
42+
},
43+
44+
// TypeScript parser and project configuration
45+
{
46+
languageOptions: {
47+
parserOptions: {
48+
projectService: true,
49+
tsconfigRootDir: import.meta.dirname,
50+
},
51+
},
52+
settings: {
53+
"import-x/resolver": {
54+
typescript: true,
55+
node: true,
56+
},
57+
},
58+
},
59+
60+
// Project-specific rule overrides
61+
{
62+
rules: {
63+
"@typescript-eslint/no-shadow": "off",
64+
"@typescript-eslint/no-unsafe-call": "off",
65+
"@typescript-eslint/no-unsafe-member-access": "off",
66+
"@typescript-eslint/require-await": "off",
67+
"@typescript-eslint/restrict-template-expressions": "off",
68+
"import-x/no-nodejs-modules": [
69+
"error",
70+
{ allow: ["node:v8", "perf_hooks", "node:child_process"] },
71+
],
72+
},
73+
},
74+
75+
// Test file overrides
76+
{
77+
files: ["src/test/**"],
78+
rules: {
79+
"import-x/no-nodejs-modules": "off",
80+
},
81+
},
82+
83+
// Prettier config - disables rules that conflict with prettier. Must be last so
84+
// no subsequent config objects can re-enable formatting rules.
85+
eslintConfigPrettier,
86+
];
87+
88+
export default config;

tools/benchmark/package.json

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
"devDependencies": {
4646
"@fluid-internal/mocha-test-setup": "~2.51.0",
4747
"@fluidframework/build-common": "^2.0.3",
48-
"@fluidframework/eslint-config-fluid": "^6.1.0",
4948
"@microsoft/api-extractor": "^7.52.11",
5049
"@types/chai": "^5.2.2",
5150
"@types/mocha": "^10.0.10",
@@ -54,14 +53,22 @@
5453
"concurrently": "^8.2.2",
5554
"copyfiles": "^2.4.1",
5655
"cross-env": "^7.0.3",
57-
"eslint": "~8.57.0",
56+
"eslint": "~9.39.1",
57+
"eslint-config-prettier": "~10.1.8",
58+
"eslint-import-resolver-typescript": "~4.4.4",
59+
"eslint-plugin-import-x": "~4.16.1",
60+
"eslint-plugin-unicorn": "~54.0.0",
61+
"jiti": "^2.6.1",
5862
"prettier": "~3.0.3",
5963
"rimraf": "^4.4.1",
60-
"typescript": "~5.4.5"
64+
"typescript": "~5.4.5",
65+
"typescript-eslint": "~8.54.0"
6166
},
6267
"packageManager": "pnpm@10.18.3+sha512.bbd16e6d7286fd7e01f6b3c0b3c932cda2965c06a908328f74663f10a9aea51f1129eea615134bf992831b009eabe167ecb7008b597f40ff9bc75946aadfb08d",
6368
"pnpm": {
64-
"onlyBuiltDependencies": ["unrs-resolver"],
69+
"onlyBuiltDependencies": [
70+
"unrs-resolver"
71+
],
6572
"overrides": {
6673
"nanoid": "^3.3.9"
6774
}

0 commit comments

Comments
 (0)