@pob/eslint-config 67.14.0 → 68.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/_base.js +21 -31
- package/lib/eslint-rules.test.js +1 -3
- package/lib/index.js +77 -343
- package/lib/index.test.js +76 -40
- package/lib/node.js +60 -0
- package/lib/overrides/dev-only.js +10 -0
- package/lib/overrides/scripts.js +1 -1
- package/lib/overrides/test.js +7 -45
- package/lib/overrides/tools-project.js +4 -10
- package/lib/oxlint-js-plugins-rules.test.js +62 -0
- package/lib/oxlint-rules.test.js +2 -4
- package/lib/oxlint.test.js +58 -46
- package/lib/plugins/import.js +69 -0
- package/lib/typescript.js +27 -0
- package/oxlint/base.json +4 -0
- package/oxlint/commonjs.json +17 -0
- package/oxlint/module.json +5 -1
- package/oxlint/node.json +5 -1
- package/package.json +10 -15
- package/lib/base/commonjs.js +0 -12
- package/lib/base/module.js +0 -29
- package/lib/node/_base.js +0 -35
- package/lib/node/commonjs.js +0 -25
- package/lib/node/module.js +0 -35
- package/lib/node/typescript.js +0 -15
- package/lib/overrides/allow-implicit-return-type.js +0 -7
- package/lib/overrides/allow-unsafe-as-warn.js +0 -10
- package/lib/overrides/allow-unsafe.js +0 -10
- package/lib/overrides/app.js +0 -8
- package/lib/plugins/import/import-base.js +0 -136
- package/lib/plugins/import/import-commonjs.js +0 -7
- package/lib/plugins/import/import-module.js +0 -7
- package/lib/plugins/node.js +0 -17
- package/lib/plugins/regexp.js +0 -12
- package/lib/plugins/typescript-eslint/typescript-eslint-replace-eslint.js +0 -126
- package/lib/plugins/typescript-eslint/typescript-eslint-replace-unicorn.js +0 -13
- package/lib/plugins/typescript-eslint/typescript-eslint-rules.js +0 -213
- package/lib/plugins/unicorn.js +0 -392
- package/lib/rules/best-practices.js +0 -470
- package/lib/rules/code-quality.js +0 -10
- package/lib/rules/dev-only.js +0 -15
- package/lib/rules/errors.js +0 -128
- package/lib/rules/node.js +0 -26
- package/lib/rules/style.js +0 -26
- package/lib/rules/typescript.js +0 -61
- package/lib/utils/oxlint.js +0 -136
- package/lib/utils/oxlint.test.js +0 -197
package/lib/node.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { createNodeResolver } from "eslint-plugin-import-x";
|
|
2
|
+
import nodePlugin from "eslint-plugin-n";
|
|
3
|
+
import { tsExtensions } from "./typescript.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @param {readonly string[]} moduleFiles
|
|
7
|
+
* @param {readonly string[]} commonjsFiles
|
|
8
|
+
* @returns {import("eslint").Linter.Config[]}
|
|
9
|
+
*/
|
|
10
|
+
export const createNodeConfigs = (moduleFiles, commonjsFiles) => [
|
|
11
|
+
{
|
|
12
|
+
name: "@pob/eslint-config/node/module",
|
|
13
|
+
files: [...moduleFiles],
|
|
14
|
+
plugins: { n: nodePlugin },
|
|
15
|
+
// node globals, for no-undef
|
|
16
|
+
languageOptions:
|
|
17
|
+
nodePlugin.configs["flat/recommended-module"].languageOptions,
|
|
18
|
+
settings: {
|
|
19
|
+
"import-x/resolver-next": [
|
|
20
|
+
createNodeResolver({
|
|
21
|
+
conditionNames: ["node", "import"],
|
|
22
|
+
}),
|
|
23
|
+
],
|
|
24
|
+
},
|
|
25
|
+
rules: {
|
|
26
|
+
// oxlint rejects its fix inserting the shebang
|
|
27
|
+
// https://github.com/eslint-community/eslint-plugin-n/blob/master/docs/rules/hashbang.md
|
|
28
|
+
"n/hashbang": "error",
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
name: "@pob/eslint-config/node/commonjs",
|
|
33
|
+
files: [...commonjsFiles],
|
|
34
|
+
plugins: { n: nodePlugin },
|
|
35
|
+
languageOptions:
|
|
36
|
+
nodePlugin.configs["flat/recommended-script"].languageOptions,
|
|
37
|
+
settings: {
|
|
38
|
+
"import-x/resolver-next": [
|
|
39
|
+
createNodeResolver({
|
|
40
|
+
conditionNames: ["require", "default", "node"],
|
|
41
|
+
}),
|
|
42
|
+
],
|
|
43
|
+
},
|
|
44
|
+
rules: {
|
|
45
|
+
"n/hashbang": "error",
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
name: "@pob/eslint-config/node/typescript",
|
|
50
|
+
files: [`**/*.${tsExtensions}`],
|
|
51
|
+
settings: {
|
|
52
|
+
"import-x/resolver-next": [
|
|
53
|
+
createNodeResolver({
|
|
54
|
+
extensions: [".mjs", ".js", ".json", ".ts"],
|
|
55
|
+
conditionNames: ["node", "import"],
|
|
56
|
+
}),
|
|
57
|
+
],
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// JS files outside of src/ and lib/: configs, scripts, ...
|
|
2
|
+
/** @type {import("eslint").Linter.Config} */
|
|
3
|
+
export default {
|
|
4
|
+
name: "@pob/eslint-config/dev-only",
|
|
5
|
+
files: ["**/*.{js,cjs,mjs}"],
|
|
6
|
+
ignores: ["**/{src,lib}/*.{js,cjs,mjs}"],
|
|
7
|
+
rules: {
|
|
8
|
+
"import-x/no-extraneous-dependencies": ["error", { devDependencies: true }],
|
|
9
|
+
},
|
|
10
|
+
};
|
package/lib/overrides/scripts.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
/** @type {import("eslint").Linter.Config} */
|
|
1
2
|
export default {
|
|
2
3
|
name: "@pob/eslint-config/overrides/scripts",
|
|
3
4
|
rules: {
|
|
4
|
-
"unicorn/no-process-exit": "off",
|
|
5
5
|
"n/hashbang": "off",
|
|
6
6
|
// allow dev dependencies
|
|
7
7
|
"import-x/no-extraneous-dependencies": ["error", { devDependencies: true }],
|
package/lib/overrides/test.js
CHANGED
|
@@ -1,46 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
"import-x/no-extraneous-dependencies": [
|
|
8
|
-
"error",
|
|
9
|
-
{ devDependencies: true },
|
|
10
|
-
],
|
|
11
|
-
},
|
|
1
|
+
/** @type {import("eslint").Linter.Config} */
|
|
2
|
+
export default {
|
|
3
|
+
name: "@pob/eslint-config/test",
|
|
4
|
+
rules: {
|
|
5
|
+
// allow dev dependencies
|
|
6
|
+
"import-x/no-extraneous-dependencies": ["error", { devDependencies: true }],
|
|
12
7
|
},
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
export const testOverrideConfigsWithTypescript = [
|
|
16
|
-
...testOverrideConfigsWithoutTypescript,
|
|
17
|
-
{
|
|
18
|
-
name: "@pob/eslint-config/test-typescript",
|
|
19
|
-
|
|
20
|
-
rules: {
|
|
21
|
-
// enable (as any).something in test
|
|
22
|
-
"@typescript-eslint/no-unsafe-member-access": "off",
|
|
23
|
-
|
|
24
|
-
// jest.mock in test
|
|
25
|
-
"@typescript-eslint/no-unsafe-return": "off",
|
|
26
|
-
|
|
27
|
-
// don't force return type in test
|
|
28
|
-
"@typescript-eslint/explicit-function-return-type": "off",
|
|
29
|
-
|
|
30
|
-
// https://github.com/nodejs/node/issues/51292
|
|
31
|
-
"@typescript-eslint/no-floating-promises": [
|
|
32
|
-
"error",
|
|
33
|
-
{
|
|
34
|
-
ignoreVoid: false,
|
|
35
|
-
allowForKnownSafeCalls: [
|
|
36
|
-
{
|
|
37
|
-
from: "package",
|
|
38
|
-
name: ["it", "describe", "test"],
|
|
39
|
-
package: "node:test",
|
|
40
|
-
},
|
|
41
|
-
],
|
|
42
|
-
},
|
|
43
|
-
],
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
];
|
|
8
|
+
};
|
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
// non-published typescript run in place (scripts/**/*.ts, root *.config.ts)
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
// (packages/*/scripts, @scope/*/scripts, ...) against the root tools project.
|
|
1
|
+
// non-published typescript run in place (scripts/**/*.ts, root *.config.ts):
|
|
2
|
+
// vitest is resolved from the root of the project. The scripts glob is
|
|
3
|
+
// **/scripts/** so it covers both single repos and monorepo package scripts.
|
|
4
|
+
/** @type {import("eslint").Linter.Config} */
|
|
6
5
|
export default {
|
|
7
6
|
name: "@pob/eslint-config/overrides/tools-project",
|
|
8
7
|
files: ["**/{scripts,e2e}/**/*.{ts,mts,cts}", "*.config.{ts,mts,cts}"],
|
|
9
|
-
languageOptions: {
|
|
10
|
-
parserOptions: {
|
|
11
|
-
project: "tsconfig.tools.json",
|
|
12
|
-
},
|
|
13
|
-
},
|
|
14
8
|
settings: {
|
|
15
9
|
"import-x/core-modules": ["vitest"],
|
|
16
10
|
},
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { readFileSync, readdirSync } from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { pathToFileURL } from "node:url";
|
|
4
|
+
import { describe, expect, it } from "vitest";
|
|
5
|
+
import {
|
|
6
|
+
getEnabledOxlintConfigRules,
|
|
7
|
+
oxlintConfigsDir,
|
|
8
|
+
reactOxlintConfigsDir,
|
|
9
|
+
} from "./test-utils/oxlint.js";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* eslint plugins run by oxlint as JS plugins (`jsPlugins` of oxlint/*.json),
|
|
13
|
+
* by plugin name.
|
|
14
|
+
*/
|
|
15
|
+
const loadJsPlugins = async () => {
|
|
16
|
+
/** @type {Map<string, import("eslint").ESLint.Plugin>} */
|
|
17
|
+
const plugins = new Map();
|
|
18
|
+
for (const dir of [oxlintConfigsDir, reactOxlintConfigsDir]) {
|
|
19
|
+
for (const fileName of readdirSync(dir)) {
|
|
20
|
+
if (!fileName.endsWith(".json")) continue;
|
|
21
|
+
/** @type {{ jsPlugins?: { name: string; specifier: string }[] }} */
|
|
22
|
+
const config = JSON.parse(readFileSync(path.join(dir, fileName), "utf8"));
|
|
23
|
+
for (const { name, specifier } of config.jsPlugins ?? []) {
|
|
24
|
+
if (plugins.has(name)) continue;
|
|
25
|
+
const { default: plugin } = await import(
|
|
26
|
+
pathToFileURL(path.resolve(dir, specifier)).href
|
|
27
|
+
);
|
|
28
|
+
plugins.set(name, plugin);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return plugins;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
describe("oxlint JS plugins rules inventory", () => {
|
|
36
|
+
// New rules and newly deprecated ones of the eslint plugins run by oxlint
|
|
37
|
+
// show up in the snapshot diff on upgrades.
|
|
38
|
+
it("matches the snapshot", async () => {
|
|
39
|
+
const enabledRules = new Set(getEnabledOxlintConfigRules());
|
|
40
|
+
/** @type {Record<string, "enabled" | "unset" | "deprecated">} */
|
|
41
|
+
const status = {};
|
|
42
|
+
const plugins = await loadJsPlugins();
|
|
43
|
+
for (const [pluginName, plugin] of [...plugins].toSorted(([a], [b]) =>
|
|
44
|
+
a.localeCompare(b),
|
|
45
|
+
)) {
|
|
46
|
+
for (const [ruleName, rule] of Object.entries(
|
|
47
|
+
plugin.rules ?? {},
|
|
48
|
+
).toSorted(([a], [b]) => a.localeCompare(b))) {
|
|
49
|
+
const fullName = `${pluginName}/${ruleName}`;
|
|
50
|
+
const enabled = enabledRules.has(fullName);
|
|
51
|
+
if (/** @type {any} */ (rule).meta?.deprecated) {
|
|
52
|
+
if (enabled) status[fullName] = "deprecated";
|
|
53
|
+
} else {
|
|
54
|
+
status[fullName] = enabled ? "enabled" : "unset";
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
await expect(`${JSON.stringify(status, null, 2)}\n`).toMatchFileSnapshot(
|
|
59
|
+
"../inventory/oxlint-js-plugins-rules.json",
|
|
60
|
+
);
|
|
61
|
+
});
|
|
62
|
+
});
|
package/lib/oxlint-rules.test.js
CHANGED
|
@@ -10,7 +10,6 @@ import {
|
|
|
10
10
|
* plugins below, so an oxlint upgrade adding or removing rules fails here.
|
|
11
11
|
* Decisions:
|
|
12
12
|
* - enabled: in oxlint/*.json
|
|
13
|
-
* - migrate: enabled in eslint, to move to oxlint (docs/oxlint-migration.md)
|
|
14
13
|
* - eslint: kept in eslint
|
|
15
14
|
* - js-plugin: checked by the eslint rule run as an oxlint JS plugin, as the
|
|
16
15
|
* oxlint rule differs (docs/oxlint-migration.md)
|
|
@@ -31,7 +30,6 @@ const plugins = new Set([
|
|
|
31
30
|
]);
|
|
32
31
|
const decisions = new Set([
|
|
33
32
|
"enabled",
|
|
34
|
-
"migrate",
|
|
35
33
|
"eslint",
|
|
36
34
|
"js-plugin",
|
|
37
35
|
"evaluate",
|
|
@@ -80,8 +78,8 @@ describe("oxlint rules inventory", () => {
|
|
|
80
78
|
.filter((name) => inventory[name] === "enabled")
|
|
81
79
|
.toSorted(),
|
|
82
80
|
).toEqual(
|
|
83
|
-
// rules of JS plugins (regexp, @pob) are listed in
|
|
84
|
-
// inventory/
|
|
81
|
+
// rules of JS plugins (regexp, @pob, ...) are listed in
|
|
82
|
+
// inventory/oxlint-js-plugins-rules.json
|
|
85
83
|
getEnabledOxlintConfigRules().filter((name) =>
|
|
86
84
|
plugins.has(name.slice(0, name.indexOf("/"))),
|
|
87
85
|
),
|
package/lib/oxlint.test.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { mkdtemp,
|
|
1
|
+
import { mkdtemp, rm, writeFile } from "node:fs/promises";
|
|
2
2
|
import { tmpdir } from "node:os";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { afterAll, beforeAll, describe, expect, it } from "vitest";
|
|
@@ -12,15 +12,7 @@ const baseConfigPath = path.join(oxlintConfigsDir, "base.json");
|
|
|
12
12
|
const moduleConfigPath = path.join(oxlintConfigsDir, "module.json");
|
|
13
13
|
const nodeConfigPath = path.join(oxlintConfigsDir, "node.json");
|
|
14
14
|
const typescriptConfigPath = path.join(oxlintConfigsDir, "typescript.json");
|
|
15
|
-
|
|
16
|
-
// eslint-disable comments working
|
|
17
|
-
const rootConfig = JSON.parse(
|
|
18
|
-
await readFile(
|
|
19
|
-
path.resolve(import.meta.dirname, "../../../.oxlintrc.json"),
|
|
20
|
-
"utf8",
|
|
21
|
-
),
|
|
22
|
-
);
|
|
23
|
-
|
|
15
|
+
const commonjsConfigPath = path.join(oxlintConfigsDir, "commonjs.json");
|
|
24
16
|
/**
|
|
25
17
|
* Lints `source` in a project whose .oxlintrc.json extends base.json, like the
|
|
26
18
|
* one written by pob.
|
|
@@ -80,14 +72,31 @@ describe("oxlint/base.json", () => {
|
|
|
80
72
|
).toEqual([]);
|
|
81
73
|
});
|
|
82
74
|
|
|
83
|
-
//
|
|
84
|
-
|
|
75
|
+
// directive options are documented as root-only, but are inherited through
|
|
76
|
+
// extends: test-lint fixtures prove each oxlint rule fires, and projects
|
|
77
|
+
// get their unused oxlint-disable directives reported
|
|
78
|
+
it("ignores eslint-disable directives", async () => {
|
|
85
79
|
expect(
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
80
|
+
summarize(
|
|
81
|
+
await lint(
|
|
82
|
+
project.cwd,
|
|
83
|
+
"// eslint-disable-next-line no-debugger\ndebugger;\n",
|
|
84
|
+
),
|
|
89
85
|
),
|
|
90
|
-
).toEqual([]);
|
|
86
|
+
).toEqual([{ line: 2, rule: "eslint(no-debugger)" }]);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it("reports unused oxlint-disable directives", async () => {
|
|
90
|
+
const diagnostics = await lint(
|
|
91
|
+
project.cwd,
|
|
92
|
+
"// oxlint-disable-next-line no-debugger\nexport const a = 1;\n",
|
|
93
|
+
);
|
|
94
|
+
expect(diagnostics).toHaveLength(1);
|
|
95
|
+
expect(diagnostics[0]).toMatchObject({
|
|
96
|
+
severity: "error",
|
|
97
|
+
message: expect.stringContaining("Unused oxlint-disable directive"),
|
|
98
|
+
labels: [{ span: { line: 1 } }],
|
|
99
|
+
});
|
|
91
100
|
});
|
|
92
101
|
});
|
|
93
102
|
|
|
@@ -118,7 +127,7 @@ describe("oxlint/node.json", () => {
|
|
|
118
127
|
]);
|
|
119
128
|
});
|
|
120
129
|
|
|
121
|
-
// like the eslint node configs, which apply
|
|
130
|
+
// like the eslint node configs, which apply CommonJS rules to .cjs files
|
|
122
131
|
it("allows CommonJS in .cjs files", async () => {
|
|
123
132
|
await rm(path.join(project.cwd, "file.js"));
|
|
124
133
|
expect(await lint(project.cwd, commonjs, "file.cjs")).toEqual([]);
|
|
@@ -142,6 +151,38 @@ describe("oxlint/node.json", () => {
|
|
|
142
151
|
});
|
|
143
152
|
});
|
|
144
153
|
|
|
154
|
+
// packages with "type": "commonjs": .js files are CommonJS
|
|
155
|
+
describe("oxlint/commonjs.json", () => {
|
|
156
|
+
const project = useProject({}, [
|
|
157
|
+
baseConfigPath,
|
|
158
|
+
nodeConfigPath,
|
|
159
|
+
commonjsConfigPath,
|
|
160
|
+
]);
|
|
161
|
+
|
|
162
|
+
it("allows CommonJS in .js files", async () => {
|
|
163
|
+
expect(
|
|
164
|
+
await lint(
|
|
165
|
+
project.cwd,
|
|
166
|
+
'"use strict";\n\nmodule.exports = require("node:path");\n',
|
|
167
|
+
"file.js",
|
|
168
|
+
),
|
|
169
|
+
).toEqual([]);
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
it("applies CommonJS rules to .js files", async () => {
|
|
173
|
+
expect(
|
|
174
|
+
summarize(
|
|
175
|
+
await lint(
|
|
176
|
+
project.cwd,
|
|
177
|
+
// oxlint-disable-next-line no-template-curly-in-string -- code sample
|
|
178
|
+
'"use strict";\n\nmodule.exports = `${__dirname}/a`;\n',
|
|
179
|
+
"file.js",
|
|
180
|
+
),
|
|
181
|
+
),
|
|
182
|
+
).toEqual([{ line: 3, rule: "node(no-path-concat)" }]);
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
|
|
145
186
|
describe("oxlint/typescript.json", () => {
|
|
146
187
|
const project = useProject({}, [baseConfigPath, typescriptConfigPath]);
|
|
147
188
|
const floatingPromise = "Promise.resolve();\nexport {};\n";
|
|
@@ -276,32 +317,3 @@ describe.each([
|
|
|
276
317
|
});
|
|
277
318
|
},
|
|
278
319
|
);
|
|
279
|
-
|
|
280
|
-
describe("root .oxlintrc.json options", () => {
|
|
281
|
-
const project = useProject({ options: rootConfig.options });
|
|
282
|
-
|
|
283
|
-
// with these options, test-lint fixtures prove each oxlint rule fires
|
|
284
|
-
it("ignores eslint-disable directives", async () => {
|
|
285
|
-
expect(
|
|
286
|
-
summarize(
|
|
287
|
-
await lint(
|
|
288
|
-
project.cwd,
|
|
289
|
-
"// eslint-disable-next-line no-debugger\ndebugger;\n",
|
|
290
|
-
),
|
|
291
|
-
),
|
|
292
|
-
).toEqual([{ line: 2, rule: "eslint(no-debugger)" }]);
|
|
293
|
-
});
|
|
294
|
-
|
|
295
|
-
it("reports unused oxlint-disable directives", async () => {
|
|
296
|
-
const diagnostics = await lint(
|
|
297
|
-
project.cwd,
|
|
298
|
-
"// oxlint-disable-next-line no-debugger\nexport const a = 1;\n",
|
|
299
|
-
);
|
|
300
|
-
expect(diagnostics).toHaveLength(1);
|
|
301
|
-
expect(diagnostics[0]).toMatchObject({
|
|
302
|
-
severity: "error",
|
|
303
|
-
message: expect.stringContaining("Unused oxlint-disable directive"),
|
|
304
|
-
labels: [{ span: { line: 1 } }],
|
|
305
|
-
});
|
|
306
|
-
});
|
|
307
|
-
});
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { createNodeResolver, flatConfigs } from "eslint-plugin-import-x";
|
|
2
|
+
|
|
3
|
+
// import-x rules depend on the resolver settings, JS objects .oxlintrc.json
|
|
4
|
+
// cannot express: they stay in eslint
|
|
5
|
+
/** @type {import("eslint").Linter.Config[]} */
|
|
6
|
+
export default [
|
|
7
|
+
{
|
|
8
|
+
name: "@pob/eslint-config/import",
|
|
9
|
+
files: ["**/*.{js,cjs,mjs,ts,cts,mts,tsx}"],
|
|
10
|
+
plugins: flatConfigs.recommended.plugins,
|
|
11
|
+
settings: {
|
|
12
|
+
"import-x/extensions": [".js", ".mjs"],
|
|
13
|
+
"import-x/ignore": ["node_modules"],
|
|
14
|
+
"import-x/parsers": {
|
|
15
|
+
// https://github.com/un-ts/eslint-plugin-import-x/issues/2556#issuecomment-1419518561
|
|
16
|
+
espree: [".js", ".cjs", ".mjs"],
|
|
17
|
+
"@typescript-eslint/parser": [".ts"],
|
|
18
|
+
},
|
|
19
|
+
"import-x/resolver-next": [createNodeResolver()],
|
|
20
|
+
},
|
|
21
|
+
rules: {
|
|
22
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-unresolved.md
|
|
23
|
+
"import-x/no-unresolved": [
|
|
24
|
+
"error",
|
|
25
|
+
{ commonjs: true, caseSensitive: true },
|
|
26
|
+
],
|
|
27
|
+
|
|
28
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/export.md
|
|
29
|
+
"import-x/export": "error",
|
|
30
|
+
|
|
31
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-extraneous-dependencies.md
|
|
32
|
+
"import-x/no-extraneous-dependencies": "error",
|
|
33
|
+
|
|
34
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-useless-path-segments.md
|
|
35
|
+
"import-x/no-useless-path-segments": ["error", { commonjs: true }],
|
|
36
|
+
|
|
37
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-import-module-exports.md
|
|
38
|
+
"import-x/no-import-module-exports": "error",
|
|
39
|
+
|
|
40
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-relative-packages.md
|
|
41
|
+
"import-x/no-relative-packages": "error",
|
|
42
|
+
|
|
43
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/order.md
|
|
44
|
+
"import-x/order": [
|
|
45
|
+
"error",
|
|
46
|
+
{
|
|
47
|
+
groups: [
|
|
48
|
+
"builtin",
|
|
49
|
+
"external",
|
|
50
|
+
"internal",
|
|
51
|
+
"parent",
|
|
52
|
+
"sibling",
|
|
53
|
+
"index",
|
|
54
|
+
],
|
|
55
|
+
alphabetize: { order: "asc", caseInsensitive: false },
|
|
56
|
+
"newlines-between": "never",
|
|
57
|
+
},
|
|
58
|
+
],
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
name: "@pob/eslint-config/import/rollup-config",
|
|
63
|
+
files: ["rollup.config.js", "rollup.config.mjs"],
|
|
64
|
+
rules: {
|
|
65
|
+
"import-x/no-relative-packages": "off",
|
|
66
|
+
"import-x/order": "off",
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
];
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import typescriptParser from "@typescript-eslint/parser";
|
|
2
|
+
import { createNodeResolver } from "eslint-plugin-import-x";
|
|
3
|
+
|
|
4
|
+
export const tsExtensions = "{ts,cts,mts,tsx}";
|
|
5
|
+
|
|
6
|
+
// eslint only parses TypeScript files for the import-x rules: type-aware rules
|
|
7
|
+
// run in oxlint, so eslint does not build the TypeScript program
|
|
8
|
+
/** @type {import("eslint").Linter.Config[]} */
|
|
9
|
+
export default [
|
|
10
|
+
{
|
|
11
|
+
name: "@pob/eslint-config/typescript",
|
|
12
|
+
files: [`**/*.${tsExtensions}`],
|
|
13
|
+
languageOptions: {
|
|
14
|
+
parser: typescriptParser,
|
|
15
|
+
sourceType: "module",
|
|
16
|
+
},
|
|
17
|
+
settings: {
|
|
18
|
+
"import-x/resolver-next": [
|
|
19
|
+
createNodeResolver({
|
|
20
|
+
extensions: [".mjs", ".js", ".json", ".ts"],
|
|
21
|
+
conditionNames: ["import"],
|
|
22
|
+
}),
|
|
23
|
+
],
|
|
24
|
+
"import-x/extensions": [".js", ".mjs", ".ts", ".d.ts"],
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
];
|
package/oxlint/base.json
CHANGED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"overrides": [
|
|
3
|
+
{
|
|
4
|
+
"files": ["**/*.js"],
|
|
5
|
+
"rules": {
|
|
6
|
+
"unicorn/prefer-module": "off",
|
|
7
|
+
"import/extensions": "off",
|
|
8
|
+
"node/no-new-require": "error",
|
|
9
|
+
"node/no-path-concat": "error",
|
|
10
|
+
"node-js/no-unsupported-features/es-syntax": [
|
|
11
|
+
"error",
|
|
12
|
+
{ "ignores": [] }
|
|
13
|
+
]
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
package/oxlint/module.json
CHANGED
|
@@ -10,7 +10,11 @@
|
|
|
10
10
|
{
|
|
11
11
|
"files": ["**/*.{ts,cts,mts,tsx}", "**/scripts/**/*.{js,cjs,mjs}"],
|
|
12
12
|
"rules": {
|
|
13
|
-
"import/extensions": [
|
|
13
|
+
"import/extensions": [
|
|
14
|
+
"error",
|
|
15
|
+
"ignorePackages",
|
|
16
|
+
{ "checkTypeImports": true }
|
|
17
|
+
]
|
|
14
18
|
}
|
|
15
19
|
}
|
|
16
20
|
]
|
package/oxlint/node.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pob/eslint-config",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "68.1.0",
|
|
4
4
|
"description": "eslint config files",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"homepage": "https://github.com/christophehurpeau/pob",
|
|
@@ -17,10 +17,11 @@
|
|
|
17
17
|
"files": [
|
|
18
18
|
"lib",
|
|
19
19
|
"oxlint/allow-implicit-return-type.json",
|
|
20
|
-
"oxlint/allow-unsafe-as-warn.json",
|
|
21
20
|
"oxlint/allow-unsafe.json",
|
|
21
|
+
"oxlint/allow-unsafe-as-warn.json",
|
|
22
22
|
"oxlint/app.json",
|
|
23
23
|
"oxlint/base.json",
|
|
24
|
+
"oxlint/commonjs.json",
|
|
24
25
|
"oxlint/module.json",
|
|
25
26
|
"oxlint/node.json",
|
|
26
27
|
"oxlint/typescript.json",
|
|
@@ -31,15 +32,12 @@
|
|
|
31
32
|
"main": "./lib/index.js",
|
|
32
33
|
"exports": {
|
|
33
34
|
".": "./lib/index.js",
|
|
34
|
-
"./lib/rules/best-practices": "./lib/rules/best-practices.js",
|
|
35
|
-
"./lib/rules/code-quality": "./lib/rules/code-quality.js",
|
|
36
|
-
"./lib/rules/errors": "./lib/rules/errors.js",
|
|
37
|
-
"./lib/rules/style": "./lib/rules/style.js",
|
|
38
35
|
"./oxlint/allow-implicit-return-type.json": "./oxlint/allow-implicit-return-type.json",
|
|
39
36
|
"./oxlint/allow-unsafe.json": "./oxlint/allow-unsafe.json",
|
|
40
37
|
"./oxlint/allow-unsafe-as-warn.json": "./oxlint/allow-unsafe-as-warn.json",
|
|
41
38
|
"./oxlint/app.json": "./oxlint/app.json",
|
|
42
39
|
"./oxlint/base.json": "./oxlint/base.json",
|
|
40
|
+
"./oxlint/commonjs.json": "./oxlint/commonjs.json",
|
|
43
41
|
"./oxlint/module.json": "./oxlint/module.json",
|
|
44
42
|
"./oxlint/node.json": "./oxlint/node.json",
|
|
45
43
|
"./oxlint/typescript.json": "./oxlint/typescript.json",
|
|
@@ -50,18 +48,14 @@
|
|
|
50
48
|
"access": "public"
|
|
51
49
|
},
|
|
52
50
|
"dependencies": {
|
|
53
|
-
"@eslint/js": "^10.0.1",
|
|
54
51
|
"@eslint/json": "^2.0.0",
|
|
55
|
-
"@pob/eslint-plugin": "
|
|
56
|
-
"@typescript-eslint/eslint-plugin": "8.63.0",
|
|
52
|
+
"@pob/eslint-plugin": "67.0.0",
|
|
57
53
|
"@typescript-eslint/parser": "8.63.0",
|
|
58
54
|
"check-package-dependencies": "^13.2.0",
|
|
59
|
-
"confusing-browser-globals": "^1.0.11",
|
|
60
55
|
"eslint-plugin-import-x": "^4.17.1",
|
|
61
56
|
"eslint-plugin-n": "^17.24.0",
|
|
62
57
|
"eslint-plugin-regexp": "^3.1.0",
|
|
63
|
-
"eslint-plugin-unicorn": "^64.0.0"
|
|
64
|
-
"typescript-eslint": "^8.63.0"
|
|
58
|
+
"eslint-plugin-unicorn": "^64.0.0"
|
|
65
59
|
},
|
|
66
60
|
"devDependencies": {
|
|
67
61
|
"@types/node": "24.19.1",
|
|
@@ -70,8 +64,7 @@
|
|
|
70
64
|
"eslint-plugin-n": "17.24.0",
|
|
71
65
|
"eslint-plugin-regexp": "3.1.0",
|
|
72
66
|
"eslint-plugin-unicorn": "64.0.0",
|
|
73
|
-
"typescript": "npm:@typescript/typescript6@6.0.2"
|
|
74
|
-
"typescript-eslint": "8.63.0"
|
|
67
|
+
"typescript": "npm:@typescript/typescript6@6.0.2"
|
|
75
68
|
},
|
|
76
69
|
"peerDependencies": {
|
|
77
70
|
"eslint": "^10.8.0",
|
|
@@ -85,7 +78,9 @@
|
|
|
85
78
|
"engines": {
|
|
86
79
|
"node": ">=22.18.0"
|
|
87
80
|
},
|
|
88
|
-
"pob": {
|
|
81
|
+
"pob": {
|
|
82
|
+
"typescript": "check-only"
|
|
83
|
+
},
|
|
89
84
|
"scripts": {
|
|
90
85
|
"lint": "pnpm run lint:oxlint && pnpm run lint:eslint",
|
|
91
86
|
"lint:eslint": "pnpm --dir '../..' exec eslint --quiet '@pob/eslint-config'",
|
package/lib/base/commonjs.js
DELETED
package/lib/base/module.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
name: "@pob/eslint-config/base/module",
|
|
3
|
-
languageOptions: {
|
|
4
|
-
sourceType: "module",
|
|
5
|
-
},
|
|
6
|
-
rules: {
|
|
7
|
-
strict: "off",
|
|
8
|
-
|
|
9
|
-
// replaced by import/no-duplicates
|
|
10
|
-
"no-duplicate-imports": "off",
|
|
11
|
-
|
|
12
|
-
// https://eslint.org/docs/rules/no-restricted-exports
|
|
13
|
-
"no-restricted-exports": [
|
|
14
|
-
"error",
|
|
15
|
-
{
|
|
16
|
-
restrictDefaultExports: {
|
|
17
|
-
direct: false, // permits `export default` declarations
|
|
18
|
-
named: true, // restricts `export { foo as default };` declarations
|
|
19
|
-
defaultFrom: false, // permits `export { default } from 'foo';` declarations
|
|
20
|
-
namedFrom: false, // permits `export { foo as default } from 'foo';` declarations
|
|
21
|
-
namespaceFrom: true, // restricts `export * as default from 'foo';` declarations
|
|
22
|
-
},
|
|
23
|
-
restrictedNamedExports: [
|
|
24
|
-
"then", // this will cause tons of confusion when your module is dynamically `import()`ed, and will break in most node ESM versions
|
|
25
|
-
],
|
|
26
|
-
},
|
|
27
|
-
],
|
|
28
|
-
},
|
|
29
|
-
};
|