@shayanthenerd/eslint-config 0.24.1 → 0.26.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 +69 -59
- package/dist/configs/base.mjs +1 -1
- package/dist/configs/baseline.mjs +22 -0
- package/dist/configs/css.mjs +6 -6
- package/dist/configs/html.mjs +8 -8
- package/dist/configs/next.mjs +20 -0
- package/dist/configs/react.mjs +29 -0
- package/dist/helpers/globs.mjs +2 -11
- package/dist/helpers/ignores/defaultIgnorePatterns.mjs +1 -0
- package/dist/helpers/isPackageDetected.mjs +1 -1
- package/dist/helpers/options/defaultOptions.mjs +48 -11
- package/dist/helpers/options/enableDetectedConfigs.mjs +33 -14
- package/dist/index.mjs +11 -7
- package/dist/prettier.config.mjs +1 -1
- package/dist/rules/astro.mjs +1 -0
- package/dist/rules/baseline.mjs +23 -0
- package/dist/rules/css.mjs +27 -6
- package/dist/rules/html.mjs +7 -7
- package/dist/rules/javascript.mjs +2 -3
- package/dist/rules/next.mjs +28 -0
- package/dist/rules/packageJson.mjs +1 -5
- package/dist/rules/react.mjs +160 -0
- package/dist/rules/typescript.mjs +1 -1
- package/dist/rules/unicorn.mjs +97 -1
- package/dist/rules/vue.mjs +2 -2
- package/dist/types/eslint-schema.d.mts +2384 -348
- package/dist/types/index.d.mts +56 -29
- package/dist/types/options/base.d.mts +0 -16
- package/dist/types/options/baseline.d.mts +106 -0
- package/dist/types/options/nuxt.d.mts +1 -2
- package/dist/types/options/react.d.mts +50 -0
- package/dist/types/options/stylistic.d.mts +1 -1
- package/dist/types/options/test.d.mts +1 -1
- package/dist/types/options/typescript.d.mts +1 -1
- package/dist/types/options/vue.d.mts +1 -1
- package/package.json +22 -17
- package/dist/configs/restrictedDefaultExports.mjs +0 -16
- package/dist/types/options/css.d.mts +0 -27
- package/dist/types/options/html.d.mts +0 -27
- package/dist/types/options/perfectionist.d.mts +0 -18
package/README.md
CHANGED
|
@@ -4,8 +4,8 @@ ESLint configuration for enforcing best practices and maintaining a consistent c
|
|
|
4
4
|
|
|
5
5
|
- **Flexible**: [Highly-customizable options](#customization) and configurations with sensible defaults.
|
|
6
6
|
- **Smart**: Context-aware linting with [automatic dependency detection](#automatic-dependency-detection) and _.gitignore_ recognition.
|
|
7
|
-
- **Comprehensive**: [Supports
|
|
8
|
-
- **Type-safe**: [Fully-typed and well-documented API](#api-reference) with `overrides` support for
|
|
7
|
+
- **Comprehensive**: [Supports useful plugins](#plugin-support) for TypeScript, React & Next, Vue & Nuxt, Astro, Tailwind, and more.
|
|
8
|
+
- **Type-safe**: [Fully-typed and well-documented API](#api-reference) with `overrides` support for built-in configuration objects.
|
|
9
9
|
- **Modern**: Requires ESLint ^10.4.0 and Node.js ^20.19.0 (ESM-only)
|
|
10
10
|
|
|
11
11
|
## Table of Contents
|
|
@@ -25,41 +25,40 @@ ESLint configuration for enforcing best practices and maintaining a consistent c
|
|
|
25
25
|
|
|
26
26
|
## Plugin Support
|
|
27
27
|
Legend:
|
|
28
|
-
- ✅
|
|
29
|
-
-
|
|
30
|
-
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
|
35
|
-
|
|
|
36
|
-
|
|
|
37
|
-
| [
|
|
38
|
-
| [
|
|
39
|
-
| [
|
|
40
|
-
|
|
|
41
|
-
| [
|
|
42
|
-
|
|
|
43
|
-
|
|
|
44
|
-
| [
|
|
45
|
-
|
|
|
46
|
-
| [
|
|
47
|
-
| [
|
|
48
|
-
| [
|
|
49
|
-
| [
|
|
50
|
-
|
|
|
51
|
-
|
|
|
52
|
-
| [
|
|
53
|
-
| [
|
|
54
|
-
| [
|
|
55
|
-
|
|
|
56
|
-
|
|
|
57
|
-
| [
|
|
58
|
-
| [
|
|
59
|
-
| [Imports][plugin-import-x]
|
|
60
|
-
| [
|
|
61
|
-
| [
|
|
62
|
-
| [Unicorn][plugin-unicorn] | ⌛️ | N/A |
|
|
28
|
+
- ✅ Enabled by default
|
|
29
|
+
- ❌ Disabled by default
|
|
30
|
+
- 🔎 [Automatically detected](#automatic-dependency-detection) (`autoDetectDeps: true`, `env: 'browser'` for Baseline)
|
|
31
|
+
|
|
32
|
+
| Category | Activation |
|
|
33
|
+
| :---------------------------------------------------------------------------------------------------- | :--------: |
|
|
34
|
+
| **Languages** | |
|
|
35
|
+
| [JavaScript][eslint] | ✅ |
|
|
36
|
+
| [TypeScript][plugin-ts] | 🔎 |
|
|
37
|
+
| [Markdown][plugin-md] | ✅ |
|
|
38
|
+
| [HTML][plugin-html] | ❌ |
|
|
39
|
+
| [CSS][plugin-css] | ❌ |
|
|
40
|
+
| **Formatting** | |
|
|
41
|
+
| [Stylistic][plugin-stylistic] | ✅ |
|
|
42
|
+
| [Perfectionist][plugin-perfectionist] | ✅ |
|
|
43
|
+
| **Frameworks & Libraries** | |
|
|
44
|
+
| [Astro][plugin-astro] ([jsx-accessibility][plugin-jsx-a11y]) | 🔎 |
|
|
45
|
+
| [React][plugin-react] ([jsx-accessibility][plugin-jsx-a11y], [@html-eslint/react][plugin-html-react]) | 🔎 |
|
|
46
|
+
| [Next][plugin-next] | 🔎 |
|
|
47
|
+
| [Vue & Nuxt][plugin-vue] ([vue-accessibility][plugin-vue-a11y]) | 🔎 |
|
|
48
|
+
| [Tailwind][plugin-tailwind] | ❌ |
|
|
49
|
+
| [Zod & Zod Mini][plugin-zod] | 🔎 |
|
|
50
|
+
| **Testing Tools** | |
|
|
51
|
+
| [Storybook][plugin-storybook] | 🔎 |
|
|
52
|
+
| [Vitest][plugin-vitest] | 🔎 |
|
|
53
|
+
| [Cypress][plugin-cypress] | 🔎 |
|
|
54
|
+
| [Playwright][plugin-playwright] | 🔎 |
|
|
55
|
+
| **Miscellaneous** | |
|
|
56
|
+
| [_package.json_][plugin-package-json] | ✅ |
|
|
57
|
+
| [Node][plugin-n] | ✅ |
|
|
58
|
+
| [Promises][plugin-promise] | ✅ |
|
|
59
|
+
| [Imports][plugin-import-x] | ✅ |
|
|
60
|
+
| [Unicorn][plugin-unicorn] | ✅ |
|
|
61
|
+
| [Baseline][plugin-baseline] | 🔎 |
|
|
63
62
|
|
|
64
63
|
## Installation and Configuration
|
|
65
64
|
1. Install the package and ESLint as dev dependencies:
|
|
@@ -461,31 +460,13 @@ _.vscode/settings.json_:
|
|
|
461
460
|
functionStyle?: 'expression' | 'declaration',
|
|
462
461
|
maxDepth?: number,
|
|
463
462
|
maxNestedCallbacks?: number,
|
|
464
|
-
preferNamedExports?: boolean,
|
|
465
463
|
overrides?: Overrides,
|
|
466
464
|
},
|
|
467
465
|
css?: boolean | {
|
|
468
|
-
allowedRelativeFontUnits?: (
|
|
469
|
-
| '%'
|
|
470
|
-
| 'ch'
|
|
471
|
-
| 'em'
|
|
472
|
-
| 'ex'
|
|
473
|
-
| 'ic'
|
|
474
|
-
| 'lh'
|
|
475
|
-
| 'cap'
|
|
476
|
-
| 'rch'
|
|
477
|
-
| 'rem'
|
|
478
|
-
| 'rex'
|
|
479
|
-
| 'ric'
|
|
480
|
-
| 'rlh'
|
|
481
|
-
| 'rcap'
|
|
482
|
-
)[],
|
|
483
|
-
useBaseline?: false | number | 'newly' | 'widely',
|
|
484
466
|
overrides?: Overrides,
|
|
485
467
|
},
|
|
486
468
|
html?: boolean | {
|
|
487
469
|
idNamingConvention?: 'camelCase' | 'kebab-case' | 'PascalCase' | 'snake_case',
|
|
488
|
-
useBaseline?: false | number | 'newly' | 'widely',
|
|
489
470
|
overrides?: Overrides,
|
|
490
471
|
},
|
|
491
472
|
importX?: boolean | {
|
|
@@ -497,6 +478,9 @@ _.vscode/settings.json_:
|
|
|
497
478
|
language?: 'gfm' | 'commonmark',
|
|
498
479
|
overrides?: Overrides,
|
|
499
480
|
},
|
|
481
|
+
next?: boolean | {
|
|
482
|
+
overrides?: Overrides,
|
|
483
|
+
},
|
|
500
484
|
node?: boolean | {
|
|
501
485
|
overrides?: Overrides,
|
|
502
486
|
},
|
|
@@ -519,6 +503,14 @@ _.vscode/settings.json_:
|
|
|
519
503
|
promise?: boolean | {
|
|
520
504
|
overrides?: Overrides,
|
|
521
505
|
},
|
|
506
|
+
react?: boolean | {
|
|
507
|
+
accessibility?: boolean | {
|
|
508
|
+
anchorComponents?: string[],
|
|
509
|
+
headingComponents?: string[],
|
|
510
|
+
imageComponents?: string[],
|
|
511
|
+
},
|
|
512
|
+
overrides?: Overrides,
|
|
513
|
+
},
|
|
522
514
|
stylistic?: boolean | {
|
|
523
515
|
arrowParens?: 'always' | 'as-needed',
|
|
524
516
|
indent?: number,
|
|
@@ -528,7 +520,7 @@ _.vscode/settings.json_:
|
|
|
528
520
|
maxLineLength?: number,
|
|
529
521
|
memberDelimiterStyle?: 'semi' | 'comma',
|
|
530
522
|
quotes?: 'double' | 'single' | 'backtick',
|
|
531
|
-
|
|
523
|
+
selfCloseVoidHtmlElements?: 'never' | 'always',
|
|
532
524
|
semi?: 'never' | 'always',
|
|
533
525
|
trailingComma?: 'never' | 'always' | 'only-multiline' | 'always-multiline',
|
|
534
526
|
overrides?: Overrides,
|
|
@@ -574,6 +566,23 @@ _.vscode/settings.json_:
|
|
|
574
566
|
unicorn?: boolean | {
|
|
575
567
|
overrides?: Overrides,
|
|
576
568
|
},
|
|
569
|
+
useBaseline?: boolean | {
|
|
570
|
+
baseline?: number | 'newly' | 'widely',
|
|
571
|
+
css?: {
|
|
572
|
+
allowedAtRules?: AllowedAtRules,
|
|
573
|
+
allowedFunctions?: AllowedFunctions,
|
|
574
|
+
allowedMediaConditions?: AllowedMediaConditions,
|
|
575
|
+
allowedProperties?: AllowedProperties,
|
|
576
|
+
allowedPropertyValues?: AllowedPropertyValues,
|
|
577
|
+
allowedSelectors?: AllowedSelectors,
|
|
578
|
+
allowedUnits?: AllowedUnits,
|
|
579
|
+
},
|
|
580
|
+
javascript?: {
|
|
581
|
+
ignoredFeatures?: string[],
|
|
582
|
+
ignoredNodeTypes?: string[],
|
|
583
|
+
},
|
|
584
|
+
overrides?: Overrides,
|
|
585
|
+
},
|
|
577
586
|
vue?: boolean | {
|
|
578
587
|
accessibility?: boolean | {
|
|
579
588
|
accessibleChildComponents?: string[],
|
|
@@ -647,7 +656,7 @@ You can find a list of all available versions and their changelogs on the [relea
|
|
|
647
656
|
|
|
648
657
|
## Roadmap to v1.0.0
|
|
649
658
|
- [x] Add integration for ESLint plugins such as [eslint-plugin-n][plugin-n], [eslint-plugin-unicorn][plugin-unicorn], and more.
|
|
650
|
-
- [
|
|
659
|
+
- [x] Add support for React, Next, Astro, and Markdown.
|
|
651
660
|
- [ ] Develop an interactive starter wizard to quickly scaffold the configurations for ESLint, Prettier, etc.
|
|
652
661
|
|
|
653
662
|
## Contribution Guide
|
|
@@ -672,20 +681,21 @@ This project was inspired by the work of [Anthony Fu][antfu], whose generous con
|
|
|
672
681
|
|
|
673
682
|
<!-- ESLint Plugins -->
|
|
674
683
|
[plugin-astro]: https://ota-meshi.github.io/eslint-plugin-astro
|
|
684
|
+
[plugin-baseline]: https://baselinejs.vercel.app
|
|
675
685
|
[plugin-css]: https://github.com/eslint/css
|
|
676
686
|
[plugin-cypress]: https://github.com/cypress-io/eslint-plugin-cypress
|
|
677
687
|
[plugin-html]: https://html-eslint.org
|
|
688
|
+
[plugin-html-react]: https://html-eslint.org/docs/react/getting-started
|
|
678
689
|
[plugin-import-x]: https://github.com/un-ts/eslint-plugin-import-x
|
|
679
690
|
[plugin-jsx-a11y]: https://github.com/jsx-eslint/eslint-plugin-jsx-a11y
|
|
680
691
|
[plugin-md]: https://github.com/eslint/markdown
|
|
681
692
|
[plugin-n]: https://github.com/eslint-community/eslint-plugin-n
|
|
682
|
-
[plugin-next]: https://
|
|
693
|
+
[plugin-next]: https://github.com/vercel/next.js/tree/HEAD/packages/eslint-plugin-next
|
|
683
694
|
[plugin-package-json]: https://github.com/JoshuaKGoldberg/eslint-plugin-package-json
|
|
684
695
|
[plugin-perfectionist]: https://perfectionist.dev
|
|
685
696
|
[plugin-playwright]: https://github.com/mskelton/eslint-plugin-playwright
|
|
686
697
|
[plugin-promise]: https://github.com/eslint-community/eslint-plugin-promise
|
|
687
698
|
[plugin-react]: https://eslint-react.xyz
|
|
688
|
-
[plugin-react-hooks]: https://react.dev/reference/eslint-plugin-react-hooks
|
|
689
699
|
[plugin-storybook]: https://storybook.js.org/docs/configure/integration/eslint-plugin
|
|
690
700
|
[plugin-stylistic]: https://eslint.style
|
|
691
701
|
[plugin-tailwind]: https://github.com/schoero/eslint-plugin-better-tailwindcss
|
package/dist/configs/base.mjs
CHANGED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { isTruthy } from "../utils/isTruthy.mjs";
|
|
2
|
+
import { globs } from "../helpers/globs.mjs";
|
|
3
|
+
import { isEnabled } from "../utils/isEnabled.mjs";
|
|
4
|
+
import { getBaselineRules } from "../rules/baseline.mjs";
|
|
5
|
+
import eslintPluginBaselineJs from "eslint-plugin-baseline-js";
|
|
6
|
+
//#region src/configs/baseline.ts
|
|
7
|
+
function getBaselineConfig(options) {
|
|
8
|
+
const { vue, astro } = options.configs;
|
|
9
|
+
return {
|
|
10
|
+
name: "shayanthenerd/baseline",
|
|
11
|
+
files: [
|
|
12
|
+
globs.src,
|
|
13
|
+
isEnabled(vue) ? globs.vue : "",
|
|
14
|
+
isEnabled(astro) ? globs.astro : ""
|
|
15
|
+
].filter(isTruthy),
|
|
16
|
+
ignores: [globs.test, globs.coverage],
|
|
17
|
+
plugins: { "baseline-js": eslintPluginBaselineJs },
|
|
18
|
+
rules: getBaselineRules(options)
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
export { getBaselineConfig };
|
package/dist/configs/css.mjs
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
import { globs } from "../helpers/globs.mjs";
|
|
2
2
|
import { isEnabled } from "../utils/isEnabled.mjs";
|
|
3
3
|
import { defaultOptions } from "../helpers/options/defaultOptions.mjs";
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
4
|
+
import { getCssRules } from "../rules/css.mjs";
|
|
5
|
+
import eslintPluginCss from "@eslint/css";
|
|
6
6
|
import { mergeConfigs } from "eslint-flat-config-utils";
|
|
7
7
|
import { tailwind3, tailwind4 } from "tailwind-csstree";
|
|
8
8
|
//#region src/configs/css.ts
|
|
9
|
-
function
|
|
9
|
+
function getCssConfig(options) {
|
|
10
10
|
const { css, tailwind } = options.configs;
|
|
11
11
|
const { overrides } = isEnabled(css) ? css : defaultOptions.configs.css;
|
|
12
12
|
const tailwindSyntax = isEnabled(tailwind) && tailwind.entryPoint ? tailwind4 : tailwind3;
|
|
13
13
|
return mergeConfigs({
|
|
14
14
|
name: "shayanthenerd/css",
|
|
15
15
|
files: [globs.css],
|
|
16
|
-
plugins: { css:
|
|
16
|
+
plugins: { css: eslintPluginCss },
|
|
17
17
|
language: "css/css",
|
|
18
18
|
languageOptions: {
|
|
19
19
|
tolerant: true,
|
|
20
20
|
customSyntax: isEnabled(tailwind) ? tailwindSyntax : void 0
|
|
21
21
|
},
|
|
22
|
-
rules:
|
|
22
|
+
rules: getCssRules(options)
|
|
23
23
|
}, overrides);
|
|
24
24
|
}
|
|
25
25
|
//#endregion
|
|
26
|
-
export {
|
|
26
|
+
export { getCssConfig };
|
package/dist/configs/html.mjs
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import { globs } from "../helpers/globs.mjs";
|
|
2
2
|
import { isEnabled } from "../utils/isEnabled.mjs";
|
|
3
3
|
import { defaultOptions } from "../helpers/options/defaultOptions.mjs";
|
|
4
|
-
import {
|
|
4
|
+
import { getHtmlRules } from "../rules/html.mjs";
|
|
5
5
|
import { mergeConfigs } from "eslint-flat-config-utils";
|
|
6
6
|
import eslintPluginUnicorn from "eslint-plugin-unicorn";
|
|
7
|
-
import
|
|
7
|
+
import eslintPluginHtml from "@html-eslint/eslint-plugin";
|
|
8
8
|
//#region src/configs/html.ts
|
|
9
|
-
function
|
|
9
|
+
function getHtmlConfig(options) {
|
|
10
10
|
const { html, unicorn } = options.configs;
|
|
11
11
|
const { overrides } = isEnabled(html) ? html : defaultOptions.configs.html;
|
|
12
12
|
return mergeConfigs({
|
|
13
13
|
name: "shayanthenerd/html",
|
|
14
|
-
files: [globs.html],
|
|
14
|
+
files: [globs.src, globs.html],
|
|
15
15
|
plugins: {
|
|
16
|
-
"@html-eslint":
|
|
16
|
+
"@html-eslint": eslintPluginHtml,
|
|
17
17
|
...isEnabled(unicorn) && { unicorn: eslintPluginUnicorn }
|
|
18
18
|
},
|
|
19
|
-
languageOptions: { parser:
|
|
20
|
-
rules:
|
|
19
|
+
languageOptions: { parser: eslintPluginHtml.configs["flat/recommended"].languageOptions.parser },
|
|
20
|
+
rules: getHtmlRules(options)
|
|
21
21
|
}, overrides);
|
|
22
22
|
}
|
|
23
23
|
//#endregion
|
|
24
|
-
export {
|
|
24
|
+
export { getHtmlConfig };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { globs } from "../helpers/globs.mjs";
|
|
2
|
+
import { isEnabled } from "../utils/isEnabled.mjs";
|
|
3
|
+
import { defaultOptions } from "../helpers/options/defaultOptions.mjs";
|
|
4
|
+
import { getNextRules } from "../rules/next.mjs";
|
|
5
|
+
import { mergeConfigs } from "eslint-flat-config-utils";
|
|
6
|
+
import eslintPluginNext from "@next/eslint-plugin-next";
|
|
7
|
+
//#region src/configs/next.ts
|
|
8
|
+
function getNextConfig(options) {
|
|
9
|
+
const { packageDir, configs: { next } } = options;
|
|
10
|
+
const { overrides } = isEnabled(next) ? next : defaultOptions.configs.next;
|
|
11
|
+
return mergeConfigs({
|
|
12
|
+
name: "shayanthenerd/next",
|
|
13
|
+
files: [globs.src],
|
|
14
|
+
plugins: { next: eslintPluginNext },
|
|
15
|
+
settings: { next: { rootDir: packageDir } },
|
|
16
|
+
rules: getNextRules()
|
|
17
|
+
}, overrides);
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
export { getNextConfig };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { globs } from "../helpers/globs.mjs";
|
|
2
|
+
import { isEnabled } from "../utils/isEnabled.mjs";
|
|
3
|
+
import { defaultOptions } from "../helpers/options/defaultOptions.mjs";
|
|
4
|
+
import { getReactRules } from "../rules/react.mjs";
|
|
5
|
+
import { mergeConfigs } from "eslint-flat-config-utils";
|
|
6
|
+
import eslintPluginUnicorn from "eslint-plugin-unicorn";
|
|
7
|
+
import eslintPluginJsxA11y from "eslint-plugin-jsx-a11y";
|
|
8
|
+
import eslintPluginReact from "@eslint-react/eslint-plugin";
|
|
9
|
+
import eslintPluginHtmlReact from "@html-eslint/eslint-plugin-react";
|
|
10
|
+
//#region src/configs/react.ts
|
|
11
|
+
function getReactConfig(options) {
|
|
12
|
+
const { react, unicorn } = options.configs;
|
|
13
|
+
const { overrides, accessibility } = isEnabled(react) ? react : defaultOptions.configs.react;
|
|
14
|
+
return mergeConfigs({
|
|
15
|
+
name: "shayanthenerd/react",
|
|
16
|
+
files: [globs.src],
|
|
17
|
+
plugins: {
|
|
18
|
+
"@eslint-react": eslintPluginReact,
|
|
19
|
+
...isEnabled(unicorn) && { unicorn: eslintPluginUnicorn },
|
|
20
|
+
...isEnabled(accessibility) && {
|
|
21
|
+
"jsx-a11y": eslintPluginJsxA11y,
|
|
22
|
+
"@html-eslint/react": eslintPluginHtmlReact
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
rules: getReactRules(options)
|
|
26
|
+
}, overrides);
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
export { getReactConfig };
|
package/dist/helpers/globs.mjs
CHANGED
|
@@ -3,16 +3,6 @@ const srcExtensions = "?([mc])[jt]s?(x)";
|
|
|
3
3
|
const vueExtensions = `{vue,${srcExtensions}}`;
|
|
4
4
|
const globs = {
|
|
5
5
|
src: `**/*.${srcExtensions}`,
|
|
6
|
-
restrictedDefaultExports: `**/{${[
|
|
7
|
-
"shared",
|
|
8
|
-
"dto?(s)",
|
|
9
|
-
"model?(s)",
|
|
10
|
-
"helper?(s)",
|
|
11
|
-
"module?(s)",
|
|
12
|
-
"util?(s|ities)",
|
|
13
|
-
"composable?(s)",
|
|
14
|
-
"repo?(s|sitory|sitories)"
|
|
15
|
-
].join(",")}}/**/*.${srcExtensions}`,
|
|
16
6
|
packageJson: "**/package.json",
|
|
17
7
|
markdown: "**/*.md",
|
|
18
8
|
html: "**/*.html",
|
|
@@ -22,7 +12,8 @@ const globs = {
|
|
|
22
12
|
vueServerComponents: `**/*.server.${vueExtensions}`,
|
|
23
13
|
vueAppErrorLayoutsPages: `**/{{app,error},{layouts,pages}/**/*}.${vueExtensions}`,
|
|
24
14
|
storybook: `**/*.(story|stories).${srcExtensions}`,
|
|
25
|
-
test: `**/{__tests__/*,*.{test,spec,cy,bench?(mark)}.${srcExtensions}
|
|
15
|
+
test: `**/{__tests__/*,*.{test,spec,cy,bench?(mark)}.${srcExtensions}`,
|
|
16
|
+
coverage: "**/coverage/**"
|
|
26
17
|
};
|
|
27
18
|
//#endregion
|
|
28
19
|
export { globs };
|
|
@@ -7,7 +7,7 @@ const detectedPackages = [];
|
|
|
7
7
|
function logDetectedPackages() {
|
|
8
8
|
if (detectedPackages.length > 0) {
|
|
9
9
|
detectedPackages.sort();
|
|
10
|
-
console.info(styleText("green", "✔")
|
|
10
|
+
console.info(`${styleText("green", "✔")} Active ESLint integrations:`, detectedPackages.map((packageName) => styleText("blue", packageName)).join(", "));
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
13
|
function isPackageDetected(packageName, options) {
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
//#region src/helpers/options/defaultOptions.ts
|
|
2
2
|
const defaultOptions = {
|
|
3
3
|
autoDetectDeps: true,
|
|
4
|
-
env: "
|
|
4
|
+
env: "browser",
|
|
5
5
|
gitignore: ".gitignore",
|
|
6
6
|
packageDir: ".",
|
|
7
|
-
tsConfig: false,
|
|
8
7
|
project: {
|
|
9
8
|
basePath: ".",
|
|
10
9
|
globals: {
|
|
@@ -39,17 +38,11 @@ const defaultOptions = {
|
|
|
39
38
|
functionStyle: "declaration",
|
|
40
39
|
maxDepth: 3,
|
|
41
40
|
maxNestedCallbacks: 3,
|
|
42
|
-
preferNamedExports: true,
|
|
43
|
-
overrides: {}
|
|
44
|
-
},
|
|
45
|
-
css: {
|
|
46
|
-
allowedRelativeFontUnits: ["rem", "em"],
|
|
47
|
-
useBaseline: false,
|
|
48
41
|
overrides: {}
|
|
49
42
|
},
|
|
43
|
+
css: { overrides: {} },
|
|
50
44
|
html: {
|
|
51
45
|
idNamingConvention: "snake_case",
|
|
52
|
-
useBaseline: false,
|
|
53
46
|
overrides: {}
|
|
54
47
|
},
|
|
55
48
|
importX: { overrides: {} },
|
|
@@ -59,6 +52,7 @@ const defaultOptions = {
|
|
|
59
52
|
language: "gfm",
|
|
60
53
|
overrides: {}
|
|
61
54
|
},
|
|
55
|
+
next: { overrides: {} },
|
|
62
56
|
node: { overrides: {} },
|
|
63
57
|
nuxt: {
|
|
64
58
|
icon: { component: "Icon" },
|
|
@@ -71,6 +65,32 @@ const defaultOptions = {
|
|
|
71
65
|
overrides: {}
|
|
72
66
|
},
|
|
73
67
|
promise: { overrides: {} },
|
|
68
|
+
react: {
|
|
69
|
+
accessibility: {
|
|
70
|
+
anchorComponents: [
|
|
71
|
+
"Link",
|
|
72
|
+
"NextLink",
|
|
73
|
+
"NavLink"
|
|
74
|
+
],
|
|
75
|
+
headingComponents: [
|
|
76
|
+
"H1",
|
|
77
|
+
"H2",
|
|
78
|
+
"H3",
|
|
79
|
+
"H4",
|
|
80
|
+
"H5",
|
|
81
|
+
"H6"
|
|
82
|
+
],
|
|
83
|
+
imageComponents: [
|
|
84
|
+
"Img",
|
|
85
|
+
"LazyImg",
|
|
86
|
+
"Image",
|
|
87
|
+
"LazyImage",
|
|
88
|
+
"NextImage",
|
|
89
|
+
"LazyNextImage"
|
|
90
|
+
]
|
|
91
|
+
},
|
|
92
|
+
overrides: {}
|
|
93
|
+
},
|
|
74
94
|
stylistic: {
|
|
75
95
|
arrowParens: "always",
|
|
76
96
|
indent: 2,
|
|
@@ -81,7 +101,7 @@ const defaultOptions = {
|
|
|
81
101
|
memberDelimiterStyle: "comma",
|
|
82
102
|
quotes: "single",
|
|
83
103
|
semi: "always",
|
|
84
|
-
|
|
104
|
+
selfCloseVoidHtmlElements: "always",
|
|
85
105
|
trailingComma: "always-multiline",
|
|
86
106
|
overrides: {}
|
|
87
107
|
},
|
|
@@ -104,11 +124,28 @@ const defaultOptions = {
|
|
|
104
124
|
typescript: {
|
|
105
125
|
allowedDefaultProjects: [],
|
|
106
126
|
methodSignatureStyle: "method",
|
|
107
|
-
removeUnusedImports:
|
|
127
|
+
removeUnusedImports: false,
|
|
108
128
|
typeDefinitionStyle: "interface",
|
|
109
129
|
overrides: {}
|
|
110
130
|
},
|
|
111
131
|
unicorn: { overrides: {} },
|
|
132
|
+
useBaseline: {
|
|
133
|
+
baseline: "widely",
|
|
134
|
+
css: {
|
|
135
|
+
allowedAtRules: [],
|
|
136
|
+
allowedFunctions: [],
|
|
137
|
+
allowedMediaConditions: [],
|
|
138
|
+
allowedProperties: [],
|
|
139
|
+
allowedPropertyValues: {},
|
|
140
|
+
allowedSelectors: [],
|
|
141
|
+
allowedUnits: []
|
|
142
|
+
},
|
|
143
|
+
javascript: {
|
|
144
|
+
ignoredFeatures: [],
|
|
145
|
+
ignoredNodeTypes: []
|
|
146
|
+
},
|
|
147
|
+
overrides: {}
|
|
148
|
+
},
|
|
112
149
|
vue: {
|
|
113
150
|
accessibility: {
|
|
114
151
|
accessibleChildComponents: [
|
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
import { isPackageDetected, logDetectedPackages } from "../isPackageDetected.mjs";
|
|
2
2
|
//#region src/helpers/options/enableDetectedConfigs.ts
|
|
3
3
|
function enableDetectedConfigs(options) {
|
|
4
|
+
const autoDetectedDeps = {
|
|
5
|
+
typescript: isPackageDetected("typescript", options),
|
|
6
|
+
zod: isPackageDetected("zod", options),
|
|
7
|
+
astro: isPackageDetected("astro", options),
|
|
8
|
+
react: isPackageDetected("react", options),
|
|
9
|
+
next: isPackageDetected("next", options),
|
|
10
|
+
vue: isPackageDetected("vue", options),
|
|
11
|
+
nuxt: isPackageDetected("nuxt", options),
|
|
12
|
+
nuxtUI: isPackageDetected("@nuxt/ui", options),
|
|
13
|
+
nuxtIcon: isPackageDetected("@nuxt/icon", options),
|
|
14
|
+
nuxtImage: isPackageDetected("@nuxt/image", options),
|
|
15
|
+
vitest: isPackageDetected("vitest", options),
|
|
16
|
+
cypress: isPackageDetected("cypress", options),
|
|
17
|
+
storybook: isPackageDetected("storybook", options),
|
|
18
|
+
playwright: isPackageDetected("@playwright/test", options)
|
|
19
|
+
};
|
|
4
20
|
options.configs ??= {};
|
|
5
21
|
options.configs.test ??= {};
|
|
6
22
|
options.configs.node ??= true;
|
|
@@ -13,28 +29,31 @@ function enableDetectedConfigs(options) {
|
|
|
13
29
|
options.configs.importX ??= true;
|
|
14
30
|
options.configs.stylistic ??= true;
|
|
15
31
|
options.configs.perfectionist ??= true;
|
|
16
|
-
options.configs.
|
|
17
|
-
options.configs.
|
|
18
|
-
options.configs.
|
|
19
|
-
options.configs.
|
|
20
|
-
options.configs.
|
|
21
|
-
options.configs.
|
|
22
|
-
options.configs.
|
|
23
|
-
options.configs.
|
|
24
|
-
options.configs.test.
|
|
32
|
+
options.configs.useBaseline ??= options.env === "browser";
|
|
33
|
+
options.configs.typescript ??= autoDetectedDeps.typescript;
|
|
34
|
+
options.configs.zod ??= autoDetectedDeps.zod;
|
|
35
|
+
options.configs.astro ??= autoDetectedDeps.astro;
|
|
36
|
+
options.configs.vue ??= autoDetectedDeps.vue;
|
|
37
|
+
options.configs.nuxt ??= autoDetectedDeps.nuxt;
|
|
38
|
+
options.configs.react ??= autoDetectedDeps.react;
|
|
39
|
+
options.configs.next ??= autoDetectedDeps.next;
|
|
40
|
+
options.configs.test.vitest ??= autoDetectedDeps.vitest;
|
|
41
|
+
options.configs.test.cypress ??= autoDetectedDeps.cypress;
|
|
42
|
+
options.configs.test.storybook ??= autoDetectedDeps.storybook;
|
|
43
|
+
options.configs.test.playwright ??= autoDetectedDeps.playwright;
|
|
25
44
|
options.tsConfig ??= options.configs.typescript ? {
|
|
26
45
|
rootDir: ".",
|
|
27
46
|
filename: "tsconfig.json"
|
|
28
|
-
} :
|
|
29
|
-
if (options.configs.
|
|
47
|
+
} : void 0;
|
|
48
|
+
if (options.configs.vue && options.configs.typescript) {
|
|
30
49
|
options.configs.vue = options.configs.vue === true ? {} : options.configs.vue;
|
|
31
50
|
options.configs.vue.blockLang = { script: "ts" };
|
|
32
51
|
}
|
|
33
52
|
if (options.configs.nuxt) {
|
|
34
53
|
if (options.configs.nuxt === true) options.configs.nuxt = {};
|
|
35
|
-
options.configs.nuxt.ui ??=
|
|
36
|
-
options.configs.nuxt.icon ??=
|
|
37
|
-
options.configs.nuxt.image ??=
|
|
54
|
+
options.configs.nuxt.ui ??= autoDetectedDeps.nuxtUI;
|
|
55
|
+
options.configs.nuxt.icon ??= autoDetectedDeps.nuxtIcon;
|
|
56
|
+
options.configs.nuxt.image ??= autoDetectedDeps.nuxtImage;
|
|
38
57
|
}
|
|
39
58
|
if (options.autoDetectDeps === "verbose") logDetectedPackages();
|
|
40
59
|
return options;
|
package/dist/index.mjs
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import { isTruthy } from "./utils/isTruthy.mjs";
|
|
2
2
|
import { isEnabled } from "./utils/isEnabled.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { getCssConfig } from "./configs/css.mjs";
|
|
4
4
|
import { getVueConfig } from "./configs/vue.mjs";
|
|
5
5
|
import { getZodConfig } from "./configs/zod.mjs";
|
|
6
6
|
import { getBaseConfig } from "./configs/base.mjs";
|
|
7
|
-
import {
|
|
7
|
+
import { getHtmlConfig } from "./configs/html.mjs";
|
|
8
|
+
import { getNextConfig } from "./configs/next.mjs";
|
|
8
9
|
import { getNodeConfig } from "./configs/node.mjs";
|
|
9
10
|
import { getAstroConfig } from "./configs/astro.mjs";
|
|
11
|
+
import { getReactConfig } from "./configs/react.mjs";
|
|
10
12
|
import { getVitestConfig } from "./configs/vitest.mjs";
|
|
11
13
|
import { getCypressConfig } from "./configs/cypress.mjs";
|
|
12
14
|
import { getImportXConfig } from "./configs/importX.mjs";
|
|
13
15
|
import { getPromiseConfig } from "./configs/promise.mjs";
|
|
14
16
|
import { getUnicornConfig } from "./configs/unicorn.mjs";
|
|
17
|
+
import { getBaselineConfig } from "./configs/baseline.mjs";
|
|
15
18
|
import { getMarkdownConfig } from "./configs/markdown.mjs";
|
|
16
19
|
import { getTailwindConfig } from "./configs/tailwind.mjs";
|
|
17
20
|
import { getStorybookConfig } from "./configs/storybook.mjs";
|
|
@@ -24,7 +27,6 @@ import { getIgnorePatterns } from "./helpers/ignores/getIgnorePatterns.mjs";
|
|
|
24
27
|
import { mergeWithDefaults } from "./helpers/options/mergeWithDefaults.mjs";
|
|
25
28
|
import { getVueComponentNamesConfig } from "./configs/vueComponentNames.mjs";
|
|
26
29
|
import { getVueServerComponentsConfig } from "./configs/vueServerComponents.mjs";
|
|
27
|
-
import { getRestrictedDefaultExports } from "./configs/restrictedDefaultExports.mjs";
|
|
28
30
|
import { defineConfig as defineConfig$1, globalIgnores } from "eslint/config";
|
|
29
31
|
//#region src/index.ts
|
|
30
32
|
/**
|
|
@@ -71,7 +73,7 @@ function defineConfig(...args) {
|
|
|
71
73
|
configs = secondArgument ?? [];
|
|
72
74
|
}
|
|
73
75
|
const mergedOptions = mergeWithDefaults(options);
|
|
74
|
-
const { gitignore, project: { rules, ignores, settings, linterOptions }, configs: { css, vue, zod, html, node, nuxt, astro, unicorn, importX, promise, markdown, tailwind, stylistic, typescript, packageJson, perfectionist,
|
|
76
|
+
const { gitignore, project: { rules, ignores, settings, linterOptions }, configs: { css, vue, zod, html, next, node, nuxt, react, astro, unicorn, importX, promise, markdown, tailwind, stylistic, typescript, useBaseline, packageJson, perfectionist, test: { vitest, cypress, storybook, playwright } } } = mergedOptions;
|
|
75
77
|
const ignorePatterns = getIgnorePatterns({
|
|
76
78
|
gitignore,
|
|
77
79
|
patterns: ignores
|
|
@@ -89,17 +91,19 @@ function defineConfig(...args) {
|
|
|
89
91
|
isEnabled(unicorn) && getUnicornConfig(mergedOptions),
|
|
90
92
|
isEnabled(promise) && getPromiseConfig(mergedOptions),
|
|
91
93
|
isEnabled(importX) && getImportXConfig(mergedOptions),
|
|
92
|
-
preferNamedExports && getRestrictedDefaultExports(),
|
|
93
94
|
isEnabled(stylistic) && getStylisticConfig(mergedOptions),
|
|
94
95
|
isEnabled(perfectionist) && getPerfectionistConfig(mergedOptions),
|
|
96
|
+
isEnabled(useBaseline) && getBaselineConfig(mergedOptions),
|
|
95
97
|
isEnabled(node) && getNodeConfig(mergedOptions),
|
|
96
98
|
isEnabled(packageJson) && getPackageJsonConfig(mergedOptions),
|
|
97
99
|
isEnabled(markdown) && getMarkdownConfig(mergedOptions),
|
|
98
|
-
isEnabled(html) &&
|
|
99
|
-
isEnabled(css) &&
|
|
100
|
+
isEnabled(html) && getHtmlConfig(mergedOptions),
|
|
101
|
+
isEnabled(css) && getCssConfig(mergedOptions),
|
|
100
102
|
isEnabled(tailwind) && getTailwindConfig(mergedOptions),
|
|
101
103
|
isEnabled(zod) && getZodConfig(mergedOptions),
|
|
102
104
|
isEnabled(astro) && getAstroConfig(mergedOptions),
|
|
105
|
+
isEnabled(react) && getReactConfig(mergedOptions),
|
|
106
|
+
isEnabled(next) && getNextConfig(mergedOptions),
|
|
103
107
|
isEnabled(vue) && getVueConfig(mergedOptions),
|
|
104
108
|
isEnabled(vue) && getVueComponentNamesConfig(),
|
|
105
109
|
isEnabled(vue) && isEnabled(nuxt) && getVueServerComponentsConfig(),
|