@will-stone/eslint-config 26.2.1 → 27.0.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 +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +74 -73
- package/package.json +1 -1
package/README.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -9,13 +9,17 @@ import { TSESLint } from '@typescript-eslint/utils';
|
|
|
9
9
|
* @param extraConfigs - Each extra argument is an optional Flat Config.
|
|
10
10
|
* @returns An array of ESLint Flat Configs.
|
|
11
11
|
*/
|
|
12
|
-
declare const config: (options
|
|
12
|
+
declare const config: (options: Options, ...extraConfigs: (TSESLint.FlatConfig.Config | Linter.Config)[]) => Promise<(TSESLint.FlatConfig.Config | Linter.Config)[]>;
|
|
13
13
|
export default config;
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* This is a set of optional features that can be turned on.
|
|
17
17
|
*/
|
|
18
18
|
declare type Options = {
|
|
19
|
+
/**
|
|
20
|
+
* Set this to `import.meta.dirname` as some IDEs look for deps in the wrong directory.
|
|
21
|
+
*/
|
|
22
|
+
cwd: string;
|
|
19
23
|
astro?: boolean;
|
|
20
24
|
react?: boolean;
|
|
21
25
|
tailwind?: {
|
package/dist/index.js
CHANGED
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
import b from "typescript-eslint";
|
|
2
2
|
import g from "@typescript-eslint/parser";
|
|
3
3
|
import h from "confusing-browser-globals";
|
|
4
|
-
import
|
|
4
|
+
import p from "globals";
|
|
5
5
|
import k from "eslint-config-flat-gitignore";
|
|
6
6
|
import q from "eslint-plugin-jsdoc";
|
|
7
7
|
import P from "eslint-plugin-n";
|
|
8
8
|
import D from "eslint-plugin-package-json";
|
|
9
|
-
import
|
|
10
|
-
import
|
|
9
|
+
import _ from "eslint-plugin-perfectionist";
|
|
10
|
+
import O from "@stylistic/eslint-plugin";
|
|
11
11
|
import w from "@typescript-eslint/eslint-plugin";
|
|
12
12
|
import C from "eslint-plugin-unicorn";
|
|
13
13
|
import { globbySync as N } from "globby";
|
|
14
14
|
import { readFileSync as E } from "node:fs";
|
|
15
|
-
import L from "
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
`**/*.
|
|
20
|
-
`**/*.
|
|
21
|
-
`**/*.
|
|
22
|
-
|
|
15
|
+
import L from "node:path";
|
|
16
|
+
import A from "debug";
|
|
17
|
+
const c = "?([cm])[jt]s?(x)", d = `**/*.${c}`, j = "**/*.?([cm])ts", x = "**/*.?([cm])tsx", S = [
|
|
18
|
+
`**/__tests__/**/*.${c}`,
|
|
19
|
+
`**/*.spec.${c}`,
|
|
20
|
+
`**/*.test.${c}`,
|
|
21
|
+
`**/*.bench.${c}`,
|
|
22
|
+
`**/*.benchmark.${c}`
|
|
23
|
+
], T = "**/*.astro", B = "**/*.astro/*.ts", I = "**/*.{jsx,tsx,astro}", G = [
|
|
23
24
|
"**/node_modules",
|
|
24
25
|
"**/dist",
|
|
25
26
|
"**/package-lock.json",
|
|
@@ -49,14 +50,14 @@ async function s(r) {
|
|
|
49
50
|
const e = await r;
|
|
50
51
|
return e.default || e;
|
|
51
52
|
}
|
|
52
|
-
async function
|
|
53
|
+
async function K(r) {
|
|
53
54
|
const [e, o] = await Promise.all([
|
|
54
55
|
s(import("eslint-plugin-astro")),
|
|
55
56
|
s(import("astro-eslint-parser"))
|
|
56
57
|
]);
|
|
57
58
|
return [
|
|
58
59
|
{
|
|
59
|
-
files: [
|
|
60
|
+
files: [T],
|
|
60
61
|
languageOptions: {
|
|
61
62
|
globals: e.environments.astro.globals,
|
|
62
63
|
parser: o,
|
|
@@ -134,13 +135,13 @@ async function G(r) {
|
|
|
134
135
|
}
|
|
135
136
|
];
|
|
136
137
|
}
|
|
137
|
-
function
|
|
138
|
+
function $() {
|
|
138
139
|
return [
|
|
139
140
|
{
|
|
140
141
|
languageOptions: {
|
|
141
142
|
globals: {
|
|
142
|
-
...
|
|
143
|
-
...
|
|
143
|
+
...p.browser,
|
|
144
|
+
...p.es2021
|
|
144
145
|
}
|
|
145
146
|
},
|
|
146
147
|
linterOptions: {
|
|
@@ -399,10 +400,10 @@ function K() {
|
|
|
399
400
|
}
|
|
400
401
|
];
|
|
401
402
|
}
|
|
402
|
-
function
|
|
403
|
+
function R() {
|
|
403
404
|
return [
|
|
404
405
|
{
|
|
405
|
-
ignores:
|
|
406
|
+
ignores: G,
|
|
406
407
|
name: "will-stone/ignores"
|
|
407
408
|
},
|
|
408
409
|
{
|
|
@@ -414,7 +415,7 @@ function $() {
|
|
|
414
415
|
}
|
|
415
416
|
];
|
|
416
417
|
}
|
|
417
|
-
function
|
|
418
|
+
function U() {
|
|
418
419
|
return [
|
|
419
420
|
{
|
|
420
421
|
files: [j, x],
|
|
@@ -503,10 +504,10 @@ function R() {
|
|
|
503
504
|
}
|
|
504
505
|
];
|
|
505
506
|
}
|
|
506
|
-
function
|
|
507
|
+
function F() {
|
|
507
508
|
return [
|
|
508
509
|
{
|
|
509
|
-
languageOptions: { globals:
|
|
510
|
+
languageOptions: { globals: p.node },
|
|
510
511
|
name: "will-stone/node",
|
|
511
512
|
plugins: { n: P },
|
|
512
513
|
rules: {
|
|
@@ -558,7 +559,7 @@ function U() {
|
|
|
558
559
|
}
|
|
559
560
|
];
|
|
560
561
|
}
|
|
561
|
-
function
|
|
562
|
+
function J() {
|
|
562
563
|
return [
|
|
563
564
|
{
|
|
564
565
|
...D.configs.recommended,
|
|
@@ -656,12 +657,12 @@ const y = [
|
|
|
656
657
|
type: "natural"
|
|
657
658
|
}
|
|
658
659
|
];
|
|
659
|
-
function
|
|
660
|
+
function z() {
|
|
660
661
|
return [
|
|
661
662
|
{
|
|
662
663
|
name: "will-stone/perfectionist",
|
|
663
664
|
plugins: {
|
|
664
|
-
perfectionist:
|
|
665
|
+
perfectionist: _
|
|
665
666
|
},
|
|
666
667
|
rules: {
|
|
667
668
|
"perfectionist/sort-array-includes": "off",
|
|
@@ -690,7 +691,7 @@ function J() {
|
|
|
690
691
|
}
|
|
691
692
|
];
|
|
692
693
|
}
|
|
693
|
-
async function
|
|
694
|
+
async function M(r) {
|
|
694
695
|
const [e, o, t] = await Promise.all([
|
|
695
696
|
// @ts-expect-error -- no types
|
|
696
697
|
s(import("eslint-plugin-jsx-a11y")),
|
|
@@ -701,7 +702,7 @@ async function z(r) {
|
|
|
701
702
|
{
|
|
702
703
|
files: [d],
|
|
703
704
|
languageOptions: {
|
|
704
|
-
globals:
|
|
705
|
+
globals: p.browser,
|
|
705
706
|
parserOptions: {
|
|
706
707
|
ecmaFeatures: {
|
|
707
708
|
jsx: !0
|
|
@@ -958,19 +959,19 @@ async function z(r) {
|
|
|
958
959
|
{
|
|
959
960
|
files: [d],
|
|
960
961
|
languageOptions: {
|
|
961
|
-
globals:
|
|
962
|
+
globals: p.browser
|
|
962
963
|
},
|
|
963
964
|
name: "will-stone/react-hooks",
|
|
964
965
|
...t.configs.flat["recommended-latest"]
|
|
965
966
|
}
|
|
966
967
|
];
|
|
967
968
|
}
|
|
968
|
-
function
|
|
969
|
+
function V() {
|
|
969
970
|
return [
|
|
970
971
|
{
|
|
971
972
|
name: "will-stone/style",
|
|
972
973
|
plugins: {
|
|
973
|
-
"@stylistic":
|
|
974
|
+
"@stylistic": O
|
|
974
975
|
},
|
|
975
976
|
rules: {
|
|
976
977
|
"@stylistic/array-bracket-newline": "off",
|
|
@@ -1075,13 +1076,13 @@ function M() {
|
|
|
1075
1076
|
}
|
|
1076
1077
|
];
|
|
1077
1078
|
}
|
|
1078
|
-
async function
|
|
1079
|
+
async function X({
|
|
1079
1080
|
options: { tailwind: r }
|
|
1080
1081
|
}) {
|
|
1081
1082
|
const e = r === !1 || r === !0 ? {} : r, o = await s(import("eslint-plugin-tailwindcss"));
|
|
1082
1083
|
return [
|
|
1083
1084
|
{
|
|
1084
|
-
files: [
|
|
1085
|
+
files: [I],
|
|
1085
1086
|
name: "will-stone/tailwind",
|
|
1086
1087
|
plugins: { tailwindcss: o },
|
|
1087
1088
|
rules: {
|
|
@@ -1115,10 +1116,10 @@ for (const r of w.configs["flat/all"])
|
|
|
1115
1116
|
for (const [e, o] of Object.entries(r.rules || {}))
|
|
1116
1117
|
!e.startsWith("@typescript") && // Deprecated rules.
|
|
1117
1118
|
!["no-new-symbol", "no-return-await"].includes(e) && (v[e] = o);
|
|
1118
|
-
function
|
|
1119
|
+
function H() {
|
|
1119
1120
|
return [
|
|
1120
1121
|
{
|
|
1121
|
-
files: [
|
|
1122
|
+
files: [B, j, x],
|
|
1122
1123
|
languageOptions: {
|
|
1123
1124
|
parser: g,
|
|
1124
1125
|
parserOptions: {
|
|
@@ -1304,7 +1305,7 @@ function X() {
|
|
|
1304
1305
|
}
|
|
1305
1306
|
];
|
|
1306
1307
|
}
|
|
1307
|
-
function
|
|
1308
|
+
function W() {
|
|
1308
1309
|
return [
|
|
1309
1310
|
{
|
|
1310
1311
|
name: "will-stone/unicorn",
|
|
@@ -1479,11 +1480,11 @@ function H() {
|
|
|
1479
1480
|
}
|
|
1480
1481
|
];
|
|
1481
1482
|
}
|
|
1482
|
-
async function
|
|
1483
|
+
async function Q(r) {
|
|
1483
1484
|
const e = await s(import("@vitest/eslint-plugin"));
|
|
1484
1485
|
return [
|
|
1485
1486
|
{
|
|
1486
|
-
files:
|
|
1487
|
+
files: S,
|
|
1487
1488
|
name: "will-stone/vitest",
|
|
1488
1489
|
plugins: { vitest: e },
|
|
1489
1490
|
rules: {
|
|
@@ -1581,73 +1582,73 @@ async function W(r) {
|
|
|
1581
1582
|
}
|
|
1582
1583
|
];
|
|
1583
1584
|
}
|
|
1584
|
-
const
|
|
1585
|
-
{ config:
|
|
1586
|
-
{ config:
|
|
1587
|
-
{ config:
|
|
1588
|
-
{ config:
|
|
1589
|
-
{ config:
|
|
1590
|
-
{ config:
|
|
1591
|
-
{ config:
|
|
1592
|
-
{ config:
|
|
1593
|
-
{ config:
|
|
1585
|
+
const Y = [
|
|
1586
|
+
{ config: R, name: "Ignores" },
|
|
1587
|
+
{ config: $, name: "Base" },
|
|
1588
|
+
{ config: W, name: "Unicorn" },
|
|
1589
|
+
{ config: F, name: "Node" },
|
|
1590
|
+
{ config: J, name: "package.json" },
|
|
1591
|
+
{ config: U, name: "JSDoc" },
|
|
1592
|
+
{ config: V, name: "Style" },
|
|
1593
|
+
{ config: z, name: "Perfectionist" },
|
|
1594
|
+
{ config: H, name: "Typescript" }
|
|
1594
1595
|
], m = [
|
|
1595
1596
|
{
|
|
1596
|
-
config:
|
|
1597
|
+
config: K,
|
|
1597
1598
|
dep: "astro",
|
|
1598
1599
|
name: "Astro.js",
|
|
1599
1600
|
optionName: "astro"
|
|
1600
1601
|
},
|
|
1601
1602
|
{
|
|
1602
|
-
config:
|
|
1603
|
+
config: M,
|
|
1603
1604
|
dep: "react",
|
|
1604
1605
|
name: "React",
|
|
1605
1606
|
optionName: "react"
|
|
1606
1607
|
},
|
|
1607
1608
|
{
|
|
1608
|
-
config:
|
|
1609
|
+
config: X,
|
|
1609
1610
|
dep: "tailwindcss",
|
|
1610
1611
|
name: "Tailwind",
|
|
1611
1612
|
optionName: "tailwind"
|
|
1612
1613
|
},
|
|
1613
1614
|
{
|
|
1614
|
-
config:
|
|
1615
|
+
config: Q,
|
|
1615
1616
|
dep: "vitest",
|
|
1616
1617
|
name: "Vitest",
|
|
1617
1618
|
optionName: "vitest"
|
|
1618
1619
|
}
|
|
1619
1620
|
];
|
|
1620
|
-
function
|
|
1621
|
-
const
|
|
1622
|
-
for (const
|
|
1623
|
-
|
|
1624
|
-
for (const
|
|
1625
|
-
const
|
|
1626
|
-
for (const
|
|
1627
|
-
if ((typeof
|
|
1621
|
+
function Z(r, e) {
|
|
1622
|
+
const o = N(["**/package.json", "!**/node_modules/**"], { cwd: e }), t = {}, l = () => Object.values(t).every(Boolean);
|
|
1623
|
+
for (const i of r)
|
|
1624
|
+
t[i] = !1;
|
|
1625
|
+
for (const i of o) {
|
|
1626
|
+
const f = E(L.join(e, i)), u = new TextDecoder().decode(f), n = JSON.parse(u);
|
|
1627
|
+
for (const a of r)
|
|
1628
|
+
if ((typeof n.dependencies?.[a] == "string" || typeof n.devDependencies?.[a] == "string") && (t[a] = !0, l()))
|
|
1628
1629
|
break;
|
|
1629
|
-
if (
|
|
1630
|
+
if (l())
|
|
1630
1631
|
break;
|
|
1631
1632
|
}
|
|
1632
|
-
return
|
|
1633
|
+
return t;
|
|
1633
1634
|
}
|
|
1634
|
-
const
|
|
1635
|
-
async function re(r
|
|
1636
|
-
const e = [], o = Object.values(m).map(({ dep: n }) => n), t =
|
|
1635
|
+
const ee = A("eslint:ws");
|
|
1636
|
+
async function re(r) {
|
|
1637
|
+
const e = [], o = Object.values(m).map(({ dep: n }) => n), t = Z(o, r.cwd), l = m.filter(({ dep: n, optionName: a }) => (
|
|
1637
1638
|
// Is forced on.
|
|
1638
|
-
!!r[
|
|
1639
|
-
t[n] && r[
|
|
1640
|
-
)),
|
|
1639
|
+
!!r[a] || // Is present and not forced off.
|
|
1640
|
+
t[n] && r[a] !== !1
|
|
1641
|
+
)), i = {
|
|
1641
1642
|
options: r
|
|
1642
1643
|
};
|
|
1643
|
-
for (const n of
|
|
1644
|
-
e.push(n.config(
|
|
1645
|
-
const
|
|
1646
|
-
|
|
1644
|
+
for (const n of Y)
|
|
1645
|
+
e.push(n.config(i));
|
|
1646
|
+
const f = await Promise.all(
|
|
1647
|
+
l.map(async (n) => (ee(`Auto-configured ${n.name} plugin`), n.config(i)))
|
|
1647
1648
|
);
|
|
1648
|
-
return e.push(...
|
|
1649
|
+
return e.push(...f), e.flat();
|
|
1649
1650
|
}
|
|
1650
|
-
const
|
|
1651
|
+
const je = async (r, ...e) => b.config(await re(r), ...e);
|
|
1651
1652
|
export {
|
|
1652
|
-
|
|
1653
|
+
je as default
|
|
1653
1654
|
};
|