@ntnyq/eslint-config 5.0.0-beta.2 → 5.0.0-beta.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/README.md +28 -8
- package/dist/index.d.ts +670 -127
- package/dist/index.js +162 -56
- package/package.json +40 -19
package/dist/index.js
CHANGED
|
@@ -10,7 +10,6 @@ import * as pluginRegexp from "eslint-plugin-regexp";
|
|
|
10
10
|
import pluginNode from "eslint-plugin-n";
|
|
11
11
|
import pluginVue from "eslint-plugin-vue";
|
|
12
12
|
import pluginYml from "eslint-plugin-yml";
|
|
13
|
-
import pluginPnpm from "eslint-plugin-pnpm";
|
|
14
13
|
import pluginSvgo from "eslint-plugin-svgo";
|
|
15
14
|
import pluginToml from "eslint-plugin-toml";
|
|
16
15
|
import pluginMarkdown from "@eslint/markdown";
|
|
@@ -678,7 +677,9 @@ const configNode = (options = {}) => [{
|
|
|
678
677
|
* @param options - {@link ConfigPnpmOptions}
|
|
679
678
|
* @returns ESLint configs
|
|
680
679
|
*/
|
|
681
|
-
const configPnpm = (options = {}) => {
|
|
680
|
+
const configPnpm = async (options = {}) => {
|
|
681
|
+
await ensurePackages(["eslint-plugin-pnpm"]);
|
|
682
|
+
const pluginPnpm = await interopDefault(import("eslint-plugin-pnpm"));
|
|
682
683
|
const { filesJson = [GLOB_PACKAGE_JSON], filesYaml = [GLOB_PNPM_WORKSPACE_YAML] } = options;
|
|
683
684
|
return [{
|
|
684
685
|
name: "ntnyq/pnpm/package-json",
|
|
@@ -1563,9 +1564,9 @@ const PRETTIER_DEFAULT_OPTIONS = {
|
|
|
1563
1564
|
//#endregion
|
|
1564
1565
|
//#region src/constants/perfectionist.ts
|
|
1565
1566
|
/**
|
|
1566
|
-
* Shared perfectionist
|
|
1567
|
+
* Shared perfectionist plugin settings
|
|
1567
1568
|
*/
|
|
1568
|
-
const
|
|
1569
|
+
const pluginSettings = {
|
|
1569
1570
|
fallbackSort: {
|
|
1570
1571
|
order: "asc",
|
|
1571
1572
|
type: "alphabetical"
|
|
@@ -1579,7 +1580,7 @@ const PERFECTIONIST_PLUGIN_SETTINGS = {
|
|
|
1579
1580
|
/**
|
|
1580
1581
|
* Shared perfectionist rule options for some rules
|
|
1581
1582
|
*/
|
|
1582
|
-
const
|
|
1583
|
+
const partialRuleOptions = {
|
|
1583
1584
|
newlinesBetween: "ignore",
|
|
1584
1585
|
partitionByComment: ["@pg", "@perfectionist-group"]
|
|
1585
1586
|
};
|
|
@@ -1588,7 +1589,7 @@ const PERFECTIONIST_EXTRA_RULE_OPTIONS = {
|
|
|
1588
1589
|
*
|
|
1589
1590
|
* @see {@link https://perfectionist.dev/rules/sort-objects}
|
|
1590
1591
|
*/
|
|
1591
|
-
const
|
|
1592
|
+
const sortObjectsGroups = [
|
|
1592
1593
|
"property",
|
|
1593
1594
|
"multiline-property",
|
|
1594
1595
|
"method",
|
|
@@ -1603,7 +1604,7 @@ const PERFECTIONIST_SORT_OBJECTS_GROUPS = [
|
|
|
1603
1604
|
* @see {@link https://perfectionist.dev/rules/sort-interfaces}
|
|
1604
1605
|
* @see {@link https://perfectionist.dev/rules/sort-object-types}
|
|
1605
1606
|
*/
|
|
1606
|
-
const
|
|
1607
|
+
const sortInterfacesOrObjectTypesGroups = [
|
|
1607
1608
|
"required-property",
|
|
1608
1609
|
"optional-property",
|
|
1609
1610
|
"required-method",
|
|
@@ -1626,7 +1627,7 @@ const PERFECTIONIST_SORT_INTERFACES_OR_OBJECT_TYPES_GROUPS = [
|
|
|
1626
1627
|
* @see {@link https://perfectionist.dev/rules/sort-intersection-types}
|
|
1627
1628
|
* @see {@link https://perfectionist.dev/rules/sort-union-types}
|
|
1628
1629
|
*/
|
|
1629
|
-
const
|
|
1630
|
+
const sortIntersectionTypesOrUnionTypesGroups = [
|
|
1630
1631
|
"literal",
|
|
1631
1632
|
"keyword",
|
|
1632
1633
|
"named",
|
|
@@ -1645,7 +1646,7 @@ const PERFECTIONIST_SORT_INTERSECTION_TYPES_OR_UNION_TYPES_GROUPS = [
|
|
|
1645
1646
|
*
|
|
1646
1647
|
* @see {@link https://perfectionist.dev/rules/sort-imports}
|
|
1647
1648
|
*/
|
|
1648
|
-
const
|
|
1649
|
+
const sortImportsTypes = [
|
|
1649
1650
|
"side-effect-style",
|
|
1650
1651
|
"value-style",
|
|
1651
1652
|
"value-builtin",
|
|
@@ -1671,7 +1672,7 @@ const PERFECTIONIST_SORT_IMPORTS_GROUPS = [
|
|
|
1671
1672
|
*
|
|
1672
1673
|
* @see {@link https://perfectionist.dev/rules/sort-exports}
|
|
1673
1674
|
*/
|
|
1674
|
-
const
|
|
1675
|
+
const sortExportsGroups = [
|
|
1675
1676
|
"value-export",
|
|
1676
1677
|
"type-export",
|
|
1677
1678
|
"unknown"
|
|
@@ -1681,7 +1682,7 @@ const PERFECTIONIST_SORT_EXPORTS_GROUPS = [
|
|
|
1681
1682
|
*
|
|
1682
1683
|
* @see {@link https://perfectionist.dev/rules/sort-named-exports}
|
|
1683
1684
|
*/
|
|
1684
|
-
const
|
|
1685
|
+
const sortNamedExportsGroups = [
|
|
1685
1686
|
"value-export",
|
|
1686
1687
|
"type-export",
|
|
1687
1688
|
"unknown"
|
|
@@ -1691,7 +1692,7 @@ const PERFECTIONIST_SORT_NAMED_EXPORTS_GROUPS = [
|
|
|
1691
1692
|
*
|
|
1692
1693
|
* @see {@link https://perfectionist.dev/rules/sort-named-imports}
|
|
1693
1694
|
*/
|
|
1694
|
-
const
|
|
1695
|
+
const sortNamedImportsGroups = [
|
|
1695
1696
|
"value-import",
|
|
1696
1697
|
"type-import",
|
|
1697
1698
|
"unknown"
|
|
@@ -1703,7 +1704,22 @@ const PERFECTIONIST_SORT_NAMED_IMPORTS_GROUPS = [
|
|
|
1703
1704
|
*
|
|
1704
1705
|
* @see {@link https://perfectionist.dev/rules/sort-classes}
|
|
1705
1706
|
*/
|
|
1706
|
-
const
|
|
1707
|
+
const sortClassesGroups = ["unknown"];
|
|
1708
|
+
/**
|
|
1709
|
+
* Shared constants about eslint-plugin-perfectionist
|
|
1710
|
+
*/
|
|
1711
|
+
const PERFECTIONIST = Object.freeze({
|
|
1712
|
+
partialRuleOptions,
|
|
1713
|
+
pluginSettings,
|
|
1714
|
+
sortClassesGroups,
|
|
1715
|
+
sortExportsGroups,
|
|
1716
|
+
sortImportsTypes,
|
|
1717
|
+
sortInterfacesOrObjectTypesGroups,
|
|
1718
|
+
sortIntersectionTypesOrUnionTypesGroups,
|
|
1719
|
+
sortNamedExportsGroups,
|
|
1720
|
+
sortNamedImportsGroups,
|
|
1721
|
+
sortObjectsGroups
|
|
1722
|
+
});
|
|
1707
1723
|
|
|
1708
1724
|
//#endregion
|
|
1709
1725
|
//#region src/configs/format.ts
|
|
@@ -1778,6 +1794,94 @@ const configRegexp = (options = {}) => {
|
|
|
1778
1794
|
}];
|
|
1779
1795
|
};
|
|
1780
1796
|
|
|
1797
|
+
//#endregion
|
|
1798
|
+
//#region src/configs/svelte.ts
|
|
1799
|
+
/**
|
|
1800
|
+
* Config for svelte files
|
|
1801
|
+
*
|
|
1802
|
+
* @see {@link https://github.com/ota-meshi/eslint-plugin-svelte}
|
|
1803
|
+
*
|
|
1804
|
+
* @param options - {@link ConfigSvelteOptions}
|
|
1805
|
+
* @returns ESLint configs
|
|
1806
|
+
*/
|
|
1807
|
+
const configSvelte = async (options = {}) => {
|
|
1808
|
+
await ensurePackages(["svelte-eslint-parser", "eslint-plugin-svelte"]);
|
|
1809
|
+
const [parserSvelte, pluginSvelte] = await Promise.all([interopDefault(import("svelte-eslint-parser")), interopDefault(import("eslint-plugin-svelte"))]);
|
|
1810
|
+
const { files = [GLOB_SVELTE], extraFileExtensions = [] } = options;
|
|
1811
|
+
return [{
|
|
1812
|
+
name: "ntnyq/svelte",
|
|
1813
|
+
files,
|
|
1814
|
+
plugins: { svelte: pluginSvelte },
|
|
1815
|
+
processor: pluginSvelte.processors[".svelte"],
|
|
1816
|
+
languageOptions: {
|
|
1817
|
+
parser: parserSvelte,
|
|
1818
|
+
sourceType: "module",
|
|
1819
|
+
parserOptions: {
|
|
1820
|
+
extraFileExtensions,
|
|
1821
|
+
parser: parserTypeScript
|
|
1822
|
+
}
|
|
1823
|
+
},
|
|
1824
|
+
rules: {
|
|
1825
|
+
"import-x/no-mutable-exports": "off",
|
|
1826
|
+
"no-undef": "off",
|
|
1827
|
+
"no-unused-vars": ["error", {
|
|
1828
|
+
args: "none",
|
|
1829
|
+
caughtErrors: "none",
|
|
1830
|
+
ignoreRestSiblings: true,
|
|
1831
|
+
vars: "all",
|
|
1832
|
+
varsIgnorePattern: "^(\\$\\$Props$|\\$\\$Events$|\\$\\$Slots$)"
|
|
1833
|
+
}],
|
|
1834
|
+
"svelte/comment-directive": "error",
|
|
1835
|
+
"svelte/derived-has-same-inputs-outputs": "error",
|
|
1836
|
+
"svelte/html-closing-bracket-spacing": "error",
|
|
1837
|
+
"svelte/html-quotes": ["error", {
|
|
1838
|
+
prefer: "double",
|
|
1839
|
+
dynamic: {
|
|
1840
|
+
avoidInvalidUnquotedInHTML: false,
|
|
1841
|
+
quoted: true
|
|
1842
|
+
}
|
|
1843
|
+
}],
|
|
1844
|
+
"svelte/indent": ["error", {
|
|
1845
|
+
alignAttributesVertically: true,
|
|
1846
|
+
indent: 2,
|
|
1847
|
+
indentScript: false
|
|
1848
|
+
}],
|
|
1849
|
+
"svelte/mustache-spacing": ["error", {
|
|
1850
|
+
attributesAndProps: "never",
|
|
1851
|
+
directiveExpressions: "always",
|
|
1852
|
+
textExpressions: "always",
|
|
1853
|
+
tags: {
|
|
1854
|
+
closingBrace: "always",
|
|
1855
|
+
openingBrace: "always"
|
|
1856
|
+
}
|
|
1857
|
+
}],
|
|
1858
|
+
"svelte/no-at-debug-tags": "error",
|
|
1859
|
+
"svelte/no-at-html-tags": "error",
|
|
1860
|
+
"svelte/no-dupe-else-if-blocks": "error",
|
|
1861
|
+
"svelte/no-dupe-style-properties": "error",
|
|
1862
|
+
"svelte/no-dupe-use-directives": "error",
|
|
1863
|
+
"svelte/no-dynamic-slot-name": "error",
|
|
1864
|
+
"svelte/no-export-load-in-svelte-module-in-kit-pages": "error",
|
|
1865
|
+
"svelte/no-inner-declarations": "error",
|
|
1866
|
+
"svelte/no-not-function-handler": "error",
|
|
1867
|
+
"svelte/no-object-in-text-mustaches": "error",
|
|
1868
|
+
"svelte/no-reactive-functions": "error",
|
|
1869
|
+
"svelte/no-reactive-literals": "error",
|
|
1870
|
+
"svelte/no-shorthand-style-property-overrides": "error",
|
|
1871
|
+
"svelte/no-spaces-around-equal-signs-in-attribute": "error",
|
|
1872
|
+
"svelte/no-trailing-spaces": "error",
|
|
1873
|
+
"svelte/no-unknown-style-directive-property": "error",
|
|
1874
|
+
"svelte/no-unused-svelte-ignore": "error",
|
|
1875
|
+
"svelte/no-useless-mustaches": "error",
|
|
1876
|
+
"svelte/require-store-callbacks-use-set-param": "error",
|
|
1877
|
+
"svelte/spaced-html-comment": "error",
|
|
1878
|
+
"svelte/system": "error",
|
|
1879
|
+
"svelte/valid-each-key": "error",
|
|
1880
|
+
...options.overrides
|
|
1881
|
+
}
|
|
1882
|
+
}];
|
|
1883
|
+
};
|
|
1884
|
+
|
|
1781
1885
|
//#endregion
|
|
1782
1886
|
//#region src/configs/unocss.ts
|
|
1783
1887
|
/**
|
|
@@ -2217,14 +2321,14 @@ const configSpecials = (options = {}) => {
|
|
|
2217
2321
|
"import-x": pluginImportX,
|
|
2218
2322
|
perfectionist: pluginPerfectionist
|
|
2219
2323
|
},
|
|
2220
|
-
settings: { perfectionist:
|
|
2324
|
+
settings: { perfectionist: PERFECTIONIST.pluginSettings },
|
|
2221
2325
|
rules: {
|
|
2222
2326
|
"@typescript-eslint/explicit-function-return-type": "off",
|
|
2223
2327
|
"import-x/no-default-export": "off",
|
|
2224
2328
|
"no-console": "off",
|
|
2225
2329
|
"perfectionist/sort-objects": ["error", {
|
|
2226
|
-
...
|
|
2227
|
-
groups:
|
|
2330
|
+
...PERFECTIONIST.partialRuleOptions,
|
|
2331
|
+
groups: PERFECTIONIST.sortObjectsGroups
|
|
2228
2332
|
}],
|
|
2229
2333
|
...options.overridesConfigFileRules
|
|
2230
2334
|
}
|
|
@@ -2326,7 +2430,7 @@ const configJavaScript = (options = {}) => [{
|
|
|
2326
2430
|
properties: "never"
|
|
2327
2431
|
}],
|
|
2328
2432
|
"constructor-super": "error",
|
|
2329
|
-
curly: ["error", "
|
|
2433
|
+
curly: ["error", "all"],
|
|
2330
2434
|
"default-case-last": "error",
|
|
2331
2435
|
"dot-notation": ["error", { allowKeywords: true }],
|
|
2332
2436
|
eqeqeq: ["error", "smart"],
|
|
@@ -2733,7 +2837,7 @@ const configGitHubAction = (options = {}) => {
|
|
|
2733
2837
|
* @returns ESLint configs
|
|
2734
2838
|
*/
|
|
2735
2839
|
const configPerfectionist = (options = {}) => {
|
|
2736
|
-
const { partitionByComment =
|
|
2840
|
+
const { partitionByComment = PERFECTIONIST.partialRuleOptions.partitionByComment, sortConstants: enableSortConstants = true, sortEnums: enableSortEnums = true, sortTypes: enableSortTypes = true } = options;
|
|
2737
2841
|
const sharedOptionsWithNewlinesBetween = {
|
|
2738
2842
|
newlinesBetween: "ignore",
|
|
2739
2843
|
partitionByComment
|
|
@@ -2741,12 +2845,12 @@ const configPerfectionist = (options = {}) => {
|
|
|
2741
2845
|
const commonRules = {
|
|
2742
2846
|
"perfectionist/sort-exports": ["error", {
|
|
2743
2847
|
...sharedOptionsWithNewlinesBetween,
|
|
2744
|
-
groups:
|
|
2848
|
+
groups: PERFECTIONIST.sortExportsGroups,
|
|
2745
2849
|
type: "line-length"
|
|
2746
2850
|
}],
|
|
2747
2851
|
"perfectionist/sort-imports": ["error", {
|
|
2748
2852
|
...sharedOptionsWithNewlinesBetween,
|
|
2749
|
-
groups:
|
|
2853
|
+
groups: PERFECTIONIST.sortImportsTypes,
|
|
2750
2854
|
internalPattern: [
|
|
2751
2855
|
"^~/.+",
|
|
2752
2856
|
"^@/.+",
|
|
@@ -2755,12 +2859,12 @@ const configPerfectionist = (options = {}) => {
|
|
|
2755
2859
|
}],
|
|
2756
2860
|
"perfectionist/sort-named-exports": ["error", {
|
|
2757
2861
|
...sharedOptionsWithNewlinesBetween,
|
|
2758
|
-
groups:
|
|
2862
|
+
groups: PERFECTIONIST.sortNamedExportsGroups,
|
|
2759
2863
|
ignoreAlias: false
|
|
2760
2864
|
}],
|
|
2761
2865
|
"perfectionist/sort-named-imports": ["error", {
|
|
2762
2866
|
...sharedOptionsWithNewlinesBetween,
|
|
2763
|
-
groups:
|
|
2867
|
+
groups: PERFECTIONIST.sortNamedImportsGroups,
|
|
2764
2868
|
ignoreAlias: false
|
|
2765
2869
|
}]
|
|
2766
2870
|
};
|
|
@@ -2770,26 +2874,26 @@ const configPerfectionist = (options = {}) => {
|
|
|
2770
2874
|
"perfectionist/sort-heritage-clauses": "error",
|
|
2771
2875
|
"perfectionist/sort-interfaces": ["error", {
|
|
2772
2876
|
...sharedOptionsWithNewlinesBetween,
|
|
2773
|
-
groups:
|
|
2877
|
+
groups: PERFECTIONIST.sortInterfacesOrObjectTypesGroups
|
|
2774
2878
|
}],
|
|
2775
2879
|
"perfectionist/sort-intersection-types": ["error", {
|
|
2776
2880
|
...sharedOptionsWithNewlinesBetween,
|
|
2777
|
-
groups:
|
|
2881
|
+
groups: PERFECTIONIST.sortIntersectionTypesOrUnionTypesGroups
|
|
2778
2882
|
}],
|
|
2779
2883
|
"perfectionist/sort-object-types": ["error", {
|
|
2780
2884
|
...sharedOptionsWithNewlinesBetween,
|
|
2781
|
-
groups:
|
|
2885
|
+
groups: PERFECTIONIST.sortInterfacesOrObjectTypesGroups
|
|
2782
2886
|
}],
|
|
2783
2887
|
"perfectionist/sort-union-types": ["error", {
|
|
2784
2888
|
...sharedOptionsWithNewlinesBetween,
|
|
2785
|
-
groups:
|
|
2889
|
+
groups: PERFECTIONIST.sortIntersectionTypesOrUnionTypesGroups
|
|
2786
2890
|
}]
|
|
2787
2891
|
};
|
|
2788
2892
|
const sortConstantsRules = {
|
|
2789
2893
|
"perfectionist/sort-maps": ["error", { ...sharedOptionsWithNewlinesBetween }],
|
|
2790
2894
|
"perfectionist/sort-objects": ["error", {
|
|
2791
2895
|
...sharedOptionsWithNewlinesBetween,
|
|
2792
|
-
groups:
|
|
2896
|
+
groups: PERFECTIONIST.sortObjectsGroups
|
|
2793
2897
|
}],
|
|
2794
2898
|
"perfectionist/sort-sets": ["error", { ...sharedOptionsWithNewlinesBetween }]
|
|
2795
2899
|
};
|
|
@@ -2800,7 +2904,7 @@ const configPerfectionist = (options = {}) => {
|
|
|
2800
2904
|
}],
|
|
2801
2905
|
"perfectionist/sort-classes": ["error", {
|
|
2802
2906
|
...sharedOptionsWithNewlinesBetween,
|
|
2803
|
-
groups:
|
|
2907
|
+
groups: PERFECTIONIST.sortClassesGroups
|
|
2804
2908
|
}],
|
|
2805
2909
|
"perfectionist/sort-decorators": ["error", { partitionByComment }],
|
|
2806
2910
|
"perfectionist/sort-jsx-props": ["error", { groups: [
|
|
@@ -2814,7 +2918,7 @@ const configPerfectionist = (options = {}) => {
|
|
|
2814
2918
|
const configs = [{
|
|
2815
2919
|
name: options.all ? "ntnyq/perfectionist/all" : "ntnyq/perfectionist/common",
|
|
2816
2920
|
plugins: { perfectionist: pluginPerfectionist },
|
|
2817
|
-
settings: { perfectionist:
|
|
2921
|
+
settings: { perfectionist: PERFECTIONIST.pluginSettings },
|
|
2818
2922
|
rules: {
|
|
2819
2923
|
...commonRules,
|
|
2820
2924
|
...options.all ? {
|
|
@@ -2832,7 +2936,7 @@ const configPerfectionist = (options = {}) => {
|
|
|
2832
2936
|
name: "ntnyq/perfectionist/enums",
|
|
2833
2937
|
files: [`**/enums/${GLOB_SRC}`, `**/enums.${GLOB_SRC_EXT}`],
|
|
2834
2938
|
plugins: { perfectionist: pluginPerfectionist },
|
|
2835
|
-
settings: { perfectionist:
|
|
2939
|
+
settings: { perfectionist: PERFECTIONIST.pluginSettings },
|
|
2836
2940
|
rules: {
|
|
2837
2941
|
...sharedRules$1,
|
|
2838
2942
|
...sortEnumsRules,
|
|
@@ -2843,7 +2947,7 @@ const configPerfectionist = (options = {}) => {
|
|
|
2843
2947
|
name: "ntnyq/perfectionist/types",
|
|
2844
2948
|
files: [...GLOB_TYPES],
|
|
2845
2949
|
plugins: { perfectionist: pluginPerfectionist },
|
|
2846
|
-
settings: { perfectionist:
|
|
2950
|
+
settings: { perfectionist: PERFECTIONIST.pluginSettings },
|
|
2847
2951
|
rules: {
|
|
2848
2952
|
...sharedRules$1,
|
|
2849
2953
|
...sortTypesRules,
|
|
@@ -2854,7 +2958,7 @@ const configPerfectionist = (options = {}) => {
|
|
|
2854
2958
|
name: "ntnyq/perfectionist/constants",
|
|
2855
2959
|
files: [`**/constants/${GLOB_SRC}`, `**/constants.${GLOB_SRC_EXT}`],
|
|
2856
2960
|
plugins: { perfectionist: pluginPerfectionist },
|
|
2857
|
-
settings: { perfectionist:
|
|
2961
|
+
settings: { perfectionist: PERFECTIONIST.pluginSettings },
|
|
2858
2962
|
rules: {
|
|
2859
2963
|
...sharedRules$1,
|
|
2860
2964
|
...sortConstantsRules,
|
|
@@ -2924,24 +3028,27 @@ const configESLintComments = (options = {}) => [{
|
|
|
2924
3028
|
* Config factory
|
|
2925
3029
|
*/
|
|
2926
3030
|
function defineESLintConfig(options = {}, ...userConfigs) {
|
|
2927
|
-
const { shareable = {}, vue: enableVue = hasVue(), pinia: enablePinia = hasPinia(), test: enableTest = hasVitest(), unocss: enableUnoCSS = hasUnoCSS(), typescript: enableTypeScript = hasTypeScript(), yml: enableYML = true, sort: enableSort = true, toml: enableTOML = true, jsonc: enableJSONC = true, antfu: enableAntfu = true, ntnyq: enableNtnyq = true, depend: enableDepend = true, regexp: enableRegexp = true, unicorn: enableUnicorn = true, deMorgan: enableDeMorgan = true, prettier: enablePrettier = true, markdown: enableMarkdown = true, gitignore: enableGitIgnore = true, githubAction: enableGitHubAction = true, perfectionist: enablePerfectionist = true, pnpm: enablePnpm = false, svgo: enableSVGO = false, html: enableHTML = false, astro: enableAstro = false, eslintPlugin: enableESLintPlugin = false } = options;
|
|
3031
|
+
const { shareable = {}, vue: enableVue = hasVue(), pinia: enablePinia = hasPinia(), test: enableTest = hasVitest(), unocss: enableUnoCSS = hasUnoCSS(), typescript: enableTypeScript = hasTypeScript(), yml: enableYML = true, sort: enableSort = true, toml: enableTOML = true, jsonc: enableJSONC = true, antfu: enableAntfu = true, ntnyq: enableNtnyq = true, depend: enableDepend = true, regexp: enableRegexp = true, unicorn: enableUnicorn = true, deMorgan: enableDeMorgan = true, prettier: enablePrettier = true, markdown: enableMarkdown = true, gitignore: enableGitIgnore = true, jsdoc: enableJsdoc = true, importX: enableImportX = true, specials: enableSpecials = true, githubAction: enableGitHubAction = true, perfectionist: enablePerfectionist = true, pnpm: enablePnpm = false, svgo: enableSVGO = false, html: enableHTML = false, astro: enableAstro = false, svelte: enableSvelte = false, eslintPlugin: enableESLintPlugin = false } = options;
|
|
2928
3032
|
const configs = [];
|
|
2929
3033
|
const { extraFileExtensions = [] } = shareable;
|
|
2930
3034
|
if (enableVue) extraFileExtensions.push(".vue");
|
|
2931
3035
|
if (enableAstro) extraFileExtensions.push(".astro");
|
|
3036
|
+
if (enableSvelte) extraFileExtensions.push(".svelte");
|
|
2932
3037
|
if (enableGitIgnore) configs.push(configGitIgnore(resolveSubOptions(options, "gitignore")));
|
|
2933
|
-
configs.push(configIgnores(options.ignores), configJSX(), configNode({ overrides: getOverrides(options, "node") }), configCommand(resolveSubOptions(options, "command")),
|
|
2934
|
-
...resolveSubOptions(options, "
|
|
3038
|
+
configs.push(configIgnores(options.ignores), configJSX(), configNode({ overrides: getOverrides(options, "node") }), configCommand(resolveSubOptions(options, "command")), configESLintComments({ overrides: getOverrides(options, "eslintComments") }), configJavaScript({
|
|
3039
|
+
...resolveSubOptions(options, "javascript"),
|
|
3040
|
+
overrides: getOverrides(options, "javascript")
|
|
3041
|
+
}));
|
|
3042
|
+
if (enableImportX) configImportX({
|
|
2935
3043
|
typescript: !!enableTypeScript,
|
|
3044
|
+
...resolveSubOptions(options, "importX"),
|
|
2936
3045
|
overrides: getOverrides(options, "importX")
|
|
2937
|
-
})
|
|
3046
|
+
});
|
|
3047
|
+
if (enableJsdoc) configJsdoc({
|
|
2938
3048
|
typescript: !!enableTypeScript,
|
|
2939
3049
|
overrides: getOverrides(options, "jsdoc"),
|
|
2940
3050
|
...resolveSubOptions(options, "jsdoc")
|
|
2941
|
-
})
|
|
2942
|
-
...resolveSubOptions(options, "javascript"),
|
|
2943
|
-
overrides: getOverrides(options, "javascript")
|
|
2944
|
-
}));
|
|
3051
|
+
});
|
|
2945
3052
|
if (enablePerfectionist) configs.push(configPerfectionist({
|
|
2946
3053
|
...resolveSubOptions(options, "perfectionist"),
|
|
2947
3054
|
overrides: getOverrides(options, "perfectionist")
|
|
@@ -2981,6 +3088,18 @@ function defineESLintConfig(options = {}, ...userConfigs) {
|
|
|
2981
3088
|
...resolveSubOptions(options, "jsonc"),
|
|
2982
3089
|
overrides: getOverrides(options, "jsonc")
|
|
2983
3090
|
}));
|
|
3091
|
+
if (enableAstro) configs.push(configAstro({
|
|
3092
|
+
...resolveSubOptions(options, "astro"),
|
|
3093
|
+
typescript: !!enableTypeScript,
|
|
3094
|
+
overrides: getOverrides(options, "astro"),
|
|
3095
|
+
extraFileExtensions
|
|
3096
|
+
}));
|
|
3097
|
+
if (enableSvelte) configs.push(configSvelte({
|
|
3098
|
+
...resolveSubOptions(options, "svelte"),
|
|
3099
|
+
typescript: !!enableTypeScript,
|
|
3100
|
+
overrides: getOverrides(options, "svelte"),
|
|
3101
|
+
extraFileExtensions
|
|
3102
|
+
}));
|
|
2984
3103
|
if (enableSort) configs.push(configSort(resolveSubOptions(options, "sort")));
|
|
2985
3104
|
if (enableTest) configs.push(configTest({
|
|
2986
3105
|
...resolveSubOptions(options, "test"),
|
|
@@ -3000,33 +3119,20 @@ function defineESLintConfig(options = {}, ...userConfigs) {
|
|
|
3000
3119
|
if (enableNtnyq) configs.push(configNtnyq({ overrides: getOverrides(options, "ntnyq") }));
|
|
3001
3120
|
if (enableGitHubAction) configs.push(configGitHubAction({ overrides: getOverrides(options, "githubAction") }));
|
|
3002
3121
|
if (enableESLintPlugin) configs.push(configESLintPlugin({ overrides: getOverrides(options, "eslintPlugin") }));
|
|
3003
|
-
if (enableAstro) configs.push(configAstro({
|
|
3004
|
-
...resolveSubOptions(options, "astro"),
|
|
3005
|
-
typescript: !!enableTypeScript,
|
|
3006
|
-
overrides: getOverrides(options, "astro"),
|
|
3007
|
-
extraFileExtensions
|
|
3008
|
-
}));
|
|
3009
3122
|
if (enablePnpm) configs.push(configPnpm(resolveSubOptions(options, "pnpm")));
|
|
3010
3123
|
if (enableSVGO) configs.push(configSVGO(resolveSubOptions(options, "svgo")));
|
|
3011
3124
|
if (enableHTML) configs.push(configHtml({
|
|
3012
3125
|
...resolveSubOptions(options, "html"),
|
|
3013
3126
|
overrides: getOverrides(options, "html")
|
|
3014
3127
|
}));
|
|
3015
|
-
|
|
3128
|
+
if (enableSpecials) configs.push(configSpecials(resolveSubOptions(options, "specials")));
|
|
3016
3129
|
const prettierConfigs = enablePrettier ? configPrettier({
|
|
3017
3130
|
...resolveSubOptions(options, "prettier"),
|
|
3018
3131
|
overrides: getOverrides(options, "prettier")
|
|
3019
3132
|
}) : [];
|
|
3020
|
-
const composer = new FlatConfigComposer(
|
|
3021
|
-
...configs,
|
|
3022
|
-
// User custom configs
|
|
3023
|
-
...userConfigs,
|
|
3024
|
-
// Keep prettier and specials at last
|
|
3025
|
-
...specialsConfigs,
|
|
3026
|
-
...prettierConfigs
|
|
3027
|
-
);
|
|
3133
|
+
const composer = new FlatConfigComposer(...configs, ...userConfigs, ...prettierConfigs);
|
|
3028
3134
|
return composer;
|
|
3029
3135
|
}
|
|
3030
3136
|
|
|
3031
3137
|
//#endregion
|
|
3032
|
-
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_SRC, GLOB_SRC_EXT, 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_YAML,
|
|
3138
|
+
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_SRC, GLOB_SRC_EXT, 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_YAML, PERFECTIONIST, PRETTIER_DEFAULT_OPTIONS, combineConfigs, configAntfu, configAstro, configCommand, configDeMorgan, configDepend, configESLintComments, configESLintPlugin, configFormat, configGitHubAction, configGitIgnore, configHtml, configIgnores, configImportX, configJSX, configJavaScript, configJsdoc, configJsonc, configMarkdown, configNode, configNtnyq, configPerfectionist, configPinia, configPnpm, configPrettier, configRegexp, configSVGO, configSort, configSpecials, configSvelte, configTest, configToml, configTypeScript, configUnicorn, configUnoCSS, configUnusedImports, configVue, configYml, configsTypeScript, defineESLintConfig, ensurePackages, getOverrides, hasPinia, hasShadcnVue, hasTypeScript, hasUnoCSS, hasVitest, hasVue, interopDefault, isInGitHooksOrRunBySpecifyPackages, mergePrettierOptions, mergeProcessors, parserJsonc, parserPlain, parserToml, parserTypeScript, parserVue, parserYaml, pluginAntfu, pluginComments, pluginDeMorgan, pluginDepend, pluginGitHubAction, pluginImportX, pluginJsdoc, pluginJsonc, pluginMarkdown, pluginNoOnlyTests, pluginNode, pluginNtnyq, pluginPerfectionist, pluginPinia, pluginPrettier, pluginRegexp, pluginSvgo, pluginToml, pluginTypeScript, pluginUnicorn, pluginUnoCSS, pluginVitest, pluginVue, pluginYml, processorPassThrough, processorVueBlocks, resolveSubOptions };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ntnyq/eslint-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "5.0.0-beta.
|
|
4
|
+
"version": "5.0.0-beta.4",
|
|
5
5
|
"description": "An opinionated ESLint config preset of ntnyq",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"eslint",
|
|
@@ -43,7 +43,11 @@
|
|
|
43
43
|
"eslint-plugin-astro": "^1.3.1",
|
|
44
44
|
"eslint-plugin-eslint-plugin": "^6.4.0",
|
|
45
45
|
"eslint-plugin-format": "^1.0.1",
|
|
46
|
-
"eslint-plugin-
|
|
46
|
+
"eslint-plugin-pnpm": "^0.3.1",
|
|
47
|
+
"eslint-plugin-svelte": "^3.8.1",
|
|
48
|
+
"eslint-plugin-unused-imports": "^4.1.4",
|
|
49
|
+
"svelte": "^5.31.1",
|
|
50
|
+
"svelte-eslint-parser": "^1.2.0"
|
|
47
51
|
},
|
|
48
52
|
"peerDependenciesMeta": {
|
|
49
53
|
"@html-eslint/eslint-plugin": {
|
|
@@ -52,35 +56,53 @@
|
|
|
52
56
|
"@html-eslint/parser": {
|
|
53
57
|
"optional": true
|
|
54
58
|
},
|
|
59
|
+
"astro-eslint-parser": {
|
|
60
|
+
"optional": true
|
|
61
|
+
},
|
|
62
|
+
"eslint-plugin-astro": {
|
|
63
|
+
"optional": true
|
|
64
|
+
},
|
|
55
65
|
"eslint-plugin-eslint-plugin": {
|
|
56
66
|
"optional": true
|
|
57
67
|
},
|
|
58
68
|
"eslint-plugin-format": {
|
|
59
69
|
"optional": true
|
|
60
70
|
},
|
|
71
|
+
"eslint-plugin-pnpm": {
|
|
72
|
+
"optional": true
|
|
73
|
+
},
|
|
74
|
+
"eslint-plugin-svelte": {
|
|
75
|
+
"optional": true
|
|
76
|
+
},
|
|
61
77
|
"eslint-plugin-unused-imports": {
|
|
62
78
|
"optional": true
|
|
79
|
+
},
|
|
80
|
+
"svelte": {
|
|
81
|
+
"optional": true
|
|
82
|
+
},
|
|
83
|
+
"svelte-eslint-parser": {
|
|
84
|
+
"optional": true
|
|
63
85
|
}
|
|
64
86
|
},
|
|
65
87
|
"dependencies": {
|
|
66
88
|
"@antfu/install-pkg": "^1.1.0",
|
|
67
|
-
"@clack/prompts": "^0.
|
|
89
|
+
"@clack/prompts": "^0.11.0",
|
|
68
90
|
"@eslint-community/eslint-plugin-eslint-comments": "^4.5.0",
|
|
69
91
|
"@eslint/js": "^9.27.0",
|
|
70
92
|
"@eslint/markdown": "^6.4.0",
|
|
71
93
|
"@unocss/eslint-plugin": "^66.1.2",
|
|
72
|
-
"@vitest/eslint-plugin": "^1.2.
|
|
94
|
+
"@vitest/eslint-plugin": "^1.2.1",
|
|
73
95
|
"eslint-config-flat-gitignore": "^2.1.0",
|
|
74
|
-
"eslint-flat-config-utils": "^2.0
|
|
75
|
-
"eslint-import-resolver-typescript": "^4.
|
|
96
|
+
"eslint-flat-config-utils": "^2.1.0",
|
|
97
|
+
"eslint-import-resolver-typescript": "^4.4.1",
|
|
76
98
|
"eslint-merge-processors": "^2.0.0",
|
|
77
99
|
"eslint-parser-plain": "^0.1.1",
|
|
78
100
|
"eslint-plugin-antfu": "^3.1.1",
|
|
79
|
-
"eslint-plugin-command": "^3.2.
|
|
101
|
+
"eslint-plugin-command": "^3.2.1",
|
|
80
102
|
"eslint-plugin-de-morgan": "^1.2.1",
|
|
81
103
|
"eslint-plugin-depend": "^1.2.0",
|
|
82
104
|
"eslint-plugin-github-action": "^0.0.16",
|
|
83
|
-
"eslint-plugin-import-x": "^4.
|
|
105
|
+
"eslint-plugin-import-x": "^4.13.2",
|
|
84
106
|
"eslint-plugin-jsdoc": "^50.6.17",
|
|
85
107
|
"eslint-plugin-jsonc": "^2.20.1",
|
|
86
108
|
"eslint-plugin-n": "^17.18.0",
|
|
@@ -88,7 +110,6 @@
|
|
|
88
110
|
"eslint-plugin-ntnyq": "^0.11.0",
|
|
89
111
|
"eslint-plugin-perfectionist": "^4.13.0",
|
|
90
112
|
"eslint-plugin-pinia": "^0.4.1",
|
|
91
|
-
"eslint-plugin-pnpm": "^0.3.1",
|
|
92
113
|
"eslint-plugin-prettier": "^5.4.0",
|
|
93
114
|
"eslint-plugin-regexp": "^2.7.0",
|
|
94
115
|
"eslint-plugin-svgo": "^0.8.0",
|
|
@@ -97,7 +118,7 @@
|
|
|
97
118
|
"eslint-plugin-vue": "^10.1.0",
|
|
98
119
|
"eslint-plugin-yml": "^1.18.0",
|
|
99
120
|
"eslint-processor-vue-blocks": "^2.0.0",
|
|
100
|
-
"globals": "^16.
|
|
121
|
+
"globals": "^16.2.0",
|
|
101
122
|
"jsonc-eslint-parser": "^2.4.0",
|
|
102
123
|
"local-pkg": "^1.1.1",
|
|
103
124
|
"prettier": "^3.5.3",
|
|
@@ -107,8 +128,8 @@
|
|
|
107
128
|
"yaml-eslint-parser": "^1.3.0"
|
|
108
129
|
},
|
|
109
130
|
"devDependencies": {
|
|
110
|
-
"@ntnyq/prettier-config": "^2.
|
|
111
|
-
"@types/node": "^22.15.
|
|
131
|
+
"@ntnyq/prettier-config": "^2.2.0",
|
|
132
|
+
"@types/node": "^22.15.21",
|
|
112
133
|
"bumpp": "^10.1.1",
|
|
113
134
|
"eslint": "^9.27.0",
|
|
114
135
|
"eslint-plugin-eslint-plugin": "^6.4.0",
|
|
@@ -116,13 +137,13 @@
|
|
|
116
137
|
"husky": "^9.1.7",
|
|
117
138
|
"jiti": "^2.4.2",
|
|
118
139
|
"nano-staged": "^0.8.0",
|
|
119
|
-
"npm-run-all2": "^8.0.
|
|
120
|
-
"tinyglobby": "^0.2.
|
|
121
|
-
"tsdown": "^0.
|
|
140
|
+
"npm-run-all2": "^8.0.4",
|
|
141
|
+
"tinyglobby": "^0.2.14",
|
|
142
|
+
"tsdown": "^0.12.3",
|
|
122
143
|
"tsx": "^4.19.4",
|
|
123
144
|
"typescript": "^5.8.3",
|
|
124
145
|
"uncase": "^0.1.0",
|
|
125
|
-
"vitest": "^3.1.
|
|
146
|
+
"vitest": "^3.1.4"
|
|
126
147
|
},
|
|
127
148
|
"engines": {
|
|
128
149
|
"node": ">=20.11.0"
|
|
@@ -132,14 +153,14 @@
|
|
|
132
153
|
"*.{css,scss,html}": "prettier -uw"
|
|
133
154
|
},
|
|
134
155
|
"scripts": {
|
|
135
|
-
"build": "run-s generate:
|
|
156
|
+
"build": "run-s generate:types build:lib",
|
|
136
157
|
"build:inspector": "pnpm dlx @eslint/config-inspector build --config eslint-inspector.config.ts",
|
|
137
158
|
"build:lib": "tsdown",
|
|
138
159
|
"dev": "tsdown --watch",
|
|
139
160
|
"docs:build": "pnpm -C docs run build",
|
|
140
161
|
"docs:dev": "pnpm -C docs run dev",
|
|
141
|
-
"generate:site": "run-s generate:
|
|
142
|
-
"generate:
|
|
162
|
+
"generate:site": "run-s generate:types build:lib build:inspector",
|
|
163
|
+
"generate:types": "tsx scripts/generateType.ts",
|
|
143
164
|
"lint": "eslint --cache",
|
|
144
165
|
"release": "run-s release:check release:version release:publish",
|
|
145
166
|
"release:check": "run-s build lint test typecheck",
|