@lincy/eslint-config 5.4.1 → 5.5.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 -2
- package/dist/index.cjs +79 -14
- package/dist/index.d.cts +1293 -348
- package/dist/index.d.ts +1293 -348
- package/dist/index.js +74 -10
- package/package.json +47 -49
package/README.md
CHANGED
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
- 也适用于 json、yaml、markdown
|
|
11
11
|
- import导入排序, 对象字⾯量项尾逗号
|
|
12
12
|
- 合理的默认值,最佳实践,只需一行配置
|
|
13
|
+
- .gitignore默认支持
|
|
14
|
+
- 需要 ESLint v9.5.0+
|
|
13
15
|
- [ESLint Flat config](https://eslint.org/docs/latest/use/configure/configuration-files-new)
|
|
14
16
|
- 使用 [ESLint Stylistic](https://github.com/eslint-stylistic/eslint-stylistic)
|
|
15
17
|
- **风格原则**: 读取最小,差异稳定
|
|
@@ -25,7 +27,7 @@ pnpm add -D eslint @lincy/eslint-config
|
|
|
25
27
|
### Create config file
|
|
26
28
|
|
|
27
29
|
```js
|
|
28
|
-
// eslint.config.
|
|
30
|
+
// eslint.config.mjs
|
|
29
31
|
import lincy from '@lincy/eslint-config'
|
|
30
32
|
|
|
31
33
|
export default lincy()
|
|
@@ -110,7 +112,7 @@ export default lincy()
|
|
|
110
112
|
如果 package.json 中开启了`"type": "module",`
|
|
111
113
|
|
|
112
114
|
```js
|
|
113
|
-
// eslint.config.
|
|
115
|
+
// eslint.config.mjs
|
|
114
116
|
import lincy from '@lincy/eslint-config'
|
|
115
117
|
|
|
116
118
|
// or
|
package/dist/index.cjs
CHANGED
|
@@ -28,8 +28,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
|
|
30
30
|
// src/index.ts
|
|
31
|
-
var
|
|
32
|
-
__export(
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
33
|
GLOB_ALL_SRC: () => GLOB_ALL_SRC,
|
|
34
34
|
GLOB_CSS: () => GLOB_CSS,
|
|
35
35
|
GLOB_EXCLUDE: () => GLOB_EXCLUDE,
|
|
@@ -61,7 +61,7 @@ __export(src_exports, {
|
|
|
61
61
|
StylisticConfigDefaults: () => StylisticConfigDefaults,
|
|
62
62
|
combine: () => combine,
|
|
63
63
|
comments: () => comments,
|
|
64
|
-
default: () =>
|
|
64
|
+
default: () => index_default,
|
|
65
65
|
defaultPluginRenaming: () => defaultPluginRenaming,
|
|
66
66
|
disables: () => disables,
|
|
67
67
|
ensurePackages: () => ensurePackages,
|
|
@@ -82,6 +82,7 @@ __export(src_exports, {
|
|
|
82
82
|
node: () => node,
|
|
83
83
|
parserPlain: () => parserPlain,
|
|
84
84
|
perfectionist: () => perfectionist,
|
|
85
|
+
pnpm: () => pnpm,
|
|
85
86
|
react: () => react,
|
|
86
87
|
regexp: () => regexp,
|
|
87
88
|
renamePluginInConfigs: () => renamePluginInConfigs,
|
|
@@ -99,9 +100,9 @@ __export(src_exports, {
|
|
|
99
100
|
vue: () => vue,
|
|
100
101
|
yaml: () => yaml
|
|
101
102
|
});
|
|
102
|
-
module.exports = __toCommonJS(
|
|
103
|
+
module.exports = __toCommonJS(index_exports);
|
|
103
104
|
|
|
104
|
-
// node_modules/.pnpm/tsup@8.
|
|
105
|
+
// node_modules/.pnpm/tsup@8.4.0_jiti@2.4.2_postcss@8.4.49_tsx@4.19.3_typescript@5.8.2_yaml@2.7.0/node_modules/tsup/assets/cjs_shims.js
|
|
105
106
|
var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
|
|
106
107
|
var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
107
108
|
|
|
@@ -388,7 +389,6 @@ async function stylistic(options = {}) {
|
|
|
388
389
|
} = typeof stylistic2 === "boolean" ? StylisticConfigDefaults : { ...StylisticConfigDefaults, ...stylistic2 };
|
|
389
390
|
const pluginStylistic = await interopDefault(import("@stylistic/eslint-plugin"));
|
|
390
391
|
const config = pluginStylistic.configs.customize({
|
|
391
|
-
flat: true,
|
|
392
392
|
indent,
|
|
393
393
|
jsx: jsx2,
|
|
394
394
|
pluginName: "style",
|
|
@@ -415,7 +415,9 @@ async function stylistic(options = {}) {
|
|
|
415
415
|
},
|
|
416
416
|
// 覆盖`stylistic`默认规则
|
|
417
417
|
"style/brace-style": ["error", "stroustrup"],
|
|
418
|
+
"style/generator-star-spacing": ["error", { after: true, before: false }],
|
|
418
419
|
"style/multiline-ternary": ["error", "never"],
|
|
420
|
+
"style/yield-star-spacing": ["error", { after: true, before: false }],
|
|
419
421
|
...overrides
|
|
420
422
|
}
|
|
421
423
|
}
|
|
@@ -685,6 +687,7 @@ async function imports(options = {}) {
|
|
|
685
687
|
"antfu/import-dedupe": "error",
|
|
686
688
|
"antfu/no-import-dist": "error",
|
|
687
689
|
"antfu/no-import-node-modules-by-path": "error",
|
|
690
|
+
"import/consistent-type-specifier-style": ["error", "prefer-top-level"],
|
|
688
691
|
"import/first": "error",
|
|
689
692
|
"import/no-duplicates": "error",
|
|
690
693
|
"import/no-mutable-exports": "error",
|
|
@@ -1195,6 +1198,30 @@ async function perfectionist(options = {}) {
|
|
|
1195
1198
|
];
|
|
1196
1199
|
}
|
|
1197
1200
|
|
|
1201
|
+
// src/configs/pnpm.ts
|
|
1202
|
+
async function pnpm() {
|
|
1203
|
+
return [
|
|
1204
|
+
{
|
|
1205
|
+
files: [
|
|
1206
|
+
"package.json",
|
|
1207
|
+
"**/package.json"
|
|
1208
|
+
],
|
|
1209
|
+
languageOptions: {
|
|
1210
|
+
parser: await interopDefault(import("jsonc-eslint-parser"))
|
|
1211
|
+
},
|
|
1212
|
+
name: "eslint/pnpm/rules",
|
|
1213
|
+
plugins: {
|
|
1214
|
+
pnpm: await interopDefault(import("eslint-plugin-pnpm"))
|
|
1215
|
+
},
|
|
1216
|
+
rules: {
|
|
1217
|
+
"pnpm/enforce-catalog": "error",
|
|
1218
|
+
"pnpm/prefer-workspace-settings": "error",
|
|
1219
|
+
"pnpm/valid-catalog": "error"
|
|
1220
|
+
}
|
|
1221
|
+
}
|
|
1222
|
+
];
|
|
1223
|
+
}
|
|
1224
|
+
|
|
1198
1225
|
// src/configs/react.ts
|
|
1199
1226
|
var import_local_pkg2 = require("local-pkg");
|
|
1200
1227
|
var ReactRefreshAllowConstantExportPackages = [
|
|
@@ -1240,7 +1267,6 @@ async function react(options = {}) {
|
|
|
1240
1267
|
pluginReactRefresh
|
|
1241
1268
|
] = await Promise.all([
|
|
1242
1269
|
interopDefault(import("@eslint-react/eslint-plugin")),
|
|
1243
|
-
// @ts-expect-error missing types
|
|
1244
1270
|
interopDefault(import("eslint-plugin-react-hooks")),
|
|
1245
1271
|
interopDefault(import("eslint-plugin-react-refresh"))
|
|
1246
1272
|
]);
|
|
@@ -1852,6 +1878,7 @@ async function typescript(options = {}) {
|
|
|
1852
1878
|
"ts/consistent-type-definitions": ["error", "interface"],
|
|
1853
1879
|
"ts/consistent-type-imports": ["error", {
|
|
1854
1880
|
disallowTypeAnnotations: false,
|
|
1881
|
+
fixStyle: "separate-type-imports",
|
|
1855
1882
|
prefer: "type-imports"
|
|
1856
1883
|
}],
|
|
1857
1884
|
"ts/method-signature-style": ["error", "property"],
|
|
@@ -2060,13 +2087,13 @@ async function vue(options = {}) {
|
|
|
2060
2087
|
rules: {
|
|
2061
2088
|
...pluginVue.configs.base.rules,
|
|
2062
2089
|
...vueVersion === "2" ? {
|
|
2063
|
-
...pluginVue.configs
|
|
2064
|
-
...pluginVue.configs["strongly-recommended"].rules,
|
|
2065
|
-
...pluginVue.configs
|
|
2090
|
+
...pluginVue.configs["vue2-essential"].rules,
|
|
2091
|
+
...pluginVue.configs["vue2-strongly-recommended"].rules,
|
|
2092
|
+
...pluginVue.configs["vue2-recommended"].rules
|
|
2066
2093
|
} : {
|
|
2067
|
-
...pluginVue.configs["
|
|
2068
|
-
...pluginVue.configs["
|
|
2069
|
-
...pluginVue.configs["
|
|
2094
|
+
...pluginVue.configs["flat/essential"].map((c) => c.rules).reduce((acc, c) => ({ ...acc, ...c }), {}),
|
|
2095
|
+
...pluginVue.configs["flat/strongly-recommended"].map((c) => c.rules).reduce((acc, c) => ({ ...acc, ...c }), {}),
|
|
2096
|
+
...pluginVue.configs["flat/recommended"].map((c) => c.rules).reduce((acc, c) => ({ ...acc, ...c }), {})
|
|
2070
2097
|
},
|
|
2071
2098
|
"antfu/no-top-level-await": "off",
|
|
2072
2099
|
"node/prefer-global/process": "off",
|
|
@@ -2233,6 +2260,37 @@ async function yaml(options = {}) {
|
|
|
2233
2260
|
} : {},
|
|
2234
2261
|
...overrides
|
|
2235
2262
|
}
|
|
2263
|
+
},
|
|
2264
|
+
{
|
|
2265
|
+
files: ["pnpm-workspace.yaml"],
|
|
2266
|
+
name: "eslint/yaml/pnpm-workspace",
|
|
2267
|
+
rules: {
|
|
2268
|
+
"yaml/sort-keys": [
|
|
2269
|
+
"error",
|
|
2270
|
+
{
|
|
2271
|
+
order: [
|
|
2272
|
+
"packages",
|
|
2273
|
+
"overrides",
|
|
2274
|
+
"patchedDependencies",
|
|
2275
|
+
"hoistPattern",
|
|
2276
|
+
"catalog",
|
|
2277
|
+
"catalogs",
|
|
2278
|
+
"allowedDeprecatedVersions",
|
|
2279
|
+
"allowNonAppliedPatches",
|
|
2280
|
+
"configDependencies",
|
|
2281
|
+
"ignoredBuiltDependencies",
|
|
2282
|
+
"ignoredOptionalDependencies",
|
|
2283
|
+
"neverBuiltDependencies",
|
|
2284
|
+
"onlyBuiltDependencies",
|
|
2285
|
+
"onlyBuiltDependenciesFile",
|
|
2286
|
+
"packageExtensions",
|
|
2287
|
+
"peerDependencyRules",
|
|
2288
|
+
"supportedArchitectures"
|
|
2289
|
+
],
|
|
2290
|
+
pathPattern: "^$"
|
|
2291
|
+
}
|
|
2292
|
+
]
|
|
2293
|
+
}
|
|
2236
2294
|
}
|
|
2237
2295
|
];
|
|
2238
2296
|
}
|
|
@@ -2273,6 +2331,7 @@ function lincy(options = {}, ...userConfigs) {
|
|
|
2273
2331
|
ignores: ignoresList = [],
|
|
2274
2332
|
jsx: enableJsx = true,
|
|
2275
2333
|
overrides = {},
|
|
2334
|
+
pnpm: enableCatalogs = false,
|
|
2276
2335
|
react: enableReact = false,
|
|
2277
2336
|
regexp: enableRegexp = true,
|
|
2278
2337
|
typescript: enableTypeScript = (0, import_local_pkg4.isPackageExists)("typescript"),
|
|
@@ -2408,6 +2467,11 @@ function lincy(options = {}, ...userConfigs) {
|
|
|
2408
2467
|
sortTsconfig()
|
|
2409
2468
|
);
|
|
2410
2469
|
}
|
|
2470
|
+
if (enableCatalogs) {
|
|
2471
|
+
configs2.push(
|
|
2472
|
+
pnpm()
|
|
2473
|
+
);
|
|
2474
|
+
}
|
|
2411
2475
|
if (options.yaml ?? true) {
|
|
2412
2476
|
configs2.push(yaml({
|
|
2413
2477
|
...resolveSubOptions(options, "yaml"),
|
|
@@ -2482,7 +2546,7 @@ function getOverrides(options, key) {
|
|
|
2482
2546
|
}
|
|
2483
2547
|
|
|
2484
2548
|
// src/index.ts
|
|
2485
|
-
var
|
|
2549
|
+
var index_default = lincy;
|
|
2486
2550
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2487
2551
|
0 && (module.exports = {
|
|
2488
2552
|
GLOB_ALL_SRC,
|
|
@@ -2536,6 +2600,7 @@ var src_default = lincy;
|
|
|
2536
2600
|
node,
|
|
2537
2601
|
parserPlain,
|
|
2538
2602
|
perfectionist,
|
|
2603
|
+
pnpm,
|
|
2539
2604
|
react,
|
|
2540
2605
|
regexp,
|
|
2541
2606
|
renamePluginInConfigs,
|