@solvro/config 1.0.5 → 1.1.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/eslint-config/cli.cjs +6 -3
- package/dist/eslint-config/cli.js +6 -3
- package/dist/eslint-config/index.cjs +433 -253
- package/dist/eslint-config/index.d.cts +6630 -6106
- package/dist/eslint-config/index.d.ts +6630 -6106
- package/dist/eslint-config/index.js +174 -249
- package/dist/eslint-config-prettier-ZT22JTBW.js +217 -0
- package/package.json +6 -3
|
@@ -136,7 +136,7 @@ async function disables() {
|
|
|
136
136
|
rules: {
|
|
137
137
|
"antfu/no-top-level-await": "off",
|
|
138
138
|
"no-console": "off",
|
|
139
|
-
"
|
|
139
|
+
"@typescript-eslint/explicit-function-return-type": "off"
|
|
140
140
|
}
|
|
141
141
|
},
|
|
142
142
|
{
|
|
@@ -160,7 +160,7 @@ async function disables() {
|
|
|
160
160
|
name: "solvro/disables/dts",
|
|
161
161
|
rules: {
|
|
162
162
|
"eslint-comments/no-unlimited-disable": "off",
|
|
163
|
-
"import/no-duplicates": "off",
|
|
163
|
+
"import-x/no-duplicates": "off",
|
|
164
164
|
"no-restricted-syntax": "off",
|
|
165
165
|
"unused-imports/no-unused-vars": "off"
|
|
166
166
|
}
|
|
@@ -169,7 +169,7 @@ async function disables() {
|
|
|
169
169
|
files: ["**/*.js", "**/*.cjs"],
|
|
170
170
|
name: "solvro/disables/cjs",
|
|
171
171
|
rules: {
|
|
172
|
-
"
|
|
172
|
+
"@typescript-eslint/no-require-imports": "off"
|
|
173
173
|
}
|
|
174
174
|
},
|
|
175
175
|
{
|
|
@@ -178,7 +178,7 @@ async function disables() {
|
|
|
178
178
|
rules: {
|
|
179
179
|
"antfu/no-top-level-await": "off",
|
|
180
180
|
"no-console": "off",
|
|
181
|
-
"
|
|
181
|
+
"@typescript-eslint/explicit-function-return-type": "off"
|
|
182
182
|
}
|
|
183
183
|
}
|
|
184
184
|
];
|
|
@@ -186,8 +186,78 @@ async function disables() {
|
|
|
186
186
|
|
|
187
187
|
// eslint-config/configs/formatters.ts
|
|
188
188
|
init_esm_shims();
|
|
189
|
+
|
|
190
|
+
// eslint-config/utils.ts
|
|
191
|
+
init_esm_shims();
|
|
192
|
+
import { isPackageExists } from "local-pkg";
|
|
193
|
+
import process from "node:process";
|
|
194
|
+
import { fileURLToPath } from "node:url";
|
|
195
|
+
var scopeUrl = fileURLToPath(new URL(".", import.meta.url));
|
|
196
|
+
var isCwdInScope = isPackageExists("@solvro/config");
|
|
197
|
+
var parserPlain = {
|
|
198
|
+
meta: {
|
|
199
|
+
name: "parser-plain"
|
|
200
|
+
},
|
|
201
|
+
parseForESLint: (code) => ({
|
|
202
|
+
ast: {
|
|
203
|
+
body: [],
|
|
204
|
+
comments: [],
|
|
205
|
+
loc: { end: code.length, start: 0 },
|
|
206
|
+
range: [0, code.length],
|
|
207
|
+
tokens: [],
|
|
208
|
+
type: "Program"
|
|
209
|
+
},
|
|
210
|
+
scopeManager: null,
|
|
211
|
+
services: { isPlain: true },
|
|
212
|
+
visitorKeys: {
|
|
213
|
+
Program: []
|
|
214
|
+
}
|
|
215
|
+
})
|
|
216
|
+
};
|
|
217
|
+
async function combine(...configs2) {
|
|
218
|
+
const resolved = await Promise.all(configs2);
|
|
219
|
+
return resolved.flat();
|
|
220
|
+
}
|
|
221
|
+
function toArray(value) {
|
|
222
|
+
return Array.isArray(value) ? value : [value];
|
|
223
|
+
}
|
|
224
|
+
async function interopDefault(m) {
|
|
225
|
+
const resolved = await m;
|
|
226
|
+
return resolved.default || resolved;
|
|
227
|
+
}
|
|
228
|
+
function isPackageInScope(name) {
|
|
229
|
+
return isPackageExists(name, { paths: [scopeUrl] });
|
|
230
|
+
}
|
|
231
|
+
async function ensurePackages(packages) {
|
|
232
|
+
if (process.env.CI || process.stdout.isTTY === false || isCwdInScope === false)
|
|
233
|
+
return;
|
|
234
|
+
const nonExistingPackages = packages.filter(
|
|
235
|
+
(i) => i && !isPackageInScope(i)
|
|
236
|
+
);
|
|
237
|
+
if (nonExistingPackages.length === 0) return;
|
|
238
|
+
const p = await import("@clack/prompts");
|
|
239
|
+
const result = await p.confirm({
|
|
240
|
+
message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?`
|
|
241
|
+
});
|
|
242
|
+
if (result)
|
|
243
|
+
await import("@antfu/install-pkg").then(
|
|
244
|
+
(i) => i.installPackage(nonExistingPackages, { dev: true })
|
|
245
|
+
);
|
|
246
|
+
}
|
|
247
|
+
function isInEditorEnv() {
|
|
248
|
+
if (process.env.CI) return false;
|
|
249
|
+
if (isInGitHooksOrLintStaged()) return false;
|
|
250
|
+
return !!(process.env.VSCODE_PID || process.env.VSCODE_CWD || process.env.JETBRAINS_IDE || process.env.VIM || process.env.NVIM);
|
|
251
|
+
}
|
|
252
|
+
function isInGitHooksOrLintStaged() {
|
|
253
|
+
return !!(process.env.GIT_PARAMS || process.env.VSCODE_GIT_COMMAND || process.env.npm_lifecycle_script?.startsWith("lint-staged"));
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
// eslint-config/configs/formatters.ts
|
|
189
257
|
async function formatters() {
|
|
190
|
-
|
|
258
|
+
await ensurePackages(["eslint-plugin-prettier"]);
|
|
259
|
+
const prettierConfig = await interopDefault(import("../eslint-config-prettier-ZT22JTBW.js"));
|
|
260
|
+
return [prettierConfig];
|
|
191
261
|
}
|
|
192
262
|
|
|
193
263
|
// eslint-config/configs/ignores.ts
|
|
@@ -209,18 +279,18 @@ async function imports() {
|
|
|
209
279
|
name: "solvro/imports/rules",
|
|
210
280
|
plugins: {
|
|
211
281
|
antfu: default3,
|
|
212
|
-
import: pluginImport
|
|
282
|
+
"import-x": pluginImport
|
|
213
283
|
},
|
|
214
284
|
rules: {
|
|
215
285
|
"antfu/import-dedupe": "error",
|
|
216
286
|
"antfu/no-import-dist": "error",
|
|
217
287
|
"antfu/no-import-node-modules-by-path": "error",
|
|
218
|
-
"import/first": "error",
|
|
219
|
-
"import/no-duplicates": "error",
|
|
220
|
-
"import/no-mutable-exports": "error",
|
|
221
|
-
"import/no-named-default": "error",
|
|
222
|
-
"import/no-self-import": "error",
|
|
223
|
-
"import/no-webpack-loader-syntax": "error"
|
|
288
|
+
"import-x/first": "error",
|
|
289
|
+
"import-x/no-duplicates": "error",
|
|
290
|
+
"import-x/no-mutable-exports": "error",
|
|
291
|
+
"import-x/no-named-default": "error",
|
|
292
|
+
"import-x/no-self-import": "error",
|
|
293
|
+
"import-x/no-webpack-loader-syntax": "error"
|
|
224
294
|
}
|
|
225
295
|
}
|
|
226
296
|
];
|
|
@@ -465,100 +535,6 @@ async function javascript(options = {}) {
|
|
|
465
535
|
|
|
466
536
|
// eslint-config/configs/jsdoc.ts
|
|
467
537
|
init_esm_shims();
|
|
468
|
-
|
|
469
|
-
// eslint-config/utils.ts
|
|
470
|
-
init_esm_shims();
|
|
471
|
-
import { isPackageExists } from "local-pkg";
|
|
472
|
-
import process from "node:process";
|
|
473
|
-
import { fileURLToPath } from "node:url";
|
|
474
|
-
var scopeUrl = fileURLToPath(new URL(".", import.meta.url));
|
|
475
|
-
var isCwdInScope = isPackageExists("@solvro/config");
|
|
476
|
-
var parserPlain = {
|
|
477
|
-
meta: {
|
|
478
|
-
name: "parser-plain"
|
|
479
|
-
},
|
|
480
|
-
parseForESLint: (code) => ({
|
|
481
|
-
ast: {
|
|
482
|
-
body: [],
|
|
483
|
-
comments: [],
|
|
484
|
-
loc: { end: code.length, start: 0 },
|
|
485
|
-
range: [0, code.length],
|
|
486
|
-
tokens: [],
|
|
487
|
-
type: "Program"
|
|
488
|
-
},
|
|
489
|
-
scopeManager: null,
|
|
490
|
-
services: { isPlain: true },
|
|
491
|
-
visitorKeys: {
|
|
492
|
-
Program: []
|
|
493
|
-
}
|
|
494
|
-
})
|
|
495
|
-
};
|
|
496
|
-
async function combine(...configs2) {
|
|
497
|
-
const resolved = await Promise.all(configs2);
|
|
498
|
-
return resolved.flat();
|
|
499
|
-
}
|
|
500
|
-
function renameRules(rules, map) {
|
|
501
|
-
return Object.fromEntries(
|
|
502
|
-
Object.entries(rules).map(([key, value]) => {
|
|
503
|
-
for (const [from, to] of Object.entries(map)) {
|
|
504
|
-
if (key.startsWith(`${from}/`))
|
|
505
|
-
return [to + key.slice(from.length), value];
|
|
506
|
-
}
|
|
507
|
-
return [key, value];
|
|
508
|
-
})
|
|
509
|
-
);
|
|
510
|
-
}
|
|
511
|
-
function renamePluginInConfigs(configs2, map) {
|
|
512
|
-
return configs2.map((i) => {
|
|
513
|
-
const clone = { ...i };
|
|
514
|
-
if (clone.rules) clone.rules = renameRules(clone.rules, map);
|
|
515
|
-
if (clone.plugins) {
|
|
516
|
-
clone.plugins = Object.fromEntries(
|
|
517
|
-
Object.entries(clone.plugins).map(([key, value]) => {
|
|
518
|
-
if (key in map) return [map[key], value];
|
|
519
|
-
return [key, value];
|
|
520
|
-
})
|
|
521
|
-
);
|
|
522
|
-
}
|
|
523
|
-
return clone;
|
|
524
|
-
});
|
|
525
|
-
}
|
|
526
|
-
function toArray(value) {
|
|
527
|
-
return Array.isArray(value) ? value : [value];
|
|
528
|
-
}
|
|
529
|
-
async function interopDefault(m) {
|
|
530
|
-
const resolved = await m;
|
|
531
|
-
return resolved.default || resolved;
|
|
532
|
-
}
|
|
533
|
-
function isPackageInScope(name) {
|
|
534
|
-
return isPackageExists(name, { paths: [scopeUrl] });
|
|
535
|
-
}
|
|
536
|
-
async function ensurePackages(packages) {
|
|
537
|
-
if (process.env.CI || process.stdout.isTTY === false || isCwdInScope === false)
|
|
538
|
-
return;
|
|
539
|
-
const nonExistingPackages = packages.filter(
|
|
540
|
-
(i) => i && !isPackageInScope(i)
|
|
541
|
-
);
|
|
542
|
-
if (nonExistingPackages.length === 0) return;
|
|
543
|
-
const p = await import("@clack/prompts");
|
|
544
|
-
const result = await p.confirm({
|
|
545
|
-
message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?`
|
|
546
|
-
});
|
|
547
|
-
if (result)
|
|
548
|
-
await import("@antfu/install-pkg").then(
|
|
549
|
-
(i) => i.installPackage(nonExistingPackages, { dev: true })
|
|
550
|
-
);
|
|
551
|
-
}
|
|
552
|
-
function isInEditorEnv() {
|
|
553
|
-
if (process.env.CI) return false;
|
|
554
|
-
if (isInGitHooksOrLintStaged()) return false;
|
|
555
|
-
return !!(process.env.VSCODE_PID || process.env.VSCODE_CWD || process.env.JETBRAINS_IDE || process.env.VIM || process.env.NVIM);
|
|
556
|
-
}
|
|
557
|
-
function isInGitHooksOrLintStaged() {
|
|
558
|
-
return !!(process.env.GIT_PARAMS || process.env.VSCODE_GIT_COMMAND || process.env.npm_lifecycle_script?.startsWith("lint-staged"));
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
// eslint-config/configs/jsdoc.ts
|
|
562
538
|
async function jsdoc() {
|
|
563
539
|
return [
|
|
564
540
|
{
|
|
@@ -656,7 +632,6 @@ async function markdown(options = {}) {
|
|
|
656
632
|
name: "solvro/markdown/disables",
|
|
657
633
|
rules: {
|
|
658
634
|
"antfu/no-top-level-await": "off",
|
|
659
|
-
"import/newline-after-import": "off",
|
|
660
635
|
"no-alert": "off",
|
|
661
636
|
"no-console": "off",
|
|
662
637
|
"no-labels": "off",
|
|
@@ -667,16 +642,14 @@ async function markdown(options = {}) {
|
|
|
667
642
|
"no-unused-labels": "off",
|
|
668
643
|
"no-unused-vars": "off",
|
|
669
644
|
"node/prefer-global/process": "off",
|
|
670
|
-
"
|
|
671
|
-
"
|
|
672
|
-
"
|
|
673
|
-
"
|
|
674
|
-
"
|
|
675
|
-
"
|
|
676
|
-
"
|
|
677
|
-
"
|
|
678
|
-
"ts/no-unused-vars": "off",
|
|
679
|
-
"ts/no-use-before-define": "off",
|
|
645
|
+
"@typescript-eslint/consistent-type-imports": "off",
|
|
646
|
+
"@typescript-eslint/explicit-function-return-type": "off",
|
|
647
|
+
"@typescript-eslint/no-namespace": "off",
|
|
648
|
+
"@typescript-eslint/no-redeclare": "off",
|
|
649
|
+
"@typescript-eslint/no-require-imports": "off",
|
|
650
|
+
"@typescript-eslint/no-unused-expressions": "off",
|
|
651
|
+
"@typescript-eslint/no-unused-vars": "off",
|
|
652
|
+
"@typescript-eslint/no-use-before-define": "off",
|
|
680
653
|
"unicode-bom": "off",
|
|
681
654
|
"unused-imports/no-unused-imports": "off",
|
|
682
655
|
"unused-imports/no-unused-vars": "off",
|
|
@@ -723,17 +696,17 @@ async function react(options = {}) {
|
|
|
723
696
|
tsconfigPath
|
|
724
697
|
} = options;
|
|
725
698
|
await ensurePackages([
|
|
726
|
-
"
|
|
699
|
+
"eslint-plugin-react",
|
|
727
700
|
"eslint-plugin-react-hooks",
|
|
728
701
|
"eslint-plugin-react-refresh"
|
|
729
702
|
]);
|
|
730
703
|
const isTypeAware = !!tsconfigPath;
|
|
731
704
|
const typeAwareRules = {
|
|
732
|
-
"react/no-leaked-
|
|
705
|
+
"react/jsx-no-leaked-render": "warn"
|
|
733
706
|
};
|
|
734
707
|
const [pluginReact, pluginReactHooks, pluginReactRefresh] = await Promise.all(
|
|
735
708
|
[
|
|
736
|
-
interopDefault(import("
|
|
709
|
+
interopDefault(import("eslint-plugin-react")),
|
|
737
710
|
interopDefault(import("eslint-plugin-react-hooks")),
|
|
738
711
|
interopDefault(import("eslint-plugin-react-refresh"))
|
|
739
712
|
]
|
|
@@ -742,19 +715,28 @@ async function react(options = {}) {
|
|
|
742
715
|
(i) => isPackageExists2(i)
|
|
743
716
|
);
|
|
744
717
|
const isUsingNext = NextJsPackages.some((i) => isPackageExists2(i));
|
|
745
|
-
const
|
|
718
|
+
const nextjsConfig = [];
|
|
719
|
+
if (isUsingNext) {
|
|
720
|
+
await ensurePackages(["@next/eslint-plugin-next"]);
|
|
721
|
+
const nextPlugin = await interopDefault(import("@next/eslint-plugin-next"));
|
|
722
|
+
nextjsConfig.push({
|
|
723
|
+
name: "solvro/next/setup",
|
|
724
|
+
plugins: {
|
|
725
|
+
"@next/next": nextPlugin
|
|
726
|
+
},
|
|
727
|
+
rules: nextPlugin.configs.recommended.rules
|
|
728
|
+
});
|
|
729
|
+
}
|
|
746
730
|
return [
|
|
747
731
|
{
|
|
748
732
|
name: "solvro/react/setup",
|
|
749
733
|
plugins: {
|
|
750
|
-
react:
|
|
751
|
-
"react-dom": plugins["@eslint-react/dom"],
|
|
734
|
+
react: pluginReact,
|
|
752
735
|
"react-hooks": pluginReactHooks,
|
|
753
|
-
"react-hooks-extra": plugins["@eslint-react/hooks-extra"],
|
|
754
|
-
"react-naming-convention": plugins["@eslint-react/naming-convention"],
|
|
755
736
|
"react-refresh": pluginReactRefresh
|
|
756
737
|
}
|
|
757
738
|
},
|
|
739
|
+
...nextjsConfig,
|
|
758
740
|
{
|
|
759
741
|
files,
|
|
760
742
|
languageOptions: {
|
|
@@ -765,23 +747,20 @@ async function react(options = {}) {
|
|
|
765
747
|
},
|
|
766
748
|
sourceType: "module"
|
|
767
749
|
},
|
|
750
|
+
settings: {
|
|
751
|
+
react: {
|
|
752
|
+
version: "detect"
|
|
753
|
+
}
|
|
754
|
+
},
|
|
768
755
|
name: "solvro/react/rules",
|
|
769
756
|
rules: {
|
|
770
|
-
|
|
771
|
-
"
|
|
772
|
-
"react-dom/no-dangerously-set-innerhtml": "warn",
|
|
773
|
-
"react-dom/no-dangerously-set-innerhtml-with-children": "error",
|
|
774
|
-
"react-dom/no-find-dom-node": "error",
|
|
775
|
-
"react-dom/no-missing-button-type": "warn",
|
|
776
|
-
"react-dom/no-missing-iframe-sandbox": "warn",
|
|
777
|
-
"react-dom/no-namespace": "error",
|
|
778
|
-
"react-dom/no-render-return-value": "error",
|
|
779
|
-
"react-dom/no-script-url": "warn",
|
|
780
|
-
"react-dom/no-unsafe-iframe-sandbox": "warn",
|
|
781
|
-
"react-dom/no-unsafe-target-blank": "warn",
|
|
757
|
+
...pluginReact.configs.flat?.recommended.rules,
|
|
758
|
+
...pluginReact.configs.flat?.["jsx-runtime"].rules,
|
|
782
759
|
// recommended rules react-hooks
|
|
783
760
|
"react-hooks/exhaustive-deps": "warn",
|
|
784
761
|
"react-hooks/rules-of-hooks": "error",
|
|
762
|
+
"react/jsx-no-useless-fragment": "error",
|
|
763
|
+
"react/jsx-no-leaked-render": "warn",
|
|
785
764
|
// react refresh
|
|
786
765
|
"react-refresh/only-export-components": [
|
|
787
766
|
"warn",
|
|
@@ -806,43 +785,6 @@ async function react(options = {}) {
|
|
|
806
785
|
]
|
|
807
786
|
}
|
|
808
787
|
],
|
|
809
|
-
// recommended rules from @eslint-react
|
|
810
|
-
"react/ensure-forward-ref-using-ref": "warn",
|
|
811
|
-
"react/no-access-state-in-setstate": "error",
|
|
812
|
-
"react/no-array-index-key": "warn",
|
|
813
|
-
"react/no-children-count": "warn",
|
|
814
|
-
"react/no-children-for-each": "warn",
|
|
815
|
-
"react/no-children-map": "warn",
|
|
816
|
-
"react/no-children-only": "warn",
|
|
817
|
-
"react/no-children-prop": "warn",
|
|
818
|
-
"react/no-children-to-array": "warn",
|
|
819
|
-
"react/no-clone-element": "warn",
|
|
820
|
-
"react/no-comment-textnodes": "warn",
|
|
821
|
-
"react/no-component-will-mount": "error",
|
|
822
|
-
"react/no-component-will-receive-props": "error",
|
|
823
|
-
"react/no-component-will-update": "error",
|
|
824
|
-
"react/no-create-ref": "error",
|
|
825
|
-
"react/no-direct-mutation-state": "error",
|
|
826
|
-
"react/no-duplicate-key": "error",
|
|
827
|
-
"react/no-implicit-key": "error",
|
|
828
|
-
"react/no-missing-key": "error",
|
|
829
|
-
"react/no-nested-components": "warn",
|
|
830
|
-
"react/no-redundant-should-component-update": "error",
|
|
831
|
-
"react/no-set-state-in-component-did-mount": "warn",
|
|
832
|
-
"react/no-set-state-in-component-did-update": "warn",
|
|
833
|
-
"react/no-set-state-in-component-will-update": "warn",
|
|
834
|
-
"react/no-string-refs": "error",
|
|
835
|
-
"react/no-unsafe-component-will-mount": "warn",
|
|
836
|
-
"react/no-unsafe-component-will-receive-props": "warn",
|
|
837
|
-
"react/no-unsafe-component-will-update": "warn",
|
|
838
|
-
"react/no-unstable-context-value": "error",
|
|
839
|
-
"react/no-unstable-default-props": "error",
|
|
840
|
-
"react/no-unused-class-component-members": "warn",
|
|
841
|
-
"react/no-unused-state": "warn",
|
|
842
|
-
"react/no-useless-fragment": "warn",
|
|
843
|
-
"react/prefer-destructuring-assignment": "warn",
|
|
844
|
-
"react/prefer-shorthand-boolean": "warn",
|
|
845
|
-
"react/prefer-shorthand-fragment": "warn",
|
|
846
788
|
// overrides
|
|
847
789
|
...overrides
|
|
848
790
|
}
|
|
@@ -907,28 +849,28 @@ async function test(options = {}) {
|
|
|
907
849
|
{
|
|
908
850
|
name: "solvro/test/setup",
|
|
909
851
|
plugins: {
|
|
910
|
-
|
|
852
|
+
"no-only-tests": _pluginTest
|
|
911
853
|
}
|
|
912
854
|
},
|
|
913
855
|
{
|
|
914
856
|
files,
|
|
915
857
|
name: "solvro/test/rules",
|
|
916
858
|
rules: {
|
|
917
|
-
"
|
|
859
|
+
"no-only-tests/consistent-test-it": [
|
|
918
860
|
"error",
|
|
919
861
|
{ fn: "it", withinDescribe: "it" }
|
|
920
862
|
],
|
|
921
|
-
"
|
|
922
|
-
"
|
|
923
|
-
"
|
|
924
|
-
"
|
|
925
|
-
"
|
|
863
|
+
"no-only-tests/no-identical-title": "error",
|
|
864
|
+
"no-only-tests/no-import-node-test": "error",
|
|
865
|
+
"no-only-tests/no-only-tests": isInEditor ? "off" : "error",
|
|
866
|
+
"no-only-tests/prefer-hooks-in-order": "error",
|
|
867
|
+
"no-only-tests/prefer-lowercase-title": "error",
|
|
926
868
|
// Disables
|
|
927
869
|
...{
|
|
928
870
|
"antfu/no-top-level-await": "off",
|
|
929
871
|
"no-unused-expressions": "off",
|
|
930
872
|
"node/prefer-global/process": "off",
|
|
931
|
-
"
|
|
873
|
+
"@typescript-eslint/explicit-function-return-type": "off"
|
|
932
874
|
},
|
|
933
875
|
...overrides
|
|
934
876
|
}
|
|
@@ -959,28 +901,28 @@ async function typescript(options = {}) {
|
|
|
959
901
|
const typeAwareRules = {
|
|
960
902
|
"dot-notation": "off",
|
|
961
903
|
"no-implied-eval": "off",
|
|
962
|
-
"
|
|
963
|
-
"
|
|
964
|
-
"
|
|
965
|
-
"
|
|
966
|
-
"
|
|
967
|
-
"
|
|
968
|
-
"
|
|
969
|
-
"
|
|
970
|
-
"
|
|
971
|
-
"
|
|
972
|
-
"
|
|
973
|
-
"
|
|
974
|
-
"
|
|
975
|
-
"
|
|
976
|
-
"
|
|
977
|
-
"
|
|
978
|
-
"
|
|
904
|
+
"@typescript-eslint/await-thenable": "error",
|
|
905
|
+
"@typescript-eslint/dot-notation": ["error", { allowKeywords: true }],
|
|
906
|
+
"@typescript-eslint/no-floating-promises": "error",
|
|
907
|
+
"@typescript-eslint/no-for-in-array": "error",
|
|
908
|
+
"@typescript-eslint/no-implied-eval": "error",
|
|
909
|
+
"@typescript-eslint/no-misused-promises": "error",
|
|
910
|
+
"@typescript-eslint/no-unnecessary-type-assertion": "error",
|
|
911
|
+
"@typescript-eslint/no-unsafe-argument": "error",
|
|
912
|
+
"@typescript-eslint/no-unsafe-assignment": "error",
|
|
913
|
+
"@typescript-eslint/no-unsafe-call": "error",
|
|
914
|
+
"@typescript-eslint/no-unsafe-member-access": "error",
|
|
915
|
+
"@typescript-eslint/no-unsafe-return": "error",
|
|
916
|
+
"@typescript-eslint/promise-function-async": "error",
|
|
917
|
+
"@typescript-eslint/restrict-plus-operands": "error",
|
|
918
|
+
"@typescript-eslint/restrict-template-expressions": "error",
|
|
919
|
+
"@typescript-eslint/return-await": ["error", "in-try-catch"],
|
|
920
|
+
"@typescript-eslint/strict-boolean-expressions": [
|
|
979
921
|
"error",
|
|
980
922
|
{ allowNullableBoolean: true, allowNullableObject: true }
|
|
981
923
|
],
|
|
982
|
-
"
|
|
983
|
-
"
|
|
924
|
+
"@typescript-eslint/switch-exhaustiveness-check": "error",
|
|
925
|
+
"@typescript-eslint/unbound-method": "error"
|
|
984
926
|
};
|
|
985
927
|
const [pluginTs, parserTs] = await Promise.all([
|
|
986
928
|
interopDefault(import("@typescript-eslint/eslint-plugin")),
|
|
@@ -1014,7 +956,7 @@ async function typescript(options = {}) {
|
|
|
1014
956
|
name: "solvro/typescript/setup",
|
|
1015
957
|
plugins: {
|
|
1016
958
|
antfu: default3,
|
|
1017
|
-
|
|
959
|
+
"@typescript-eslint": pluginTs
|
|
1018
960
|
}
|
|
1019
961
|
},
|
|
1020
962
|
// assign type-aware parser for type-aware files and type-unaware parser for the rest
|
|
@@ -1026,42 +968,43 @@ async function typescript(options = {}) {
|
|
|
1026
968
|
files,
|
|
1027
969
|
name: "solvro/typescript/rules",
|
|
1028
970
|
rules: {
|
|
1029
|
-
...
|
|
1030
|
-
|
|
1031
|
-
{ "@typescript-eslint": "ts" }
|
|
1032
|
-
),
|
|
1033
|
-
...renameRules(pluginTs.configs.strict.rules, {
|
|
1034
|
-
"@typescript-eslint": "ts"
|
|
1035
|
-
}),
|
|
971
|
+
...pluginTs.configs["eslint-recommended"].overrides[0].rules,
|
|
972
|
+
...pluginTs.configs.strict.rules,
|
|
1036
973
|
"no-dupe-class-members": "off",
|
|
1037
974
|
"no-redeclare": "off",
|
|
1038
975
|
"no-use-before-define": "off",
|
|
1039
976
|
"no-useless-constructor": "off",
|
|
1040
|
-
"
|
|
977
|
+
"@typescript-eslint/ban-ts-comment": [
|
|
1041
978
|
"error",
|
|
1042
979
|
{ "ts-expect-error": "allow-with-description" }
|
|
1043
980
|
],
|
|
1044
|
-
"
|
|
1045
|
-
|
|
981
|
+
"@typescript-eslint/consistent-type-definitions": [
|
|
982
|
+
"error",
|
|
983
|
+
"interface"
|
|
984
|
+
],
|
|
985
|
+
"@typescript-eslint/consistent-type-imports": [
|
|
1046
986
|
"error",
|
|
1047
987
|
{
|
|
1048
988
|
disallowTypeAnnotations: false,
|
|
1049
989
|
prefer: "type-imports"
|
|
1050
990
|
}
|
|
1051
991
|
],
|
|
1052
|
-
"
|
|
992
|
+
"@typescript-eslint/method-signature-style": ["error", "property"],
|
|
1053
993
|
// https://www.totaltypescript.com/method-shorthand-syntax-considered-harmful
|
|
1054
|
-
"
|
|
1055
|
-
"
|
|
1056
|
-
"
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
"
|
|
1061
|
-
"
|
|
1062
|
-
"
|
|
1063
|
-
"
|
|
1064
|
-
"
|
|
994
|
+
"@typescript-eslint/no-dupe-class-members": "error",
|
|
995
|
+
"@typescript-eslint/no-dynamic-delete": "off",
|
|
996
|
+
"@typescript-eslint/no-empty-object-type": [
|
|
997
|
+
"error",
|
|
998
|
+
{ allowInterfaces: "always" }
|
|
999
|
+
],
|
|
1000
|
+
"@typescript-eslint/no-explicit-any": "off",
|
|
1001
|
+
"@typescript-eslint/no-extraneous-class": "off",
|
|
1002
|
+
"@typescript-eslint/no-import-type-side-effects": "error",
|
|
1003
|
+
"@typescript-eslint/no-invalid-void-type": "off",
|
|
1004
|
+
"@typescript-eslint/no-non-null-assertion": "off",
|
|
1005
|
+
"@typescript-eslint/no-redeclare": ["error", { builtinGlobals: false }],
|
|
1006
|
+
"@typescript-eslint/no-require-imports": "error",
|
|
1007
|
+
"@typescript-eslint/no-unused-expressions": [
|
|
1065
1008
|
"error",
|
|
1066
1009
|
{
|
|
1067
1010
|
allowShortCircuit: true,
|
|
@@ -1069,17 +1012,17 @@ async function typescript(options = {}) {
|
|
|
1069
1012
|
allowTernary: true
|
|
1070
1013
|
}
|
|
1071
1014
|
],
|
|
1072
|
-
"
|
|
1073
|
-
"
|
|
1015
|
+
"@typescript-eslint/no-unused-vars": "off",
|
|
1016
|
+
"@typescript-eslint/no-use-before-define": [
|
|
1074
1017
|
"error",
|
|
1075
1018
|
{ classes: false, functions: false, variables: true }
|
|
1076
1019
|
],
|
|
1077
|
-
"
|
|
1078
|
-
"
|
|
1079
|
-
"
|
|
1080
|
-
"
|
|
1020
|
+
"@typescript-eslint/no-useless-constructor": "off",
|
|
1021
|
+
"@typescript-eslint/no-wrapper-object-types": "error",
|
|
1022
|
+
"@typescript-eslint/triple-slash-reference": "off",
|
|
1023
|
+
"@typescript-eslint/unified-signatures": "off",
|
|
1081
1024
|
...type === "lib" ? {
|
|
1082
|
-
"
|
|
1025
|
+
"@typescript-eslint/explicit-function-return-type": [
|
|
1083
1026
|
"error",
|
|
1084
1027
|
{
|
|
1085
1028
|
allowExpressions: true,
|
|
@@ -1147,20 +1090,8 @@ var flatConfigProps = [
|
|
|
1147
1090
|
"rules",
|
|
1148
1091
|
"settings"
|
|
1149
1092
|
];
|
|
1150
|
-
var defaultPluginRenaming = {
|
|
1151
|
-
"@eslint-react": "react",
|
|
1152
|
-
"@eslint-react/dom": "react-dom",
|
|
1153
|
-
"@eslint-react/hooks-extra": "react-hooks-extra",
|
|
1154
|
-
"@eslint-react/naming-convention": "react-naming-convention",
|
|
1155
|
-
"@typescript-eslint": "ts",
|
|
1156
|
-
"import-x": "import",
|
|
1157
|
-
n: "node",
|
|
1158
|
-
vitest: "test",
|
|
1159
|
-
yml: "yaml"
|
|
1160
|
-
};
|
|
1161
1093
|
function solvro(options = {}, ...userConfigs) {
|
|
1162
1094
|
const {
|
|
1163
|
-
autoRenamePlugins = true,
|
|
1164
1095
|
componentExts = [],
|
|
1165
1096
|
gitignore: enableGitignore = true,
|
|
1166
1097
|
jsx: enableJsx = true,
|
|
@@ -1273,9 +1204,6 @@ function solvro(options = {}, ...userConfigs) {
|
|
|
1273
1204
|
if (Object.keys(fusedConfig).length) configs2.push([fusedConfig]);
|
|
1274
1205
|
let composer = new FlatConfigComposer();
|
|
1275
1206
|
composer = composer.append(...configs2, ...userConfigs);
|
|
1276
|
-
if (autoRenamePlugins) {
|
|
1277
|
-
composer = composer.renamePlugins(defaultPluginRenaming);
|
|
1278
|
-
}
|
|
1279
1207
|
return composer;
|
|
1280
1208
|
}
|
|
1281
1209
|
function resolveSubOptions(options, key) {
|
|
@@ -1318,7 +1246,6 @@ export {
|
|
|
1318
1246
|
command,
|
|
1319
1247
|
comments,
|
|
1320
1248
|
eslint_config_default as default,
|
|
1321
|
-
defaultPluginRenaming,
|
|
1322
1249
|
disables,
|
|
1323
1250
|
ensurePackages,
|
|
1324
1251
|
formatters,
|
|
@@ -1337,8 +1264,6 @@ export {
|
|
|
1337
1264
|
parserPlain,
|
|
1338
1265
|
react,
|
|
1339
1266
|
regexp,
|
|
1340
|
-
renamePluginInConfigs,
|
|
1341
|
-
renameRules,
|
|
1342
1267
|
resolveSubOptions,
|
|
1343
1268
|
solvro,
|
|
1344
1269
|
test,
|