@ntnyq/eslint-config 3.9.3 → 3.10.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 +7 -1
- package/dist/index.cjs +152 -9
- package/dist/index.d.cts +762 -213
- package/dist/index.d.ts +762 -213
- package/dist/index.js +216 -78
- package/package.json +11 -11
package/README.md
CHANGED
|
@@ -109,7 +109,7 @@ Check for detail in:
|
|
|
109
109
|
### Config interface
|
|
110
110
|
|
|
111
111
|
```ts
|
|
112
|
-
export interface ConfigOptions extends ConfigOptionsInternal {
|
|
112
|
+
export interface ConfigOptions extends ConfigOptionsInternal, OptionsExtensions {
|
|
113
113
|
command?: ConfigCommandOptions
|
|
114
114
|
comments?: ConfigCommentsOptions
|
|
115
115
|
ignores?: ConfigIgnoresOptions
|
|
@@ -123,6 +123,7 @@ export interface ConfigOptions extends ConfigOptionsInternal {
|
|
|
123
123
|
* bellow can be disabled
|
|
124
124
|
*/
|
|
125
125
|
antfu?: boolean | ConfigAntfuOptions
|
|
126
|
+
depend?: boolean | ConfigDependOptions
|
|
126
127
|
githubAction?: boolean | ConfigGitHubActionOptions
|
|
127
128
|
gitignore?: boolean | ConfigGitIgnoreOptions
|
|
128
129
|
jsonc?: boolean | ConfigJsoncOptions
|
|
@@ -140,6 +141,11 @@ export interface ConfigOptions extends ConfigOptionsInternal {
|
|
|
140
141
|
unocss?: boolean | ConfigUnoCSSOptions
|
|
141
142
|
vue?: boolean | ConfigVueOptions
|
|
142
143
|
yml?: boolean | ConfigYmlOptions
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* bellow need enable explicitly
|
|
147
|
+
*/
|
|
148
|
+
svgo?: boolean | ConfigSVGOOptions
|
|
143
149
|
}
|
|
144
150
|
```
|
|
145
151
|
|
package/dist/index.cjs
CHANGED
|
@@ -51,6 +51,7 @@ __export(src_exports, {
|
|
|
51
51
|
GLOB_MARKDOWN_CODE: () => GLOB_MARKDOWN_CODE,
|
|
52
52
|
GLOB_MARKDOWN_NESTED: () => GLOB_MARKDOWN_NESTED,
|
|
53
53
|
GLOB_NODE_MODULES: () => GLOB_NODE_MODULES,
|
|
54
|
+
GLOB_PACKAGE_JSON: () => GLOB_PACKAGE_JSON,
|
|
54
55
|
GLOB_PINIA_STORE: () => GLOB_PINIA_STORE,
|
|
55
56
|
GLOB_POSTCSS: () => GLOB_POSTCSS,
|
|
56
57
|
GLOB_SCSS: () => GLOB_SCSS,
|
|
@@ -69,6 +70,7 @@ __export(src_exports, {
|
|
|
69
70
|
command: () => command,
|
|
70
71
|
comments: () => comments,
|
|
71
72
|
defineESLintConfig: () => defineESLintConfig,
|
|
73
|
+
depend: () => depend,
|
|
72
74
|
esX: () => esX,
|
|
73
75
|
format: () => format,
|
|
74
76
|
getOverrides: () => getOverrides,
|
|
@@ -102,6 +104,7 @@ __export(src_exports, {
|
|
|
102
104
|
pinia: () => pinia,
|
|
103
105
|
pluginAntfu: () => import_eslint_plugin_antfu.default,
|
|
104
106
|
pluginComments: () => import_eslint_plugin_eslint_comments.default,
|
|
107
|
+
pluginDepend: () => pluginDepend,
|
|
105
108
|
pluginEsX: () => import_eslint_plugin_es_x.default,
|
|
106
109
|
pluginFormat: () => import_eslint_plugin_format.default,
|
|
107
110
|
pluginGitHubAction: () => import_eslint_plugin_github_action.default,
|
|
@@ -116,6 +119,7 @@ __export(src_exports, {
|
|
|
116
119
|
pluginPrettier: () => import_eslint_plugin_prettier.default,
|
|
117
120
|
pluginRegexp: () => pluginRegexp,
|
|
118
121
|
pluginStylistic: () => import_eslint_plugin3.default,
|
|
122
|
+
pluginSvgo: () => import_eslint_plugin_svgo.default,
|
|
119
123
|
pluginToml: () => import_eslint_plugin_toml.default,
|
|
120
124
|
pluginTypeScript: () => import_typescript_eslint2.plugin,
|
|
121
125
|
pluginUnicorn: () => import_eslint_plugin_unicorn.default,
|
|
@@ -132,6 +136,7 @@ __export(src_exports, {
|
|
|
132
136
|
sort: () => sort,
|
|
133
137
|
specials: () => specials,
|
|
134
138
|
stylistic: () => stylistic,
|
|
139
|
+
svgo: () => svgo,
|
|
135
140
|
test: () => test,
|
|
136
141
|
toArray: () => toArray,
|
|
137
142
|
toml: () => toml,
|
|
@@ -182,10 +187,12 @@ var parserPlain = {
|
|
|
182
187
|
|
|
183
188
|
// src/eslint/plugins.ts
|
|
184
189
|
var pluginRegexp = __toESM(require("eslint-plugin-regexp"), 1);
|
|
190
|
+
var pluginDepend = __toESM(require("eslint-plugin-depend"), 1);
|
|
185
191
|
var import_eslint_plugin_n = __toESM(require("eslint-plugin-n"), 1);
|
|
186
192
|
var import_eslint_plugin_vue = __toESM(require("eslint-plugin-vue"), 1);
|
|
187
193
|
var import_eslint_plugin_es_x = __toESM(require("eslint-plugin-es-x"), 1);
|
|
188
194
|
var import_eslint_plugin_yml = __toESM(require("eslint-plugin-yml"), 1);
|
|
195
|
+
var import_eslint_plugin_svgo = __toESM(require("eslint-plugin-svgo"), 1);
|
|
189
196
|
var import_eslint_plugin_toml = __toESM(require("eslint-plugin-toml"), 1);
|
|
190
197
|
var import_eslint_plugin_pinia = __toESM(require("eslint-plugin-pinia"), 1);
|
|
191
198
|
var import_eslint_plugin_ntnyq = __toESM(require("eslint-plugin-ntnyq"), 1);
|
|
@@ -237,6 +244,7 @@ var GLOB_POSTCSS = "**/*.{p,post}css";
|
|
|
237
244
|
var GLOB_JSON = "**/*.json";
|
|
238
245
|
var GLOB_JSON5 = "**/*.json5";
|
|
239
246
|
var GLOB_JSONC = "**/*.jsonc";
|
|
247
|
+
var GLOB_PACKAGE_JSON = "**/package.json";
|
|
240
248
|
var GLOB_VUE = "**/*.vue";
|
|
241
249
|
var GLOB_YAML = "**/*.y?(a)ml";
|
|
242
250
|
var GLOB_TOML = "**/*.toml";
|
|
@@ -1132,6 +1140,17 @@ var vitest = (options = {}) => [
|
|
|
1132
1140
|
}
|
|
1133
1141
|
];
|
|
1134
1142
|
|
|
1143
|
+
// src/configs/svgo.ts
|
|
1144
|
+
var import_eslint_plugin_svgo2 = require("eslint-plugin-svgo");
|
|
1145
|
+
var svgo = (options = {}) => [
|
|
1146
|
+
// TODO: remove after fix type
|
|
1147
|
+
// @ts-expect-error type
|
|
1148
|
+
{
|
|
1149
|
+
...(0, import_eslint_plugin_svgo2.config)(options),
|
|
1150
|
+
name: "ntnyq/svgo"
|
|
1151
|
+
}
|
|
1152
|
+
];
|
|
1153
|
+
|
|
1135
1154
|
// src/configs/antfu.ts
|
|
1136
1155
|
var antfu = (options = {}) => [
|
|
1137
1156
|
{
|
|
@@ -1194,6 +1213,8 @@ var jsdoc = (options = {}) => [
|
|
|
1194
1213
|
// magic-comments
|
|
1195
1214
|
"vite-ignore",
|
|
1196
1215
|
"unocss-include",
|
|
1216
|
+
// eslint-plugin-command (block comment only)
|
|
1217
|
+
"regex101",
|
|
1197
1218
|
// non-standard, but common used
|
|
1198
1219
|
"compatibility",
|
|
1199
1220
|
"category",
|
|
@@ -1476,6 +1497,47 @@ var ntnyq = (options = {}) => [
|
|
|
1476
1497
|
}
|
|
1477
1498
|
];
|
|
1478
1499
|
|
|
1500
|
+
// src/configs/depend.ts
|
|
1501
|
+
var depend = (options = {}) => {
|
|
1502
|
+
const {
|
|
1503
|
+
files = [GLOB_SRC],
|
|
1504
|
+
// check package.json file
|
|
1505
|
+
packageJson: enableCheckPackageJson = true
|
|
1506
|
+
} = options;
|
|
1507
|
+
const configs2 = [
|
|
1508
|
+
{
|
|
1509
|
+
name: "ntnyq/depend",
|
|
1510
|
+
files,
|
|
1511
|
+
plugins: {
|
|
1512
|
+
depend: pluginDepend
|
|
1513
|
+
},
|
|
1514
|
+
rules: {
|
|
1515
|
+
"depend/ban-dependencies": "error",
|
|
1516
|
+
// Overrides rules
|
|
1517
|
+
...options.overrides
|
|
1518
|
+
}
|
|
1519
|
+
}
|
|
1520
|
+
];
|
|
1521
|
+
if (enableCheckPackageJson) {
|
|
1522
|
+
configs2.push({
|
|
1523
|
+
name: "ntnyq/depend/package-json",
|
|
1524
|
+
files: [GLOB_PACKAGE_JSON],
|
|
1525
|
+
plugins: {
|
|
1526
|
+
depend: pluginDepend
|
|
1527
|
+
},
|
|
1528
|
+
languageOptions: {
|
|
1529
|
+
parser: parserJsonc
|
|
1530
|
+
},
|
|
1531
|
+
rules: {
|
|
1532
|
+
"depend/ban-dependencies": "error",
|
|
1533
|
+
// Overrides rules
|
|
1534
|
+
...options.overrides
|
|
1535
|
+
}
|
|
1536
|
+
});
|
|
1537
|
+
}
|
|
1538
|
+
return configs2;
|
|
1539
|
+
};
|
|
1540
|
+
|
|
1479
1541
|
// src/configs/regexp.ts
|
|
1480
1542
|
var regexp = (options = {}) => {
|
|
1481
1543
|
const recommendedConfig = pluginRegexp.configs["flat/recommended"];
|
|
@@ -1716,10 +1778,60 @@ var format = (options = {}) => {
|
|
|
1716
1778
|
};
|
|
1717
1779
|
|
|
1718
1780
|
// src/configs/command.ts
|
|
1781
|
+
var import_commands2 = require("eslint-plugin-command/commands");
|
|
1719
1782
|
var import_config = __toESM(require("eslint-plugin-command/config"), 1);
|
|
1783
|
+
|
|
1784
|
+
// src/commands/regexper.ts
|
|
1785
|
+
var import_commands = require("eslint-plugin-command/commands");
|
|
1786
|
+
var regexper = (0, import_commands.defineCommand)({
|
|
1787
|
+
name: "regexper",
|
|
1788
|
+
// @regexper https://regexper.com/#(%5Cb%7C%5Cs%7C%5E)(%40regexper)(%5Cs%5CS%2B)%3F(%5Cb%7C%5Cs%7C%24)
|
|
1789
|
+
match: /(\b|\s|^)(@regexper)(\s\S+)?(\b|\s|$)/,
|
|
1790
|
+
action(ctx) {
|
|
1791
|
+
const literal = ctx.findNodeBelow((node2) => {
|
|
1792
|
+
return node2.type === "Literal" && "regex" in node2;
|
|
1793
|
+
});
|
|
1794
|
+
if (!literal) {
|
|
1795
|
+
return ctx.reportError("Unable to find a regexp literal to generate");
|
|
1796
|
+
}
|
|
1797
|
+
const [_fullStr = "", spaceBefore = "", commandStr = "", existingUrl = "", _spaceAfter = ""] = ctx.matches;
|
|
1798
|
+
const url = `https://regexper.com/#${encodeURIComponent(literal.regex.pattern)}`;
|
|
1799
|
+
if (existingUrl.trim() === url.trim()) {
|
|
1800
|
+
return;
|
|
1801
|
+
}
|
|
1802
|
+
const indexStart = ctx.comment.range[0] + ctx.matches.index + spaceBefore.length + 2;
|
|
1803
|
+
const indexEnd = indexStart + commandStr.length + existingUrl.length;
|
|
1804
|
+
ctx.report({
|
|
1805
|
+
loc: {
|
|
1806
|
+
start: ctx.source.getLocFromIndex(indexStart),
|
|
1807
|
+
end: ctx.source.getLocFromIndex(indexEnd)
|
|
1808
|
+
},
|
|
1809
|
+
removeComment: false,
|
|
1810
|
+
message: "Update the regexper link",
|
|
1811
|
+
fix(fixer) {
|
|
1812
|
+
return fixer.replaceTextRange([indexStart, indexEnd], `@regexper ${url}`);
|
|
1813
|
+
}
|
|
1814
|
+
});
|
|
1815
|
+
}
|
|
1816
|
+
});
|
|
1817
|
+
|
|
1818
|
+
// src/commands/index.ts
|
|
1819
|
+
var commands = [regexper];
|
|
1820
|
+
|
|
1821
|
+
// src/configs/command.ts
|
|
1720
1822
|
var command = (options = {}) => [
|
|
1721
1823
|
{
|
|
1722
|
-
...(0, import_config.default)(
|
|
1824
|
+
...(0, import_config.default)({
|
|
1825
|
+
...options,
|
|
1826
|
+
commands: [
|
|
1827
|
+
// built-in commands
|
|
1828
|
+
...import_commands2.builtinCommands,
|
|
1829
|
+
// config internal commands
|
|
1830
|
+
...commands,
|
|
1831
|
+
// user custom commands
|
|
1832
|
+
...options.commands || []
|
|
1833
|
+
]
|
|
1834
|
+
}),
|
|
1723
1835
|
name: "ntnyq/command"
|
|
1724
1836
|
}
|
|
1725
1837
|
];
|
|
@@ -1737,6 +1849,7 @@ var ignores = (customIgnores = []) => [
|
|
|
1737
1849
|
];
|
|
1738
1850
|
|
|
1739
1851
|
// src/configs/importX.ts
|
|
1852
|
+
var { createNodeResolver } = import_eslint_plugin_import_x.default;
|
|
1740
1853
|
var importX = (options = {}) => [
|
|
1741
1854
|
{
|
|
1742
1855
|
name: "ntnyq/import-x",
|
|
@@ -1744,9 +1857,11 @@ var importX = (options = {}) => [
|
|
|
1744
1857
|
"import-x": import_eslint_plugin_import_x.default
|
|
1745
1858
|
},
|
|
1746
1859
|
settings: {
|
|
1747
|
-
"import-x/resolver":
|
|
1748
|
-
|
|
1749
|
-
|
|
1860
|
+
"import-x/resolver-next": [
|
|
1861
|
+
createNodeResolver({
|
|
1862
|
+
extensions: [".js", ".mjs", ".ts", ".mts", ".d.ts", ".json"]
|
|
1863
|
+
})
|
|
1864
|
+
]
|
|
1750
1865
|
},
|
|
1751
1866
|
rules: {
|
|
1752
1867
|
"import-x/no-unresolved": "off",
|
|
@@ -2694,14 +2809,17 @@ var perfectionist = (options = {}) => {
|
|
|
2694
2809
|
type: "natural",
|
|
2695
2810
|
ignoreCase: true,
|
|
2696
2811
|
internalPattern: ["^~/.+", "^@/.+", "^#.+"],
|
|
2697
|
-
newlinesBetween: "ignore"
|
|
2812
|
+
newlinesBetween: "ignore",
|
|
2813
|
+
partitionByComment: true
|
|
2698
2814
|
}
|
|
2699
2815
|
],
|
|
2700
2816
|
"perfectionist/sort-exports": [
|
|
2701
2817
|
"error",
|
|
2702
2818
|
{
|
|
2703
2819
|
order: "asc",
|
|
2704
|
-
type: "line-length"
|
|
2820
|
+
type: "line-length",
|
|
2821
|
+
groupKind: "values-first",
|
|
2822
|
+
partitionByComment: true
|
|
2705
2823
|
}
|
|
2706
2824
|
],
|
|
2707
2825
|
"perfectionist/sort-named-exports": [
|
|
@@ -2710,7 +2828,8 @@ var perfectionist = (options = {}) => {
|
|
|
2710
2828
|
type: "alphabetical",
|
|
2711
2829
|
order: "asc",
|
|
2712
2830
|
ignoreCase: true,
|
|
2713
|
-
groupKind: "values-first"
|
|
2831
|
+
groupKind: "values-first",
|
|
2832
|
+
partitionByComment: true
|
|
2714
2833
|
}
|
|
2715
2834
|
],
|
|
2716
2835
|
"perfectionist/sort-named-imports": [
|
|
@@ -2720,7 +2839,8 @@ var perfectionist = (options = {}) => {
|
|
|
2720
2839
|
order: "asc",
|
|
2721
2840
|
ignoreCase: true,
|
|
2722
2841
|
ignoreAlias: false,
|
|
2723
|
-
groupKind: "values-first"
|
|
2842
|
+
groupKind: "values-first",
|
|
2843
|
+
partitionByComment: true
|
|
2724
2844
|
}
|
|
2725
2845
|
],
|
|
2726
2846
|
// Overrides rules
|
|
@@ -2922,6 +3042,7 @@ function defineESLintConfig(options = {}, ...userConfigs) {
|
|
|
2922
3042
|
toml: enableTOML = true,
|
|
2923
3043
|
jsonc: enableJSONC = true,
|
|
2924
3044
|
antfu: enableAntfu = true,
|
|
3045
|
+
depend: enableDepend = true,
|
|
2925
3046
|
regexp: enableRegexp = true,
|
|
2926
3047
|
unicorn: enableUnicorn = true,
|
|
2927
3048
|
prettier: enablePrettier = true,
|
|
@@ -2929,7 +3050,9 @@ function defineESLintConfig(options = {}, ...userConfigs) {
|
|
|
2929
3050
|
stylistic: enableStylistic = true,
|
|
2930
3051
|
gitignore: enableGitIgnore = true,
|
|
2931
3052
|
githubAction: enableGitHubAction = true,
|
|
2932
|
-
perfectionist: enablePerfectionist = true
|
|
3053
|
+
perfectionist: enablePerfectionist = true,
|
|
3054
|
+
// disabled by default
|
|
3055
|
+
svgo: enableSVGO = false
|
|
2933
3056
|
} = options;
|
|
2934
3057
|
const configs2 = [];
|
|
2935
3058
|
if (enableVue) {
|
|
@@ -3082,6 +3205,14 @@ function defineESLintConfig(options = {}, ...userConfigs) {
|
|
|
3082
3205
|
})
|
|
3083
3206
|
);
|
|
3084
3207
|
}
|
|
3208
|
+
if (enableDepend) {
|
|
3209
|
+
configs2.push(
|
|
3210
|
+
...depend({
|
|
3211
|
+
...resolveSubOptions(options, "depend"),
|
|
3212
|
+
overrides: getOverrides(options, "depend")
|
|
3213
|
+
})
|
|
3214
|
+
);
|
|
3215
|
+
}
|
|
3085
3216
|
if (enableGitHubAction) {
|
|
3086
3217
|
configs2.push(
|
|
3087
3218
|
...githubAction({
|
|
@@ -3089,6 +3220,13 @@ function defineESLintConfig(options = {}, ...userConfigs) {
|
|
|
3089
3220
|
})
|
|
3090
3221
|
);
|
|
3091
3222
|
}
|
|
3223
|
+
if (enableSVGO) {
|
|
3224
|
+
configs2.push(
|
|
3225
|
+
...svgo({
|
|
3226
|
+
...resolveSubOptions(options, "svgo")
|
|
3227
|
+
})
|
|
3228
|
+
);
|
|
3229
|
+
}
|
|
3092
3230
|
const configSpecials = specials({
|
|
3093
3231
|
...resolveSubOptions(options, "specials")
|
|
3094
3232
|
});
|
|
@@ -3127,6 +3265,7 @@ function defineESLintConfig(options = {}, ...userConfigs) {
|
|
|
3127
3265
|
GLOB_MARKDOWN_CODE,
|
|
3128
3266
|
GLOB_MARKDOWN_NESTED,
|
|
3129
3267
|
GLOB_NODE_MODULES,
|
|
3268
|
+
GLOB_PACKAGE_JSON,
|
|
3130
3269
|
GLOB_PINIA_STORE,
|
|
3131
3270
|
GLOB_POSTCSS,
|
|
3132
3271
|
GLOB_SCSS,
|
|
@@ -3145,6 +3284,7 @@ function defineESLintConfig(options = {}, ...userConfigs) {
|
|
|
3145
3284
|
command,
|
|
3146
3285
|
comments,
|
|
3147
3286
|
defineESLintConfig,
|
|
3287
|
+
depend,
|
|
3148
3288
|
esX,
|
|
3149
3289
|
format,
|
|
3150
3290
|
getOverrides,
|
|
@@ -3178,6 +3318,7 @@ function defineESLintConfig(options = {}, ...userConfigs) {
|
|
|
3178
3318
|
pinia,
|
|
3179
3319
|
pluginAntfu,
|
|
3180
3320
|
pluginComments,
|
|
3321
|
+
pluginDepend,
|
|
3181
3322
|
pluginEsX,
|
|
3182
3323
|
pluginFormat,
|
|
3183
3324
|
pluginGitHubAction,
|
|
@@ -3192,6 +3333,7 @@ function defineESLintConfig(options = {}, ...userConfigs) {
|
|
|
3192
3333
|
pluginPrettier,
|
|
3193
3334
|
pluginRegexp,
|
|
3194
3335
|
pluginStylistic,
|
|
3336
|
+
pluginSvgo,
|
|
3195
3337
|
pluginToml,
|
|
3196
3338
|
pluginTypeScript,
|
|
3197
3339
|
pluginUnicorn,
|
|
@@ -3208,6 +3350,7 @@ function defineESLintConfig(options = {}, ...userConfigs) {
|
|
|
3208
3350
|
sort,
|
|
3209
3351
|
specials,
|
|
3210
3352
|
stylistic,
|
|
3353
|
+
svgo,
|
|
3211
3354
|
test,
|
|
3212
3355
|
toArray,
|
|
3213
3356
|
toml,
|