@lincy/eslint-config 4.6.2 → 4.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +77 -26
- package/dist/index.d.cts +826 -1186
- package/dist/index.d.ts +826 -1186
- package/dist/index.js +75 -26
- package/package.json +39 -39
package/dist/index.cjs
CHANGED
|
@@ -66,9 +66,11 @@ __export(src_exports, {
|
|
|
66
66
|
ignores: () => ignores,
|
|
67
67
|
imports: () => imports,
|
|
68
68
|
interopDefault: () => interopDefault,
|
|
69
|
+
isInEditorEnv: () => isInEditorEnv,
|
|
69
70
|
javascript: () => javascript,
|
|
70
71
|
jsdoc: () => jsdoc,
|
|
71
72
|
jsonc: () => jsonc,
|
|
73
|
+
jsx: () => jsx,
|
|
72
74
|
lincy: () => lincy,
|
|
73
75
|
markdown: () => markdown,
|
|
74
76
|
node: () => node,
|
|
@@ -92,8 +94,6 @@ __export(src_exports, {
|
|
|
92
94
|
module.exports = __toCommonJS(src_exports);
|
|
93
95
|
|
|
94
96
|
// src/factory.ts
|
|
95
|
-
var import_node_process3 = __toESM(require("process"), 1);
|
|
96
|
-
var import_node_fs = __toESM(require("fs"), 1);
|
|
97
97
|
var import_local_pkg4 = require("local-pkg");
|
|
98
98
|
var import_eslint_flat_config_utils = require("eslint-flat-config-utils");
|
|
99
99
|
|
|
@@ -186,6 +186,7 @@ var GLOB_EXCLUDE = [
|
|
|
186
186
|
"**/.output",
|
|
187
187
|
"**/.vite-inspect",
|
|
188
188
|
"**/.yarn",
|
|
189
|
+
"**/vite.config.*.timestamp-*",
|
|
189
190
|
"**/CHANGELOG*.md",
|
|
190
191
|
"**/*.min.*",
|
|
191
192
|
"**/LICENSE*",
|
|
@@ -204,7 +205,8 @@ async function ignores(options = {}) {
|
|
|
204
205
|
ignores: [
|
|
205
206
|
...GLOB_EXCLUDE,
|
|
206
207
|
...ignores2
|
|
207
|
-
]
|
|
208
|
+
],
|
|
209
|
+
name: "eslint:ignores"
|
|
208
210
|
}
|
|
209
211
|
];
|
|
210
212
|
}
|
|
@@ -279,6 +281,9 @@ async function javascript(options = {}) {
|
|
|
279
281
|
linterOptions: {
|
|
280
282
|
reportUnusedDisableDirectives: true
|
|
281
283
|
},
|
|
284
|
+
name: "eslint:javascript:setup"
|
|
285
|
+
},
|
|
286
|
+
{
|
|
282
287
|
name: "eslint:javascript:rules",
|
|
283
288
|
plugins: {
|
|
284
289
|
"antfu": import_eslint_plugin_antfu.default,
|
|
@@ -536,6 +541,9 @@ async function ensurePackages(packages) {
|
|
|
536
541
|
await import("@antfu/install-pkg").then((i) => i.installPackage(nonExistingPackages, { dev: true }));
|
|
537
542
|
}
|
|
538
543
|
}
|
|
544
|
+
function isInEditorEnv() {
|
|
545
|
+
return !!((import_node_process.default.env.VSCODE_PID || import_node_process.default.env.VSCODE_CWD || import_node_process.default.env.JETBRAINS_IDE || import_node_process.default.env.VIM || import_node_process.default.env.NVIM) && !import_node_process.default.env.CI);
|
|
546
|
+
}
|
|
539
547
|
|
|
540
548
|
// src/configs/jsdoc.ts
|
|
541
549
|
async function jsdoc(options = {}) {
|
|
@@ -645,6 +653,23 @@ async function jsonc(options = {}) {
|
|
|
645
653
|
];
|
|
646
654
|
}
|
|
647
655
|
|
|
656
|
+
// src/configs/jsx.ts
|
|
657
|
+
async function jsx() {
|
|
658
|
+
return [
|
|
659
|
+
{
|
|
660
|
+
files: [GLOB_JSX, GLOB_TSX],
|
|
661
|
+
languageOptions: {
|
|
662
|
+
parserOptions: {
|
|
663
|
+
ecmaFeatures: {
|
|
664
|
+
jsx: true
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
},
|
|
668
|
+
name: "eslint:jsx:setup"
|
|
669
|
+
}
|
|
670
|
+
];
|
|
671
|
+
}
|
|
672
|
+
|
|
648
673
|
// src/configs/markdown.ts
|
|
649
674
|
var parserPlain = __toESM(require("eslint-parser-plain"), 1);
|
|
650
675
|
var import_eslint_merge_processors = require("eslint-merge-processors");
|
|
@@ -709,6 +734,7 @@ async function markdown(options = {}) {
|
|
|
709
734
|
"ts/no-namespace": "off",
|
|
710
735
|
"ts/no-redeclare": "off",
|
|
711
736
|
"ts/no-require-imports": "off",
|
|
737
|
+
"ts/no-unused-expressions": "off",
|
|
712
738
|
"ts/no-unused-vars": "off",
|
|
713
739
|
"ts/no-use-before-define": "off",
|
|
714
740
|
"ts/no-var-requires": "off",
|
|
@@ -769,7 +795,7 @@ async function stylistic(options = {}) {
|
|
|
769
795
|
} = options;
|
|
770
796
|
const {
|
|
771
797
|
indent,
|
|
772
|
-
jsx,
|
|
798
|
+
jsx: jsx2,
|
|
773
799
|
lessOpinionated,
|
|
774
800
|
quotes,
|
|
775
801
|
semi
|
|
@@ -778,7 +804,7 @@ async function stylistic(options = {}) {
|
|
|
778
804
|
const config = pluginStylistic.configs.customize({
|
|
779
805
|
flat: true,
|
|
780
806
|
indent,
|
|
781
|
-
jsx,
|
|
807
|
+
jsx: jsx2,
|
|
782
808
|
pluginName: "style",
|
|
783
809
|
quotes,
|
|
784
810
|
semi
|
|
@@ -1005,13 +1031,12 @@ var ReactRefreshAllowConstantExportPackages = [
|
|
|
1005
1031
|
async function react(options = {}) {
|
|
1006
1032
|
const {
|
|
1007
1033
|
files = [GLOB_JSX, GLOB_TSX],
|
|
1008
|
-
jsx = true,
|
|
1034
|
+
jsx: jsx2 = true,
|
|
1009
1035
|
overrides = {},
|
|
1010
|
-
typescript: typescript2 = true,
|
|
1011
1036
|
version = "detect"
|
|
1012
1037
|
} = options;
|
|
1013
1038
|
const tsconfigPath = options?.tsconfigPath ? toArray(options.tsconfigPath) : void 0;
|
|
1014
|
-
const isTypeAware = !!tsconfigPath
|
|
1039
|
+
const isTypeAware = !!tsconfigPath;
|
|
1015
1040
|
await ensurePackages([
|
|
1016
1041
|
"@eslint-react/eslint-plugin",
|
|
1017
1042
|
"eslint-plugin-react-hooks",
|
|
@@ -1052,7 +1077,7 @@ async function react(options = {}) {
|
|
|
1052
1077
|
parser: parserTs,
|
|
1053
1078
|
parserOptions: {
|
|
1054
1079
|
ecmaFeatures: {
|
|
1055
|
-
jsx
|
|
1080
|
+
jsx: jsx2
|
|
1056
1081
|
},
|
|
1057
1082
|
...isTypeAware ? { project: tsconfigPath } : {}
|
|
1058
1083
|
}
|
|
@@ -1182,6 +1207,7 @@ async function sortPackageJson() {
|
|
|
1182
1207
|
"private",
|
|
1183
1208
|
"packageManager",
|
|
1184
1209
|
"description",
|
|
1210
|
+
"contributors",
|
|
1185
1211
|
"author",
|
|
1186
1212
|
"license",
|
|
1187
1213
|
"funding",
|
|
@@ -1424,6 +1450,7 @@ async function test(options = {}) {
|
|
|
1424
1450
|
"test/no-only-tests": isInEditor ? "off" : "error",
|
|
1425
1451
|
"test/prefer-hooks-in-order": "error",
|
|
1426
1452
|
"test/prefer-lowercase-title": "error",
|
|
1453
|
+
"ts/explicit-function-return-type": "off",
|
|
1427
1454
|
...overrides
|
|
1428
1455
|
}
|
|
1429
1456
|
}
|
|
@@ -1436,19 +1463,19 @@ async function typescript(options = {}) {
|
|
|
1436
1463
|
const {
|
|
1437
1464
|
componentExts = [],
|
|
1438
1465
|
overrides = {},
|
|
1439
|
-
parserOptions = {}
|
|
1466
|
+
parserOptions = {},
|
|
1467
|
+
type = "app"
|
|
1440
1468
|
} = options;
|
|
1441
1469
|
const files = options.files ?? [
|
|
1442
1470
|
GLOB_SRC,
|
|
1443
1471
|
...componentExts.map((ext) => `**/*.${ext}`)
|
|
1444
1472
|
];
|
|
1445
1473
|
const filesTypeAware = options.filesTypeAware ?? [GLOB_TS, GLOB_TSX];
|
|
1446
|
-
const tsconfigPath = options?.tsconfigPath ?
|
|
1474
|
+
const tsconfigPath = options?.tsconfigPath ? options.tsconfigPath : void 0;
|
|
1447
1475
|
const isTypeAware = !!tsconfigPath;
|
|
1448
1476
|
const typeAwareRules = {
|
|
1449
1477
|
"dot-notation": "off",
|
|
1450
1478
|
"no-implied-eval": "off",
|
|
1451
|
-
"no-throw-literal": "off",
|
|
1452
1479
|
"ts/await-thenable": "error",
|
|
1453
1480
|
"ts/dot-notation": ["error", { allowKeywords: true }],
|
|
1454
1481
|
"ts/no-floating-promises": "error",
|
|
@@ -1461,8 +1488,12 @@ async function typescript(options = {}) {
|
|
|
1461
1488
|
"ts/no-unsafe-call": "error",
|
|
1462
1489
|
"ts/no-unsafe-member-access": "error",
|
|
1463
1490
|
"ts/no-unsafe-return": "error",
|
|
1491
|
+
"ts/promise-function-async": "error",
|
|
1464
1492
|
"ts/restrict-plus-operands": "error",
|
|
1465
1493
|
"ts/restrict-template-expressions": "error",
|
|
1494
|
+
"ts/return-await": ["error", "in-try-catch"],
|
|
1495
|
+
"ts/strict-boolean-expressions": ["error", { allowNullableBoolean: true, allowNullableObject: true }],
|
|
1496
|
+
"ts/switch-exhaustiveness-check": "error",
|
|
1466
1497
|
"ts/unbound-method": "error"
|
|
1467
1498
|
};
|
|
1468
1499
|
const [
|
|
@@ -1482,7 +1513,10 @@ async function typescript(options = {}) {
|
|
|
1482
1513
|
extraFileExtensions: componentExts.map((ext) => `.${ext}`),
|
|
1483
1514
|
sourceType: "module",
|
|
1484
1515
|
...typeAware ? {
|
|
1485
|
-
|
|
1516
|
+
projectService: {
|
|
1517
|
+
allowDefaultProject: ["./*.js"],
|
|
1518
|
+
defaultProject: tsconfigPath
|
|
1519
|
+
},
|
|
1486
1520
|
tsconfigRootDir: import_node_process2.default.cwd()
|
|
1487
1521
|
} : {},
|
|
1488
1522
|
...parserOptions
|
|
@@ -1525,12 +1559,15 @@ async function typescript(options = {}) {
|
|
|
1525
1559
|
"no-use-before-define": "off",
|
|
1526
1560
|
"no-useless-constructor": "off",
|
|
1527
1561
|
"ts/ban-ts-comment": ["error", { "ts-ignore": "allow-with-description" }],
|
|
1528
|
-
"ts/ban-types": ["error", { types: { Function: false } }],
|
|
1529
1562
|
"ts/consistent-type-definitions": ["error", "interface"],
|
|
1530
|
-
"ts/consistent-type-imports": ["error", {
|
|
1563
|
+
"ts/consistent-type-imports": ["error", {
|
|
1564
|
+
disallowTypeAnnotations: false,
|
|
1565
|
+
prefer: "type-imports"
|
|
1566
|
+
}],
|
|
1531
1567
|
"ts/method-signature-style": ["error", "property"],
|
|
1532
1568
|
"ts/no-dupe-class-members": "error",
|
|
1533
1569
|
"ts/no-dynamic-delete": "off",
|
|
1570
|
+
"ts/no-empty-object-type": ["error", { allowInterfaces: "always" }],
|
|
1534
1571
|
"ts/no-explicit-any": "off",
|
|
1535
1572
|
"ts/no-extraneous-class": "off",
|
|
1536
1573
|
"ts/no-import-type-side-effects": "error",
|
|
@@ -1542,9 +1579,16 @@ async function typescript(options = {}) {
|
|
|
1542
1579
|
"ts/no-unused-vars": "off",
|
|
1543
1580
|
"ts/no-use-before-define": ["error", { classes: false, functions: false, variables: true }],
|
|
1544
1581
|
"ts/no-useless-constructor": "off",
|
|
1545
|
-
"ts/
|
|
1582
|
+
"ts/no-wrapper-object-types": "error",
|
|
1546
1583
|
"ts/triple-slash-reference": "off",
|
|
1547
1584
|
"ts/unified-signatures": "off",
|
|
1585
|
+
...type === "lib" ? {
|
|
1586
|
+
"ts/explicit-function-return-type": ["error", {
|
|
1587
|
+
allowExpressions: true,
|
|
1588
|
+
allowHigherOrderFunctions: true,
|
|
1589
|
+
allowIIFEs: true
|
|
1590
|
+
}]
|
|
1591
|
+
} : {},
|
|
1548
1592
|
...overrides
|
|
1549
1593
|
}
|
|
1550
1594
|
},
|
|
@@ -1552,12 +1596,12 @@ async function typescript(options = {}) {
|
|
|
1552
1596
|
files: filesTypeAware,
|
|
1553
1597
|
name: "eslint:typescript:rules-type-aware",
|
|
1554
1598
|
rules: {
|
|
1555
|
-
...
|
|
1599
|
+
...typeAwareRules,
|
|
1556
1600
|
...overrides
|
|
1557
1601
|
}
|
|
1558
1602
|
}] : [],
|
|
1559
1603
|
{
|
|
1560
|
-
files: ["**/*.d
|
|
1604
|
+
files: ["**/*.d.?([cm])ts"],
|
|
1561
1605
|
name: "eslint:typescript:disables:dts",
|
|
1562
1606
|
rules: {
|
|
1563
1607
|
"eslint-comments/no-unlimited-disable": "off",
|
|
@@ -1990,7 +2034,8 @@ function lincy(options = {}, ...userConfigs) {
|
|
|
1990
2034
|
autoRenamePlugins = true,
|
|
1991
2035
|
componentExts = [],
|
|
1992
2036
|
gitignore: enableGitignore = true,
|
|
1993
|
-
isInEditor =
|
|
2037
|
+
isInEditor = isInEditorEnv(),
|
|
2038
|
+
jsx: enableJsx = true,
|
|
1994
2039
|
overrides = {},
|
|
1995
2040
|
react: enableReact = ReactPackages.some((i) => (0, import_local_pkg4.isPackageExists)(i)),
|
|
1996
2041
|
regexp: enableRegexp = true,
|
|
@@ -1999,9 +2044,10 @@ function lincy(options = {}, ...userConfigs) {
|
|
|
1999
2044
|
vue: enableVue = VuePackages.some((i) => (0, import_local_pkg4.isPackageExists)(i))
|
|
2000
2045
|
} = options;
|
|
2001
2046
|
const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
|
|
2047
|
+
const tsconfigPath = typeof enableTypeScript !== "boolean" && "tsconfigPath" in enableTypeScript ? enableTypeScript.tsconfigPath : void 0;
|
|
2002
2048
|
if (stylisticOptions) {
|
|
2003
2049
|
if (!("jsx" in stylisticOptions)) {
|
|
2004
|
-
stylisticOptions.jsx =
|
|
2050
|
+
stylisticOptions.jsx = enableJsx;
|
|
2005
2051
|
}
|
|
2006
2052
|
}
|
|
2007
2053
|
const configs2 = [];
|
|
@@ -2009,9 +2055,7 @@ function lincy(options = {}, ...userConfigs) {
|
|
|
2009
2055
|
if (typeof enableGitignore !== "boolean") {
|
|
2010
2056
|
configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r(enableGitignore)]));
|
|
2011
2057
|
} else {
|
|
2012
|
-
|
|
2013
|
-
configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r()]));
|
|
2014
|
-
}
|
|
2058
|
+
configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({ strict: false })]));
|
|
2015
2059
|
}
|
|
2016
2060
|
}
|
|
2017
2061
|
configs2.push(
|
|
@@ -2041,9 +2085,14 @@ function lincy(options = {}, ...userConfigs) {
|
|
|
2041
2085
|
configs2.push(typescript({
|
|
2042
2086
|
...typeof enableTypeScript !== "boolean" ? enableTypeScript : {},
|
|
2043
2087
|
componentExts,
|
|
2044
|
-
overrides: overrides.typescript
|
|
2088
|
+
overrides: overrides.typescript,
|
|
2089
|
+
tsconfigPath,
|
|
2090
|
+
type: options.type
|
|
2045
2091
|
}));
|
|
2046
2092
|
}
|
|
2093
|
+
if (enableJsx) {
|
|
2094
|
+
configs2.push(jsx());
|
|
2095
|
+
}
|
|
2047
2096
|
if (stylisticOptions) {
|
|
2048
2097
|
configs2.push(stylistic({
|
|
2049
2098
|
overrides: overrides.stylistic,
|
|
@@ -2073,9 +2122,9 @@ function lincy(options = {}, ...userConfigs) {
|
|
|
2073
2122
|
}
|
|
2074
2123
|
if (enableReact) {
|
|
2075
2124
|
configs2.push(react({
|
|
2125
|
+
tsconfigPath,
|
|
2076
2126
|
...typeof enableReact !== "boolean" ? enableReact : {},
|
|
2077
|
-
overrides: overrides.react
|
|
2078
|
-
typescript: !!enableTypeScript
|
|
2127
|
+
overrides: overrides.react
|
|
2079
2128
|
}));
|
|
2080
2129
|
}
|
|
2081
2130
|
if (enableUnoCSS) {
|
|
@@ -2180,9 +2229,11 @@ var src_default = lincy;
|
|
|
2180
2229
|
ignores,
|
|
2181
2230
|
imports,
|
|
2182
2231
|
interopDefault,
|
|
2232
|
+
isInEditorEnv,
|
|
2183
2233
|
javascript,
|
|
2184
2234
|
jsdoc,
|
|
2185
2235
|
jsonc,
|
|
2236
|
+
jsx,
|
|
2186
2237
|
lincy,
|
|
2187
2238
|
markdown,
|
|
2188
2239
|
node,
|