@lincy/eslint-config 4.2.6 → 4.3.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/README.md +4 -6
- package/dist/index.cjs +63 -12
- package/dist/index.d.cts +11309 -57
- package/dist/index.d.ts +11309 -57
- package/dist/index.js +65 -16
- package/package.json +31 -28
package/README.md
CHANGED
|
@@ -33,9 +33,7 @@ export default lincy()
|
|
|
33
33
|
|
|
34
34
|
> 通常您不需要`.eslintignore`,因为它已由预设提供。
|
|
35
35
|
|
|
36
|
-
###
|
|
37
|
-
|
|
38
|
-
For example:
|
|
36
|
+
### 在 package.json 中添加脚本
|
|
39
37
|
|
|
40
38
|
```json
|
|
41
39
|
{
|
|
@@ -46,7 +44,7 @@ For example:
|
|
|
46
44
|
}
|
|
47
45
|
```
|
|
48
46
|
|
|
49
|
-
## VS Code support (
|
|
47
|
+
## VS Code support (保存时自动修复)
|
|
50
48
|
|
|
51
49
|
安装 [VS Code ESLint扩展](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)
|
|
52
50
|
|
|
@@ -365,7 +363,7 @@ export default combine(
|
|
|
365
363
|
|
|
366
364
|
| New Prefix | Original Prefix | Source Plugin |
|
|
367
365
|
| ---------- | ---------------------- | ------------------------------------------------------------------------------------------ |
|
|
368
|
-
| `import/*` | `
|
|
366
|
+
| `import/*` | `import-x/*` | [eslint-plugin-import-x](https://github.com/un-es/eslint-plugin-import-x) |
|
|
369
367
|
| `node/*` | `n/*` | [eslint-plugin-n](https://github.com/eslint-community/eslint-plugin-n) |
|
|
370
368
|
| `yaml/*` | `yml/*` | [eslint-plugin-yml](https://github.com/ota-meshi/eslint-plugin-yml) |
|
|
371
369
|
| `ts/*` | `@typescript-eslint/*` | [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint) |
|
|
@@ -478,7 +476,7 @@ import lincy from '@lincy/eslint-config'
|
|
|
478
476
|
export default lincy({
|
|
479
477
|
formatters: {
|
|
480
478
|
/**
|
|
481
|
-
* 格式化 CSS、LESS、SCSS 文件,以及 Vue 中的 `<style>`
|
|
479
|
+
* 格式化 CSS、LESS、SCSS 文件,以及 Vue 中的 `<style>` 模块
|
|
482
480
|
* 默认使用 Prettier
|
|
483
481
|
*/
|
|
484
482
|
css: true,
|
package/dist/index.cjs
CHANGED
|
@@ -59,6 +59,7 @@ __export(src_exports, {
|
|
|
59
59
|
combine: () => combine,
|
|
60
60
|
comments: () => comments,
|
|
61
61
|
default: () => src_default,
|
|
62
|
+
defaultPluginRenaming: () => defaultPluginRenaming,
|
|
62
63
|
ensurePackages: () => ensurePackages,
|
|
63
64
|
formatters: () => formatters,
|
|
64
65
|
ignores: () => ignores,
|
|
@@ -72,6 +73,7 @@ __export(src_exports, {
|
|
|
72
73
|
node: () => node,
|
|
73
74
|
perfectionist: () => perfectionist,
|
|
74
75
|
react: () => react,
|
|
76
|
+
renamePluginInConfigs: () => renamePluginInConfigs,
|
|
75
77
|
renameRules: () => renameRules,
|
|
76
78
|
sortPackageJson: () => sortPackageJson,
|
|
77
79
|
sortTsconfig: () => sortTsconfig,
|
|
@@ -91,11 +93,12 @@ module.exports = __toCommonJS(src_exports);
|
|
|
91
93
|
var import_node_process3 = __toESM(require("process"), 1);
|
|
92
94
|
var import_node_fs = __toESM(require("fs"), 1);
|
|
93
95
|
var import_local_pkg4 = require("local-pkg");
|
|
96
|
+
var import_eslint_flat_config_utils = require("eslint-flat-config-utils");
|
|
94
97
|
|
|
95
98
|
// src/plugins.ts
|
|
96
99
|
var import_eslint_plugin_antfu = __toESM(require("eslint-plugin-antfu"), 1);
|
|
97
100
|
var import_eslint_plugin_eslint_comments = __toESM(require("eslint-plugin-eslint-comments"), 1);
|
|
98
|
-
var pluginImport = __toESM(require("eslint-plugin-
|
|
101
|
+
var pluginImport = __toESM(require("eslint-plugin-import-x"), 1);
|
|
99
102
|
var import_eslint_plugin_n = __toESM(require("eslint-plugin-n"), 1);
|
|
100
103
|
var import_eslint_plugin_unicorn = __toESM(require("eslint-plugin-unicorn"), 1);
|
|
101
104
|
var import_eslint_plugin_unused_imports = __toESM(require("eslint-plugin-unused-imports"), 1);
|
|
@@ -179,6 +182,7 @@ var GLOB_EXCLUDE = [
|
|
|
179
182
|
"**/.idea",
|
|
180
183
|
"**/.output",
|
|
181
184
|
"**/.vite-inspect",
|
|
185
|
+
"**/.yarn",
|
|
182
186
|
"**/CHANGELOG*.md",
|
|
183
187
|
"**/*.min.*",
|
|
184
188
|
"**/LICENSE*",
|
|
@@ -462,15 +466,34 @@ async function combine(...configs) {
|
|
|
462
466
|
const resolved = await Promise.all(configs);
|
|
463
467
|
return resolved.flat();
|
|
464
468
|
}
|
|
465
|
-
function renameRules(rules,
|
|
469
|
+
function renameRules(rules, map) {
|
|
466
470
|
return Object.fromEntries(
|
|
467
471
|
Object.entries(rules).map(([key, value]) => {
|
|
468
|
-
|
|
469
|
-
|
|
472
|
+
for (const [from, to] of Object.entries(map)) {
|
|
473
|
+
if (key.startsWith(`${from}/`))
|
|
474
|
+
return [to + key.slice(from.length), value];
|
|
475
|
+
}
|
|
470
476
|
return [key, value];
|
|
471
477
|
})
|
|
472
478
|
);
|
|
473
479
|
}
|
|
480
|
+
function renamePluginInConfigs(configs, map) {
|
|
481
|
+
return configs.map((i) => {
|
|
482
|
+
const clone = { ...i };
|
|
483
|
+
if (clone.rules)
|
|
484
|
+
clone.rules = renameRules(clone.rules, map);
|
|
485
|
+
if (clone.plugins) {
|
|
486
|
+
clone.plugins = Object.fromEntries(
|
|
487
|
+
Object.entries(clone.plugins).map(([key, value]) => {
|
|
488
|
+
if (key in map)
|
|
489
|
+
return [map[key], value];
|
|
490
|
+
return [key, value];
|
|
491
|
+
})
|
|
492
|
+
);
|
|
493
|
+
}
|
|
494
|
+
return clone;
|
|
495
|
+
});
|
|
496
|
+
}
|
|
474
497
|
function toArray(value) {
|
|
475
498
|
return Array.isArray(value) ? value : [value];
|
|
476
499
|
}
|
|
@@ -1047,7 +1070,6 @@ async function react(options = {}) {
|
|
|
1047
1070
|
"react/jsx-no-target-blank": "error",
|
|
1048
1071
|
"react/jsx-no-undef": "error",
|
|
1049
1072
|
"react/jsx-no-useless-fragment": "error",
|
|
1050
|
-
"react/jsx-pascal-case": "error",
|
|
1051
1073
|
"react/jsx-props-no-spreading": "off",
|
|
1052
1074
|
// 强制任何 JSX 属性都不会传播
|
|
1053
1075
|
"react/jsx-uses-react": "error",
|
|
@@ -1104,6 +1126,7 @@ async function react(options = {}) {
|
|
|
1104
1126
|
"react/static-property-placement": "error",
|
|
1105
1127
|
"react/style-prop-object": "error",
|
|
1106
1128
|
"react/void-dom-elements-no-children": "error",
|
|
1129
|
+
"style/jsx-pascal-case": "error",
|
|
1107
1130
|
...typescript2 ? {
|
|
1108
1131
|
"react/jsx-no-undef": "off",
|
|
1109
1132
|
"react/prop-type": "off"
|
|
@@ -1199,6 +1222,22 @@ async function sortPackageJson() {
|
|
|
1199
1222
|
"default"
|
|
1200
1223
|
],
|
|
1201
1224
|
pathPattern: "^exports.*$"
|
|
1225
|
+
},
|
|
1226
|
+
{
|
|
1227
|
+
order: [
|
|
1228
|
+
// client hooks only
|
|
1229
|
+
"pre-commit",
|
|
1230
|
+
"prepare-commit-msg",
|
|
1231
|
+
"commit-msg",
|
|
1232
|
+
"post-commit",
|
|
1233
|
+
"pre-rebase",
|
|
1234
|
+
"post-rewrite",
|
|
1235
|
+
"post-checkout",
|
|
1236
|
+
"post-merge",
|
|
1237
|
+
"pre-push",
|
|
1238
|
+
"pre-auto-gc"
|
|
1239
|
+
],
|
|
1240
|
+
pathPattern: "^(?:gitHooks|husky|simple-git-hooks)$"
|
|
1202
1241
|
}
|
|
1203
1242
|
]
|
|
1204
1243
|
}
|
|
@@ -1461,13 +1500,11 @@ async function typescript(options = {}) {
|
|
|
1461
1500
|
rules: {
|
|
1462
1501
|
...renameRules(
|
|
1463
1502
|
pluginTs.configs["eslint-recommended"].overrides[0].rules,
|
|
1464
|
-
"@typescript-eslint
|
|
1465
|
-
"ts/"
|
|
1503
|
+
{ "@typescript-eslint": "ts" }
|
|
1466
1504
|
),
|
|
1467
1505
|
...renameRules(
|
|
1468
1506
|
pluginTs.configs.strict.rules,
|
|
1469
|
-
"@typescript-eslint
|
|
1470
|
-
"ts/"
|
|
1507
|
+
{ "@typescript-eslint": "ts" }
|
|
1471
1508
|
),
|
|
1472
1509
|
"no-dupe-class-members": "off",
|
|
1473
1510
|
"no-loss-of-precision": "off",
|
|
@@ -1922,12 +1959,21 @@ var VuePackages = [
|
|
|
1922
1959
|
"vitepress",
|
|
1923
1960
|
"@slidev/cli"
|
|
1924
1961
|
];
|
|
1962
|
+
var defaultPluginRenaming = {
|
|
1963
|
+
"@stylistic": "style",
|
|
1964
|
+
"@typescript-eslint": "ts",
|
|
1965
|
+
"import-x": "import",
|
|
1966
|
+
"n": "node",
|
|
1967
|
+
"vitest": "test",
|
|
1968
|
+
"yml": "yaml"
|
|
1969
|
+
};
|
|
1925
1970
|
var ReactPackages = [
|
|
1926
1971
|
"react",
|
|
1927
1972
|
"next"
|
|
1928
1973
|
];
|
|
1929
|
-
|
|
1974
|
+
function lincy(options = {}, ...userConfigs) {
|
|
1930
1975
|
const {
|
|
1976
|
+
autoRenamePlugins = true,
|
|
1931
1977
|
componentExts = [],
|
|
1932
1978
|
gitignore: enableGitignore = true,
|
|
1933
1979
|
isInEditor = !!((import_node_process3.default.env.VSCODE_PID || import_node_process3.default.env.JETBRAINS_IDE || import_node_process3.default.env.VIM) && !import_node_process3.default.env.CI),
|
|
@@ -2058,11 +2104,14 @@ async function lincy(options = {}, ...userConfigs) {
|
|
|
2058
2104
|
}, {});
|
|
2059
2105
|
if (Object.keys(fusedConfig).length)
|
|
2060
2106
|
configs.push([fusedConfig]);
|
|
2061
|
-
|
|
2107
|
+
let pipeline = new import_eslint_flat_config_utils.FlatConfigPipeline();
|
|
2108
|
+
pipeline = pipeline.append(
|
|
2062
2109
|
...configs,
|
|
2063
2110
|
...userConfigs
|
|
2064
2111
|
);
|
|
2065
|
-
|
|
2112
|
+
if (autoRenamePlugins)
|
|
2113
|
+
pipeline = pipeline.renamePlugins(defaultPluginRenaming);
|
|
2114
|
+
return pipeline;
|
|
2066
2115
|
}
|
|
2067
2116
|
|
|
2068
2117
|
// src/index.ts
|
|
@@ -2097,6 +2146,7 @@ var src_default = lincy;
|
|
|
2097
2146
|
StylisticConfigDefaults,
|
|
2098
2147
|
combine,
|
|
2099
2148
|
comments,
|
|
2149
|
+
defaultPluginRenaming,
|
|
2100
2150
|
ensurePackages,
|
|
2101
2151
|
formatters,
|
|
2102
2152
|
ignores,
|
|
@@ -2110,6 +2160,7 @@ var src_default = lincy;
|
|
|
2110
2160
|
node,
|
|
2111
2161
|
perfectionist,
|
|
2112
2162
|
react,
|
|
2163
|
+
renamePluginInConfigs,
|
|
2113
2164
|
renameRules,
|
|
2114
2165
|
sortPackageJson,
|
|
2115
2166
|
sortTsconfig,
|