@pengzhanbo/eslint-config 1.5.2 → 1.5.4
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/dist/index.cjs +30 -17
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +30 -17
- package/package.json +11 -11
package/dist/index.cjs
CHANGED
|
@@ -376,7 +376,6 @@ async function javascript(options = {}) {
|
|
|
376
376
|
"no-multi-str": "error",
|
|
377
377
|
"no-new": "error",
|
|
378
378
|
"no-new-func": "error",
|
|
379
|
-
"no-new-object": "error",
|
|
380
379
|
"no-new-symbol": "error",
|
|
381
380
|
"no-new-wrappers": "error",
|
|
382
381
|
"no-obj-calls": "error",
|
|
@@ -1008,6 +1007,8 @@ async function typescript(options = {}) {
|
|
|
1008
1007
|
...componentExts.map((ext) => `**/*.${ext}`)
|
|
1009
1008
|
];
|
|
1010
1009
|
const filesTypeAware = options.filesTypeAware ?? [GLOB_TS, GLOB_TSX];
|
|
1010
|
+
const tsconfigPath = options?.tsconfigPath ? toArray(options.tsconfigPath) : void 0;
|
|
1011
|
+
const isTypeAware = !!tsconfigPath;
|
|
1011
1012
|
const typeAwareRules = {
|
|
1012
1013
|
"dot-notation": "off",
|
|
1013
1014
|
"no-implied-eval": "off",
|
|
@@ -1029,7 +1030,6 @@ async function typescript(options = {}) {
|
|
|
1029
1030
|
"ts/restrict-template-expressions": "error",
|
|
1030
1031
|
"ts/unbound-method": "error"
|
|
1031
1032
|
};
|
|
1032
|
-
const tsconfigPath = options?.tsconfigPath ? toArray(options.tsconfigPath) : void 0;
|
|
1033
1033
|
const [
|
|
1034
1034
|
pluginTs,
|
|
1035
1035
|
parserTs
|
|
@@ -1037,29 +1037,41 @@ async function typescript(options = {}) {
|
|
|
1037
1037
|
interopDefault(import("@typescript-eslint/eslint-plugin")),
|
|
1038
1038
|
interopDefault(import("@typescript-eslint/parser"))
|
|
1039
1039
|
]);
|
|
1040
|
-
|
|
1041
|
-
{
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
plugins: {
|
|
1045
|
-
antfu: import_eslint_plugin_antfu.default,
|
|
1046
|
-
ts: pluginTs
|
|
1047
|
-
}
|
|
1048
|
-
},
|
|
1049
|
-
{
|
|
1050
|
-
files,
|
|
1040
|
+
function makeParser(typeAware, files2, ignores2) {
|
|
1041
|
+
return {
|
|
1042
|
+
files: files2,
|
|
1043
|
+
...ignores2 ? { ignores: ignores2 } : {},
|
|
1051
1044
|
languageOptions: {
|
|
1052
1045
|
parser: parserTs,
|
|
1053
1046
|
parserOptions: {
|
|
1054
1047
|
extraFileExtensions: componentExts.map((ext) => `.${ext}`),
|
|
1055
1048
|
sourceType: "module",
|
|
1056
|
-
...
|
|
1049
|
+
...typeAware ? {
|
|
1057
1050
|
project: tsconfigPath,
|
|
1058
1051
|
tsconfigRootDir: import_node_process.default.cwd()
|
|
1059
1052
|
} : {},
|
|
1060
1053
|
...parserOptions
|
|
1061
1054
|
}
|
|
1062
1055
|
},
|
|
1056
|
+
name: `antfu:typescript:${typeAware ? "type-aware-parser" : "parser"}`
|
|
1057
|
+
};
|
|
1058
|
+
}
|
|
1059
|
+
return [
|
|
1060
|
+
{
|
|
1061
|
+
// Install the plugins without globs, so they can be configured separately.
|
|
1062
|
+
name: "config:typescript:setup",
|
|
1063
|
+
plugins: {
|
|
1064
|
+
antfu: import_eslint_plugin_antfu.default,
|
|
1065
|
+
ts: pluginTs
|
|
1066
|
+
}
|
|
1067
|
+
},
|
|
1068
|
+
// assign type-aware parser for type-aware files and type-unaware parser for the rest
|
|
1069
|
+
...isTypeAware ? [
|
|
1070
|
+
makeParser(true, filesTypeAware),
|
|
1071
|
+
makeParser(false, files, filesTypeAware)
|
|
1072
|
+
] : [makeParser(false, files)],
|
|
1073
|
+
{
|
|
1074
|
+
files,
|
|
1063
1075
|
name: "config:typescript:rules",
|
|
1064
1076
|
rules: {
|
|
1065
1077
|
...renameRules(
|
|
@@ -1661,7 +1673,8 @@ var defaultPreset = (options) => {
|
|
|
1661
1673
|
if (enableTypeScript) {
|
|
1662
1674
|
configs.push(typescript({
|
|
1663
1675
|
...resolveSubOptions(options, "typescript"),
|
|
1664
|
-
componentExts
|
|
1676
|
+
componentExts,
|
|
1677
|
+
overrides: getOverrides(options, "typescript")
|
|
1665
1678
|
}));
|
|
1666
1679
|
}
|
|
1667
1680
|
if (stylisticOptions) {
|
|
@@ -1817,12 +1830,12 @@ function eslintFlatConfig(options = {}, ...userConfigs) {
|
|
|
1817
1830
|
|
|
1818
1831
|
// src/createConfig.ts
|
|
1819
1832
|
function createConfig(preset) {
|
|
1820
|
-
return function
|
|
1833
|
+
return function(options = {}, ...userConfigs) {
|
|
1821
1834
|
const userPreset = options.preset || [];
|
|
1822
1835
|
const presetList = Array.isArray(preset) ? preset : [preset];
|
|
1823
1836
|
presetList.push(...userPreset);
|
|
1824
1837
|
options.preset = presetList;
|
|
1825
|
-
return
|
|
1838
|
+
return eslintFlatConfig(options, ...userConfigs);
|
|
1826
1839
|
};
|
|
1827
1840
|
}
|
|
1828
1841
|
|
package/dist/index.d.cts
CHANGED
|
@@ -330,7 +330,7 @@ interface OptionsConfig extends OptionsComponentExts, OptionsFrameworkExtract {
|
|
|
330
330
|
*
|
|
331
331
|
* @default true
|
|
332
332
|
*/
|
|
333
|
-
stylistic?: boolean | StylisticConfig;
|
|
333
|
+
stylistic?: boolean | (StylisticConfig & OptionsOverrides);
|
|
334
334
|
/**
|
|
335
335
|
* Use external formatters to format files.
|
|
336
336
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -330,7 +330,7 @@ interface OptionsConfig extends OptionsComponentExts, OptionsFrameworkExtract {
|
|
|
330
330
|
*
|
|
331
331
|
* @default true
|
|
332
332
|
*/
|
|
333
|
-
stylistic?: boolean | StylisticConfig;
|
|
333
|
+
stylistic?: boolean | (StylisticConfig & OptionsOverrides);
|
|
334
334
|
/**
|
|
335
335
|
* Use external formatters to format files.
|
|
336
336
|
*
|
package/dist/index.js
CHANGED
|
@@ -277,7 +277,6 @@ async function javascript(options = {}) {
|
|
|
277
277
|
"no-multi-str": "error",
|
|
278
278
|
"no-new": "error",
|
|
279
279
|
"no-new-func": "error",
|
|
280
|
-
"no-new-object": "error",
|
|
281
280
|
"no-new-symbol": "error",
|
|
282
281
|
"no-new-wrappers": "error",
|
|
283
282
|
"no-obj-calls": "error",
|
|
@@ -909,6 +908,8 @@ async function typescript(options = {}) {
|
|
|
909
908
|
...componentExts.map((ext) => `**/*.${ext}`)
|
|
910
909
|
];
|
|
911
910
|
const filesTypeAware = options.filesTypeAware ?? [GLOB_TS, GLOB_TSX];
|
|
911
|
+
const tsconfigPath = options?.tsconfigPath ? toArray(options.tsconfigPath) : void 0;
|
|
912
|
+
const isTypeAware = !!tsconfigPath;
|
|
912
913
|
const typeAwareRules = {
|
|
913
914
|
"dot-notation": "off",
|
|
914
915
|
"no-implied-eval": "off",
|
|
@@ -930,7 +931,6 @@ async function typescript(options = {}) {
|
|
|
930
931
|
"ts/restrict-template-expressions": "error",
|
|
931
932
|
"ts/unbound-method": "error"
|
|
932
933
|
};
|
|
933
|
-
const tsconfigPath = options?.tsconfigPath ? toArray(options.tsconfigPath) : void 0;
|
|
934
934
|
const [
|
|
935
935
|
pluginTs,
|
|
936
936
|
parserTs
|
|
@@ -938,29 +938,41 @@ async function typescript(options = {}) {
|
|
|
938
938
|
interopDefault(import("@typescript-eslint/eslint-plugin")),
|
|
939
939
|
interopDefault(import("@typescript-eslint/parser"))
|
|
940
940
|
]);
|
|
941
|
-
|
|
942
|
-
{
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
plugins: {
|
|
946
|
-
antfu: default2,
|
|
947
|
-
ts: pluginTs
|
|
948
|
-
}
|
|
949
|
-
},
|
|
950
|
-
{
|
|
951
|
-
files,
|
|
941
|
+
function makeParser(typeAware, files2, ignores2) {
|
|
942
|
+
return {
|
|
943
|
+
files: files2,
|
|
944
|
+
...ignores2 ? { ignores: ignores2 } : {},
|
|
952
945
|
languageOptions: {
|
|
953
946
|
parser: parserTs,
|
|
954
947
|
parserOptions: {
|
|
955
948
|
extraFileExtensions: componentExts.map((ext) => `.${ext}`),
|
|
956
949
|
sourceType: "module",
|
|
957
|
-
...
|
|
950
|
+
...typeAware ? {
|
|
958
951
|
project: tsconfigPath,
|
|
959
952
|
tsconfigRootDir: process.cwd()
|
|
960
953
|
} : {},
|
|
961
954
|
...parserOptions
|
|
962
955
|
}
|
|
963
956
|
},
|
|
957
|
+
name: `antfu:typescript:${typeAware ? "type-aware-parser" : "parser"}`
|
|
958
|
+
};
|
|
959
|
+
}
|
|
960
|
+
return [
|
|
961
|
+
{
|
|
962
|
+
// Install the plugins without globs, so they can be configured separately.
|
|
963
|
+
name: "config:typescript:setup",
|
|
964
|
+
plugins: {
|
|
965
|
+
antfu: default2,
|
|
966
|
+
ts: pluginTs
|
|
967
|
+
}
|
|
968
|
+
},
|
|
969
|
+
// assign type-aware parser for type-aware files and type-unaware parser for the rest
|
|
970
|
+
...isTypeAware ? [
|
|
971
|
+
makeParser(true, filesTypeAware),
|
|
972
|
+
makeParser(false, files, filesTypeAware)
|
|
973
|
+
] : [makeParser(false, files)],
|
|
974
|
+
{
|
|
975
|
+
files,
|
|
964
976
|
name: "config:typescript:rules",
|
|
965
977
|
rules: {
|
|
966
978
|
...renameRules(
|
|
@@ -1562,7 +1574,8 @@ var defaultPreset = (options) => {
|
|
|
1562
1574
|
if (enableTypeScript) {
|
|
1563
1575
|
configs.push(typescript({
|
|
1564
1576
|
...resolveSubOptions(options, "typescript"),
|
|
1565
|
-
componentExts
|
|
1577
|
+
componentExts,
|
|
1578
|
+
overrides: getOverrides(options, "typescript")
|
|
1566
1579
|
}));
|
|
1567
1580
|
}
|
|
1568
1581
|
if (stylisticOptions) {
|
|
@@ -1718,12 +1731,12 @@ function eslintFlatConfig(options = {}, ...userConfigs) {
|
|
|
1718
1731
|
|
|
1719
1732
|
// src/createConfig.ts
|
|
1720
1733
|
function createConfig(preset) {
|
|
1721
|
-
return function
|
|
1734
|
+
return function(options = {}, ...userConfigs) {
|
|
1722
1735
|
const userPreset = options.preset || [];
|
|
1723
1736
|
const presetList = Array.isArray(preset) ? preset : [preset];
|
|
1724
1737
|
presetList.push(...userPreset);
|
|
1725
1738
|
options.preset = presetList;
|
|
1726
|
-
return
|
|
1739
|
+
return eslintFlatConfig(options, ...userConfigs);
|
|
1727
1740
|
};
|
|
1728
1741
|
}
|
|
1729
1742
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pengzhanbo/eslint-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.5.
|
|
4
|
+
"version": "1.5.4",
|
|
5
5
|
"author": "pengzhanbo <q942450674@outlook.com> (https://github/pengzhanbo/)",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://github.com/pengzhanbo/configs#readme",
|
|
@@ -51,27 +51,27 @@
|
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"@antfu/eslint-define-config": "^1.23.0-2",
|
|
53
53
|
"@eslint-types/jsdoc": "47.0.2",
|
|
54
|
-
"@eslint-types/typescript-eslint": "^6.
|
|
54
|
+
"@eslint-types/typescript-eslint": "^6.18.1",
|
|
55
55
|
"@eslint-types/unicorn": "^50.0.1",
|
|
56
|
-
"@stylistic/eslint-plugin": "^1.5.
|
|
57
|
-
"@typescript-eslint/eslint-plugin": "^6.
|
|
58
|
-
"@typescript-eslint/parser": "^6.
|
|
56
|
+
"@stylistic/eslint-plugin": "^1.5.4",
|
|
57
|
+
"@typescript-eslint/eslint-plugin": "^6.19.0",
|
|
58
|
+
"@typescript-eslint/parser": "^6.19.0",
|
|
59
59
|
"eslint-config-flat-gitignore": "^0.1.2",
|
|
60
60
|
"eslint-merge-processors": "^0.1.0",
|
|
61
61
|
"eslint-plugin-antfu": "^2.1.1",
|
|
62
62
|
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
63
63
|
"eslint-plugin-i": "^2.29.1",
|
|
64
64
|
"eslint-plugin-jsdoc": "^48.0.2",
|
|
65
|
-
"eslint-plugin-jsonc": "^2.
|
|
65
|
+
"eslint-plugin-jsonc": "^2.12.2",
|
|
66
66
|
"eslint-plugin-markdown": "^3.0.1",
|
|
67
|
-
"eslint-plugin-n": "^16.6.
|
|
67
|
+
"eslint-plugin-n": "^16.6.2",
|
|
68
68
|
"eslint-plugin-no-only-tests": "^3.1.0",
|
|
69
69
|
"eslint-plugin-perfectionist": "^2.5.0",
|
|
70
|
-
"eslint-plugin-toml": "^0.
|
|
70
|
+
"eslint-plugin-toml": "^0.9.2",
|
|
71
71
|
"eslint-plugin-unicorn": "^50.0.1",
|
|
72
72
|
"eslint-plugin-unused-imports": "^3.0.0",
|
|
73
73
|
"eslint-plugin-vitest": "^0.3.20",
|
|
74
|
-
"eslint-plugin-yml": "^1.
|
|
74
|
+
"eslint-plugin-yml": "^1.12.2",
|
|
75
75
|
"globals": "^13.24.0",
|
|
76
76
|
"jsonc-eslint-parser": "^2.4.0",
|
|
77
77
|
"local-pkg": "^0.5.0",
|
|
@@ -82,9 +82,9 @@
|
|
|
82
82
|
"devDependencies": {
|
|
83
83
|
"@unocss/eslint-plugin": "^0.58.3",
|
|
84
84
|
"eslint": "^8.56.0",
|
|
85
|
-
"eslint-flat-config-viewer": "^0.1.
|
|
85
|
+
"eslint-flat-config-viewer": "^0.1.11",
|
|
86
86
|
"eslint-plugin-format": "^0.1.0",
|
|
87
|
-
"eslint-plugin-tailwindcss": "^3.
|
|
87
|
+
"eslint-plugin-tailwindcss": "^3.14.0",
|
|
88
88
|
"tsup": "^8.0.1"
|
|
89
89
|
},
|
|
90
90
|
"scripts": {
|