@pob/eslint-config 68.4.0 → 68.6.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/index.js +1 -1
- package/lib/index.test.js +14 -0
- package/lib/overrides/test.js +4 -0
- package/lib/oxlint-js-plugins-rules.test.js +17 -13
- package/lib/test-utils/oxlint.js +23 -5
- package/package.json +11 -11
package/lib/index.js
CHANGED
|
@@ -46,7 +46,7 @@ const scriptsCommonjsFiles = isCommonjsPackage
|
|
|
46
46
|
|
|
47
47
|
const testFiles = [
|
|
48
48
|
`**/*.{test,test-e2e,spec}.{js,cjs,mjs,${tsExtensions.slice(1, -1)}}`,
|
|
49
|
-
`**/{__tests__,__mocks__}/**/*.{js,cjs,mjs,${tsExtensions.slice(1, -1)}}`,
|
|
49
|
+
`**/{__tests__,__mocks__,test,tests}/**/*.{js,cjs,mjs,${tsExtensions.slice(1, -1)}}`,
|
|
50
50
|
];
|
|
51
51
|
|
|
52
52
|
/** @type {import("eslint").Linter.Config[]} */
|
package/lib/index.test.js
CHANGED
|
@@ -71,6 +71,20 @@ describe("configs.node", () => {
|
|
|
71
71
|
);
|
|
72
72
|
expect(config.languageOptions.parserOptions.project).toBeUndefined();
|
|
73
73
|
});
|
|
74
|
+
|
|
75
|
+
it.each([
|
|
76
|
+
["src/file.test.ts", ["vitest"]],
|
|
77
|
+
["src/tests/helpers.ts", ["vitest"]],
|
|
78
|
+
["src/git/test/fixture.ts", ["vitest"]],
|
|
79
|
+
["src/file.ts", undefined],
|
|
80
|
+
])("resolves vitest as a core module in %s", async (filePath, expected) => {
|
|
81
|
+
const config = await new ESLint({
|
|
82
|
+
cwd: rootDir,
|
|
83
|
+
overrideConfigFile: true,
|
|
84
|
+
overrideConfig: configs.node,
|
|
85
|
+
}).calculateConfigForFile(path.join(rootDir, filePath));
|
|
86
|
+
expect(config.settings["import-x/core-modules"]).toEqual(expected);
|
|
87
|
+
});
|
|
74
88
|
});
|
|
75
89
|
|
|
76
90
|
describe("configs.baseModule", () => {
|
package/lib/overrides/test.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
/** @type {import("eslint").Linter.Config} */
|
|
2
2
|
export default {
|
|
3
3
|
name: "@pob/eslint-config/test",
|
|
4
|
+
// in a monorepo, vitest is a dependency of the root, not of each package
|
|
5
|
+
settings: {
|
|
6
|
+
"import-x/core-modules": ["vitest"],
|
|
7
|
+
},
|
|
4
8
|
rules: {
|
|
5
9
|
// allow dev dependencies
|
|
6
10
|
"import-x/no-extraneous-dependencies": ["error", { devDependencies: true }],
|
|
@@ -5,6 +5,7 @@ import { pathToFileURL } from "node:url";
|
|
|
5
5
|
import { beforeAll, describe, expect, it } from "vitest";
|
|
6
6
|
import {
|
|
7
7
|
getEnabledOxlintConfigRules,
|
|
8
|
+
getOffOxlintConfigRules,
|
|
8
9
|
oxlintConfigsDir,
|
|
9
10
|
reactOxlintConfigsDir,
|
|
10
11
|
} from "./test-utils/oxlint.js";
|
|
@@ -80,18 +81,20 @@ const loadJsPlugins = async () => {
|
|
|
80
81
|
|
|
81
82
|
/*
|
|
82
83
|
* inventory/oxlint-js-plugins-rules.json records the status of every rule of
|
|
83
|
-
* the JS plugins:
|
|
84
|
-
* - enabled:
|
|
85
|
-
* - enabled
|
|
86
|
-
*
|
|
87
|
-
* -
|
|
88
|
-
*
|
|
89
|
-
* -
|
|
84
|
+
* the JS plugins, derived from oxlint/*.json:
|
|
85
|
+
* - enabled: enabled, no native oxlint equivalent
|
|
86
|
+
* - enabled:over-native: enabled instead of the native oxlint equivalent
|
|
87
|
+
* (decision `js-plugin` in inventory/oxlint-rules.json)
|
|
88
|
+
* - native: not enabled, a native oxlint equivalent exists (its decision is in
|
|
89
|
+
* inventory/oxlint-rules.json)
|
|
90
|
+
* - rejected: explicitly "off", no native oxlint equivalent
|
|
91
|
+
* - evaluate: not in oxlint/*.json, no native oxlint equivalent (new rules of
|
|
92
|
+
* plugin upgrades)
|
|
90
93
|
* - deprecated: deprecated and enabled (deprecated rules not enabled are not
|
|
91
94
|
* listed)
|
|
92
95
|
* The native equivalent is the rule of the same name (nativePluginNames) or a
|
|
93
96
|
* rule of another plugin (nativeRuleNamesOfOtherPlugins), named after the
|
|
94
|
-
* status: `
|
|
97
|
+
* status: `native:eslint/no-loss-of-precision`.
|
|
95
98
|
*/
|
|
96
99
|
describe("oxlint JS plugins rules inventory", () => {
|
|
97
100
|
/** @type {Record<string, string>} */
|
|
@@ -106,6 +109,7 @@ describe("oxlint JS plugins rules inventory", () => {
|
|
|
106
109
|
await readFile(oxlintRulesInventoryPath, "utf8"),
|
|
107
110
|
);
|
|
108
111
|
const enabledRules = new Set(getEnabledOxlintConfigRules());
|
|
112
|
+
const offRules = new Set(getOffOxlintConfigRules());
|
|
109
113
|
const plugins = await loadJsPlugins();
|
|
110
114
|
for (const [pluginName, plugin] of [...plugins].toSorted(([a], [b]) =>
|
|
111
115
|
a.localeCompare(b),
|
|
@@ -131,12 +135,12 @@ describe("oxlint JS plugins rules inventory", () => {
|
|
|
131
135
|
if (enabled) status[fullName] = "deprecated";
|
|
132
136
|
} else if (enabled) {
|
|
133
137
|
status[fullName] = hasNative
|
|
134
|
-
? `enabled
|
|
138
|
+
? `enabled:over-native${nativeSuffix}`
|
|
135
139
|
: "enabled";
|
|
140
|
+
} else if (hasNative) {
|
|
141
|
+
status[fullName] = `native${nativeSuffix}`;
|
|
136
142
|
} else {
|
|
137
|
-
status[fullName] =
|
|
138
|
-
? `unset-has-native${nativeSuffix}`
|
|
139
|
-
: "unset";
|
|
143
|
+
status[fullName] = offRules.has(fullName) ? "rejected" : "evaluate";
|
|
140
144
|
}
|
|
141
145
|
}
|
|
142
146
|
}
|
|
@@ -166,7 +170,7 @@ describe("oxlint JS plugins rules inventory", () => {
|
|
|
166
170
|
.filter(
|
|
167
171
|
([fullName]) =>
|
|
168
172
|
Object.hasOwn(status, fullName) &&
|
|
169
|
-
(status[fullName].startsWith("enabled
|
|
173
|
+
(status[fullName].startsWith("enabled:over-native") ||
|
|
170
174
|
status[fullName] === "deprecated"),
|
|
171
175
|
)
|
|
172
176
|
.map(([, nativeRuleName]) => nativeRuleName),
|
package/lib/test-utils/oxlint.js
CHANGED
|
@@ -99,13 +99,14 @@ const isRuleEnabled = (ruleEntry) => {
|
|
|
99
99
|
};
|
|
100
100
|
|
|
101
101
|
/**
|
|
102
|
-
* Rules
|
|
103
|
-
* @pob/eslint-config-typescript-react (including `overrides`)
|
|
104
|
-
* `plugin/rule`.
|
|
102
|
+
* Rules of `oxlint/*.json` of this package and of
|
|
103
|
+
* @pob/eslint-config-typescript-react (including `overrides`) whose entry
|
|
104
|
+
* matches `filter`, as `plugin/rule`.
|
|
105
105
|
*
|
|
106
|
+
* @param {(ruleEntry: unknown) => boolean} filter
|
|
106
107
|
* @returns {string[]}
|
|
107
108
|
*/
|
|
108
|
-
|
|
109
|
+
const getOxlintConfigRules = (filter) => {
|
|
109
110
|
const ruleNames = new Set();
|
|
110
111
|
const configPaths = [oxlintConfigsDir, reactOxlintConfigsDir].flatMap((dir) =>
|
|
111
112
|
readdirSync(dir)
|
|
@@ -120,7 +121,7 @@ export const getEnabledOxlintConfigRules = () => {
|
|
|
120
121
|
...(config.overrides ?? []).map((override) => override.rules),
|
|
121
122
|
]) {
|
|
122
123
|
for (const [ruleName, ruleEntry] of Object.entries(rules ?? {})) {
|
|
123
|
-
if (
|
|
124
|
+
if (filter(ruleEntry)) {
|
|
124
125
|
ruleNames.add(toCanonicalOxlintRuleName(ruleName));
|
|
125
126
|
}
|
|
126
127
|
}
|
|
@@ -128,3 +129,20 @@ export const getEnabledOxlintConfigRules = () => {
|
|
|
128
129
|
}
|
|
129
130
|
return [...ruleNames].toSorted();
|
|
130
131
|
};
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Rules enabled in `oxlint/*.json`, see getOxlintConfigRules.
|
|
135
|
+
*
|
|
136
|
+
* @returns {string[]}
|
|
137
|
+
*/
|
|
138
|
+
export const getEnabledOxlintConfigRules = () =>
|
|
139
|
+
getOxlintConfigRules(isRuleEnabled);
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Rules turned off in `oxlint/*.json` (enabled in another file or override
|
|
143
|
+
* included), see getOxlintConfigRules.
|
|
144
|
+
*
|
|
145
|
+
* @returns {string[]}
|
|
146
|
+
*/
|
|
147
|
+
export const getOffOxlintConfigRules = () =>
|
|
148
|
+
getOxlintConfigRules((ruleEntry) => !isRuleEnabled(ruleEntry));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pob/eslint-config",
|
|
3
|
-
"version": "68.
|
|
3
|
+
"version": "68.6.0",
|
|
4
4
|
"description": "eslint config files",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"homepage": "https://github.com/christophehurpeau/pob",
|
|
@@ -48,26 +48,26 @@
|
|
|
48
48
|
"access": "public"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@eslint/json": "^2.
|
|
52
|
-
"@pob/eslint-plugin": "67.
|
|
53
|
-
"@typescript-eslint/parser": "8.72.
|
|
54
|
-
"check-package-dependencies": "^13.
|
|
55
|
-
"eslint-plugin-import-x": "^4.
|
|
51
|
+
"@eslint/json": "^2.1.1",
|
|
52
|
+
"@pob/eslint-plugin": "67.4.0",
|
|
53
|
+
"@typescript-eslint/parser": "8.72.2",
|
|
54
|
+
"check-package-dependencies": "^13.3.0",
|
|
55
|
+
"eslint-plugin-import-x": "^4.18.1",
|
|
56
56
|
"eslint-plugin-n": "^18.5.0",
|
|
57
|
-
"eslint-plugin-regexp": "^3.3.
|
|
57
|
+
"eslint-plugin-regexp": "^3.3.3",
|
|
58
58
|
"eslint-plugin-unicorn": "^79.0.0"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@types/node": "24.19.1",
|
|
62
|
-
"eslint": "10.
|
|
63
|
-
"eslint-plugin-import-x": "4.
|
|
62
|
+
"eslint": "10.15.0",
|
|
63
|
+
"eslint-plugin-import-x": "4.18.1",
|
|
64
64
|
"eslint-plugin-n": "18.5.0",
|
|
65
|
-
"eslint-plugin-regexp": "3.3.
|
|
65
|
+
"eslint-plugin-regexp": "3.3.3",
|
|
66
66
|
"eslint-plugin-unicorn": "79.0.0",
|
|
67
67
|
"typescript": "npm:@typescript/typescript6@6.0.2"
|
|
68
68
|
},
|
|
69
69
|
"peerDependencies": {
|
|
70
|
-
"eslint": "^10.
|
|
70
|
+
"eslint": "^10.14.0",
|
|
71
71
|
"typescript": ">=5.0.0 <8.0.0"
|
|
72
72
|
},
|
|
73
73
|
"peerDependenciesMeta": {
|