@ntnyq/eslint-config 7.0.0-beta.30 → 7.0.0-beta.32
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 +1 -0
- package/dist/index.d.mts +917 -564
- package/dist/index.mjs +263 -114
- package/package.json +36 -33
package/dist/index.mjs
CHANGED
|
@@ -6,7 +6,6 @@ import * as parserToml from "toml-eslint-parser";
|
|
|
6
6
|
import * as parserYaml from "yaml-eslint-parser";
|
|
7
7
|
import * as parserPlain from "eslint-parser-plain";
|
|
8
8
|
import * as parserJsonc from "jsonc-eslint-parser";
|
|
9
|
-
import pluginShell from "@eslint/shell";
|
|
10
9
|
import pluginNode from "eslint-plugin-n";
|
|
11
10
|
import pluginVue from "eslint-plugin-vue";
|
|
12
11
|
import pluginYml from "eslint-plugin-yml";
|
|
@@ -27,7 +26,6 @@ import pluginUnicorn from "eslint-plugin-unicorn";
|
|
|
27
26
|
import pluginImportX from "eslint-plugin-import-x";
|
|
28
27
|
import pluginPrettier from "eslint-plugin-prettier";
|
|
29
28
|
import pluginDeMorgan from "eslint-plugin-de-morgan";
|
|
30
|
-
import pluginNoOnlyTests from "eslint-plugin-no-only-tests";
|
|
31
29
|
import pluginGitHubAction from "eslint-plugin-github-action";
|
|
32
30
|
import pluginPerfectionist from "eslint-plugin-perfectionist";
|
|
33
31
|
import pluginVuePerfectionist from "eslint-plugin-vue-perfectionist";
|
|
@@ -136,6 +134,7 @@ const GLOB_EXCLUDE = [
|
|
|
136
134
|
"**/typed-router.d.ts",
|
|
137
135
|
"**/routes.d.ts",
|
|
138
136
|
"**/uni-pages.d.ts",
|
|
137
|
+
"**/uni-layouts.d.ts",
|
|
139
138
|
"**/coverage",
|
|
140
139
|
"**/fixtures",
|
|
141
140
|
"**/output",
|
|
@@ -249,12 +248,16 @@ function isInGitHooksOrRunBySpecifyPackages() {
|
|
|
249
248
|
* @copyright {@link https://github.com/antfu/eslint-config}
|
|
250
249
|
*/
|
|
251
250
|
const isCwdInScope = isPackageExists("@ntnyq/eslint-config");
|
|
251
|
+
let installationQueue = Promise.resolve();
|
|
252
252
|
/**
|
|
253
253
|
* Check whether a package can be resolved from this config package scope.
|
|
254
254
|
*/
|
|
255
255
|
function isPackageInScope(name) {
|
|
256
256
|
return isPackageExists(name, { paths: [import.meta.dirname] });
|
|
257
257
|
}
|
|
258
|
+
function getMissingPackages(packages) {
|
|
259
|
+
return packages.filter((pkg) => !!pkg && !isPackageInScope(pkg));
|
|
260
|
+
}
|
|
258
261
|
/**
|
|
259
262
|
* Ensure required packages are installed for optional config features.
|
|
260
263
|
*
|
|
@@ -264,18 +267,22 @@ function isPackageInScope(name) {
|
|
|
264
267
|
* @param packages - Package names to verify and optionally install.
|
|
265
268
|
*/
|
|
266
269
|
async function ensurePackages(packages) {
|
|
267
|
-
if (process.env.CI || !process.stdout.isTTY || isInGitHooksOrRunBySpecifyPackages() || !isCwdInScope) return;
|
|
268
|
-
const
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
270
|
+
if (process.env.CI || !process.stdout.isTTY || isInGitHooksOrRunBySpecifyPackages() || !isCwdInScope || getMissingPackages(packages).length === 0) return;
|
|
271
|
+
const installation = installationQueue.then(async () => {
|
|
272
|
+
const missingPackages = getMissingPackages(packages);
|
|
273
|
+
if (missingPackages.length === 0) return;
|
|
274
|
+
const { confirm, isCancel } = await import("@clack/prompts");
|
|
275
|
+
const confirmInstall = await confirm({ message: `${missingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${missingPackages.join(", ")}. Do you want to install them?` });
|
|
276
|
+
if (isCancel(confirmInstall) || !confirmInstall) return;
|
|
277
|
+
try {
|
|
278
|
+
const { installPackage } = await import("@antfu/install-pkg");
|
|
279
|
+
await installPackage(missingPackages, { dev: true });
|
|
280
|
+
} catch (error) {
|
|
281
|
+
throw new Error(`Failed to install required packages: ${missingPackages.join(", ")}`, { cause: error });
|
|
282
|
+
}
|
|
283
|
+
});
|
|
284
|
+
installationQueue = installation.catch(() => void 0);
|
|
285
|
+
await installation;
|
|
279
286
|
}
|
|
280
287
|
// src/utils/interopDefault.ts
|
|
281
288
|
/**
|
|
@@ -470,6 +477,7 @@ const configVue = (options = {}) => {
|
|
|
470
477
|
const { files = [GLOB_VUE], ecmaVersion = "latest", extraFileExtensions = [], typescript = false, vuePerfectionist: enableVuePerfectionist = false } = options;
|
|
471
478
|
const vuePerfectionistOptions = resolveSubOptions(options, "vuePerfectionist");
|
|
472
479
|
const enableAutoImport = vuePerfectionistOptions.autoImport ?? hasAutoImport();
|
|
480
|
+
const enableVueuseFunctions = vuePerfectionistOptions.vueuse ?? false;
|
|
473
481
|
const sfcBlocks = options.sfcBlocks === true ? {} : options.sfcBlocks ?? {};
|
|
474
482
|
function getVueProcessor() {
|
|
475
483
|
const processorVueSFC = pluginVue.processors[".vue"];
|
|
@@ -640,7 +648,10 @@ const configVue = (options = {}) => {
|
|
|
640
648
|
...GLOB_VUE_COMPOSABLES
|
|
641
649
|
],
|
|
642
650
|
plugins: { "vue-perfectionist": pluginVuePerfectionist },
|
|
643
|
-
settings: { "vue-perfectionist": {
|
|
651
|
+
settings: { "vue-perfectionist": {
|
|
652
|
+
autoImport: enableAutoImport,
|
|
653
|
+
vueuse: enableVueuseFunctions
|
|
654
|
+
} },
|
|
644
655
|
rules: {
|
|
645
656
|
"vue-perfectionist/prefer-define-model": "warn",
|
|
646
657
|
"vue-perfectionist/callback-style": "error",
|
|
@@ -655,27 +666,31 @@ const configVue = (options = {}) => {
|
|
|
655
666
|
allowLogical: true
|
|
656
667
|
}],
|
|
657
668
|
"vue-perfectionist/prefer-watch-effect-alias": "error",
|
|
658
|
-
"vue-perfectionist/
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
669
|
+
"vue-perfectionist/require-composable-return-bindings": "error",
|
|
670
|
+
"vue-perfectionist/sort-script-setup": ["error", {
|
|
671
|
+
newlinesBetween: 1,
|
|
672
|
+
groups: [
|
|
673
|
+
["interface", "type"],
|
|
674
|
+
"define-props",
|
|
675
|
+
"define-emits",
|
|
676
|
+
"define-options",
|
|
677
|
+
"define-slots",
|
|
678
|
+
"define-model",
|
|
679
|
+
"constant",
|
|
680
|
+
"inject",
|
|
681
|
+
"composable",
|
|
682
|
+
"template-ref",
|
|
683
|
+
["ref", "reactive"],
|
|
684
|
+
"computed",
|
|
685
|
+
"variable",
|
|
686
|
+
["enum", "class"],
|
|
687
|
+
"function",
|
|
688
|
+
"watch",
|
|
689
|
+
"lifecycle-hook",
|
|
690
|
+
"provide",
|
|
691
|
+
"define-expose"
|
|
692
|
+
]
|
|
693
|
+
}],
|
|
679
694
|
...vuePerfectionistOptions.overrides
|
|
680
695
|
}
|
|
681
696
|
});
|
|
@@ -755,9 +770,10 @@ const configYml = (options = {}) => {
|
|
|
755
770
|
* @see {@link https://github.com/yeonjuan/html-eslint}
|
|
756
771
|
*
|
|
757
772
|
* @param options - {@link ConfigHtmlOptions}
|
|
773
|
+
* @param oxfmtConfigs - File scopes formatted by oxfmt
|
|
758
774
|
* @returns ESLint configs
|
|
759
775
|
*/
|
|
760
|
-
const configHtml = async (options = {}) => {
|
|
776
|
+
const configHtml = async (options = {}, oxfmtConfigs = []) => {
|
|
761
777
|
await ensurePackages(["@html-eslint/parser", "@html-eslint/eslint-plugin"]);
|
|
762
778
|
const [parserHtml, pluginHtml] = await Promise.all([interopDefault(import("@html-eslint/parser")), interopDefault(import("@html-eslint/eslint-plugin"))]);
|
|
763
779
|
const { files = [GLOB_HTML] } = options;
|
|
@@ -785,7 +801,20 @@ const configHtml = async (options = {}) => {
|
|
|
785
801
|
"@html-eslint/use-baseline": "error",
|
|
786
802
|
...options.overrides
|
|
787
803
|
}
|
|
788
|
-
}]
|
|
804
|
+
}, ...oxfmtConfigs.map(({ name, files: formattedFiles = [], ignores }) => ({
|
|
805
|
+
name: `${name}/html`,
|
|
806
|
+
files: files.flatMap((file) => formattedFiles.map((formattedFile) => [file, formattedFile].flat())),
|
|
807
|
+
ignores,
|
|
808
|
+
rules: {
|
|
809
|
+
"@html-eslint/attrs-newline": "off",
|
|
810
|
+
"@html-eslint/element-newline": "off",
|
|
811
|
+
"@html-eslint/indent": "off",
|
|
812
|
+
"@html-eslint/no-extra-spacing-tags": "off",
|
|
813
|
+
"@html-eslint/quotes": "off",
|
|
814
|
+
"@html-eslint/require-closing-tags": ["error", { selfClosing: "always" }],
|
|
815
|
+
...options.overrides
|
|
816
|
+
}
|
|
817
|
+
}))];
|
|
789
818
|
};
|
|
790
819
|
// src/configs/node.ts
|
|
791
820
|
/**
|
|
@@ -864,9 +893,18 @@ const configPnpm = async (options = {}) => {
|
|
|
864
893
|
const configSort = (options = {}) => {
|
|
865
894
|
const configs = [];
|
|
866
895
|
const { additionalJsonFiles = [], additionalYamlFiles = [], i18nLocale: enableSortI18nLocale = true, jsonSchema: enableSortJsonSchema = true, packageJson: enableSortPackageJson = true, pnpmWorkspace: enableSortPnpmWorkspace = true, tsconfig: enableSortTsconfig = true } = options;
|
|
896
|
+
const jsoncLanguageConfig = {
|
|
897
|
+
plugins: { jsonc: pluginJsonc },
|
|
898
|
+
languageOptions: { parser: parserJsonc }
|
|
899
|
+
};
|
|
900
|
+
const yamlLanguageConfig = {
|
|
901
|
+
plugins: { yml: pluginYml },
|
|
902
|
+
languageOptions: { parser: parserYaml }
|
|
903
|
+
};
|
|
867
904
|
if (enableSortTsconfig) configs.push({
|
|
868
905
|
name: "ntnyq/sort/tsconfig",
|
|
869
906
|
files: [...GLOB_TSCONFIG_JSON],
|
|
907
|
+
...jsoncLanguageConfig,
|
|
870
908
|
rules: { "jsonc/sort-keys": [
|
|
871
909
|
"error",
|
|
872
910
|
{
|
|
@@ -988,6 +1026,7 @@ const configSort = (options = {}) => {
|
|
|
988
1026
|
if (enableSortPackageJson) configs.push({
|
|
989
1027
|
name: "ntnyq/sort/package-json",
|
|
990
1028
|
files: [GLOB_PACKAGE_JSON],
|
|
1029
|
+
...jsoncLanguageConfig,
|
|
991
1030
|
rules: {
|
|
992
1031
|
"jsonc/sort-array-values": ["error", {
|
|
993
1032
|
order: { type: "asc" },
|
|
@@ -1095,7 +1134,6 @@ const configSort = (options = {}) => {
|
|
|
1095
1134
|
* @see {@link https://pnpm.io/package_json#publishconfig}
|
|
1096
1135
|
*/
|
|
1097
1136
|
{
|
|
1098
|
-
pathPattern: "^publishConfig.*$",
|
|
1099
1137
|
order: [
|
|
1100
1138
|
"./package.json",
|
|
1101
1139
|
"types",
|
|
@@ -1103,7 +1141,8 @@ const configSort = (options = {}) => {
|
|
|
1103
1141
|
"require",
|
|
1104
1142
|
"default",
|
|
1105
1143
|
{ order: { type: "asc" } }
|
|
1106
|
-
]
|
|
1144
|
+
],
|
|
1145
|
+
pathPattern: "^publishConfig(?!\\.(?:exports|imports)(?:\\.|\\[|$)).*$"
|
|
1107
1146
|
}),
|
|
1108
1147
|
{
|
|
1109
1148
|
order: { type: "asc" },
|
|
@@ -1131,6 +1170,7 @@ const configSort = (options = {}) => {
|
|
|
1131
1170
|
if (enableSortI18nLocale) configs.push({
|
|
1132
1171
|
name: "ntnyq/sort/i18n-locale/json",
|
|
1133
1172
|
files: ["**/{i18n,langs,locales}/*.json"],
|
|
1173
|
+
...jsoncLanguageConfig,
|
|
1134
1174
|
rules: { "jsonc/sort-keys": ["error", {
|
|
1135
1175
|
order: { type: "asc" },
|
|
1136
1176
|
pathPattern: ".*"
|
|
@@ -1138,6 +1178,7 @@ const configSort = (options = {}) => {
|
|
|
1138
1178
|
}, {
|
|
1139
1179
|
name: "ntnyq/sort/i18n-locale/yaml",
|
|
1140
1180
|
files: ["**/{i18n,langs,locales}/*.y?(a)ml"],
|
|
1181
|
+
...yamlLanguageConfig,
|
|
1141
1182
|
rules: { "yml/sort-keys": ["error", {
|
|
1142
1183
|
order: { type: "asc" },
|
|
1143
1184
|
pathPattern: ".*"
|
|
@@ -1150,6 +1191,7 @@ const configSort = (options = {}) => {
|
|
|
1150
1191
|
name: "ntnyq/sort/json-schema",
|
|
1151
1192
|
files: [...GLOB_JSON_SCHEMA],
|
|
1152
1193
|
ignores: [GLOB_PACKAGE_JSON],
|
|
1194
|
+
...jsoncLanguageConfig,
|
|
1153
1195
|
rules: {
|
|
1154
1196
|
"jsonc/sort-array-values": ["error", {
|
|
1155
1197
|
order: { type: "asc" },
|
|
@@ -1185,6 +1227,7 @@ const configSort = (options = {}) => {
|
|
|
1185
1227
|
if (enableSortPnpmWorkspace) configs.push({
|
|
1186
1228
|
name: "ntnyq/sort/pnpm-workspace",
|
|
1187
1229
|
files: [GLOB_PNPM_WORKSPACE_YAML],
|
|
1230
|
+
...yamlLanguageConfig,
|
|
1188
1231
|
rules: {
|
|
1189
1232
|
"yml/sort-keys": [
|
|
1190
1233
|
"error",
|
|
@@ -1233,6 +1276,7 @@ const configSort = (options = {}) => {
|
|
|
1233
1276
|
if (additionalJsonFiles.length) configs.push({
|
|
1234
1277
|
name: "ntnyq/sort/additional-json",
|
|
1235
1278
|
files: additionalJsonFiles,
|
|
1279
|
+
...jsoncLanguageConfig,
|
|
1236
1280
|
rules: { "jsonc/sort-keys": ["error", {
|
|
1237
1281
|
pathPattern: ".*",
|
|
1238
1282
|
order: ["$schema", { order: { type: "asc" } }]
|
|
@@ -1241,6 +1285,7 @@ const configSort = (options = {}) => {
|
|
|
1241
1285
|
if (additionalYamlFiles.length) configs.push({
|
|
1242
1286
|
name: "ntnyq/sort/additional-yaml",
|
|
1243
1287
|
files: additionalYamlFiles,
|
|
1288
|
+
...yamlLanguageConfig,
|
|
1244
1289
|
rules: { "yml/sort-keys": ["error", {
|
|
1245
1290
|
order: { type: "asc" },
|
|
1246
1291
|
pathPattern: ".*"
|
|
@@ -1292,15 +1337,11 @@ const configTest = (options = {}) => {
|
|
|
1292
1337
|
const vitestOptions = resolveSubOptions(options, "vitest");
|
|
1293
1338
|
const configs = [];
|
|
1294
1339
|
if (enableBase) configs.push({
|
|
1295
|
-
name: "ntnyq/test/setup",
|
|
1296
|
-
plugins: { "no-only-tests": pluginNoOnlyTests }
|
|
1297
|
-
}, {
|
|
1298
1340
|
name: "ntnyq/test/base",
|
|
1299
1341
|
files: baseOptions.files ?? files,
|
|
1300
1342
|
rules: {
|
|
1301
1343
|
"max-lines-per-function": "off",
|
|
1302
1344
|
"no-unused-expressions": "off",
|
|
1303
|
-
"no-only-tests/no-only-tests": "error",
|
|
1304
1345
|
...baseOptions.overrides
|
|
1305
1346
|
}
|
|
1306
1347
|
});
|
|
@@ -1679,6 +1720,77 @@ const configNtnyq = (options = {}) => [{
|
|
|
1679
1720
|
],
|
|
1680
1721
|
scope: "top-level"
|
|
1681
1722
|
}] }],
|
|
1723
|
+
"ntnyq/padding-line-between-statements": [
|
|
1724
|
+
"error",
|
|
1725
|
+
{
|
|
1726
|
+
blankLine: "always",
|
|
1727
|
+
prev: "*",
|
|
1728
|
+
next: [
|
|
1729
|
+
"if",
|
|
1730
|
+
"for",
|
|
1731
|
+
"while",
|
|
1732
|
+
"do",
|
|
1733
|
+
"switch",
|
|
1734
|
+
"try",
|
|
1735
|
+
"return",
|
|
1736
|
+
"throw"
|
|
1737
|
+
]
|
|
1738
|
+
},
|
|
1739
|
+
{
|
|
1740
|
+
blankLine: "always",
|
|
1741
|
+
next: "*",
|
|
1742
|
+
prev: [
|
|
1743
|
+
"if",
|
|
1744
|
+
"for",
|
|
1745
|
+
"while",
|
|
1746
|
+
"do",
|
|
1747
|
+
"switch",
|
|
1748
|
+
"try"
|
|
1749
|
+
]
|
|
1750
|
+
},
|
|
1751
|
+
{
|
|
1752
|
+
blankLine: "always",
|
|
1753
|
+
next: "*",
|
|
1754
|
+
prev: [
|
|
1755
|
+
"const",
|
|
1756
|
+
"let",
|
|
1757
|
+
"var"
|
|
1758
|
+
]
|
|
1759
|
+
},
|
|
1760
|
+
{
|
|
1761
|
+
blankLine: "any",
|
|
1762
|
+
next: [
|
|
1763
|
+
"const",
|
|
1764
|
+
"let",
|
|
1765
|
+
"var"
|
|
1766
|
+
],
|
|
1767
|
+
prev: [
|
|
1768
|
+
"const",
|
|
1769
|
+
"let",
|
|
1770
|
+
"var"
|
|
1771
|
+
]
|
|
1772
|
+
},
|
|
1773
|
+
{
|
|
1774
|
+
blankLine: "always",
|
|
1775
|
+
next: ["function", "class"],
|
|
1776
|
+
prev: "*"
|
|
1777
|
+
},
|
|
1778
|
+
{
|
|
1779
|
+
blankLine: "always",
|
|
1780
|
+
next: "*",
|
|
1781
|
+
prev: ["function", "class"]
|
|
1782
|
+
},
|
|
1783
|
+
{
|
|
1784
|
+
blankLine: "always",
|
|
1785
|
+
next: "*",
|
|
1786
|
+
prev: "import"
|
|
1787
|
+
},
|
|
1788
|
+
{
|
|
1789
|
+
blankLine: "never",
|
|
1790
|
+
next: "import",
|
|
1791
|
+
prev: "import"
|
|
1792
|
+
}
|
|
1793
|
+
],
|
|
1682
1794
|
"ntnyq/prefer-newline-after-file-header": "error",
|
|
1683
1795
|
"ntnyq/prefer-object-method-syntax": ["error", {
|
|
1684
1796
|
allowArrowFunctions: "singleLineOnly",
|
|
@@ -1707,27 +1819,36 @@ const configOxfmt = (options = {}) => {
|
|
|
1707
1819
|
GLOB_YAML,
|
|
1708
1820
|
GLOB_TOML,
|
|
1709
1821
|
GLOB_MARKDOWN
|
|
1710
|
-
], ignores
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1822
|
+
], ignores = [], filesExtensions: plainParserFiles = [GLOB_STYLE, GLOB_HTML] } = options;
|
|
1823
|
+
const plainParserIgnores = [...nativeFiles.flat(), ...ignores];
|
|
1824
|
+
return [
|
|
1825
|
+
{
|
|
1826
|
+
name: "ntnyq/oxfmt/plain-parser",
|
|
1827
|
+
files: plainParserFiles,
|
|
1828
|
+
ignores: plainParserIgnores,
|
|
1829
|
+
languageOptions: { parser: parserPlain }
|
|
1830
|
+
},
|
|
1831
|
+
{
|
|
1832
|
+
name: "ntnyq/oxfmt/native-files",
|
|
1833
|
+
files: nativeFiles,
|
|
1834
|
+
ignores,
|
|
1835
|
+
plugins: { oxfmt: pluginOxfmt },
|
|
1836
|
+
rules: {
|
|
1837
|
+
"oxfmt/oxfmt": "error",
|
|
1838
|
+
...options.overrides
|
|
1839
|
+
}
|
|
1840
|
+
},
|
|
1841
|
+
{
|
|
1842
|
+
name: "ntnyq/oxfmt/plain-parser-files",
|
|
1843
|
+
files: plainParserFiles,
|
|
1844
|
+
ignores: plainParserIgnores,
|
|
1845
|
+
plugins: { oxfmt: pluginOxfmt },
|
|
1846
|
+
rules: {
|
|
1847
|
+
"oxfmt/oxfmt": "error",
|
|
1848
|
+
...options.overrides
|
|
1849
|
+
}
|
|
1729
1850
|
}
|
|
1730
|
-
|
|
1851
|
+
];
|
|
1731
1852
|
};
|
|
1732
1853
|
// src/configs/pinia.ts
|
|
1733
1854
|
/**
|
|
@@ -1768,12 +1889,13 @@ const configPinia = (options = {}) => {
|
|
|
1768
1889
|
* @param options - {@link ConfigShellOptions}
|
|
1769
1890
|
* @returns ESLint configs
|
|
1770
1891
|
*/
|
|
1771
|
-
const configShell = (options = {}) => {
|
|
1892
|
+
const configShell = async (options = {}) => {
|
|
1772
1893
|
const { files = [GLOB_SHELL], language = "bash" } = options;
|
|
1894
|
+
await ensurePackages(["@eslint/shell"]);
|
|
1773
1895
|
return [{
|
|
1774
1896
|
name: "ntnyq/shell",
|
|
1775
1897
|
files,
|
|
1776
|
-
plugins: { shell:
|
|
1898
|
+
plugins: { shell: await interopDefault(import("@eslint/shell")) },
|
|
1777
1899
|
language: `shell/${language}`,
|
|
1778
1900
|
rules: {
|
|
1779
1901
|
"shell/no-expansions-in-single-quotes": "warn",
|
|
@@ -2178,7 +2300,6 @@ const configUnicorn = (options = {}) => {
|
|
|
2178
2300
|
/**
|
|
2179
2301
|
* @pg Promise
|
|
2180
2302
|
*/
|
|
2181
|
-
"unicorn/no-async-promise-finally": "error",
|
|
2182
2303
|
"unicorn/no-await-in-promise-methods": "error",
|
|
2183
2304
|
"unicorn/no-multiple-promise-resolver-calls": "error",
|
|
2184
2305
|
"unicorn/no-unnecessary-await": "error",
|
|
@@ -2226,6 +2347,7 @@ const configUnicorn = (options = {}) => {
|
|
|
2226
2347
|
/**
|
|
2227
2348
|
* @pg RegExp
|
|
2228
2349
|
*/
|
|
2350
|
+
"unicorn/prefer-regexp-exec": "error",
|
|
2229
2351
|
"unicorn/prefer-regexp-test": "error",
|
|
2230
2352
|
/**
|
|
2231
2353
|
* @pg Date
|
|
@@ -2330,6 +2452,7 @@ const configUnicorn = (options = {}) => {
|
|
|
2330
2452
|
"unicorn/no-unsafe-property-key": "error",
|
|
2331
2453
|
"unicorn/prefer-object-from-entries": "error",
|
|
2332
2454
|
"unicorn/prefer-single-object-destructuring": "error",
|
|
2455
|
+
"unicorn/require-spread-parentheses": "error",
|
|
2333
2456
|
/**
|
|
2334
2457
|
* @pg Data
|
|
2335
2458
|
*/
|
|
@@ -2389,13 +2512,13 @@ const configMarkdown = (options = {}) => {
|
|
|
2389
2512
|
*/
|
|
2390
2513
|
{
|
|
2391
2514
|
name: "ntnyq/markdown/processor",
|
|
2392
|
-
files,
|
|
2515
|
+
files: [GLOB_MARKDOWN],
|
|
2393
2516
|
ignores: [GLOB_MARKDOWN_NESTED],
|
|
2394
2517
|
processor: mergeProcessors([pluginMarkdown.processors.markdown, processorPassThrough])
|
|
2395
2518
|
}),
|
|
2396
2519
|
{
|
|
2397
2520
|
name: "ntnyq/markdown/parser",
|
|
2398
|
-
files,
|
|
2521
|
+
files: [GLOB_MARKDOWN],
|
|
2399
2522
|
languageOptions: { parser: parserPlain }
|
|
2400
2523
|
},
|
|
2401
2524
|
{
|
|
@@ -2969,6 +3092,7 @@ const typeAwareRules = {
|
|
|
2969
3092
|
"@typescript-eslint/no-unsafe-argument": "error",
|
|
2970
3093
|
"@typescript-eslint/no-unsafe-assignment": "error",
|
|
2971
3094
|
"@typescript-eslint/no-unsafe-call": "error",
|
|
3095
|
+
"@typescript-eslint/no-unsafe-class-instance-assignment": "error",
|
|
2972
3096
|
"@typescript-eslint/no-unsafe-member-access": "error",
|
|
2973
3097
|
"@typescript-eslint/no-unsafe-return": "error",
|
|
2974
3098
|
"@typescript-eslint/only-throw-error": "error",
|
|
@@ -3003,7 +3127,11 @@ const configTypeScript = (options = {}) => {
|
|
|
3003
3127
|
* @see {@link https://typescript-eslint.io/troubleshooting/typed-linting}
|
|
3004
3128
|
*/
|
|
3005
3129
|
const enableTypeAwareLint = !!options?.tsconfigPath;
|
|
3006
|
-
const { allowDefaultProject = [], ecmaVersion = "latest", extraFileExtensions = [], filesTypeAware = [GLOB_TS, GLOB_TSX], ignoresTypeAware = [
|
|
3130
|
+
const { allowDefaultProject = [], ecmaVersion = "latest", extraFileExtensions = [], filesTypeAware = [GLOB_TS, GLOB_TSX], ignoresTypeAware = [
|
|
3131
|
+
GLOB_ASTRO,
|
|
3132
|
+
GLOB_ASTRO_TS,
|
|
3133
|
+
`${GLOB_MARKDOWN}/**`
|
|
3134
|
+
], overridesTypeAwareRules = {}, parserOptions = {} } = options;
|
|
3007
3135
|
const files = options.files ?? [
|
|
3008
3136
|
"**/*.?([cm])ts",
|
|
3009
3137
|
"**/*.?([cm])tsx",
|
|
@@ -3413,6 +3541,9 @@ function defineESLintConfig(options = {}, ...userConfigs) {
|
|
|
3413
3541
|
if (enableVue) extraFileExtensions.push(".vue");
|
|
3414
3542
|
if (enableAstro) extraFileExtensions.push(".astro");
|
|
3415
3543
|
if (enableSvelte) extraFileExtensions.push(".svelte");
|
|
3544
|
+
function mergeExtraFileExtensions(moduleExtensions = []) {
|
|
3545
|
+
return [.../* @__PURE__ */ new Set([...extraFileExtensions, ...moduleExtensions])];
|
|
3546
|
+
}
|
|
3416
3547
|
if (enableGitIgnore) configs.push(configGitIgnore(resolveSubOptions(options, "gitignore")));
|
|
3417
3548
|
configs.push(configIgnores(userIgnores), configJSX(), configNode({ overrides: getOverrides(options, "node") }), configCommand(resolveSubOptions(options, "command")), configESLintComments({ overrides: getOverrides(options, "eslintComments") }), configJavaScript({
|
|
3418
3549
|
ecmaVersion,
|
|
@@ -3442,20 +3573,26 @@ function defineESLintConfig(options = {}, ...userConfigs) {
|
|
|
3442
3573
|
...resolveSubOptions(options, "regexp"),
|
|
3443
3574
|
overrides: getOverrides(options, "regexp")
|
|
3444
3575
|
}));
|
|
3445
|
-
if (enableTypeScript)
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3576
|
+
if (enableTypeScript) {
|
|
3577
|
+
const typescriptOptions = resolveSubOptions(options, "typescript");
|
|
3578
|
+
configs.push(configTypeScript({
|
|
3579
|
+
ecmaVersion,
|
|
3580
|
+
...typescriptOptions,
|
|
3581
|
+
overrides: getOverrides(options, "typescript"),
|
|
3582
|
+
extraFileExtensions: mergeExtraFileExtensions(typescriptOptions.extraFileExtensions)
|
|
3583
|
+
}));
|
|
3584
|
+
}
|
|
3585
|
+
if (enableVue) {
|
|
3586
|
+
const vueOptions = resolveSubOptions(options, "vue");
|
|
3587
|
+
configs.push(configVue({
|
|
3588
|
+
ecmaVersion,
|
|
3589
|
+
usingFormatter: !!usingFormatter,
|
|
3590
|
+
typescript: !!enableTypeScript,
|
|
3591
|
+
...vueOptions,
|
|
3592
|
+
overrides: getOverrides(options, "vue"),
|
|
3593
|
+
extraFileExtensions: mergeExtraFileExtensions(vueOptions.extraFileExtensions)
|
|
3594
|
+
}));
|
|
3595
|
+
}
|
|
3459
3596
|
if (enableYML) configs.push(configYml({
|
|
3460
3597
|
usingFormatter: !!usingFormatter,
|
|
3461
3598
|
...resolveSubOptions(options, "yml"),
|
|
@@ -3470,43 +3607,57 @@ function defineESLintConfig(options = {}, ...userConfigs) {
|
|
|
3470
3607
|
...resolveSubOptions(options, "jsonc"),
|
|
3471
3608
|
overrides: getOverrides(options, "jsonc")
|
|
3472
3609
|
}));
|
|
3473
|
-
if (enableAstro)
|
|
3474
|
-
|
|
3475
|
-
|
|
3476
|
-
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
|
|
3610
|
+
if (enableAstro) {
|
|
3611
|
+
const astroOptions = resolveSubOptions(options, "astro");
|
|
3612
|
+
configs.push(configAstro({
|
|
3613
|
+
ecmaVersion,
|
|
3614
|
+
typescript: !!enableTypeScript,
|
|
3615
|
+
...astroOptions,
|
|
3616
|
+
overrides: getOverrides(options, "astro"),
|
|
3617
|
+
extraFileExtensions: mergeExtraFileExtensions(astroOptions.extraFileExtensions)
|
|
3618
|
+
}));
|
|
3619
|
+
}
|
|
3620
|
+
if (enableSvelte) {
|
|
3621
|
+
const svelteOptions = resolveSubOptions(options, "svelte");
|
|
3622
|
+
configs.push(configSvelte({
|
|
3623
|
+
ecmaVersion,
|
|
3624
|
+
typescript: !!enableTypeScript,
|
|
3625
|
+
...svelteOptions,
|
|
3626
|
+
overrides: getOverrides(options, "svelte"),
|
|
3627
|
+
extraFileExtensions: mergeExtraFileExtensions(svelteOptions.extraFileExtensions)
|
|
3628
|
+
}));
|
|
3629
|
+
}
|
|
3487
3630
|
if (enableSort) configs.push(configSort(resolveSubOptions(options, "sort")));
|
|
3488
3631
|
if (enableTest) configs.push(configTest(resolveSubOptions(options, "test")));
|
|
3489
|
-
if (enableUnoCSS) configs.push(configUnoCSS(
|
|
3490
|
-
if (enableMarkdown) configs.push(configMarkdown({
|
|
3491
|
-
...resolveSubOptions(options, "markdown"),
|
|
3492
|
-
overrides: getOverrides(options, "markdown"),
|
|
3493
|
-
extraFileExtensions
|
|
3494
|
-
}));
|
|
3632
|
+
if (enableUnoCSS) configs.push(configUnoCSS(resolveSubOptions(options, "unocss")));
|
|
3495
3633
|
if (enableAntfu) configs.push(configAntfu({ overrides: getOverrides(options, "antfu") }));
|
|
3496
3634
|
if (enableDepend) configs.push(configDepend({
|
|
3497
3635
|
...resolveSubOptions(options, "depend"),
|
|
3498
3636
|
overrides: getOverrides(options, "depend")
|
|
3499
3637
|
}));
|
|
3500
3638
|
if (enableNtnyq) configs.push(configNtnyq({ overrides: getOverrides(options, "ntnyq") }));
|
|
3501
|
-
if (enableGitHubAction) configs.push(configGitHubAction(
|
|
3639
|
+
if (enableGitHubAction) configs.push(configGitHubAction(resolveSubOptions(options, "githubAction")));
|
|
3502
3640
|
if (enableESLintPlugin) configs.push(configESLintPlugin({ overrides: getOverrides(options, "eslintPlugin") }));
|
|
3503
3641
|
if (enablePnpm) configs.push(configPnpm(resolveSubOptions(options, "pnpm")));
|
|
3504
3642
|
if (enableSVGO) configs.push(configSVGO(resolveSubOptions(options, "svgo")));
|
|
3505
3643
|
if (enableUnusedImports) configs.push(configUnusedImports({ overrides: getOverrides(options, "unusedImports") }));
|
|
3644
|
+
if (enableMarkdown) {
|
|
3645
|
+
const markdownOptions = resolveSubOptions(options, "markdown");
|
|
3646
|
+
configs.push(configMarkdown({
|
|
3647
|
+
...markdownOptions,
|
|
3648
|
+
overrides: getOverrides(options, "markdown"),
|
|
3649
|
+
extraFileExtensions: mergeExtraFileExtensions(markdownOptions.extraFileExtensions)
|
|
3650
|
+
}));
|
|
3651
|
+
}
|
|
3652
|
+
const useOxfmt = options.__DEV__ || !enablePrettier && !!enableOxfmt;
|
|
3653
|
+
const [oxfmtParserConfig, ...oxfmtRuleConfigs] = configOxfmt({
|
|
3654
|
+
...resolveSubOptions(options, "oxfmt"),
|
|
3655
|
+
overrides: getOverrides(options, "oxfmt")
|
|
3656
|
+
});
|
|
3506
3657
|
if (enableHTML) configs.push(configHtml({
|
|
3507
3658
|
...resolveSubOptions(options, "html"),
|
|
3508
3659
|
overrides: getOverrides(options, "html")
|
|
3509
|
-
}));
|
|
3660
|
+
}, useOxfmt ? oxfmtRuleConfigs : []));
|
|
3510
3661
|
if (enableSpecials) configs.push(configSpecials(resolveSubOptions(options, "specials")));
|
|
3511
3662
|
if (enableShell) configs.push(configShell({
|
|
3512
3663
|
...resolveSubOptions(options, "shell"),
|
|
@@ -3517,13 +3668,11 @@ function defineESLintConfig(options = {}, ...userConfigs) {
|
|
|
3517
3668
|
...resolveSubOptions(options, "prettier"),
|
|
3518
3669
|
overrides: getOverrides(options, "prettier")
|
|
3519
3670
|
});
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
else if (enablePrettier) formatterConfigs.push(...prettierConfigs);
|
|
3526
|
-
else if (enableOxfmt) formatterConfigs.push(...oxfmtConfigs);
|
|
3671
|
+
if (options.__DEV__ || enablePrettier) formatterConfigs.push(...prettierConfigs);
|
|
3672
|
+
if (useOxfmt) {
|
|
3673
|
+
configs.unshift(oxfmtParserConfig);
|
|
3674
|
+
formatterConfigs.push(...oxfmtRuleConfigs);
|
|
3675
|
+
}
|
|
3527
3676
|
const composer = new FlatConfigComposer(...configs, ...userConfigs, ...formatterConfigs);
|
|
3528
3677
|
if (enableShell) {
|
|
3529
3678
|
const { files = [GLOB_SHELL] } = resolveSubOptions(options, "shell");
|
|
@@ -3531,4 +3680,4 @@ function defineESLintConfig(options = {}, ...userConfigs) {
|
|
|
3531
3680
|
}
|
|
3532
3681
|
return composer;
|
|
3533
3682
|
}
|
|
3534
|
-
export { GLOB_ALL_SRC, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CSS, GLOB_DIST, GLOB_DTS, GLOB_EXCLUDE, GLOB_GITHUB_ACTION, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSON_SCHEMA, GLOB_JSX, GLOB_JSX_ONLY, GLOB_LESS, GLOB_LOCKFILE, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_NESTED, GLOB_NODE_MODULES, GLOB_PACKAGE_JSON, GLOB_PINIA_STORE, GLOB_PNPM_WORKSPACE_YAML, GLOB_POSTCSS, GLOB_SCSS, GLOB_SHELL, GLOB_SRC, GLOB_SRC_EXT, GLOB_SRC_EXTENSIONS, GLOB_STYLE, GLOB_SVELTE, GLOB_SVG, GLOB_TEST, GLOB_TOML, GLOB_TS, GLOB_TSCONFIG_JSON, GLOB_TSX, GLOB_TSX_ONLY, GLOB_TYPES, GLOB_TYPE_TEST, GLOB_VUE, GLOB_VUE_COMPOSABLES, GLOB_YAML, PERFECTIONIST, configAntfu, configAstro, configCommand, configDeMorgan, configDepend, configESLintComments, configESLintPlugin, configGitHubAction, configGitIgnore, configHtml, configIgnores, configImportX, configJSX, configJavaScript, configJsdoc, configJsonc, configMarkdown, configNode, configNtnyq, configOxfmt, configPerfectionist, configPinia, configPnpm, configPrettier, configRegexp, configSVGO, configShell, configSort, configSpecials, configSvelte, configTest, configToml, configTypeScript, configUnicorn, configUnoCSS, configUnusedImports, configVue, configYml, configsTypeScript, defineESLintConfig, ensurePackages, getOverrides, hasAutoImport, hasOxfmt, hasPinia, hasPrettier, hasShadcnVue, hasTypeScript, hasUnoCSS, hasVitest, hasVue, interopDefault, isInGitHooksOrRunBySpecifyPackages, mergeProcessors, parserJsonc, parserPlain, parserToml, parserTypeScript, parserVue, parserYaml, pluginAntfu, pluginDeMorgan, pluginDepend, pluginESLintComments, pluginGitHubAction, pluginImportX, pluginJsdoc, pluginJsonc, pluginMarkdown,
|
|
3683
|
+
export { GLOB_ALL_SRC, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CSS, GLOB_DIST, GLOB_DTS, GLOB_EXCLUDE, GLOB_GITHUB_ACTION, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSON_SCHEMA, GLOB_JSX, GLOB_JSX_ONLY, GLOB_LESS, GLOB_LOCKFILE, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_NESTED, GLOB_NODE_MODULES, GLOB_PACKAGE_JSON, GLOB_PINIA_STORE, GLOB_PNPM_WORKSPACE_YAML, GLOB_POSTCSS, GLOB_SCSS, GLOB_SHELL, GLOB_SRC, GLOB_SRC_EXT, GLOB_SRC_EXTENSIONS, GLOB_STYLE, GLOB_SVELTE, GLOB_SVG, GLOB_TEST, GLOB_TOML, GLOB_TS, GLOB_TSCONFIG_JSON, GLOB_TSX, GLOB_TSX_ONLY, GLOB_TYPES, GLOB_TYPE_TEST, GLOB_VUE, GLOB_VUE_COMPOSABLES, GLOB_YAML, PERFECTIONIST, configAntfu, configAstro, configCommand, configDeMorgan, configDepend, configESLintComments, configESLintPlugin, configGitHubAction, configGitIgnore, configHtml, configIgnores, configImportX, configJSX, configJavaScript, configJsdoc, configJsonc, configMarkdown, configNode, configNtnyq, configOxfmt, configPerfectionist, configPinia, configPnpm, configPrettier, configRegexp, configSVGO, configShell, configSort, configSpecials, configSvelte, configTest, configToml, configTypeScript, configUnicorn, configUnoCSS, configUnusedImports, configVue, configYml, configsTypeScript, defineESLintConfig, ensurePackages, getOverrides, hasAutoImport, hasOxfmt, hasPinia, hasPrettier, hasShadcnVue, hasTypeScript, hasUnoCSS, hasVitest, hasVue, interopDefault, isInGitHooksOrRunBySpecifyPackages, mergeProcessors, parserJsonc, parserPlain, parserToml, parserTypeScript, parserVue, parserYaml, pluginAntfu, pluginDeMorgan, pluginDepend, pluginESLintComments, pluginGitHubAction, pluginImportX, pluginJsdoc, pluginJsonc, pluginMarkdown, pluginNode, pluginNtnyq, pluginOxfmt, pluginPerfectionist, pluginPinia, pluginPrettier, pluginRegexp, pluginSvgo, pluginToml, pluginTypeScript, pluginUnicorn, pluginUnoCSS, pluginVitest, pluginVue, pluginVuePerfectionist, pluginYml, processorPassThrough, processorVueBlocks, resolveSubOptions };
|