Skip to content

Commit 1f2442f

Browse files
committed
feat(lint): migrate to ESLint 9 flat config
Replace .eslintrc.json and .eslintignore with a single eslint.config.mjs using the new flat config format. typescript-eslint v8 split ban-types into three rules: - no-unsafe-function-type (for Function) - no-wrapper-object-types (for Object, String, etc.) - no-restricted-types (user-defined) Update all inline eslint-disable directives to use the new rule names. Fix one real Object -> object type issue in transformerInterceptor.ts. The old header/header plugin is gone; update 5 test files to use the replacement headers/header-format directive. Add *.fuzz.{js,ts} to the jest globals config, which the old config covered via a global env setting.
1 parent e78de78 commit 1f2442f

18 files changed

Lines changed: 156 additions & 92 deletions

File tree

.eslintignore

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

.eslintrc.json

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

eslint.config.mjs

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
import js from "@eslint/js";
2+
import eslintConfigPrettier from "eslint-config-prettier";
3+
import headers from "eslint-plugin-headers";
4+
import importX from "eslint-plugin-import-x";
5+
import jest from "eslint-plugin-jest";
6+
import markdownlint from "eslint-plugin-markdownlint";
7+
import markdownlintParser from "eslint-plugin-markdownlint/parser.js";
8+
import globals from "globals";
9+
import tseslint from "typescript-eslint";
10+
11+
export default tseslint.config(
12+
// Global ignores (replaces .eslintignore)
13+
{
14+
ignores: [
15+
"**/dist/",
16+
"**/build/",
17+
"**/cmake-build-*/",
18+
"**/coverage/",
19+
"**/node_modules/",
20+
"**/.idea/",
21+
],
22+
},
23+
24+
// Base config for all JS/TS files
25+
js.configs.recommended,
26+
...tseslint.configs.recommended,
27+
eslintConfigPrettier,
28+
importX.flatConfigs.recommended,
29+
importX.flatConfigs.typescript,
30+
31+
// Global settings for JS/TS files
32+
{
33+
languageOptions: {
34+
globals: {
35+
...globals.node,
36+
},
37+
},
38+
settings: {
39+
"import-x/resolver": {
40+
typescript: true,
41+
node: true,
42+
},
43+
},
44+
rules: {
45+
"import-x/no-named-as-default": "off",
46+
"import-x/no-named-as-default-member": "off",
47+
},
48+
},
49+
50+
// JS/TS specific rules (replaces the *.js, *.ts override)
51+
{
52+
files: ["**/*.js", "**/*.ts"],
53+
plugins: {
54+
headers,
55+
},
56+
rules: {
57+
"@typescript-eslint/ban-ts-comment": "off",
58+
"@typescript-eslint/no-require-imports": "off",
59+
"@typescript-eslint/no-unused-expressions": "off",
60+
"@typescript-eslint/no-unused-vars": "off",
61+
"headers/header-format": [
62+
"error",
63+
{
64+
source: "string",
65+
blockPrefix: "\n",
66+
content:
67+
'Copyright 2026 Code Intelligence GmbH\n\nLicensed under the Apache License, Version 2.0 (the "License");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an "AS IS" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.',
68+
},
69+
],
70+
"import-x/first": "error",
71+
"import-x/newline-after-import": "error",
72+
"import-x/no-unresolved": "warn",
73+
"import-x/order": [
74+
"error",
75+
{
76+
alphabetize: { order: "asc", caseInsensitive: true },
77+
"newlines-between": "always",
78+
distinctGroup: true,
79+
pathGroupsExcludedImportTypes: ["builtin"],
80+
pathGroups: [
81+
{
82+
pattern: "@jazzer.js/**",
83+
group: "external",
84+
position: "after",
85+
},
86+
],
87+
},
88+
],
89+
"sort-imports": [
90+
"error",
91+
{
92+
ignoreCase: true,
93+
ignoreDeclarationSort: true,
94+
},
95+
],
96+
},
97+
},
98+
99+
// Exclude header check from the header template file itself
100+
{
101+
files: [".header.js"],
102+
rules: {
103+
"headers/header-format": "off",
104+
},
105+
},
106+
107+
// Disable unresolved import warnings for examples/tests with their own deps
108+
{
109+
files: ["examples/**", "tests/**"],
110+
rules: {
111+
"import-x/no-unresolved": "off",
112+
},
113+
},
114+
115+
// Jest globals for test and fuzz files
116+
{
117+
files: ["**/*.test.ts", "**/*.test.js", "**/*.fuzz.ts", "**/*.fuzz.js"],
118+
plugins: {
119+
jest,
120+
},
121+
languageOptions: {
122+
globals: {
123+
...globals.jest,
124+
},
125+
},
126+
},
127+
128+
// Markdown files
129+
{
130+
files: ["**/*.md"],
131+
plugins: {
132+
markdownlint,
133+
},
134+
languageOptions: {
135+
parser: markdownlintParser,
136+
},
137+
rules: {
138+
...markdownlint.configs.recommended.rules,
139+
"markdownlint/md010": "off",
140+
"markdownlint/md013": "off",
141+
"markdownlint/md033": "off",
142+
"markdownlint/md041": "off",
143+
},
144+
},
145+
);

examples/bug-detectors/prototype-pollution/config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
const {
1818
getBugDetectorConfiguration,
19-
// eslint-disable-next-line @typescript-eslint/no-var-requires
2019
} = require("../../../packages/bug-detectors");
2120

2221
getBugDetectorConfiguration("prototype-pollution")

packages/bug-detectors/internal/prototype-pollution.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ interface PrototypePollution {
9999
}
100100

101101
declare global {
102-
// eslint-disable-next-line no-var
103102
var PrototypePollution: PrototypePollution;
104103
}
105104

packages/core/globals.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
*/
1616

1717
declare global {
18-
// eslint-disable-next-line no-var
1918
var JazzerJS: Map<string, unknown> | undefined;
2019
}
2120

packages/hooking/hook.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export type ReplaceHookFn = (
2828
thisPtr: any,
2929
params: any[],
3030
hookId: number,
31-
// eslint-disable-next-line @typescript-eslint/ban-types
31+
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
3232
origFn: Function,
3333
) => any;
3434

packages/hooking/manager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ export class HookManager {
226226
thisPtr,
227227
params,
228228
callSiteId(),
229-
// eslint-disable-next-line @typescript-eslint/ban-types
229+
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
230230
resultOrOriginalFunction as Function,
231231
);
232232
case HookType.After:

packages/instrumentor/plugins/codeCoverage.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ export function codeCoverage(idStrategy: EdgeIdStrategy): () => PluginTarget {
5959
return () => {
6060
return {
6161
visitor: {
62-
// eslint-disable-next-line @typescript-eslint/ban-types
6362
Function(path: NodePath<Function>) {
6463
if (isBlockStatement(path.node.body)) {
6564
const bodyStmt = path.node.body as BlockStatement;

packages/instrumentor/plugins/functionHooks.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -946,12 +946,12 @@ function registerHook(
946946
target,
947947
"pkg",
948948
isAsync,
949-
// eslint-disable-next-line @typescript-eslint/ban-types
949+
950950
(
951951
thisPtr: unknown,
952952
params: number[],
953953
_hookId: number,
954-
// eslint-disable-next-line @typescript-eslint/ban-types
954+
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
955955
originalFunction: Function,
956956
) => {
957957
const [calls, hook] = hookCallMap.get(i) as [number, Hook];

0 commit comments

Comments
 (0)