@pengzhanbo/eslint-config 1.4.0 → 1.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/dist/index.cjs +70 -28
- package/dist/index.d.cts +31 -13
- package/dist/index.d.ts +31 -13
- package/dist/index.js +68 -28
- package/package.json +13 -13
package/dist/index.cjs
CHANGED
|
@@ -63,6 +63,7 @@ __export(src_exports, {
|
|
|
63
63
|
default: () => src_default,
|
|
64
64
|
defaultPreset: () => defaultPreset,
|
|
65
65
|
formatters: () => formatters,
|
|
66
|
+
getOverrides: () => getOverrides,
|
|
66
67
|
html: () => html,
|
|
67
68
|
ignores: () => ignores,
|
|
68
69
|
imports: () => imports,
|
|
@@ -82,6 +83,7 @@ __export(src_exports, {
|
|
|
82
83
|
pluginUnicorn: () => import_eslint_plugin_unicorn.default,
|
|
83
84
|
pluginUnusedImports: () => import_eslint_plugin_unused_imports.default,
|
|
84
85
|
renameRules: () => renameRules,
|
|
86
|
+
resolveSubOptions: () => resolveSubOptions,
|
|
85
87
|
sortPackageJson: () => sortPackageJson,
|
|
86
88
|
sortTsconfig: () => sortTsconfig,
|
|
87
89
|
stylistic: () => stylistic,
|
|
@@ -265,6 +267,7 @@ async function imports(options = {}) {
|
|
|
265
267
|
},
|
|
266
268
|
rules: {
|
|
267
269
|
"antfu/import-dedupe": "error",
|
|
270
|
+
"antfu/no-import-dist": "error",
|
|
268
271
|
"antfu/no-import-node-modules-by-path": "error",
|
|
269
272
|
"import/first": "error",
|
|
270
273
|
"import/no-duplicates": "error",
|
|
@@ -277,6 +280,14 @@ async function imports(options = {}) {
|
|
|
277
280
|
"import/newline-after-import": ["error", { considerComments: true, count: 1 }]
|
|
278
281
|
} : {}
|
|
279
282
|
}
|
|
283
|
+
},
|
|
284
|
+
{
|
|
285
|
+
files: ["**/bin/**/*", `**/bin.${GLOB_SRC_EXT}`],
|
|
286
|
+
name: "antfu:imports:bin",
|
|
287
|
+
rules: {
|
|
288
|
+
"antfu/no-import-dist": "off",
|
|
289
|
+
"antfu/no-import-node-modules-by-path": "off"
|
|
290
|
+
}
|
|
280
291
|
}
|
|
281
292
|
];
|
|
282
293
|
}
|
|
@@ -951,6 +962,7 @@ async function stylistic(options = {}) {
|
|
|
951
962
|
const {
|
|
952
963
|
indent,
|
|
953
964
|
jsx,
|
|
965
|
+
overrides = {},
|
|
954
966
|
quotes,
|
|
955
967
|
semi
|
|
956
968
|
} = {
|
|
@@ -978,7 +990,8 @@ async function stylistic(options = {}) {
|
|
|
978
990
|
"antfu/consistent-list-newline": "error",
|
|
979
991
|
"antfu/if-newline": "error",
|
|
980
992
|
"antfu/top-level-function": "error",
|
|
981
|
-
"curly": ["error", "multi-or-nest", "consistent"]
|
|
993
|
+
"curly": ["error", "multi-or-nest", "consistent"],
|
|
994
|
+
...overrides
|
|
982
995
|
}
|
|
983
996
|
}
|
|
984
997
|
];
|
|
@@ -996,6 +1009,7 @@ async function typescript(options = {}) {
|
|
|
996
1009
|
GLOB_SRC,
|
|
997
1010
|
...componentExts.map((ext) => `**/*.${ext}`)
|
|
998
1011
|
];
|
|
1012
|
+
const filesTypeAware = options.filesTypeAware ?? [GLOB_TS, GLOB_TSX];
|
|
999
1013
|
const typeAwareRules = {
|
|
1000
1014
|
"dot-notation": "off",
|
|
1001
1015
|
"no-implied-eval": "off",
|
|
@@ -1085,6 +1099,13 @@ async function typescript(options = {}) {
|
|
|
1085
1099
|
"ts/prefer-ts-expect-error": "error",
|
|
1086
1100
|
"ts/triple-slash-reference": "off",
|
|
1087
1101
|
"ts/unified-signatures": "off",
|
|
1102
|
+
...overrides
|
|
1103
|
+
}
|
|
1104
|
+
},
|
|
1105
|
+
{
|
|
1106
|
+
files: filesTypeAware,
|
|
1107
|
+
name: "config:typescript:rules-type-aware",
|
|
1108
|
+
rules: {
|
|
1088
1109
|
...tsconfigPath ? typeAwareRules : {},
|
|
1089
1110
|
...overrides
|
|
1090
1111
|
}
|
|
@@ -1519,7 +1540,7 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
1519
1540
|
const pluginFormat = await interopDefault(import("eslint-plugin-format"));
|
|
1520
1541
|
const configs = [
|
|
1521
1542
|
{
|
|
1522
|
-
name: "
|
|
1543
|
+
name: "config:formatters:setup",
|
|
1523
1544
|
plugins: {
|
|
1524
1545
|
format: pluginFormat
|
|
1525
1546
|
}
|
|
@@ -1532,7 +1553,7 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
1532
1553
|
languageOptions: {
|
|
1533
1554
|
parser: parserPlain
|
|
1534
1555
|
},
|
|
1535
|
-
name: "
|
|
1556
|
+
name: "config:formatter:css",
|
|
1536
1557
|
rules: {
|
|
1537
1558
|
"format/prettier": [
|
|
1538
1559
|
"error",
|
|
@@ -1548,7 +1569,7 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
1548
1569
|
languageOptions: {
|
|
1549
1570
|
parser: parserPlain
|
|
1550
1571
|
},
|
|
1551
|
-
name: "
|
|
1572
|
+
name: "config:formatter:scss",
|
|
1552
1573
|
rules: {
|
|
1553
1574
|
"format/prettier": [
|
|
1554
1575
|
"error",
|
|
@@ -1564,7 +1585,7 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
1564
1585
|
languageOptions: {
|
|
1565
1586
|
parser: parserPlain
|
|
1566
1587
|
},
|
|
1567
|
-
name: "
|
|
1588
|
+
name: "config:formatter:less",
|
|
1568
1589
|
rules: {
|
|
1569
1590
|
"format/prettier": [
|
|
1570
1591
|
"error",
|
|
@@ -1583,7 +1604,7 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
1583
1604
|
languageOptions: {
|
|
1584
1605
|
parser: parserPlain
|
|
1585
1606
|
},
|
|
1586
|
-
name: "
|
|
1607
|
+
name: "config:formatter:html",
|
|
1587
1608
|
rules: {
|
|
1588
1609
|
"format/prettier": [
|
|
1589
1610
|
"error",
|
|
@@ -1602,11 +1623,12 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
1602
1623
|
languageOptions: {
|
|
1603
1624
|
parser: parserPlain
|
|
1604
1625
|
},
|
|
1605
|
-
name: "
|
|
1626
|
+
name: "config:formatter:markdown",
|
|
1606
1627
|
rules: {
|
|
1607
1628
|
[`format/${formater}`]: [
|
|
1608
1629
|
"error",
|
|
1609
1630
|
formater === "prettier" ? {
|
|
1631
|
+
printWidth: 120,
|
|
1610
1632
|
...prettierOptions,
|
|
1611
1633
|
embeddedLanguageFormatting: "off",
|
|
1612
1634
|
parser: "markdown"
|
|
@@ -1624,7 +1646,7 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
1624
1646
|
languageOptions: {
|
|
1625
1647
|
parser: parserPlain
|
|
1626
1648
|
},
|
|
1627
|
-
name: "
|
|
1649
|
+
name: "config:formatter:graphql",
|
|
1628
1650
|
rules: {
|
|
1629
1651
|
"format/prettier": [
|
|
1630
1652
|
"error",
|
|
@@ -1645,7 +1667,6 @@ var defaultPreset = (options) => {
|
|
|
1645
1667
|
componentExts,
|
|
1646
1668
|
gitignore: enableGitignore,
|
|
1647
1669
|
isInEditor,
|
|
1648
|
-
overrides,
|
|
1649
1670
|
typescript: enableTypeScript,
|
|
1650
1671
|
stylistic: stylisticOptions
|
|
1651
1672
|
} = options;
|
|
@@ -1667,7 +1688,7 @@ var defaultPreset = (options) => {
|
|
|
1667
1688
|
ignores(),
|
|
1668
1689
|
javascript({
|
|
1669
1690
|
isInEditor,
|
|
1670
|
-
overrides:
|
|
1691
|
+
overrides: getOverrides(options, "javascript")
|
|
1671
1692
|
}),
|
|
1672
1693
|
comments(),
|
|
1673
1694
|
node(),
|
|
@@ -1683,23 +1704,26 @@ var defaultPreset = (options) => {
|
|
|
1683
1704
|
);
|
|
1684
1705
|
if (enableTypeScript) {
|
|
1685
1706
|
configs.push(typescript({
|
|
1686
|
-
...
|
|
1687
|
-
componentExts
|
|
1688
|
-
|
|
1707
|
+
...resolveSubOptions(options, "typescript"),
|
|
1708
|
+
componentExts
|
|
1709
|
+
}));
|
|
1710
|
+
}
|
|
1711
|
+
if (stylisticOptions) {
|
|
1712
|
+
configs.push(stylistic({
|
|
1713
|
+
...typeof stylisticOptions === "boolean" ? {} : stylisticOptions,
|
|
1714
|
+
overrides: getOverrides(options, "stylistic")
|
|
1689
1715
|
}));
|
|
1690
1716
|
}
|
|
1691
|
-
if (stylisticOptions)
|
|
1692
|
-
configs.push(stylistic(stylisticOptions));
|
|
1693
1717
|
if (options.test) {
|
|
1694
1718
|
configs.push(test({
|
|
1695
1719
|
isInEditor,
|
|
1696
|
-
overrides:
|
|
1720
|
+
overrides: getOverrides(options, "test")
|
|
1697
1721
|
}));
|
|
1698
1722
|
}
|
|
1699
1723
|
if (options.jsonc) {
|
|
1700
1724
|
configs.push(
|
|
1701
1725
|
jsonc({
|
|
1702
|
-
overrides:
|
|
1726
|
+
overrides: getOverrides(options, "jsonc"),
|
|
1703
1727
|
stylistic: stylisticOptions
|
|
1704
1728
|
}),
|
|
1705
1729
|
sortPackageJson(),
|
|
@@ -1708,31 +1732,39 @@ var defaultPreset = (options) => {
|
|
|
1708
1732
|
}
|
|
1709
1733
|
if (options.yaml) {
|
|
1710
1734
|
configs.push(yaml({
|
|
1711
|
-
overrides:
|
|
1735
|
+
overrides: getOverrides(options, "yaml"),
|
|
1712
1736
|
stylistic: stylisticOptions
|
|
1713
1737
|
}));
|
|
1714
1738
|
}
|
|
1715
1739
|
if (options.toml) {
|
|
1716
1740
|
configs.push(toml({
|
|
1717
|
-
overrides:
|
|
1741
|
+
overrides: getOverrides(options, "toml"),
|
|
1718
1742
|
stylistic: stylisticOptions
|
|
1719
1743
|
}));
|
|
1720
1744
|
}
|
|
1721
1745
|
if (options.html) {
|
|
1722
1746
|
configs.push(html({
|
|
1723
|
-
overrides:
|
|
1747
|
+
overrides: getOverrides(options, "html"),
|
|
1724
1748
|
stylistic: stylisticOptions
|
|
1725
1749
|
}));
|
|
1726
1750
|
}
|
|
1727
|
-
if (options.unocss)
|
|
1728
|
-
configs.push(unocss(
|
|
1729
|
-
|
|
1730
|
-
|
|
1751
|
+
if (options.unocss) {
|
|
1752
|
+
configs.push(unocss({
|
|
1753
|
+
...resolveSubOptions(options, "unocss"),
|
|
1754
|
+
overrides: getOverrides(options, "unocss")
|
|
1755
|
+
}));
|
|
1756
|
+
}
|
|
1757
|
+
if (options.tailwindcss) {
|
|
1758
|
+
configs.push(tailwindcss({
|
|
1759
|
+
...resolveSubOptions(options, "tailwindcss"),
|
|
1760
|
+
overrides: getOverrides(options, "tailwindcss")
|
|
1761
|
+
}));
|
|
1762
|
+
}
|
|
1731
1763
|
if (options.markdown) {
|
|
1732
1764
|
configs.push(
|
|
1733
1765
|
markdown({
|
|
1734
1766
|
componentExts,
|
|
1735
|
-
overrides:
|
|
1767
|
+
overrides: getOverrides(options, "markdown")
|
|
1736
1768
|
})
|
|
1737
1769
|
);
|
|
1738
1770
|
}
|
|
@@ -1759,8 +1791,7 @@ function resolveOptions(options = {}) {
|
|
|
1759
1791
|
componentExts = [],
|
|
1760
1792
|
preset = [],
|
|
1761
1793
|
gitignore = true,
|
|
1762
|
-
isInEditor = !!((import_node_process2.default.env.VSCODE_PID || import_node_process2.default.env.JETBRAINS_IDE) && !import_node_process2.default.env.CI),
|
|
1763
|
-
overrides = {},
|
|
1794
|
+
isInEditor = !!((import_node_process2.default.env.VSCODE_PID || import_node_process2.default.env.JETBRAINS_IDE || import_node_process2.default.env.VIM) && !import_node_process2.default.env.CI),
|
|
1764
1795
|
typescript: typescript2 = (0, import_local_pkg4.isPackageExists)("typescript"),
|
|
1765
1796
|
jsx = true,
|
|
1766
1797
|
test: test2 = true,
|
|
@@ -1790,7 +1821,6 @@ function resolveOptions(options = {}) {
|
|
|
1790
1821
|
preset,
|
|
1791
1822
|
gitignore,
|
|
1792
1823
|
isInEditor,
|
|
1793
|
-
overrides,
|
|
1794
1824
|
typescript: typescript2,
|
|
1795
1825
|
stylistic: stylistic2,
|
|
1796
1826
|
jsx,
|
|
@@ -1845,6 +1875,16 @@ function createConfig(preset) {
|
|
|
1845
1875
|
return eslintFlatConfig(options, ...userConfigs);
|
|
1846
1876
|
};
|
|
1847
1877
|
}
|
|
1878
|
+
function resolveSubOptions(options, key) {
|
|
1879
|
+
return typeof options[key] === "boolean" ? {} : options[key] || {};
|
|
1880
|
+
}
|
|
1881
|
+
function getOverrides(options, key) {
|
|
1882
|
+
const sub = resolveSubOptions(options, key);
|
|
1883
|
+
return {
|
|
1884
|
+
...options.overrides?.[key],
|
|
1885
|
+
..."overrides" in sub ? sub.overrides || {} : {}
|
|
1886
|
+
};
|
|
1887
|
+
}
|
|
1848
1888
|
|
|
1849
1889
|
// src/index.ts
|
|
1850
1890
|
var src_default = eslintFlatConfig;
|
|
@@ -1882,6 +1922,7 @@ var src_default = eslintFlatConfig;
|
|
|
1882
1922
|
createConfig,
|
|
1883
1923
|
defaultPreset,
|
|
1884
1924
|
formatters,
|
|
1925
|
+
getOverrides,
|
|
1885
1926
|
html,
|
|
1886
1927
|
ignores,
|
|
1887
1928
|
imports,
|
|
@@ -1901,6 +1942,7 @@ var src_default = eslintFlatConfig;
|
|
|
1901
1942
|
pluginUnicorn,
|
|
1902
1943
|
pluginUnusedImports,
|
|
1903
1944
|
renameRules,
|
|
1945
|
+
resolveSubOptions,
|
|
1904
1946
|
sortPackageJson,
|
|
1905
1947
|
sortTsconfig,
|
|
1906
1948
|
stylistic,
|
package/dist/index.d.cts
CHANGED
|
@@ -21,6 +21,11 @@ export { default as pluginPerfectionist } from 'eslint-plugin-perfectionist';
|
|
|
21
21
|
*/
|
|
22
22
|
type VendoredPrettierOptions = Partial<VendoredPrettierOptionsRequired>;
|
|
23
23
|
interface VendoredPrettierOptionsRequired {
|
|
24
|
+
/**
|
|
25
|
+
* Specify the line length that the printer will wrap on.
|
|
26
|
+
* @default 120
|
|
27
|
+
*/
|
|
28
|
+
printWidth: number;
|
|
24
29
|
/**
|
|
25
30
|
* Specify the number of spaces per indentation-level.
|
|
26
31
|
*/
|
|
@@ -192,7 +197,13 @@ interface OptionsTypeScriptParserOptions {
|
|
|
192
197
|
* Additional parser options for TypeScript.
|
|
193
198
|
*/
|
|
194
199
|
parserOptions?: Partial<ParserOptions>;
|
|
200
|
+
/**
|
|
201
|
+
* Glob patterns for files that should be type aware.
|
|
202
|
+
* @default ['**\/*.{ts,tsx}']
|
|
203
|
+
*/
|
|
204
|
+
filesTypeAware?: string[];
|
|
195
205
|
}
|
|
206
|
+
type OptionsTypescript = (OptionsTypeScriptWithTypes & OptionsOverrides) | (OptionsTypeScriptParserOptions & OptionsOverrides);
|
|
196
207
|
interface OptionsTypeScriptWithTypes {
|
|
197
208
|
/**
|
|
198
209
|
* When this options is provided, type aware rules will be enabled.
|
|
@@ -214,7 +225,7 @@ interface OptionsOverrides {
|
|
|
214
225
|
interface OptionsIsInEditor {
|
|
215
226
|
isInEditor?: boolean;
|
|
216
227
|
}
|
|
217
|
-
interface OptionsUnoCSS {
|
|
228
|
+
interface OptionsUnoCSS extends OptionsOverrides {
|
|
218
229
|
/**
|
|
219
230
|
* Enable attributify support.
|
|
220
231
|
* @default true
|
|
@@ -226,7 +237,7 @@ interface OptionsUnoCSS {
|
|
|
226
237
|
*/
|
|
227
238
|
strict?: boolean;
|
|
228
239
|
}
|
|
229
|
-
interface OptionsTailwindCSS {
|
|
240
|
+
interface OptionsTailwindCSS extends OptionsOverrides {
|
|
230
241
|
/**
|
|
231
242
|
* Read CSS files
|
|
232
243
|
*/
|
|
@@ -246,9 +257,7 @@ interface OptionsTailwindCSS {
|
|
|
246
257
|
*/
|
|
247
258
|
customClassNames?: boolean;
|
|
248
259
|
}
|
|
249
|
-
type PresetItem = (options: Required<Omit<OptionsConfig, 'preset'>>
|
|
250
|
-
stylistic: false | StylisticConfig;
|
|
251
|
-
}) => Awaitable<FlatConfigItem[]>[];
|
|
260
|
+
type PresetItem = (options: Required<Omit<OptionsConfig, 'preset'>>) => Awaitable<FlatConfigItem[]>[];
|
|
252
261
|
interface OptionsConfig extends OptionsComponentExts, OptionsFrameworkExtract {
|
|
253
262
|
/**
|
|
254
263
|
* Enable gitignore support.
|
|
@@ -267,6 +276,10 @@ interface OptionsConfig extends OptionsComponentExts, OptionsFrameworkExtract {
|
|
|
267
276
|
* default: [defaultPreset]
|
|
268
277
|
*/
|
|
269
278
|
preset?: PresetItem[];
|
|
279
|
+
/**
|
|
280
|
+
* Core rules. Can't be disabled.
|
|
281
|
+
*/
|
|
282
|
+
javascript?: OptionsOverrides;
|
|
270
283
|
/**
|
|
271
284
|
* Enable TypeScript support.
|
|
272
285
|
*
|
|
@@ -274,7 +287,7 @@ interface OptionsConfig extends OptionsComponentExts, OptionsFrameworkExtract {
|
|
|
274
287
|
*
|
|
275
288
|
* @default auto-detect based on the dependencies
|
|
276
289
|
*/
|
|
277
|
-
typescript?: boolean |
|
|
290
|
+
typescript?: boolean | OptionsTypescript;
|
|
278
291
|
/**
|
|
279
292
|
* Enable JSX related rules.
|
|
280
293
|
*
|
|
@@ -288,23 +301,23 @@ interface OptionsConfig extends OptionsComponentExts, OptionsFrameworkExtract {
|
|
|
288
301
|
*
|
|
289
302
|
* @default true
|
|
290
303
|
*/
|
|
291
|
-
test?: boolean;
|
|
304
|
+
test?: boolean | OptionsOverrides;
|
|
292
305
|
/**
|
|
293
306
|
* Enable JSONC support.
|
|
294
307
|
*
|
|
295
308
|
* @default true
|
|
296
309
|
*/
|
|
297
|
-
jsonc?: boolean;
|
|
310
|
+
jsonc?: boolean | OptionsOverrides;
|
|
298
311
|
/**
|
|
299
312
|
* Enable TOML support.
|
|
300
313
|
*/
|
|
301
|
-
toml?: boolean;
|
|
314
|
+
toml?: boolean | OptionsOverrides;
|
|
302
315
|
/**
|
|
303
316
|
* Enable YAML support.
|
|
304
317
|
*
|
|
305
318
|
* @default true
|
|
306
319
|
*/
|
|
307
|
-
yaml?: boolean;
|
|
320
|
+
yaml?: boolean | OptionsOverrides;
|
|
308
321
|
/**
|
|
309
322
|
* Enable Markdown support.
|
|
310
323
|
*
|
|
@@ -315,7 +328,7 @@ interface OptionsConfig extends OptionsComponentExts, OptionsFrameworkExtract {
|
|
|
315
328
|
/**
|
|
316
329
|
* Enable HTML support.
|
|
317
330
|
*/
|
|
318
|
-
html?: boolean;
|
|
331
|
+
html?: boolean | OptionsOverrides;
|
|
319
332
|
/**
|
|
320
333
|
* Enable stylistic rules.
|
|
321
334
|
*
|
|
@@ -356,6 +369,8 @@ interface OptionsConfig extends OptionsComponentExts, OptionsFrameworkExtract {
|
|
|
356
369
|
isInEditor?: boolean;
|
|
357
370
|
/**
|
|
358
371
|
* Provide overrides for rules for each integration.
|
|
372
|
+
*
|
|
373
|
+
* @deprecated use `overrides` option in each integration key instead
|
|
359
374
|
*/
|
|
360
375
|
overrides?: {
|
|
361
376
|
html?: FlatConfigItem['rules'];
|
|
@@ -377,6 +392,9 @@ interface OptionsConfig extends OptionsComponentExts, OptionsFrameworkExtract {
|
|
|
377
392
|
|
|
378
393
|
declare function eslintFlatConfig(options?: OptionsConfig & FlatConfigItem, ...userConfigs: Awaitable<UserConfigItem | UserConfigItem[]>[]): Promise<UserConfigItem[]>;
|
|
379
394
|
declare function createConfig(preset: PresetItem | PresetItem[]): typeof eslintFlatConfig;
|
|
395
|
+
type ResolvedOptions<T> = T extends boolean ? never : NonNullable<T>;
|
|
396
|
+
declare function resolveSubOptions<K extends keyof OptionsConfig>(options: OptionsConfig, key: K): ResolvedOptions<OptionsConfig[K]>;
|
|
397
|
+
declare function getOverrides<K extends keyof OptionsConfig>(options: OptionsConfig, key: K): any;
|
|
380
398
|
|
|
381
399
|
declare const parserPlain: {
|
|
382
400
|
meta: {
|
|
@@ -472,7 +490,7 @@ declare function sortPackageJson(): Promise<FlatConfigItem[]>;
|
|
|
472
490
|
declare function sortTsconfig(): FlatConfigItem[];
|
|
473
491
|
|
|
474
492
|
declare const StylisticConfigDefaults: StylisticConfig;
|
|
475
|
-
declare function stylistic(options?: StylisticConfig): Promise<FlatConfigItem[]>;
|
|
493
|
+
declare function stylistic(options?: StylisticConfig & OptionsOverrides): Promise<FlatConfigItem[]>;
|
|
476
494
|
|
|
477
495
|
declare function typescript(options?: OptionsFiles & OptionsComponentExts & OptionsOverrides & OptionsTypeScriptWithTypes & OptionsTypeScriptParserOptions): Promise<FlatConfigItem[]>;
|
|
478
496
|
|
|
@@ -501,4 +519,4 @@ declare function formatters(options?: OptionsFormatters | true, stylistic?: Styl
|
|
|
501
519
|
|
|
502
520
|
declare const defaultPreset: PresetItem;
|
|
503
521
|
|
|
504
|
-
export { type Awaitable, type FlatConfigItem, GLOB_ALL_SRC, GLOB_ASTRO, GLOB_CSS, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_IN_MARKDOWN, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_SVELTE, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_YAML, type OptionsComponentExts, type OptionsConfig, type OptionsFiles, type OptionsFormatters, type OptionsFrameworkExtract, type OptionsHasTypeScript, type OptionsIsInEditor, type OptionsOverrides, type OptionsStylistic, type OptionsTailwindCSS, type OptionsTypeScriptParserOptions, type OptionsTypeScriptWithTypes, type OptionsUnoCSS, type PresetItem, type Rules, type StylisticConfig, StylisticConfigDefaults, type UserConfigItem, type WrapRuleConfig, combine, comments, createConfig, eslintFlatConfig as default, defaultPreset, formatters, html, ignores, imports, interopDefault, javascript, jsdoc, jsonc, markdown, node, parserPlain, perfectionist, renameRules, sortPackageJson, sortTsconfig, stylistic, tailwindcss, test, toArray, toml, typescript, unicorn, unocss, yaml };
|
|
522
|
+
export { type Awaitable, type FlatConfigItem, GLOB_ALL_SRC, GLOB_ASTRO, GLOB_CSS, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_IN_MARKDOWN, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_SVELTE, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_YAML, type OptionsComponentExts, type OptionsConfig, type OptionsFiles, type OptionsFormatters, type OptionsFrameworkExtract, type OptionsHasTypeScript, type OptionsIsInEditor, type OptionsOverrides, type OptionsStylistic, type OptionsTailwindCSS, type OptionsTypeScriptParserOptions, type OptionsTypeScriptWithTypes, type OptionsTypescript, type OptionsUnoCSS, type PresetItem, type Rules, type StylisticConfig, StylisticConfigDefaults, type UserConfigItem, type WrapRuleConfig, combine, comments, createConfig, eslintFlatConfig as default, defaultPreset, formatters, getOverrides, html, ignores, imports, interopDefault, javascript, jsdoc, jsonc, markdown, node, parserPlain, perfectionist, renameRules, resolveSubOptions, sortPackageJson, sortTsconfig, stylistic, tailwindcss, test, toArray, toml, typescript, unicorn, unocss, yaml };
|
package/dist/index.d.ts
CHANGED
|
@@ -21,6 +21,11 @@ export { default as pluginPerfectionist } from 'eslint-plugin-perfectionist';
|
|
|
21
21
|
*/
|
|
22
22
|
type VendoredPrettierOptions = Partial<VendoredPrettierOptionsRequired>;
|
|
23
23
|
interface VendoredPrettierOptionsRequired {
|
|
24
|
+
/**
|
|
25
|
+
* Specify the line length that the printer will wrap on.
|
|
26
|
+
* @default 120
|
|
27
|
+
*/
|
|
28
|
+
printWidth: number;
|
|
24
29
|
/**
|
|
25
30
|
* Specify the number of spaces per indentation-level.
|
|
26
31
|
*/
|
|
@@ -192,7 +197,13 @@ interface OptionsTypeScriptParserOptions {
|
|
|
192
197
|
* Additional parser options for TypeScript.
|
|
193
198
|
*/
|
|
194
199
|
parserOptions?: Partial<ParserOptions>;
|
|
200
|
+
/**
|
|
201
|
+
* Glob patterns for files that should be type aware.
|
|
202
|
+
* @default ['**\/*.{ts,tsx}']
|
|
203
|
+
*/
|
|
204
|
+
filesTypeAware?: string[];
|
|
195
205
|
}
|
|
206
|
+
type OptionsTypescript = (OptionsTypeScriptWithTypes & OptionsOverrides) | (OptionsTypeScriptParserOptions & OptionsOverrides);
|
|
196
207
|
interface OptionsTypeScriptWithTypes {
|
|
197
208
|
/**
|
|
198
209
|
* When this options is provided, type aware rules will be enabled.
|
|
@@ -214,7 +225,7 @@ interface OptionsOverrides {
|
|
|
214
225
|
interface OptionsIsInEditor {
|
|
215
226
|
isInEditor?: boolean;
|
|
216
227
|
}
|
|
217
|
-
interface OptionsUnoCSS {
|
|
228
|
+
interface OptionsUnoCSS extends OptionsOverrides {
|
|
218
229
|
/**
|
|
219
230
|
* Enable attributify support.
|
|
220
231
|
* @default true
|
|
@@ -226,7 +237,7 @@ interface OptionsUnoCSS {
|
|
|
226
237
|
*/
|
|
227
238
|
strict?: boolean;
|
|
228
239
|
}
|
|
229
|
-
interface OptionsTailwindCSS {
|
|
240
|
+
interface OptionsTailwindCSS extends OptionsOverrides {
|
|
230
241
|
/**
|
|
231
242
|
* Read CSS files
|
|
232
243
|
*/
|
|
@@ -246,9 +257,7 @@ interface OptionsTailwindCSS {
|
|
|
246
257
|
*/
|
|
247
258
|
customClassNames?: boolean;
|
|
248
259
|
}
|
|
249
|
-
type PresetItem = (options: Required<Omit<OptionsConfig, 'preset'>>
|
|
250
|
-
stylistic: false | StylisticConfig;
|
|
251
|
-
}) => Awaitable<FlatConfigItem[]>[];
|
|
260
|
+
type PresetItem = (options: Required<Omit<OptionsConfig, 'preset'>>) => Awaitable<FlatConfigItem[]>[];
|
|
252
261
|
interface OptionsConfig extends OptionsComponentExts, OptionsFrameworkExtract {
|
|
253
262
|
/**
|
|
254
263
|
* Enable gitignore support.
|
|
@@ -267,6 +276,10 @@ interface OptionsConfig extends OptionsComponentExts, OptionsFrameworkExtract {
|
|
|
267
276
|
* default: [defaultPreset]
|
|
268
277
|
*/
|
|
269
278
|
preset?: PresetItem[];
|
|
279
|
+
/**
|
|
280
|
+
* Core rules. Can't be disabled.
|
|
281
|
+
*/
|
|
282
|
+
javascript?: OptionsOverrides;
|
|
270
283
|
/**
|
|
271
284
|
* Enable TypeScript support.
|
|
272
285
|
*
|
|
@@ -274,7 +287,7 @@ interface OptionsConfig extends OptionsComponentExts, OptionsFrameworkExtract {
|
|
|
274
287
|
*
|
|
275
288
|
* @default auto-detect based on the dependencies
|
|
276
289
|
*/
|
|
277
|
-
typescript?: boolean |
|
|
290
|
+
typescript?: boolean | OptionsTypescript;
|
|
278
291
|
/**
|
|
279
292
|
* Enable JSX related rules.
|
|
280
293
|
*
|
|
@@ -288,23 +301,23 @@ interface OptionsConfig extends OptionsComponentExts, OptionsFrameworkExtract {
|
|
|
288
301
|
*
|
|
289
302
|
* @default true
|
|
290
303
|
*/
|
|
291
|
-
test?: boolean;
|
|
304
|
+
test?: boolean | OptionsOverrides;
|
|
292
305
|
/**
|
|
293
306
|
* Enable JSONC support.
|
|
294
307
|
*
|
|
295
308
|
* @default true
|
|
296
309
|
*/
|
|
297
|
-
jsonc?: boolean;
|
|
310
|
+
jsonc?: boolean | OptionsOverrides;
|
|
298
311
|
/**
|
|
299
312
|
* Enable TOML support.
|
|
300
313
|
*/
|
|
301
|
-
toml?: boolean;
|
|
314
|
+
toml?: boolean | OptionsOverrides;
|
|
302
315
|
/**
|
|
303
316
|
* Enable YAML support.
|
|
304
317
|
*
|
|
305
318
|
* @default true
|
|
306
319
|
*/
|
|
307
|
-
yaml?: boolean;
|
|
320
|
+
yaml?: boolean | OptionsOverrides;
|
|
308
321
|
/**
|
|
309
322
|
* Enable Markdown support.
|
|
310
323
|
*
|
|
@@ -315,7 +328,7 @@ interface OptionsConfig extends OptionsComponentExts, OptionsFrameworkExtract {
|
|
|
315
328
|
/**
|
|
316
329
|
* Enable HTML support.
|
|
317
330
|
*/
|
|
318
|
-
html?: boolean;
|
|
331
|
+
html?: boolean | OptionsOverrides;
|
|
319
332
|
/**
|
|
320
333
|
* Enable stylistic rules.
|
|
321
334
|
*
|
|
@@ -356,6 +369,8 @@ interface OptionsConfig extends OptionsComponentExts, OptionsFrameworkExtract {
|
|
|
356
369
|
isInEditor?: boolean;
|
|
357
370
|
/**
|
|
358
371
|
* Provide overrides for rules for each integration.
|
|
372
|
+
*
|
|
373
|
+
* @deprecated use `overrides` option in each integration key instead
|
|
359
374
|
*/
|
|
360
375
|
overrides?: {
|
|
361
376
|
html?: FlatConfigItem['rules'];
|
|
@@ -377,6 +392,9 @@ interface OptionsConfig extends OptionsComponentExts, OptionsFrameworkExtract {
|
|
|
377
392
|
|
|
378
393
|
declare function eslintFlatConfig(options?: OptionsConfig & FlatConfigItem, ...userConfigs: Awaitable<UserConfigItem | UserConfigItem[]>[]): Promise<UserConfigItem[]>;
|
|
379
394
|
declare function createConfig(preset: PresetItem | PresetItem[]): typeof eslintFlatConfig;
|
|
395
|
+
type ResolvedOptions<T> = T extends boolean ? never : NonNullable<T>;
|
|
396
|
+
declare function resolveSubOptions<K extends keyof OptionsConfig>(options: OptionsConfig, key: K): ResolvedOptions<OptionsConfig[K]>;
|
|
397
|
+
declare function getOverrides<K extends keyof OptionsConfig>(options: OptionsConfig, key: K): any;
|
|
380
398
|
|
|
381
399
|
declare const parserPlain: {
|
|
382
400
|
meta: {
|
|
@@ -472,7 +490,7 @@ declare function sortPackageJson(): Promise<FlatConfigItem[]>;
|
|
|
472
490
|
declare function sortTsconfig(): FlatConfigItem[];
|
|
473
491
|
|
|
474
492
|
declare const StylisticConfigDefaults: StylisticConfig;
|
|
475
|
-
declare function stylistic(options?: StylisticConfig): Promise<FlatConfigItem[]>;
|
|
493
|
+
declare function stylistic(options?: StylisticConfig & OptionsOverrides): Promise<FlatConfigItem[]>;
|
|
476
494
|
|
|
477
495
|
declare function typescript(options?: OptionsFiles & OptionsComponentExts & OptionsOverrides & OptionsTypeScriptWithTypes & OptionsTypeScriptParserOptions): Promise<FlatConfigItem[]>;
|
|
478
496
|
|
|
@@ -501,4 +519,4 @@ declare function formatters(options?: OptionsFormatters | true, stylistic?: Styl
|
|
|
501
519
|
|
|
502
520
|
declare const defaultPreset: PresetItem;
|
|
503
521
|
|
|
504
|
-
export { type Awaitable, type FlatConfigItem, GLOB_ALL_SRC, GLOB_ASTRO, GLOB_CSS, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_IN_MARKDOWN, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_SVELTE, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_YAML, type OptionsComponentExts, type OptionsConfig, type OptionsFiles, type OptionsFormatters, type OptionsFrameworkExtract, type OptionsHasTypeScript, type OptionsIsInEditor, type OptionsOverrides, type OptionsStylistic, type OptionsTailwindCSS, type OptionsTypeScriptParserOptions, type OptionsTypeScriptWithTypes, type OptionsUnoCSS, type PresetItem, type Rules, type StylisticConfig, StylisticConfigDefaults, type UserConfigItem, type WrapRuleConfig, combine, comments, createConfig, eslintFlatConfig as default, defaultPreset, formatters, html, ignores, imports, interopDefault, javascript, jsdoc, jsonc, markdown, node, parserPlain, perfectionist, renameRules, sortPackageJson, sortTsconfig, stylistic, tailwindcss, test, toArray, toml, typescript, unicorn, unocss, yaml };
|
|
522
|
+
export { type Awaitable, type FlatConfigItem, GLOB_ALL_SRC, GLOB_ASTRO, GLOB_CSS, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_IN_MARKDOWN, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_SVELTE, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_YAML, type OptionsComponentExts, type OptionsConfig, type OptionsFiles, type OptionsFormatters, type OptionsFrameworkExtract, type OptionsHasTypeScript, type OptionsIsInEditor, type OptionsOverrides, type OptionsStylistic, type OptionsTailwindCSS, type OptionsTypeScriptParserOptions, type OptionsTypeScriptWithTypes, type OptionsTypescript, type OptionsUnoCSS, type PresetItem, type Rules, type StylisticConfig, StylisticConfigDefaults, type UserConfigItem, type WrapRuleConfig, combine, comments, createConfig, eslintFlatConfig as default, defaultPreset, formatters, getOverrides, html, ignores, imports, interopDefault, javascript, jsdoc, jsonc, markdown, node, parserPlain, perfectionist, renameRules, resolveSubOptions, sortPackageJson, sortTsconfig, stylistic, tailwindcss, test, toArray, toml, typescript, unicorn, unocss, yaml };
|
package/dist/index.js
CHANGED
|
@@ -167,6 +167,7 @@ async function imports(options = {}) {
|
|
|
167
167
|
},
|
|
168
168
|
rules: {
|
|
169
169
|
"antfu/import-dedupe": "error",
|
|
170
|
+
"antfu/no-import-dist": "error",
|
|
170
171
|
"antfu/no-import-node-modules-by-path": "error",
|
|
171
172
|
"import/first": "error",
|
|
172
173
|
"import/no-duplicates": "error",
|
|
@@ -179,6 +180,14 @@ async function imports(options = {}) {
|
|
|
179
180
|
"import/newline-after-import": ["error", { considerComments: true, count: 1 }]
|
|
180
181
|
} : {}
|
|
181
182
|
}
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
files: ["**/bin/**/*", `**/bin.${GLOB_SRC_EXT}`],
|
|
186
|
+
name: "antfu:imports:bin",
|
|
187
|
+
rules: {
|
|
188
|
+
"antfu/no-import-dist": "off",
|
|
189
|
+
"antfu/no-import-node-modules-by-path": "off"
|
|
190
|
+
}
|
|
182
191
|
}
|
|
183
192
|
];
|
|
184
193
|
}
|
|
@@ -853,6 +862,7 @@ async function stylistic(options = {}) {
|
|
|
853
862
|
const {
|
|
854
863
|
indent,
|
|
855
864
|
jsx,
|
|
865
|
+
overrides = {},
|
|
856
866
|
quotes,
|
|
857
867
|
semi
|
|
858
868
|
} = {
|
|
@@ -880,7 +890,8 @@ async function stylistic(options = {}) {
|
|
|
880
890
|
"antfu/consistent-list-newline": "error",
|
|
881
891
|
"antfu/if-newline": "error",
|
|
882
892
|
"antfu/top-level-function": "error",
|
|
883
|
-
"curly": ["error", "multi-or-nest", "consistent"]
|
|
893
|
+
"curly": ["error", "multi-or-nest", "consistent"],
|
|
894
|
+
...overrides
|
|
884
895
|
}
|
|
885
896
|
}
|
|
886
897
|
];
|
|
@@ -898,6 +909,7 @@ async function typescript(options = {}) {
|
|
|
898
909
|
GLOB_SRC,
|
|
899
910
|
...componentExts.map((ext) => `**/*.${ext}`)
|
|
900
911
|
];
|
|
912
|
+
const filesTypeAware = options.filesTypeAware ?? [GLOB_TS, GLOB_TSX];
|
|
901
913
|
const typeAwareRules = {
|
|
902
914
|
"dot-notation": "off",
|
|
903
915
|
"no-implied-eval": "off",
|
|
@@ -987,6 +999,13 @@ async function typescript(options = {}) {
|
|
|
987
999
|
"ts/prefer-ts-expect-error": "error",
|
|
988
1000
|
"ts/triple-slash-reference": "off",
|
|
989
1001
|
"ts/unified-signatures": "off",
|
|
1002
|
+
...overrides
|
|
1003
|
+
}
|
|
1004
|
+
},
|
|
1005
|
+
{
|
|
1006
|
+
files: filesTypeAware,
|
|
1007
|
+
name: "config:typescript:rules-type-aware",
|
|
1008
|
+
rules: {
|
|
990
1009
|
...tsconfigPath ? typeAwareRules : {},
|
|
991
1010
|
...overrides
|
|
992
1011
|
}
|
|
@@ -1421,7 +1440,7 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
1421
1440
|
const pluginFormat = await interopDefault(import("eslint-plugin-format"));
|
|
1422
1441
|
const configs = [
|
|
1423
1442
|
{
|
|
1424
|
-
name: "
|
|
1443
|
+
name: "config:formatters:setup",
|
|
1425
1444
|
plugins: {
|
|
1426
1445
|
format: pluginFormat
|
|
1427
1446
|
}
|
|
@@ -1434,7 +1453,7 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
1434
1453
|
languageOptions: {
|
|
1435
1454
|
parser: parserPlain
|
|
1436
1455
|
},
|
|
1437
|
-
name: "
|
|
1456
|
+
name: "config:formatter:css",
|
|
1438
1457
|
rules: {
|
|
1439
1458
|
"format/prettier": [
|
|
1440
1459
|
"error",
|
|
@@ -1450,7 +1469,7 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
1450
1469
|
languageOptions: {
|
|
1451
1470
|
parser: parserPlain
|
|
1452
1471
|
},
|
|
1453
|
-
name: "
|
|
1472
|
+
name: "config:formatter:scss",
|
|
1454
1473
|
rules: {
|
|
1455
1474
|
"format/prettier": [
|
|
1456
1475
|
"error",
|
|
@@ -1466,7 +1485,7 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
1466
1485
|
languageOptions: {
|
|
1467
1486
|
parser: parserPlain
|
|
1468
1487
|
},
|
|
1469
|
-
name: "
|
|
1488
|
+
name: "config:formatter:less",
|
|
1470
1489
|
rules: {
|
|
1471
1490
|
"format/prettier": [
|
|
1472
1491
|
"error",
|
|
@@ -1485,7 +1504,7 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
1485
1504
|
languageOptions: {
|
|
1486
1505
|
parser: parserPlain
|
|
1487
1506
|
},
|
|
1488
|
-
name: "
|
|
1507
|
+
name: "config:formatter:html",
|
|
1489
1508
|
rules: {
|
|
1490
1509
|
"format/prettier": [
|
|
1491
1510
|
"error",
|
|
@@ -1504,11 +1523,12 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
1504
1523
|
languageOptions: {
|
|
1505
1524
|
parser: parserPlain
|
|
1506
1525
|
},
|
|
1507
|
-
name: "
|
|
1526
|
+
name: "config:formatter:markdown",
|
|
1508
1527
|
rules: {
|
|
1509
1528
|
[`format/${formater}`]: [
|
|
1510
1529
|
"error",
|
|
1511
1530
|
formater === "prettier" ? {
|
|
1531
|
+
printWidth: 120,
|
|
1512
1532
|
...prettierOptions,
|
|
1513
1533
|
embeddedLanguageFormatting: "off",
|
|
1514
1534
|
parser: "markdown"
|
|
@@ -1526,7 +1546,7 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
1526
1546
|
languageOptions: {
|
|
1527
1547
|
parser: parserPlain
|
|
1528
1548
|
},
|
|
1529
|
-
name: "
|
|
1549
|
+
name: "config:formatter:graphql",
|
|
1530
1550
|
rules: {
|
|
1531
1551
|
"format/prettier": [
|
|
1532
1552
|
"error",
|
|
@@ -1547,7 +1567,6 @@ var defaultPreset = (options) => {
|
|
|
1547
1567
|
componentExts,
|
|
1548
1568
|
gitignore: enableGitignore,
|
|
1549
1569
|
isInEditor,
|
|
1550
|
-
overrides,
|
|
1551
1570
|
typescript: enableTypeScript,
|
|
1552
1571
|
stylistic: stylisticOptions
|
|
1553
1572
|
} = options;
|
|
@@ -1569,7 +1588,7 @@ var defaultPreset = (options) => {
|
|
|
1569
1588
|
ignores(),
|
|
1570
1589
|
javascript({
|
|
1571
1590
|
isInEditor,
|
|
1572
|
-
overrides:
|
|
1591
|
+
overrides: getOverrides(options, "javascript")
|
|
1573
1592
|
}),
|
|
1574
1593
|
comments(),
|
|
1575
1594
|
node(),
|
|
@@ -1585,23 +1604,26 @@ var defaultPreset = (options) => {
|
|
|
1585
1604
|
);
|
|
1586
1605
|
if (enableTypeScript) {
|
|
1587
1606
|
configs.push(typescript({
|
|
1588
|
-
...
|
|
1589
|
-
componentExts
|
|
1590
|
-
|
|
1607
|
+
...resolveSubOptions(options, "typescript"),
|
|
1608
|
+
componentExts
|
|
1609
|
+
}));
|
|
1610
|
+
}
|
|
1611
|
+
if (stylisticOptions) {
|
|
1612
|
+
configs.push(stylistic({
|
|
1613
|
+
...typeof stylisticOptions === "boolean" ? {} : stylisticOptions,
|
|
1614
|
+
overrides: getOverrides(options, "stylistic")
|
|
1591
1615
|
}));
|
|
1592
1616
|
}
|
|
1593
|
-
if (stylisticOptions)
|
|
1594
|
-
configs.push(stylistic(stylisticOptions));
|
|
1595
1617
|
if (options.test) {
|
|
1596
1618
|
configs.push(test({
|
|
1597
1619
|
isInEditor,
|
|
1598
|
-
overrides:
|
|
1620
|
+
overrides: getOverrides(options, "test")
|
|
1599
1621
|
}));
|
|
1600
1622
|
}
|
|
1601
1623
|
if (options.jsonc) {
|
|
1602
1624
|
configs.push(
|
|
1603
1625
|
jsonc({
|
|
1604
|
-
overrides:
|
|
1626
|
+
overrides: getOverrides(options, "jsonc"),
|
|
1605
1627
|
stylistic: stylisticOptions
|
|
1606
1628
|
}),
|
|
1607
1629
|
sortPackageJson(),
|
|
@@ -1610,31 +1632,39 @@ var defaultPreset = (options) => {
|
|
|
1610
1632
|
}
|
|
1611
1633
|
if (options.yaml) {
|
|
1612
1634
|
configs.push(yaml({
|
|
1613
|
-
overrides:
|
|
1635
|
+
overrides: getOverrides(options, "yaml"),
|
|
1614
1636
|
stylistic: stylisticOptions
|
|
1615
1637
|
}));
|
|
1616
1638
|
}
|
|
1617
1639
|
if (options.toml) {
|
|
1618
1640
|
configs.push(toml({
|
|
1619
|
-
overrides:
|
|
1641
|
+
overrides: getOverrides(options, "toml"),
|
|
1620
1642
|
stylistic: stylisticOptions
|
|
1621
1643
|
}));
|
|
1622
1644
|
}
|
|
1623
1645
|
if (options.html) {
|
|
1624
1646
|
configs.push(html({
|
|
1625
|
-
overrides:
|
|
1647
|
+
overrides: getOverrides(options, "html"),
|
|
1626
1648
|
stylistic: stylisticOptions
|
|
1627
1649
|
}));
|
|
1628
1650
|
}
|
|
1629
|
-
if (options.unocss)
|
|
1630
|
-
configs.push(unocss(
|
|
1631
|
-
|
|
1632
|
-
|
|
1651
|
+
if (options.unocss) {
|
|
1652
|
+
configs.push(unocss({
|
|
1653
|
+
...resolveSubOptions(options, "unocss"),
|
|
1654
|
+
overrides: getOverrides(options, "unocss")
|
|
1655
|
+
}));
|
|
1656
|
+
}
|
|
1657
|
+
if (options.tailwindcss) {
|
|
1658
|
+
configs.push(tailwindcss({
|
|
1659
|
+
...resolveSubOptions(options, "tailwindcss"),
|
|
1660
|
+
overrides: getOverrides(options, "tailwindcss")
|
|
1661
|
+
}));
|
|
1662
|
+
}
|
|
1633
1663
|
if (options.markdown) {
|
|
1634
1664
|
configs.push(
|
|
1635
1665
|
markdown({
|
|
1636
1666
|
componentExts,
|
|
1637
|
-
overrides:
|
|
1667
|
+
overrides: getOverrides(options, "markdown")
|
|
1638
1668
|
})
|
|
1639
1669
|
);
|
|
1640
1670
|
}
|
|
@@ -1661,8 +1691,7 @@ function resolveOptions(options = {}) {
|
|
|
1661
1691
|
componentExts = [],
|
|
1662
1692
|
preset = [],
|
|
1663
1693
|
gitignore = true,
|
|
1664
|
-
isInEditor = !!((process2.env.VSCODE_PID || process2.env.JETBRAINS_IDE) && !process2.env.CI),
|
|
1665
|
-
overrides = {},
|
|
1694
|
+
isInEditor = !!((process2.env.VSCODE_PID || process2.env.JETBRAINS_IDE || process2.env.VIM) && !process2.env.CI),
|
|
1666
1695
|
typescript: typescript2 = isPackageExists4("typescript"),
|
|
1667
1696
|
jsx = true,
|
|
1668
1697
|
test: test2 = true,
|
|
@@ -1692,7 +1721,6 @@ function resolveOptions(options = {}) {
|
|
|
1692
1721
|
preset,
|
|
1693
1722
|
gitignore,
|
|
1694
1723
|
isInEditor,
|
|
1695
|
-
overrides,
|
|
1696
1724
|
typescript: typescript2,
|
|
1697
1725
|
stylistic: stylistic2,
|
|
1698
1726
|
jsx,
|
|
@@ -1747,6 +1775,16 @@ function createConfig(preset) {
|
|
|
1747
1775
|
return eslintFlatConfig(options, ...userConfigs);
|
|
1748
1776
|
};
|
|
1749
1777
|
}
|
|
1778
|
+
function resolveSubOptions(options, key) {
|
|
1779
|
+
return typeof options[key] === "boolean" ? {} : options[key] || {};
|
|
1780
|
+
}
|
|
1781
|
+
function getOverrides(options, key) {
|
|
1782
|
+
const sub = resolveSubOptions(options, key);
|
|
1783
|
+
return {
|
|
1784
|
+
...options.overrides?.[key],
|
|
1785
|
+
..."overrides" in sub ? sub.overrides || {} : {}
|
|
1786
|
+
};
|
|
1787
|
+
}
|
|
1750
1788
|
|
|
1751
1789
|
// src/index.ts
|
|
1752
1790
|
var src_default = eslintFlatConfig;
|
|
@@ -1784,6 +1822,7 @@ export {
|
|
|
1784
1822
|
src_default as default,
|
|
1785
1823
|
defaultPreset,
|
|
1786
1824
|
formatters,
|
|
1825
|
+
getOverrides,
|
|
1787
1826
|
html,
|
|
1788
1827
|
ignores,
|
|
1789
1828
|
imports,
|
|
@@ -1803,6 +1842,7 @@ export {
|
|
|
1803
1842
|
default5 as pluginUnicorn,
|
|
1804
1843
|
default6 as pluginUnusedImports,
|
|
1805
1844
|
renameRules,
|
|
1845
|
+
resolveSubOptions,
|
|
1806
1846
|
sortPackageJson,
|
|
1807
1847
|
sortTsconfig,
|
|
1808
1848
|
stylistic,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pengzhanbo/eslint-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.5.0",
|
|
5
5
|
"author": "pengzhanbo <q942450674@outlook.com> (https://github/pengzhanbo/)",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://github.com/pengzhanbo/configs#readme",
|
|
@@ -51,28 +51,28 @@
|
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"@antfu/eslint-define-config": "^1.23.0-2",
|
|
53
53
|
"@eslint-types/jsdoc": "46.9.0",
|
|
54
|
-
"@eslint-types/typescript-eslint": "^6.
|
|
55
|
-
"@eslint-types/unicorn": "^
|
|
54
|
+
"@eslint-types/typescript-eslint": "^6.16.0",
|
|
55
|
+
"@eslint-types/unicorn": "^50.0.1",
|
|
56
56
|
"@html-eslint/eslint-plugin": "^0.22.0",
|
|
57
57
|
"@html-eslint/parser": "^0.22.0",
|
|
58
58
|
"@stylistic/eslint-plugin": "^1.5.1",
|
|
59
|
-
"@typescript-eslint/eslint-plugin": "^6.
|
|
60
|
-
"@typescript-eslint/parser": "^6.
|
|
59
|
+
"@typescript-eslint/eslint-plugin": "^6.16.0",
|
|
60
|
+
"@typescript-eslint/parser": "^6.16.0",
|
|
61
61
|
"eslint-config-flat-gitignore": "^0.1.2",
|
|
62
62
|
"eslint-merge-processors": "^0.1.0",
|
|
63
|
-
"eslint-plugin-antfu": "^2.
|
|
63
|
+
"eslint-plugin-antfu": "^2.1.1",
|
|
64
64
|
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
65
65
|
"eslint-plugin-i": "^2.29.1",
|
|
66
|
-
"eslint-plugin-jsdoc": "^46.
|
|
66
|
+
"eslint-plugin-jsdoc": "^46.10.1",
|
|
67
67
|
"eslint-plugin-jsonc": "^2.11.2",
|
|
68
68
|
"eslint-plugin-markdown": "^3.0.1",
|
|
69
|
-
"eslint-plugin-n": "^16.
|
|
69
|
+
"eslint-plugin-n": "^16.6.0",
|
|
70
70
|
"eslint-plugin-no-only-tests": "^3.1.0",
|
|
71
71
|
"eslint-plugin-perfectionist": "^2.5.0",
|
|
72
72
|
"eslint-plugin-toml": "^0.8.0",
|
|
73
|
-
"eslint-plugin-unicorn": "^
|
|
73
|
+
"eslint-plugin-unicorn": "^50.0.1",
|
|
74
74
|
"eslint-plugin-unused-imports": "^3.0.0",
|
|
75
|
-
"eslint-plugin-vitest": "^0.3.
|
|
75
|
+
"eslint-plugin-vitest": "^0.3.20",
|
|
76
76
|
"eslint-plugin-yml": "^1.11.0",
|
|
77
77
|
"globals": "^13.24.0",
|
|
78
78
|
"jsonc-eslint-parser": "^2.4.0",
|
|
@@ -82,11 +82,11 @@
|
|
|
82
82
|
"yaml-eslint-parser": "^1.2.2"
|
|
83
83
|
},
|
|
84
84
|
"devDependencies": {
|
|
85
|
-
"@unocss/eslint-plugin": "^0.58.
|
|
85
|
+
"@unocss/eslint-plugin": "^0.58.2",
|
|
86
86
|
"eslint": "^8.56.0",
|
|
87
|
-
"eslint-flat-config-viewer": "^0.1.
|
|
87
|
+
"eslint-flat-config-viewer": "^0.1.4",
|
|
88
88
|
"eslint-plugin-format": "^0.1.0",
|
|
89
|
-
"eslint-plugin-tailwindcss": "^3.13.
|
|
89
|
+
"eslint-plugin-tailwindcss": "^3.13.1",
|
|
90
90
|
"tsup": "^8.0.1"
|
|
91
91
|
},
|
|
92
92
|
"scripts": {
|