@luxass/eslint-config 4.4.3 → 4.6.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 +4 -1
- package/dist/index.cjs +169 -334
- package/dist/index.d.cts +320 -903
- package/dist/index.d.ts +320 -903
- package/dist/index.js +167 -332
- package/package.json +37 -53
package/dist/index.js
CHANGED
|
@@ -424,172 +424,6 @@ function sortTsconfig() {
|
|
|
424
424
|
];
|
|
425
425
|
}
|
|
426
426
|
|
|
427
|
-
// src/utils.ts
|
|
428
|
-
import process from "node:process";
|
|
429
|
-
import { isPackageExists } from "local-pkg";
|
|
430
|
-
var parserPlain = {
|
|
431
|
-
meta: {
|
|
432
|
-
name: "parser-plain"
|
|
433
|
-
},
|
|
434
|
-
parseForESLint: (code) => ({
|
|
435
|
-
ast: {
|
|
436
|
-
body: [],
|
|
437
|
-
comments: [],
|
|
438
|
-
loc: { end: code.length, start: 0 },
|
|
439
|
-
range: [0, code.length],
|
|
440
|
-
tokens: [],
|
|
441
|
-
type: "Program"
|
|
442
|
-
},
|
|
443
|
-
scopeManager: null,
|
|
444
|
-
services: { isPlain: true },
|
|
445
|
-
visitorKeys: {
|
|
446
|
-
Program: []
|
|
447
|
-
}
|
|
448
|
-
})
|
|
449
|
-
};
|
|
450
|
-
async function combine(...configs) {
|
|
451
|
-
const resolved = await Promise.all(configs);
|
|
452
|
-
return resolved.flat();
|
|
453
|
-
}
|
|
454
|
-
function renameRules(rules, from, to) {
|
|
455
|
-
return Object.fromEntries(
|
|
456
|
-
Object.entries(rules).map(([key, value]) => {
|
|
457
|
-
if (key.startsWith(from)) {
|
|
458
|
-
return [to + key.slice(from.length), value];
|
|
459
|
-
}
|
|
460
|
-
return [key, value];
|
|
461
|
-
})
|
|
462
|
-
);
|
|
463
|
-
}
|
|
464
|
-
function toArray(value) {
|
|
465
|
-
return Array.isArray(value) ? value : [value];
|
|
466
|
-
}
|
|
467
|
-
async function interop(m) {
|
|
468
|
-
const resolved = await m;
|
|
469
|
-
return resolved.default || resolved;
|
|
470
|
-
}
|
|
471
|
-
async function ensure(packages) {
|
|
472
|
-
if (process.env.CI || process.stdout.isTTY === false) {
|
|
473
|
-
return;
|
|
474
|
-
}
|
|
475
|
-
;
|
|
476
|
-
const nonExistingPackages = packages.filter((i) => i && !isPackageExists(i));
|
|
477
|
-
if (nonExistingPackages.length === 0) {
|
|
478
|
-
return;
|
|
479
|
-
}
|
|
480
|
-
const p = await import("@clack/prompts");
|
|
481
|
-
const result = await p.confirm({
|
|
482
|
-
message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?`
|
|
483
|
-
});
|
|
484
|
-
if (result) {
|
|
485
|
-
await import("@antfu/install-pkg").then((i) => i.installPackage(nonExistingPackages, { dev: true }));
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
function resolveSubOptions(options, key) {
|
|
489
|
-
return typeof options[key] === "boolean" ? {} : options[key] || {};
|
|
490
|
-
}
|
|
491
|
-
function getOverrides(options, key) {
|
|
492
|
-
const sub = resolveSubOptions(options, key);
|
|
493
|
-
return {
|
|
494
|
-
..."overrides" in sub ? sub.overrides : {}
|
|
495
|
-
};
|
|
496
|
-
}
|
|
497
|
-
|
|
498
|
-
// src/configs/svelte.ts
|
|
499
|
-
async function svelte(options = {}) {
|
|
500
|
-
const {
|
|
501
|
-
files = [GLOB_SVELTE],
|
|
502
|
-
overrides = {},
|
|
503
|
-
stylistic: stylistic2 = true
|
|
504
|
-
} = options;
|
|
505
|
-
const {
|
|
506
|
-
indent = 2,
|
|
507
|
-
quotes = "single"
|
|
508
|
-
} = typeof stylistic2 === "boolean" ? {} : stylistic2;
|
|
509
|
-
await ensure([
|
|
510
|
-
"eslint-plugin-svelte"
|
|
511
|
-
]);
|
|
512
|
-
const [
|
|
513
|
-
pluginSvelte,
|
|
514
|
-
parserSvelte
|
|
515
|
-
] = await Promise.all([
|
|
516
|
-
interop(import("eslint-plugin-svelte")),
|
|
517
|
-
interop(import("svelte-eslint-parser"))
|
|
518
|
-
]);
|
|
519
|
-
return [
|
|
520
|
-
{
|
|
521
|
-
name: "antfu/svelte/setup",
|
|
522
|
-
plugins: {
|
|
523
|
-
svelte: pluginSvelte
|
|
524
|
-
}
|
|
525
|
-
},
|
|
526
|
-
{
|
|
527
|
-
files,
|
|
528
|
-
languageOptions: {
|
|
529
|
-
parser: parserSvelte,
|
|
530
|
-
parserOptions: {
|
|
531
|
-
extraFileExtensions: [".svelte"],
|
|
532
|
-
parser: options.typescript ? await interop(import("@typescript-eslint/parser")) : null
|
|
533
|
-
}
|
|
534
|
-
},
|
|
535
|
-
name: "antfu/svelte/rules",
|
|
536
|
-
processor: pluginSvelte.processors[".svelte"],
|
|
537
|
-
rules: {
|
|
538
|
-
"import/no-mutable-exports": "off",
|
|
539
|
-
"no-undef": "off",
|
|
540
|
-
// incompatible with most recent (attribute-form) generic types RFC
|
|
541
|
-
"no-unused-vars": ["error", {
|
|
542
|
-
args: "none",
|
|
543
|
-
caughtErrors: "none",
|
|
544
|
-
ignoreRestSiblings: true,
|
|
545
|
-
vars: "all",
|
|
546
|
-
varsIgnorePattern: "^(\\$\\$Props$|\\$\\$Events$|\\$\\$Slots$)"
|
|
547
|
-
}],
|
|
548
|
-
"svelte/comment-directive": "error",
|
|
549
|
-
"svelte/no-at-debug-tags": "warn",
|
|
550
|
-
"svelte/no-at-html-tags": "error",
|
|
551
|
-
"svelte/no-dupe-else-if-blocks": "error",
|
|
552
|
-
"svelte/no-dupe-style-properties": "error",
|
|
553
|
-
"svelte/no-dupe-use-directives": "error",
|
|
554
|
-
"svelte/no-dynamic-slot-name": "error",
|
|
555
|
-
"svelte/no-export-load-in-svelte-module-in-kit-pages": "error",
|
|
556
|
-
"svelte/no-inner-declarations": "error",
|
|
557
|
-
"svelte/no-not-function-handler": "error",
|
|
558
|
-
"svelte/no-object-in-text-mustaches": "error",
|
|
559
|
-
"svelte/no-reactive-functions": "error",
|
|
560
|
-
"svelte/no-reactive-literals": "error",
|
|
561
|
-
"svelte/no-shorthand-style-property-overrides": "error",
|
|
562
|
-
"svelte/no-unknown-style-directive-property": "error",
|
|
563
|
-
"svelte/no-unused-svelte-ignore": "error",
|
|
564
|
-
"svelte/no-useless-mustaches": "error",
|
|
565
|
-
"svelte/require-store-callbacks-use-set-param": "error",
|
|
566
|
-
"svelte/system": "error",
|
|
567
|
-
"svelte/valid-compile": "error",
|
|
568
|
-
"svelte/valid-each-key": "error",
|
|
569
|
-
"unused-imports/no-unused-vars": [
|
|
570
|
-
"error",
|
|
571
|
-
{ args: "after-used", argsIgnorePattern: "^_", vars: "all", varsIgnorePattern: "^(_|\\$\\$Props$|\\$\\$Events$|\\$\\$Slots$)" }
|
|
572
|
-
],
|
|
573
|
-
...stylistic2 ? {
|
|
574
|
-
"style/indent": "off",
|
|
575
|
-
// superseded by svelte/indent
|
|
576
|
-
"style/no-trailing-spaces": "off",
|
|
577
|
-
// superseded by svelte/no-trailing-spaces
|
|
578
|
-
"svelte/derived-has-same-inputs-outputs": "error",
|
|
579
|
-
"svelte/html-closing-bracket-spacing": "error",
|
|
580
|
-
"svelte/html-quotes": ["error", { prefer: quotes }],
|
|
581
|
-
"svelte/indent": ["error", { alignAttributesVertically: true, indent }],
|
|
582
|
-
"svelte/mustache-spacing": "error",
|
|
583
|
-
"svelte/no-spaces-around-equal-signs-in-attribute": "error",
|
|
584
|
-
"svelte/no-trailing-spaces": "error",
|
|
585
|
-
"svelte/spaced-html-comment": "error"
|
|
586
|
-
} : {},
|
|
587
|
-
...overrides
|
|
588
|
-
}
|
|
589
|
-
}
|
|
590
|
-
];
|
|
591
|
-
}
|
|
592
|
-
|
|
593
427
|
// src/configs/imports.ts
|
|
594
428
|
import pluginImport from "eslint-plugin-import-x";
|
|
595
429
|
import pluginAntfu from "eslint-plugin-antfu";
|
|
@@ -889,6 +723,77 @@ async function javascript(options = {}) {
|
|
|
889
723
|
];
|
|
890
724
|
}
|
|
891
725
|
|
|
726
|
+
// src/utils.ts
|
|
727
|
+
import process from "node:process";
|
|
728
|
+
import { isPackageExists } from "local-pkg";
|
|
729
|
+
var parserPlain = {
|
|
730
|
+
meta: {
|
|
731
|
+
name: "parser-plain"
|
|
732
|
+
},
|
|
733
|
+
parseForESLint: (code) => ({
|
|
734
|
+
ast: {
|
|
735
|
+
body: [],
|
|
736
|
+
comments: [],
|
|
737
|
+
loc: { end: code.length, start: 0 },
|
|
738
|
+
range: [0, code.length],
|
|
739
|
+
tokens: [],
|
|
740
|
+
type: "Program"
|
|
741
|
+
},
|
|
742
|
+
scopeManager: null,
|
|
743
|
+
services: { isPlain: true },
|
|
744
|
+
visitorKeys: {
|
|
745
|
+
Program: []
|
|
746
|
+
}
|
|
747
|
+
})
|
|
748
|
+
};
|
|
749
|
+
async function combine(...configs2) {
|
|
750
|
+
const resolved = await Promise.all(configs2);
|
|
751
|
+
return resolved.flat();
|
|
752
|
+
}
|
|
753
|
+
function renameRules(rules, from, to) {
|
|
754
|
+
return Object.fromEntries(
|
|
755
|
+
Object.entries(rules).map(([key, value]) => {
|
|
756
|
+
if (key.startsWith(from)) {
|
|
757
|
+
return [to + key.slice(from.length), value];
|
|
758
|
+
}
|
|
759
|
+
return [key, value];
|
|
760
|
+
})
|
|
761
|
+
);
|
|
762
|
+
}
|
|
763
|
+
function toArray(value) {
|
|
764
|
+
return Array.isArray(value) ? value : [value];
|
|
765
|
+
}
|
|
766
|
+
async function interop(m) {
|
|
767
|
+
const resolved = await m;
|
|
768
|
+
return resolved.default || resolved;
|
|
769
|
+
}
|
|
770
|
+
async function ensure(packages) {
|
|
771
|
+
if (process.env.CI || process.stdout.isTTY === false) {
|
|
772
|
+
return;
|
|
773
|
+
}
|
|
774
|
+
;
|
|
775
|
+
const nonExistingPackages = packages.filter((i) => i && !isPackageExists(i));
|
|
776
|
+
if (nonExistingPackages.length === 0) {
|
|
777
|
+
return;
|
|
778
|
+
}
|
|
779
|
+
const p = await import("@clack/prompts");
|
|
780
|
+
const result = await p.confirm({
|
|
781
|
+
message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?`
|
|
782
|
+
});
|
|
783
|
+
if (result) {
|
|
784
|
+
await import("@antfu/install-pkg").then((i) => i.installPackage(nonExistingPackages, { dev: true }));
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
function resolveSubOptions(options, key) {
|
|
788
|
+
return typeof options[key] === "boolean" ? {} : options[key] || {};
|
|
789
|
+
}
|
|
790
|
+
function getOverrides(options, key) {
|
|
791
|
+
const sub = resolveSubOptions(options, key);
|
|
792
|
+
return {
|
|
793
|
+
..."overrides" in sub ? sub.overrides : {}
|
|
794
|
+
};
|
|
795
|
+
}
|
|
796
|
+
|
|
892
797
|
// src/configs/jsdoc.ts
|
|
893
798
|
async function jsdoc(options = {}) {
|
|
894
799
|
const {
|
|
@@ -1110,7 +1015,7 @@ var StylisticConfigDefaults = {
|
|
|
1110
1015
|
async function stylistic(options = {}) {
|
|
1111
1016
|
const {
|
|
1112
1017
|
indent,
|
|
1113
|
-
jsx,
|
|
1018
|
+
jsx: jsx2,
|
|
1114
1019
|
overrides = {},
|
|
1115
1020
|
quotes,
|
|
1116
1021
|
semi
|
|
@@ -1122,7 +1027,7 @@ async function stylistic(options = {}) {
|
|
|
1122
1027
|
const config = pluginStylistic.configs.customize({
|
|
1123
1028
|
flat: true,
|
|
1124
1029
|
indent,
|
|
1125
|
-
jsx,
|
|
1030
|
+
jsx: jsx2,
|
|
1126
1031
|
pluginName: "style",
|
|
1127
1032
|
quotes,
|
|
1128
1033
|
semi
|
|
@@ -1638,11 +1543,13 @@ async function test(options = {}) {
|
|
|
1638
1543
|
name: "luxass/test/rules",
|
|
1639
1544
|
files,
|
|
1640
1545
|
rules: {
|
|
1546
|
+
"node/prefer-global/process": "off",
|
|
1641
1547
|
"test/consistent-test-it": [
|
|
1642
1548
|
"error",
|
|
1643
1549
|
{ fn: "it", withinDescribe: "it" }
|
|
1644
1550
|
],
|
|
1645
1551
|
"test/no-identical-title": "error",
|
|
1552
|
+
"test/no-import-node-test": "error",
|
|
1646
1553
|
"test/no-focused-tests": editor ? "off" : "error",
|
|
1647
1554
|
"test/prefer-hooks-in-order": "error",
|
|
1648
1555
|
"test/prefer-lowercase-title": "error",
|
|
@@ -1705,7 +1612,7 @@ var RemixPackages = [
|
|
|
1705
1612
|
];
|
|
1706
1613
|
async function react(options = {}) {
|
|
1707
1614
|
const {
|
|
1708
|
-
files = [GLOB_TS, GLOB_TSX],
|
|
1615
|
+
files = [GLOB_JS, GLOB_JSX, GLOB_TS, GLOB_TSX],
|
|
1709
1616
|
overrides = {}
|
|
1710
1617
|
} = options;
|
|
1711
1618
|
await ensure([
|
|
@@ -1850,7 +1757,6 @@ async function astro(options = {}) {
|
|
|
1850
1757
|
const {
|
|
1851
1758
|
files = [GLOB_ASTRO],
|
|
1852
1759
|
overrides = {},
|
|
1853
|
-
typescript: typescript2 = true,
|
|
1854
1760
|
stylistic: stylistic2 = true
|
|
1855
1761
|
} = options;
|
|
1856
1762
|
await ensure([
|
|
@@ -1877,63 +1783,35 @@ async function astro(options = {}) {
|
|
|
1877
1783
|
name: "luxass/astro/rules",
|
|
1878
1784
|
files,
|
|
1879
1785
|
languageOptions: {
|
|
1786
|
+
globals: pluginAstro.environments.astro.globals,
|
|
1880
1787
|
parser: parserAstro,
|
|
1881
1788
|
parserOptions: {
|
|
1882
1789
|
extraFileExtensions: [".astro"],
|
|
1883
|
-
parser:
|
|
1884
|
-
|
|
1885
|
-
|
|
1790
|
+
parser: parserTs
|
|
1791
|
+
},
|
|
1792
|
+
sourceType: "module"
|
|
1886
1793
|
},
|
|
1794
|
+
processor: "astro/client-side-ts",
|
|
1887
1795
|
rules: {
|
|
1888
|
-
|
|
1889
|
-
// https://ota-meshi.github.io/eslint-plugin-astro/rules/no-conflict-set-directives/
|
|
1796
|
+
"astro/missing-client-only-directive-value": "error",
|
|
1890
1797
|
"astro/no-conflict-set-directives": "error",
|
|
1891
|
-
|
|
1892
|
-
|
|
1798
|
+
"astro/no-deprecated-astro-canonicalurl": "error",
|
|
1799
|
+
"astro/no-deprecated-astro-fetchcontent": "error",
|
|
1800
|
+
"astro/no-deprecated-astro-resolve": "error",
|
|
1801
|
+
"astro/no-deprecated-getentrybyslug": "error",
|
|
1893
1802
|
"astro/no-set-html-directive": "off",
|
|
1803
|
+
"astro/no-unused-define-vars-in-style": "error",
|
|
1804
|
+
"astro/semi": "off",
|
|
1805
|
+
"astro/valid-compile": "error",
|
|
1894
1806
|
...stylistic2 ? {
|
|
1895
1807
|
"style/indent": "off",
|
|
1896
|
-
"style/jsx-indent": "off",
|
|
1897
1808
|
"style/jsx-closing-tag-location": "off",
|
|
1809
|
+
"style/jsx-indent": "off",
|
|
1898
1810
|
"style/jsx-one-expression-per-line": "off",
|
|
1899
1811
|
"style/no-multiple-empty-lines": "off"
|
|
1900
1812
|
} : {},
|
|
1901
1813
|
...overrides
|
|
1902
1814
|
}
|
|
1903
|
-
},
|
|
1904
|
-
{
|
|
1905
|
-
name: "luxass/astro/scripts-js",
|
|
1906
|
-
files: [
|
|
1907
|
-
"**/*.astro/*.js",
|
|
1908
|
-
"*.astro/*.js"
|
|
1909
|
-
],
|
|
1910
|
-
languageOptions: {
|
|
1911
|
-
globals: {
|
|
1912
|
-
browser: true,
|
|
1913
|
-
es2020: true
|
|
1914
|
-
},
|
|
1915
|
-
parserOptions: {
|
|
1916
|
-
sourceType: "module"
|
|
1917
|
-
}
|
|
1918
|
-
}
|
|
1919
|
-
},
|
|
1920
|
-
{
|
|
1921
|
-
name: "luxass/astro/scripts-ts",
|
|
1922
|
-
files: [
|
|
1923
|
-
"**/*.astro/*.ts",
|
|
1924
|
-
"*.astro/*.ts"
|
|
1925
|
-
],
|
|
1926
|
-
languageOptions: {
|
|
1927
|
-
globals: {
|
|
1928
|
-
browser: true,
|
|
1929
|
-
es2020: true
|
|
1930
|
-
},
|
|
1931
|
-
parser: typescript2 ? parserTs : null,
|
|
1932
|
-
parserOptions: {
|
|
1933
|
-
project: null,
|
|
1934
|
-
sourceType: "module"
|
|
1935
|
-
}
|
|
1936
|
-
}
|
|
1937
1815
|
}
|
|
1938
1816
|
];
|
|
1939
1817
|
}
|
|
@@ -2034,7 +1912,7 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
2034
1912
|
options.dprintOptions || {}
|
|
2035
1913
|
);
|
|
2036
1914
|
const pluginFormat = await interop(import("eslint-plugin-format"));
|
|
2037
|
-
const
|
|
1915
|
+
const configs2 = [
|
|
2038
1916
|
{
|
|
2039
1917
|
name: "luxass/formatter/setup",
|
|
2040
1918
|
plugins: {
|
|
@@ -2043,7 +1921,7 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
2043
1921
|
}
|
|
2044
1922
|
];
|
|
2045
1923
|
if (options.css) {
|
|
2046
|
-
|
|
1924
|
+
configs2.push(
|
|
2047
1925
|
{
|
|
2048
1926
|
name: "luxass/formatter/css",
|
|
2049
1927
|
files: [GLOB_CSS, GLOB_POSTCSS],
|
|
@@ -2095,7 +1973,7 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
2095
1973
|
);
|
|
2096
1974
|
}
|
|
2097
1975
|
if (options.html) {
|
|
2098
|
-
|
|
1976
|
+
configs2.push({
|
|
2099
1977
|
name: "luxass/formatter/html",
|
|
2100
1978
|
files: [GLOB_HTML],
|
|
2101
1979
|
languageOptions: {
|
|
@@ -2114,7 +1992,7 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
2114
1992
|
}
|
|
2115
1993
|
if (options.markdown) {
|
|
2116
1994
|
const formater = options.markdown === true ? "prettier" : options.markdown;
|
|
2117
|
-
|
|
1995
|
+
configs2.push({
|
|
2118
1996
|
name: "luxass/formatter/markdown",
|
|
2119
1997
|
files: [GLOB_MARKDOWN],
|
|
2120
1998
|
languageOptions: {
|
|
@@ -2137,7 +2015,7 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
2137
2015
|
});
|
|
2138
2016
|
}
|
|
2139
2017
|
if (options.astro) {
|
|
2140
|
-
|
|
2018
|
+
configs2.push({
|
|
2141
2019
|
name: "luxass/formatter/astro",
|
|
2142
2020
|
files: [GLOB_ASTRO],
|
|
2143
2021
|
languageOptions: {
|
|
@@ -2158,7 +2036,7 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
2158
2036
|
});
|
|
2159
2037
|
}
|
|
2160
2038
|
if (options.graphql) {
|
|
2161
|
-
|
|
2039
|
+
configs2.push({
|
|
2162
2040
|
name: "luxass/formatter/graphql",
|
|
2163
2041
|
files: [GLOB_GRAPHQL],
|
|
2164
2042
|
languageOptions: {
|
|
@@ -2175,7 +2053,7 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
2175
2053
|
}
|
|
2176
2054
|
});
|
|
2177
2055
|
}
|
|
2178
|
-
return
|
|
2056
|
+
return configs2;
|
|
2179
2057
|
}
|
|
2180
2058
|
|
|
2181
2059
|
// src/configs/toml.ts
|
|
@@ -2237,78 +2115,44 @@ async function toml(options = {}) {
|
|
|
2237
2115
|
];
|
|
2238
2116
|
}
|
|
2239
2117
|
|
|
2240
|
-
// src/configs/
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
}
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
parserTs
|
|
2255
|
-
] = await Promise.all([
|
|
2256
|
-
interop(import("eslint-plugin-solid")),
|
|
2257
|
-
interop(import("@typescript-eslint/parser"))
|
|
2258
|
-
]);
|
|
2118
|
+
// src/configs/regexp.ts
|
|
2119
|
+
import { configs } from "eslint-plugin-regexp";
|
|
2120
|
+
async function regexp(options = {}) {
|
|
2121
|
+
const config = configs["flat/recommended"];
|
|
2122
|
+
const rules = {
|
|
2123
|
+
...config.rules
|
|
2124
|
+
};
|
|
2125
|
+
if (options.level === "warn") {
|
|
2126
|
+
for (const key in rules) {
|
|
2127
|
+
if (rules[key] === "error") {
|
|
2128
|
+
rules[key] = "warn";
|
|
2129
|
+
}
|
|
2130
|
+
}
|
|
2131
|
+
}
|
|
2259
2132
|
return [
|
|
2260
2133
|
{
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2134
|
+
...config,
|
|
2135
|
+
name: "luxass/regexp/rules",
|
|
2136
|
+
rules: {
|
|
2137
|
+
...rules,
|
|
2138
|
+
...options.overrides
|
|
2264
2139
|
}
|
|
2265
|
-
}
|
|
2140
|
+
}
|
|
2141
|
+
];
|
|
2142
|
+
}
|
|
2143
|
+
|
|
2144
|
+
// src/configs/jsx.ts
|
|
2145
|
+
async function jsx() {
|
|
2146
|
+
return [
|
|
2266
2147
|
{
|
|
2267
|
-
name: "luxass/
|
|
2268
|
-
files,
|
|
2148
|
+
name: "luxass/jsx/setup",
|
|
2149
|
+
files: [GLOB_JSX, GLOB_TSX],
|
|
2269
2150
|
languageOptions: {
|
|
2270
|
-
parser: parserTs,
|
|
2271
2151
|
parserOptions: {
|
|
2272
2152
|
ecmaFeatures: {
|
|
2273
2153
|
jsx: true
|
|
2274
|
-
}
|
|
2275
|
-
|
|
2276
|
-
},
|
|
2277
|
-
sourceType: "module"
|
|
2278
|
-
},
|
|
2279
|
-
rules: {
|
|
2280
|
-
// reactivity
|
|
2281
|
-
"solid/components-return-once": "warn",
|
|
2282
|
-
"solid/event-handlers": ["error", {
|
|
2283
|
-
// if true, don't warn on ambiguously named event handlers like `onclick` or `onchange`
|
|
2284
|
-
ignoreCase: false,
|
|
2285
|
-
// if true, warn when spreading event handlers onto JSX. Enable for Solid < v1.6.
|
|
2286
|
-
warnOnSpread: false
|
|
2287
|
-
}],
|
|
2288
|
-
// these rules are mostly style suggestions
|
|
2289
|
-
"solid/imports": "error",
|
|
2290
|
-
// identifier usage is important
|
|
2291
|
-
"solid/jsx-no-duplicate-props": "error",
|
|
2292
|
-
"solid/jsx-no-script-url": "error",
|
|
2293
|
-
"solid/jsx-no-undef": "error",
|
|
2294
|
-
"solid/jsx-uses-vars": "error",
|
|
2295
|
-
"solid/no-destructure": "error",
|
|
2296
|
-
// security problems
|
|
2297
|
-
"solid/no-innerhtml": ["error", { allowStatic: true }],
|
|
2298
|
-
"solid/no-react-deps": "error",
|
|
2299
|
-
"solid/no-react-specific-props": "error",
|
|
2300
|
-
"solid/no-unknown-namespaces": "error",
|
|
2301
|
-
"solid/prefer-for": "error",
|
|
2302
|
-
"solid/reactivity": "warn",
|
|
2303
|
-
"solid/self-closing-comp": "error",
|
|
2304
|
-
"solid/style-prop": ["error", { styleProps: ["style", "css"] }],
|
|
2305
|
-
...typescript2 ? {
|
|
2306
|
-
"solid/jsx-no-undef": ["error", { typescriptEnabled: true }],
|
|
2307
|
-
// namespaces taken care of by TS
|
|
2308
|
-
"solid/no-unknown-namespaces": "off"
|
|
2309
|
-
} : {},
|
|
2310
|
-
// overrides
|
|
2311
|
-
...overrides
|
|
2154
|
+
}
|
|
2155
|
+
}
|
|
2312
2156
|
}
|
|
2313
2157
|
}
|
|
2314
2158
|
];
|
|
@@ -2348,32 +2192,34 @@ function luxass(options = {}, ...userConfigs) {
|
|
|
2348
2192
|
const {
|
|
2349
2193
|
astro: enableAstro = false,
|
|
2350
2194
|
autoRenamePlugins = true,
|
|
2351
|
-
editor = !!((process3.env.VSCODE_PID || process3.env.JETBRAINS_IDE || process3.env.VIM) && !process3.env.CI),
|
|
2352
2195
|
exts = [],
|
|
2353
2196
|
gitignore: enableGitignore = true,
|
|
2197
|
+
editor = !!((process3.env.VSCODE_PID || process3.env.JETBRAINS_IDE || process3.env.VIM) && !process3.env.CI),
|
|
2198
|
+
jsx: enableJsx = true,
|
|
2354
2199
|
react: enableReact = false,
|
|
2355
|
-
|
|
2356
|
-
svelte: enableSvelte = false,
|
|
2357
|
-
solid: enableSolid = false,
|
|
2200
|
+
regexp: enableRegexp = true,
|
|
2358
2201
|
typescript: enableTypeScript = isPackageExists4("typescript"),
|
|
2359
2202
|
unocss: enableUnoCSS = false,
|
|
2203
|
+
tailwindcss: enableTailwindCSS = false,
|
|
2360
2204
|
vue: enableVue = VuePackages.some((i) => isPackageExists4(i))
|
|
2361
2205
|
} = options;
|
|
2362
2206
|
const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
|
|
2363
2207
|
if (stylisticOptions && !("jsx" in stylisticOptions)) {
|
|
2364
|
-
stylisticOptions.jsx =
|
|
2208
|
+
stylisticOptions.jsx = enableJsx;
|
|
2365
2209
|
}
|
|
2366
|
-
const
|
|
2210
|
+
const configs2 = [];
|
|
2367
2211
|
if (enableGitignore) {
|
|
2368
2212
|
if (typeof enableGitignore !== "boolean") {
|
|
2369
|
-
|
|
2213
|
+
configs2.push(interop(import("eslint-config-flat-gitignore")).then((plugin) => [plugin(enableGitignore)]));
|
|
2370
2214
|
} else {
|
|
2371
2215
|
if (existsSync(".gitignore")) {
|
|
2372
|
-
|
|
2216
|
+
configs2.push(interop(import("eslint-config-flat-gitignore")).then((plugin) => [plugin()]));
|
|
2373
2217
|
}
|
|
2374
2218
|
}
|
|
2375
2219
|
}
|
|
2376
|
-
|
|
2220
|
+
const typescriptOptions = resolveSubOptions(options, "typescript");
|
|
2221
|
+
const tsconfigPath = "tsconfigPath" in typescriptOptions ? typescriptOptions.tsconfigPath : void 0;
|
|
2222
|
+
configs2.push(
|
|
2377
2223
|
ignores(),
|
|
2378
2224
|
javascript({
|
|
2379
2225
|
editor,
|
|
@@ -2392,53 +2238,43 @@ function luxass(options = {}, ...userConfigs) {
|
|
|
2392
2238
|
if (enableVue) {
|
|
2393
2239
|
exts.push("vue");
|
|
2394
2240
|
}
|
|
2241
|
+
if (enableJsx) {
|
|
2242
|
+
configs2.push(jsx());
|
|
2243
|
+
}
|
|
2395
2244
|
if (enableTypeScript) {
|
|
2396
|
-
|
|
2397
|
-
...
|
|
2245
|
+
configs2.push(typescript({
|
|
2246
|
+
...typescriptOptions,
|
|
2398
2247
|
exts,
|
|
2399
2248
|
overrides: getOverrides(options, "typescript")
|
|
2400
2249
|
}));
|
|
2401
2250
|
}
|
|
2402
2251
|
if (stylisticOptions) {
|
|
2403
|
-
|
|
2252
|
+
configs2.push(stylistic({
|
|
2404
2253
|
...stylisticOptions,
|
|
2405
2254
|
overrides: getOverrides(options, "stylistic")
|
|
2406
2255
|
}));
|
|
2407
2256
|
}
|
|
2257
|
+
if (enableRegexp) {
|
|
2258
|
+
configs2.push(regexp({
|
|
2259
|
+
...resolveSubOptions(options, "regexp"),
|
|
2260
|
+
overrides: getOverrides(options, "regexp")
|
|
2261
|
+
}));
|
|
2262
|
+
}
|
|
2408
2263
|
if (options.test ?? true) {
|
|
2409
|
-
|
|
2264
|
+
configs2.push(test({
|
|
2410
2265
|
editor,
|
|
2411
2266
|
overrides: getOverrides(options, "test")
|
|
2412
2267
|
}));
|
|
2413
2268
|
}
|
|
2414
2269
|
if (enableReact) {
|
|
2415
|
-
|
|
2270
|
+
configs2.push(react({
|
|
2416
2271
|
...resolveSubOptions(options, "react"),
|
|
2417
2272
|
overrides: getOverrides(options, "react"),
|
|
2418
|
-
tsconfigPath
|
|
2273
|
+
tsconfigPath
|
|
2419
2274
|
}));
|
|
2420
2275
|
}
|
|
2421
|
-
if (enableSolid) {
|
|
2422
|
-
configs.push(
|
|
2423
|
-
solid({
|
|
2424
|
-
...resolveSubOptions(options, "solid"),
|
|
2425
|
-
overrides: getOverrides(options, "solid"),
|
|
2426
|
-
typescript: !!enableTypeScript
|
|
2427
|
-
})
|
|
2428
|
-
);
|
|
2429
|
-
}
|
|
2430
|
-
if (enableSvelte) {
|
|
2431
|
-
configs.push(
|
|
2432
|
-
svelte({
|
|
2433
|
-
...resolveSubOptions(options, "svelte"),
|
|
2434
|
-
overrides: getOverrides(options, "svelte"),
|
|
2435
|
-
stylistic: stylisticOptions,
|
|
2436
|
-
typescript: !!enableTypeScript
|
|
2437
|
-
})
|
|
2438
|
-
);
|
|
2439
|
-
}
|
|
2440
2276
|
if (enableVue) {
|
|
2441
|
-
|
|
2277
|
+
configs2.push(
|
|
2442
2278
|
vue({
|
|
2443
2279
|
...resolveSubOptions(options, "vue"),
|
|
2444
2280
|
overrides: getOverrides(options, "vue"),
|
|
@@ -2448,28 +2284,27 @@ function luxass(options = {}, ...userConfigs) {
|
|
|
2448
2284
|
);
|
|
2449
2285
|
}
|
|
2450
2286
|
if (enableAstro) {
|
|
2451
|
-
|
|
2287
|
+
configs2.push(
|
|
2452
2288
|
astro({
|
|
2453
2289
|
...resolveSubOptions(options, "astro"),
|
|
2454
|
-
overrides: getOverrides(options, "astro")
|
|
2455
|
-
typescript: !!enableTypeScript
|
|
2290
|
+
overrides: getOverrides(options, "astro")
|
|
2456
2291
|
})
|
|
2457
2292
|
);
|
|
2458
2293
|
}
|
|
2459
2294
|
if (enableUnoCSS) {
|
|
2460
|
-
|
|
2295
|
+
configs2.push(unocss({
|
|
2461
2296
|
...resolveSubOptions(options, "unocss"),
|
|
2462
2297
|
overrides: getOverrides(options, "unocss")
|
|
2463
2298
|
}));
|
|
2464
2299
|
}
|
|
2465
2300
|
if (enableTailwindCSS) {
|
|
2466
|
-
|
|
2301
|
+
configs2.push(tailwindcss({
|
|
2467
2302
|
...resolveSubOptions(options, "tailwindcss"),
|
|
2468
2303
|
overrides: getOverrides(options, "tailwindcss")
|
|
2469
2304
|
}));
|
|
2470
2305
|
}
|
|
2471
2306
|
if (options.jsonc ?? true) {
|
|
2472
|
-
|
|
2307
|
+
configs2.push(
|
|
2473
2308
|
jsonc({
|
|
2474
2309
|
overrides: getOverrides(options, "jsonc"),
|
|
2475
2310
|
stylistic: stylisticOptions
|
|
@@ -2479,19 +2314,19 @@ function luxass(options = {}, ...userConfigs) {
|
|
|
2479
2314
|
);
|
|
2480
2315
|
}
|
|
2481
2316
|
if (options.yaml ?? true) {
|
|
2482
|
-
|
|
2317
|
+
configs2.push(yaml({
|
|
2483
2318
|
overrides: getOverrides(options, "yaml"),
|
|
2484
2319
|
stylistic: stylisticOptions
|
|
2485
2320
|
}));
|
|
2486
2321
|
}
|
|
2487
2322
|
if (options.toml ?? true) {
|
|
2488
|
-
|
|
2323
|
+
configs2.push(toml({
|
|
2489
2324
|
overrides: getOverrides(options, "toml"),
|
|
2490
2325
|
stylistic: stylisticOptions
|
|
2491
2326
|
}));
|
|
2492
2327
|
}
|
|
2493
2328
|
if (options.markdown ?? true) {
|
|
2494
|
-
|
|
2329
|
+
configs2.push(
|
|
2495
2330
|
markdown({
|
|
2496
2331
|
exts,
|
|
2497
2332
|
overrides: getOverrides(options, "markdown")
|
|
@@ -2499,7 +2334,7 @@ function luxass(options = {}, ...userConfigs) {
|
|
|
2499
2334
|
);
|
|
2500
2335
|
}
|
|
2501
2336
|
if (options.formatters) {
|
|
2502
|
-
|
|
2337
|
+
configs2.push(formatters(
|
|
2503
2338
|
options.formatters,
|
|
2504
2339
|
typeof stylisticOptions === "boolean" ? {} : stylisticOptions
|
|
2505
2340
|
));
|
|
@@ -2511,11 +2346,11 @@ function luxass(options = {}, ...userConfigs) {
|
|
|
2511
2346
|
return acc;
|
|
2512
2347
|
}, {});
|
|
2513
2348
|
if (Object.keys(fusedConfig).length) {
|
|
2514
|
-
|
|
2349
|
+
configs2.push([fusedConfig]);
|
|
2515
2350
|
}
|
|
2516
2351
|
let composer = new FlatConfigComposer();
|
|
2517
2352
|
composer = composer.append(
|
|
2518
|
-
...
|
|
2353
|
+
...configs2,
|
|
2519
2354
|
...userConfigs
|
|
2520
2355
|
);
|
|
2521
2356
|
if (autoRenamePlugins) {
|
|
@@ -2568,18 +2403,18 @@ export {
|
|
|
2568
2403
|
javascript,
|
|
2569
2404
|
jsdoc,
|
|
2570
2405
|
jsonc,
|
|
2406
|
+
jsx,
|
|
2571
2407
|
luxass,
|
|
2572
2408
|
markdown,
|
|
2573
2409
|
node,
|
|
2574
2410
|
parserPlain,
|
|
2575
2411
|
react,
|
|
2412
|
+
regexp,
|
|
2576
2413
|
renameRules,
|
|
2577
2414
|
resolveSubOptions,
|
|
2578
|
-
solid,
|
|
2579
2415
|
sortPackageJson,
|
|
2580
2416
|
sortTsconfig,
|
|
2581
2417
|
stylistic,
|
|
2582
|
-
svelte,
|
|
2583
2418
|
tailwindcss,
|
|
2584
2419
|
test,
|
|
2585
2420
|
toArray,
|