@lincy/eslint-config 3.5.1 → 3.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/README.md +11 -3
- package/dist/index.cjs +28 -3
- package/dist/index.d.cts +18 -3
- package/dist/index.d.ts +18 -3
- package/dist/index.js +34 -12
- package/package.json +18 -18
package/README.md
CHANGED
|
@@ -148,6 +148,8 @@ export default lincy({
|
|
|
148
148
|
test: false, // 默认值: true, 可选: false
|
|
149
149
|
// 是否启用 markdown 规则
|
|
150
150
|
markdown: false, // 默认值: true, 可选: false
|
|
151
|
+
// 是否启用 eslint-plugin-sort-keys 规则
|
|
152
|
+
sortKeys: true, // 默认值: false, 可选: true
|
|
151
153
|
// 覆盖规则
|
|
152
154
|
overrides: {},
|
|
153
155
|
|
|
@@ -219,6 +221,7 @@ import {
|
|
|
219
221
|
jsonc,
|
|
220
222
|
markdown,
|
|
221
223
|
node,
|
|
224
|
+
sortKeys,
|
|
222
225
|
sortPackageJson,
|
|
223
226
|
sortTsconfig,
|
|
224
227
|
stylistic,
|
|
@@ -229,12 +232,15 @@ import {
|
|
|
229
232
|
} from '@lincy/eslint-config'
|
|
230
233
|
|
|
231
234
|
export default [
|
|
235
|
+
...comments(),
|
|
232
236
|
...ignores(),
|
|
237
|
+
...imports(),
|
|
233
238
|
...javascript(),
|
|
234
|
-
...comments(),
|
|
235
|
-
...node(),
|
|
236
239
|
...jsdoc(),
|
|
237
|
-
...
|
|
240
|
+
...node(),
|
|
241
|
+
...sortKeys(),
|
|
242
|
+
...sortPackageJson(),
|
|
243
|
+
...sortTsconfig(),
|
|
238
244
|
...unicorn(),
|
|
239
245
|
|
|
240
246
|
...typescript(),
|
|
@@ -290,6 +296,7 @@ export default lincy(
|
|
|
290
296
|
jsonc: true,
|
|
291
297
|
yaml: true,
|
|
292
298
|
markdown: true,
|
|
299
|
+
sortKeys: true,
|
|
293
300
|
overrides: {}
|
|
294
301
|
},
|
|
295
302
|
{
|
|
@@ -358,6 +365,7 @@ import lincy from '@lincy/eslint-config'
|
|
|
358
365
|
export default lincy({
|
|
359
366
|
typescript: {
|
|
360
367
|
tsconfigPath: 'tsconfig.json',
|
|
368
|
+
// tsconfigPath: ['tsconfig.json'], // 也可以是数组
|
|
361
369
|
},
|
|
362
370
|
})
|
|
363
371
|
```
|
package/dist/index.cjs
CHANGED
|
@@ -74,6 +74,7 @@ __export(src_exports, {
|
|
|
74
74
|
pluginMarkdown: () => import_eslint_plugin_markdown.default,
|
|
75
75
|
pluginNoOnlyTests: () => import_eslint_plugin_no_only_tests.default,
|
|
76
76
|
pluginNode: () => import_eslint_plugin_n.default,
|
|
77
|
+
pluginSortKeys: () => import_eslint_plugin_sort_keys.default,
|
|
77
78
|
pluginStylistic: () => import_eslint_plugin.default,
|
|
78
79
|
pluginTs: () => import_eslint_plugin2.default,
|
|
79
80
|
pluginUnicorn: () => import_eslint_plugin_unicorn.default,
|
|
@@ -81,10 +82,12 @@ __export(src_exports, {
|
|
|
81
82
|
pluginVue: () => import_eslint_plugin_vue.default,
|
|
82
83
|
pluginYaml: () => pluginYaml,
|
|
83
84
|
renameRules: () => renameRules,
|
|
85
|
+
sortKeys: () => sortKeys,
|
|
84
86
|
sortPackageJson: () => sortPackageJson,
|
|
85
87
|
sortTsconfig: () => sortTsconfig,
|
|
86
88
|
stylistic: () => stylistic,
|
|
87
89
|
test: () => test,
|
|
90
|
+
toArray: () => toArray,
|
|
88
91
|
typescript: () => typescript,
|
|
89
92
|
unicorn: () => unicorn,
|
|
90
93
|
vue: () => vue,
|
|
@@ -113,6 +116,7 @@ var import_eslint_plugin_unused_imports = __toESM(require("eslint-plugin-unused-
|
|
|
113
116
|
var import_eslint_plugin_vue = __toESM(require("eslint-plugin-vue"), 1);
|
|
114
117
|
var pluginYaml = __toESM(require("eslint-plugin-yml"), 1);
|
|
115
118
|
var import_eslint_plugin_no_only_tests = __toESM(require("eslint-plugin-no-only-tests"), 1);
|
|
119
|
+
var import_eslint_plugin_sort_keys = __toESM(require("eslint-plugin-sort-keys"), 1);
|
|
116
120
|
var parserTs = __toESM(require("@typescript-eslint/parser"), 1);
|
|
117
121
|
var import_vue_eslint_parser = __toESM(require("vue-eslint-parser"), 1);
|
|
118
122
|
var import_yaml_eslint_parser = __toESM(require("yaml-eslint-parser"), 1);
|
|
@@ -1040,14 +1044,16 @@ function renameRules(rules, from, to) {
|
|
|
1040
1044
|
})
|
|
1041
1045
|
);
|
|
1042
1046
|
}
|
|
1047
|
+
function toArray(value) {
|
|
1048
|
+
return Array.isArray(value) ? value : [value];
|
|
1049
|
+
}
|
|
1043
1050
|
|
|
1044
1051
|
// src/configs/typescript.ts
|
|
1045
1052
|
function typescript(options) {
|
|
1046
1053
|
const {
|
|
1047
1054
|
componentExts = [],
|
|
1048
1055
|
overrides = {},
|
|
1049
|
-
parserOptions = {}
|
|
1050
|
-
tsconfigPath
|
|
1056
|
+
parserOptions = {}
|
|
1051
1057
|
} = options ?? {};
|
|
1052
1058
|
const typeAwareRules = {
|
|
1053
1059
|
"dot-notation": "off",
|
|
@@ -1070,6 +1076,7 @@ function typescript(options) {
|
|
|
1070
1076
|
"ts/restrict-template-expressions": "error",
|
|
1071
1077
|
"ts/unbound-method": "error"
|
|
1072
1078
|
};
|
|
1079
|
+
const tsconfigPath = options?.tsconfigPath ? toArray(options.tsconfigPath) : void 0;
|
|
1073
1080
|
return [
|
|
1074
1081
|
{
|
|
1075
1082
|
// Install the plugins without globs, so they can be configured separately.
|
|
@@ -1087,9 +1094,10 @@ function typescript(options) {
|
|
|
1087
1094
|
languageOptions: {
|
|
1088
1095
|
parser: parserTs,
|
|
1089
1096
|
parserOptions: {
|
|
1097
|
+
extraFileExtensions: componentExts.map((ext) => `.${ext}`),
|
|
1090
1098
|
sourceType: "module",
|
|
1091
1099
|
...tsconfigPath ? {
|
|
1092
|
-
project:
|
|
1100
|
+
project: tsconfigPath,
|
|
1093
1101
|
tsconfigRootDir: import_node_process.default.cwd()
|
|
1094
1102
|
} : {},
|
|
1095
1103
|
...parserOptions
|
|
@@ -1411,6 +1419,17 @@ function test(options = {}) {
|
|
|
1411
1419
|
];
|
|
1412
1420
|
}
|
|
1413
1421
|
|
|
1422
|
+
// src/configs/sort-keys.ts
|
|
1423
|
+
function sortKeys() {
|
|
1424
|
+
return [
|
|
1425
|
+
{
|
|
1426
|
+
plugins: {
|
|
1427
|
+
"sort-keys": import_eslint_plugin_sort_keys.default
|
|
1428
|
+
}
|
|
1429
|
+
}
|
|
1430
|
+
];
|
|
1431
|
+
}
|
|
1432
|
+
|
|
1414
1433
|
// src/factory.ts
|
|
1415
1434
|
var flatConfigProps = [
|
|
1416
1435
|
"files",
|
|
@@ -1434,6 +1453,7 @@ function lincy(options = {}, ...userConfigs) {
|
|
|
1434
1453
|
vue: enableVue = VuePackages.some((i) => (0, import_local_pkg2.isPackageExists)(i)),
|
|
1435
1454
|
typescript: enableTypeScript = (0, import_local_pkg2.isPackageExists)("typescript"),
|
|
1436
1455
|
gitignore: enableGitignore = true,
|
|
1456
|
+
sortKeys: enableSortKeys = false,
|
|
1437
1457
|
overrides = {},
|
|
1438
1458
|
componentExts = []
|
|
1439
1459
|
} = options;
|
|
@@ -1467,6 +1487,8 @@ function lincy(options = {}, ...userConfigs) {
|
|
|
1467
1487
|
}),
|
|
1468
1488
|
unicorn()
|
|
1469
1489
|
);
|
|
1490
|
+
if (enableSortKeys)
|
|
1491
|
+
configs.push(sortKeys());
|
|
1470
1492
|
if (enableVue)
|
|
1471
1493
|
componentExts.push("vue");
|
|
1472
1494
|
if (enableTypeScript) {
|
|
@@ -1578,6 +1600,7 @@ var src_default = lincy;
|
|
|
1578
1600
|
pluginMarkdown,
|
|
1579
1601
|
pluginNoOnlyTests,
|
|
1580
1602
|
pluginNode,
|
|
1603
|
+
pluginSortKeys,
|
|
1581
1604
|
pluginStylistic,
|
|
1582
1605
|
pluginTs,
|
|
1583
1606
|
pluginUnicorn,
|
|
@@ -1585,10 +1608,12 @@ var src_default = lincy;
|
|
|
1585
1608
|
pluginVue,
|
|
1586
1609
|
pluginYaml,
|
|
1587
1610
|
renameRules,
|
|
1611
|
+
sortKeys,
|
|
1588
1612
|
sortPackageJson,
|
|
1589
1613
|
sortTsconfig,
|
|
1590
1614
|
stylistic,
|
|
1591
1615
|
test,
|
|
1616
|
+
toArray,
|
|
1592
1617
|
typescript,
|
|
1593
1618
|
unicorn,
|
|
1594
1619
|
vue,
|
package/dist/index.d.cts
CHANGED
|
@@ -21,6 +21,7 @@ export { default as pluginVue } from 'eslint-plugin-vue';
|
|
|
21
21
|
import * as eslintPluginYml from 'eslint-plugin-yml';
|
|
22
22
|
export { eslintPluginYml as pluginYaml };
|
|
23
23
|
export { default as pluginNoOnlyTests } from 'eslint-plugin-no-only-tests';
|
|
24
|
+
export { default as pluginSortKeys } from 'eslint-plugin-sort-keys';
|
|
24
25
|
export { default as parserVue } from 'vue-eslint-parser';
|
|
25
26
|
export { default as parserYaml } from 'yaml-eslint-parser';
|
|
26
27
|
export { default as parserJsonc } from 'jsonc-eslint-parser';
|
|
@@ -63,7 +64,7 @@ interface OptionsTypeScriptWithTypes {
|
|
|
63
64
|
* When this options is provided, type aware rules will be enabled.
|
|
64
65
|
* @see https://typescript-eslint.io/linting/typed-linting/
|
|
65
66
|
*/
|
|
66
|
-
tsconfigPath?: string;
|
|
67
|
+
tsconfigPath?: string | string[];
|
|
67
68
|
}
|
|
68
69
|
interface OptionsHasTypeScript {
|
|
69
70
|
typescript?: boolean;
|
|
@@ -105,7 +106,7 @@ interface OptionsConfig extends OptionsComponentExts {
|
|
|
105
106
|
*
|
|
106
107
|
* @default auto-detect based on the dependencies
|
|
107
108
|
*/
|
|
108
|
-
typescript?: boolean | OptionsTypeScriptWithTypes;
|
|
109
|
+
typescript?: boolean | OptionsTypeScriptWithTypes | OptionsTypeScriptParserOptions;
|
|
109
110
|
/**
|
|
110
111
|
* Enable JSX related rules.
|
|
111
112
|
*
|
|
@@ -144,6 +145,12 @@ interface OptionsConfig extends OptionsComponentExts {
|
|
|
144
145
|
* @default true
|
|
145
146
|
*/
|
|
146
147
|
markdown?: boolean;
|
|
148
|
+
/**
|
|
149
|
+
* Enable SortKeys support.
|
|
150
|
+
*
|
|
151
|
+
* @default false
|
|
152
|
+
*/
|
|
153
|
+
sortKeys?: boolean;
|
|
147
154
|
/**
|
|
148
155
|
* Enable stylistic rules.
|
|
149
156
|
*
|
|
@@ -217,6 +224,13 @@ declare function yaml(options?: OptionsOverrides & OptionsStylistic): ConfigItem
|
|
|
217
224
|
|
|
218
225
|
declare function test(options?: OptionsIsInEditor & OptionsOverrides): ConfigItem[];
|
|
219
226
|
|
|
227
|
+
/**
|
|
228
|
+
* Optional sort-keys plugin
|
|
229
|
+
*
|
|
230
|
+
* @see https://github.com/namnm/eslint-plugin-sort-keys
|
|
231
|
+
*/
|
|
232
|
+
declare function sortKeys(): ConfigItem[];
|
|
233
|
+
|
|
220
234
|
/**
|
|
221
235
|
* Combine array and non-array configs into a single array.
|
|
222
236
|
*/
|
|
@@ -224,6 +238,7 @@ declare function combine(...configs: (ConfigItem | ConfigItem[])[]): ConfigItem[
|
|
|
224
238
|
declare function renameRules(rules: Record<string, any>, from: string, to: string): {
|
|
225
239
|
[k: string]: any;
|
|
226
240
|
};
|
|
241
|
+
declare function toArray<T>(value: T | T[]): T[];
|
|
227
242
|
|
|
228
243
|
declare const GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
|
|
229
244
|
declare const GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
|
|
@@ -247,4 +262,4 @@ declare const GLOB_TESTS: string[];
|
|
|
247
262
|
declare const GLOB_ALL_SRC: string[];
|
|
248
263
|
declare const GLOB_EXCLUDE: string[];
|
|
249
264
|
|
|
250
|
-
export { ConfigItem, GLOB_ALL_SRC, GLOB_CSS, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_TESTS, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_YAML, OptionsComponentExts, OptionsConfig, OptionsHasTypeScript, OptionsIgnores, OptionsIsInEditor, OptionsOverrides, OptionsStylistic, OptionsTypeScriptParserOptions, OptionsTypeScriptWithTypes, Rules, StylisticConfig, StylisticOverridesConfig, combine, comments, lincy as default, ignores, imports, javascript, jsdoc, jsonc, lincy, markdown, node, renameRules, sortPackageJson, sortTsconfig, stylistic, test, typescript, unicorn, vue, yaml };
|
|
265
|
+
export { ConfigItem, GLOB_ALL_SRC, GLOB_CSS, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_TESTS, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_YAML, OptionsComponentExts, OptionsConfig, OptionsHasTypeScript, OptionsIgnores, OptionsIsInEditor, OptionsOverrides, OptionsStylistic, OptionsTypeScriptParserOptions, OptionsTypeScriptWithTypes, Rules, StylisticConfig, StylisticOverridesConfig, combine, comments, lincy as default, ignores, imports, javascript, jsdoc, jsonc, lincy, markdown, node, renameRules, sortKeys, sortPackageJson, sortTsconfig, stylistic, test, toArray, typescript, unicorn, vue, yaml };
|
package/dist/index.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ export { default as pluginVue } from 'eslint-plugin-vue';
|
|
|
21
21
|
import * as eslintPluginYml from 'eslint-plugin-yml';
|
|
22
22
|
export { eslintPluginYml as pluginYaml };
|
|
23
23
|
export { default as pluginNoOnlyTests } from 'eslint-plugin-no-only-tests';
|
|
24
|
+
export { default as pluginSortKeys } from 'eslint-plugin-sort-keys';
|
|
24
25
|
export { default as parserVue } from 'vue-eslint-parser';
|
|
25
26
|
export { default as parserYaml } from 'yaml-eslint-parser';
|
|
26
27
|
export { default as parserJsonc } from 'jsonc-eslint-parser';
|
|
@@ -63,7 +64,7 @@ interface OptionsTypeScriptWithTypes {
|
|
|
63
64
|
* When this options is provided, type aware rules will be enabled.
|
|
64
65
|
* @see https://typescript-eslint.io/linting/typed-linting/
|
|
65
66
|
*/
|
|
66
|
-
tsconfigPath?: string;
|
|
67
|
+
tsconfigPath?: string | string[];
|
|
67
68
|
}
|
|
68
69
|
interface OptionsHasTypeScript {
|
|
69
70
|
typescript?: boolean;
|
|
@@ -105,7 +106,7 @@ interface OptionsConfig extends OptionsComponentExts {
|
|
|
105
106
|
*
|
|
106
107
|
* @default auto-detect based on the dependencies
|
|
107
108
|
*/
|
|
108
|
-
typescript?: boolean | OptionsTypeScriptWithTypes;
|
|
109
|
+
typescript?: boolean | OptionsTypeScriptWithTypes | OptionsTypeScriptParserOptions;
|
|
109
110
|
/**
|
|
110
111
|
* Enable JSX related rules.
|
|
111
112
|
*
|
|
@@ -144,6 +145,12 @@ interface OptionsConfig extends OptionsComponentExts {
|
|
|
144
145
|
* @default true
|
|
145
146
|
*/
|
|
146
147
|
markdown?: boolean;
|
|
148
|
+
/**
|
|
149
|
+
* Enable SortKeys support.
|
|
150
|
+
*
|
|
151
|
+
* @default false
|
|
152
|
+
*/
|
|
153
|
+
sortKeys?: boolean;
|
|
147
154
|
/**
|
|
148
155
|
* Enable stylistic rules.
|
|
149
156
|
*
|
|
@@ -217,6 +224,13 @@ declare function yaml(options?: OptionsOverrides & OptionsStylistic): ConfigItem
|
|
|
217
224
|
|
|
218
225
|
declare function test(options?: OptionsIsInEditor & OptionsOverrides): ConfigItem[];
|
|
219
226
|
|
|
227
|
+
/**
|
|
228
|
+
* Optional sort-keys plugin
|
|
229
|
+
*
|
|
230
|
+
* @see https://github.com/namnm/eslint-plugin-sort-keys
|
|
231
|
+
*/
|
|
232
|
+
declare function sortKeys(): ConfigItem[];
|
|
233
|
+
|
|
220
234
|
/**
|
|
221
235
|
* Combine array and non-array configs into a single array.
|
|
222
236
|
*/
|
|
@@ -224,6 +238,7 @@ declare function combine(...configs: (ConfigItem | ConfigItem[])[]): ConfigItem[
|
|
|
224
238
|
declare function renameRules(rules: Record<string, any>, from: string, to: string): {
|
|
225
239
|
[k: string]: any;
|
|
226
240
|
};
|
|
241
|
+
declare function toArray<T>(value: T | T[]): T[];
|
|
227
242
|
|
|
228
243
|
declare const GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
|
|
229
244
|
declare const GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
|
|
@@ -247,4 +262,4 @@ declare const GLOB_TESTS: string[];
|
|
|
247
262
|
declare const GLOB_ALL_SRC: string[];
|
|
248
263
|
declare const GLOB_EXCLUDE: string[];
|
|
249
264
|
|
|
250
|
-
export { ConfigItem, GLOB_ALL_SRC, GLOB_CSS, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_TESTS, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_YAML, OptionsComponentExts, OptionsConfig, OptionsHasTypeScript, OptionsIgnores, OptionsIsInEditor, OptionsOverrides, OptionsStylistic, OptionsTypeScriptParserOptions, OptionsTypeScriptWithTypes, Rules, StylisticConfig, StylisticOverridesConfig, combine, comments, lincy as default, ignores, imports, javascript, jsdoc, jsonc, lincy, markdown, node, renameRules, sortPackageJson, sortTsconfig, stylistic, test, typescript, unicorn, vue, yaml };
|
|
265
|
+
export { ConfigItem, GLOB_ALL_SRC, GLOB_CSS, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_TESTS, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_YAML, OptionsComponentExts, OptionsConfig, OptionsHasTypeScript, OptionsIgnores, OptionsIsInEditor, OptionsOverrides, OptionsStylistic, OptionsTypeScriptParserOptions, OptionsTypeScriptWithTypes, Rules, StylisticConfig, StylisticOverridesConfig, combine, comments, lincy as default, ignores, imports, javascript, jsdoc, jsonc, lincy, markdown, node, renameRules, sortKeys, sortPackageJson, sortTsconfig, stylistic, test, toArray, typescript, unicorn, vue, yaml };
|
package/dist/index.js
CHANGED
|
@@ -19,10 +19,11 @@ import { default as default10 } from "eslint-plugin-unused-imports";
|
|
|
19
19
|
import { default as default11 } from "eslint-plugin-vue";
|
|
20
20
|
import * as pluginYaml from "eslint-plugin-yml";
|
|
21
21
|
import { default as default12 } from "eslint-plugin-no-only-tests";
|
|
22
|
+
import { default as default13 } from "eslint-plugin-sort-keys";
|
|
22
23
|
import * as parserTs from "@typescript-eslint/parser";
|
|
23
|
-
import { default as
|
|
24
|
-
import { default as
|
|
25
|
-
import { default as
|
|
24
|
+
import { default as default14 } from "vue-eslint-parser";
|
|
25
|
+
import { default as default15 } from "yaml-eslint-parser";
|
|
26
|
+
import { default as default16 } from "jsonc-eslint-parser";
|
|
26
27
|
|
|
27
28
|
// src/configs/comments.ts
|
|
28
29
|
function comments() {
|
|
@@ -415,7 +416,7 @@ function jsonc(options = {}) {
|
|
|
415
416
|
{
|
|
416
417
|
files: [GLOB_JSON, GLOB_JSON5, GLOB_JSONC],
|
|
417
418
|
languageOptions: {
|
|
418
|
-
parser:
|
|
419
|
+
parser: default16
|
|
419
420
|
},
|
|
420
421
|
rules: {
|
|
421
422
|
"jsonc/no-bigint-literals": "error",
|
|
@@ -946,14 +947,16 @@ function renameRules(rules, from, to) {
|
|
|
946
947
|
})
|
|
947
948
|
);
|
|
948
949
|
}
|
|
950
|
+
function toArray(value) {
|
|
951
|
+
return Array.isArray(value) ? value : [value];
|
|
952
|
+
}
|
|
949
953
|
|
|
950
954
|
// src/configs/typescript.ts
|
|
951
955
|
function typescript(options) {
|
|
952
956
|
const {
|
|
953
957
|
componentExts = [],
|
|
954
958
|
overrides = {},
|
|
955
|
-
parserOptions = {}
|
|
956
|
-
tsconfigPath
|
|
959
|
+
parserOptions = {}
|
|
957
960
|
} = options ?? {};
|
|
958
961
|
const typeAwareRules = {
|
|
959
962
|
"dot-notation": "off",
|
|
@@ -976,6 +979,7 @@ function typescript(options) {
|
|
|
976
979
|
"ts/restrict-template-expressions": "error",
|
|
977
980
|
"ts/unbound-method": "error"
|
|
978
981
|
};
|
|
982
|
+
const tsconfigPath = options?.tsconfigPath ? toArray(options.tsconfigPath) : void 0;
|
|
979
983
|
return [
|
|
980
984
|
{
|
|
981
985
|
// Install the plugins without globs, so they can be configured separately.
|
|
@@ -993,9 +997,10 @@ function typescript(options) {
|
|
|
993
997
|
languageOptions: {
|
|
994
998
|
parser: parserTs,
|
|
995
999
|
parserOptions: {
|
|
1000
|
+
extraFileExtensions: componentExts.map((ext) => `.${ext}`),
|
|
996
1001
|
sourceType: "module",
|
|
997
1002
|
...tsconfigPath ? {
|
|
998
|
-
project:
|
|
1003
|
+
project: tsconfigPath,
|
|
999
1004
|
tsconfigRootDir: process.cwd()
|
|
1000
1005
|
} : {},
|
|
1001
1006
|
...parserOptions
|
|
@@ -1137,7 +1142,7 @@ function vue(options = {}) {
|
|
|
1137
1142
|
{
|
|
1138
1143
|
files: [GLOB_VUE],
|
|
1139
1144
|
languageOptions: {
|
|
1140
|
-
parser:
|
|
1145
|
+
parser: default14,
|
|
1141
1146
|
parserOptions: {
|
|
1142
1147
|
ecmaFeatures: {
|
|
1143
1148
|
jsx: true
|
|
@@ -1265,7 +1270,7 @@ function yaml(options = {}) {
|
|
|
1265
1270
|
{
|
|
1266
1271
|
files: [GLOB_YAML],
|
|
1267
1272
|
languageOptions: {
|
|
1268
|
-
parser:
|
|
1273
|
+
parser: default15
|
|
1269
1274
|
},
|
|
1270
1275
|
rules: {
|
|
1271
1276
|
"style/spaced-comment": "off",
|
|
@@ -1317,6 +1322,17 @@ function test(options = {}) {
|
|
|
1317
1322
|
];
|
|
1318
1323
|
}
|
|
1319
1324
|
|
|
1325
|
+
// src/configs/sort-keys.ts
|
|
1326
|
+
function sortKeys() {
|
|
1327
|
+
return [
|
|
1328
|
+
{
|
|
1329
|
+
plugins: {
|
|
1330
|
+
"sort-keys": default13
|
|
1331
|
+
}
|
|
1332
|
+
}
|
|
1333
|
+
];
|
|
1334
|
+
}
|
|
1335
|
+
|
|
1320
1336
|
// src/factory.ts
|
|
1321
1337
|
var flatConfigProps = [
|
|
1322
1338
|
"files",
|
|
@@ -1340,6 +1356,7 @@ function lincy(options = {}, ...userConfigs) {
|
|
|
1340
1356
|
vue: enableVue = VuePackages.some((i) => isPackageExists(i)),
|
|
1341
1357
|
typescript: enableTypeScript = isPackageExists("typescript"),
|
|
1342
1358
|
gitignore: enableGitignore = true,
|
|
1359
|
+
sortKeys: enableSortKeys = false,
|
|
1343
1360
|
overrides = {},
|
|
1344
1361
|
componentExts = []
|
|
1345
1362
|
} = options;
|
|
@@ -1373,6 +1390,8 @@ function lincy(options = {}, ...userConfigs) {
|
|
|
1373
1390
|
}),
|
|
1374
1391
|
unicorn()
|
|
1375
1392
|
);
|
|
1393
|
+
if (enableSortKeys)
|
|
1394
|
+
configs.push(sortKeys());
|
|
1376
1395
|
if (enableVue)
|
|
1377
1396
|
componentExts.push("vue");
|
|
1378
1397
|
if (enableTypeScript) {
|
|
@@ -1472,10 +1491,10 @@ export {
|
|
|
1472
1491
|
lincy,
|
|
1473
1492
|
markdown,
|
|
1474
1493
|
node,
|
|
1475
|
-
|
|
1494
|
+
default16 as parserJsonc,
|
|
1476
1495
|
parserTs,
|
|
1477
|
-
|
|
1478
|
-
|
|
1496
|
+
default14 as parserVue,
|
|
1497
|
+
default15 as parserYaml,
|
|
1479
1498
|
default2 as pluginAntfu,
|
|
1480
1499
|
default3 as pluginComments,
|
|
1481
1500
|
pluginImport,
|
|
@@ -1484,6 +1503,7 @@ export {
|
|
|
1484
1503
|
default5 as pluginMarkdown,
|
|
1485
1504
|
default12 as pluginNoOnlyTests,
|
|
1486
1505
|
default6 as pluginNode,
|
|
1506
|
+
default13 as pluginSortKeys,
|
|
1487
1507
|
default7 as pluginStylistic,
|
|
1488
1508
|
default8 as pluginTs,
|
|
1489
1509
|
default9 as pluginUnicorn,
|
|
@@ -1491,10 +1511,12 @@ export {
|
|
|
1491
1511
|
default11 as pluginVue,
|
|
1492
1512
|
pluginYaml,
|
|
1493
1513
|
renameRules,
|
|
1514
|
+
sortKeys,
|
|
1494
1515
|
sortPackageJson,
|
|
1495
1516
|
sortTsconfig,
|
|
1496
1517
|
stylistic,
|
|
1497
1518
|
test,
|
|
1519
|
+
toArray,
|
|
1498
1520
|
typescript,
|
|
1499
1521
|
unicorn,
|
|
1500
1522
|
vue,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lincy/eslint-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "3.
|
|
4
|
+
"version": "3.6.0",
|
|
5
5
|
"packageManager": "pnpm@8.7.6",
|
|
6
6
|
"description": "LinCenYing's ESLint config",
|
|
7
7
|
"author": "LinCenYing <lincenying@gmail.com> (https://github.com/lincenying/)",
|
|
@@ -39,26 +39,27 @@
|
|
|
39
39
|
"eslint": ">=8.0.0"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@antfu/eslint-define-config": "
|
|
43
|
-
"@stylistic/eslint-plugin": "0.
|
|
44
|
-
"@typescript-eslint/eslint-plugin": "^6.
|
|
45
|
-
"@typescript-eslint/parser": "^6.
|
|
46
|
-
"eslint-config-flat-gitignore": "^0.1.
|
|
47
|
-
"eslint-plugin-antfu": "^1.0.
|
|
42
|
+
"@antfu/eslint-define-config": "1.23.0-2",
|
|
43
|
+
"@stylistic/eslint-plugin": "0.1.2",
|
|
44
|
+
"@typescript-eslint/eslint-plugin": "^6.9.1",
|
|
45
|
+
"@typescript-eslint/parser": "^6.9.1",
|
|
46
|
+
"eslint-config-flat-gitignore": "^0.1.1",
|
|
47
|
+
"eslint-plugin-antfu": "^1.0.1",
|
|
48
48
|
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
49
|
-
"eslint-plugin-i": "^2.
|
|
49
|
+
"eslint-plugin-i": "^2.29.0",
|
|
50
50
|
"eslint-plugin-jsdoc": "^46.8.2",
|
|
51
51
|
"eslint-plugin-jsonc": "^2.10.0",
|
|
52
52
|
"eslint-plugin-markdown": "^3.0.1",
|
|
53
53
|
"eslint-plugin-n": "^16.2.0",
|
|
54
54
|
"eslint-plugin-no-only-tests": "^3.1.0",
|
|
55
|
-
"eslint-plugin-
|
|
55
|
+
"eslint-plugin-sort-keys": "^2.3.5",
|
|
56
|
+
"eslint-plugin-unicorn": "^49.0.0",
|
|
56
57
|
"eslint-plugin-unused-imports": "^3.0.0",
|
|
57
|
-
"eslint-plugin-vitest": "^0.3.
|
|
58
|
-
"eslint-plugin-vue": "^9.
|
|
58
|
+
"eslint-plugin-vitest": "^0.3.8",
|
|
59
|
+
"eslint-plugin-vue": "^9.18.1",
|
|
59
60
|
"eslint-plugin-yml": "^1.10.0",
|
|
60
61
|
"globals": "^13.23.0",
|
|
61
|
-
"jsonc-eslint-parser": "^2.
|
|
62
|
+
"jsonc-eslint-parser": "^2.4.0",
|
|
62
63
|
"local-pkg": "^0.5.0",
|
|
63
64
|
"vue-eslint-parser": "^9.3.2",
|
|
64
65
|
"yaml-eslint-parser": "^1.2.2"
|
|
@@ -66,15 +67,14 @@
|
|
|
66
67
|
"devDependencies": {
|
|
67
68
|
"@antfu/ni": "^0.21.8",
|
|
68
69
|
"@lincy/eslint-config": "workspace:*",
|
|
69
|
-
"@stylistic/eslint-plugin-migrate": "^0.
|
|
70
|
-
"@types/eslint": "^8.44.
|
|
71
|
-
"@types/node": "^20.8.
|
|
70
|
+
"@stylistic/eslint-plugin-migrate": "^0.1.2",
|
|
71
|
+
"@types/eslint": "^8.44.6",
|
|
72
|
+
"@types/node": "^20.8.10",
|
|
72
73
|
"bumpp": "^9.2.0",
|
|
73
|
-
"eslint": "^8.
|
|
74
|
+
"eslint": "^8.52.0",
|
|
74
75
|
"eslint-flat-config-viewer": "^0.1.0",
|
|
75
|
-
"eslint-plugin-sort-keys": "^2.3.5",
|
|
76
76
|
"esno": "^0.17.0",
|
|
77
|
-
"lint-staged": "^
|
|
77
|
+
"lint-staged": "^15.0.2",
|
|
78
78
|
"rimraf": "^5.0.5",
|
|
79
79
|
"simple-git-hooks": "^2.9.0",
|
|
80
80
|
"simple-open-url": "^3.0.1",
|