@shayanthenerd/eslint-config 0.25.0 → 0.26.1
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 +71 -58
- 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 +7 -7
- package/dist/configs/next.mjs +20 -0
- package/dist/configs/react.mjs +29 -0
- package/dist/helpers/globs.mjs +2 -1
- package/dist/helpers/ignores/defaultIgnorePatterns.mjs +2 -0
- package/dist/helpers/isPackageDetected.mjs +1 -1
- package/dist/helpers/options/defaultOptions.mjs +47 -8
- package/dist/helpers/options/enableDetectedConfigs.mjs +6 -1
- package/dist/index.mjs +11 -5
- 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 +1 -2
- package/dist/rules/next.mjs +28 -0
- package/dist/rules/packageJson.mjs +1 -1
- package/dist/rules/react.mjs +160 -0
- package/dist/rules/typescript.mjs +1 -0
- 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 +55 -22
- 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/package.json +21 -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)
|
|
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:
|
|
@@ -176,6 +175,8 @@ PNPM's strict dependency resolution avoids this issue.
|
|
|
176
175
|
> [!NOTE]
|
|
177
176
|
> For example, `eslint-plugin-storybook` depends on `storybook`, which is hoisted by NPM and Bun. As a result, the integration for `storybook` will be enabled automatically, even if you haven't explicitly installed it.
|
|
178
177
|
|
|
178
|
+
`configs.useBaseline` is automatically enabled when `autoDetectDeps: true` and `env: 'browser'` (both are the defaults).
|
|
179
|
+
|
|
179
180
|
To opt out of this behavior, either [globally disable automatic dependency detection](#customization) or manually disable the unwanted integrations that were enabled automatically.
|
|
180
181
|
|
|
181
182
|
## Framework and Tool Integrations
|
|
@@ -464,27 +465,10 @@ _.vscode/settings.json_:
|
|
|
464
465
|
overrides?: Overrides,
|
|
465
466
|
},
|
|
466
467
|
css?: boolean | {
|
|
467
|
-
allowedRelativeFontUnits?: (
|
|
468
|
-
| '%'
|
|
469
|
-
| 'ch'
|
|
470
|
-
| 'em'
|
|
471
|
-
| 'ex'
|
|
472
|
-
| 'ic'
|
|
473
|
-
| 'lh'
|
|
474
|
-
| 'cap'
|
|
475
|
-
| 'rch'
|
|
476
|
-
| 'rem'
|
|
477
|
-
| 'rex'
|
|
478
|
-
| 'ric'
|
|
479
|
-
| 'rlh'
|
|
480
|
-
| 'rcap'
|
|
481
|
-
)[],
|
|
482
|
-
useBaseline?: false | number | 'newly' | 'widely',
|
|
483
468
|
overrides?: Overrides,
|
|
484
469
|
},
|
|
485
470
|
html?: boolean | {
|
|
486
471
|
idNamingConvention?: 'camelCase' | 'kebab-case' | 'PascalCase' | 'snake_case',
|
|
487
|
-
useBaseline?: false | number | 'newly' | 'widely',
|
|
488
472
|
overrides?: Overrides,
|
|
489
473
|
},
|
|
490
474
|
importX?: boolean | {
|
|
@@ -496,6 +480,9 @@ _.vscode/settings.json_:
|
|
|
496
480
|
language?: 'gfm' | 'commonmark',
|
|
497
481
|
overrides?: Overrides,
|
|
498
482
|
},
|
|
483
|
+
next?: boolean | {
|
|
484
|
+
overrides?: Overrides,
|
|
485
|
+
},
|
|
499
486
|
node?: boolean | {
|
|
500
487
|
overrides?: Overrides,
|
|
501
488
|
},
|
|
@@ -518,6 +505,14 @@ _.vscode/settings.json_:
|
|
|
518
505
|
promise?: boolean | {
|
|
519
506
|
overrides?: Overrides,
|
|
520
507
|
},
|
|
508
|
+
react?: boolean | {
|
|
509
|
+
accessibility?: boolean | {
|
|
510
|
+
anchorComponents?: string[],
|
|
511
|
+
headingComponents?: string[],
|
|
512
|
+
imageComponents?: string[],
|
|
513
|
+
},
|
|
514
|
+
overrides?: Overrides,
|
|
515
|
+
},
|
|
521
516
|
stylistic?: boolean | {
|
|
522
517
|
arrowParens?: 'always' | 'as-needed',
|
|
523
518
|
indent?: number,
|
|
@@ -527,7 +522,7 @@ _.vscode/settings.json_:
|
|
|
527
522
|
maxLineLength?: number,
|
|
528
523
|
memberDelimiterStyle?: 'semi' | 'comma',
|
|
529
524
|
quotes?: 'double' | 'single' | 'backtick',
|
|
530
|
-
|
|
525
|
+
selfCloseVoidHtmlElements?: 'never' | 'always',
|
|
531
526
|
semi?: 'never' | 'always',
|
|
532
527
|
trailingComma?: 'never' | 'always' | 'only-multiline' | 'always-multiline',
|
|
533
528
|
overrides?: Overrides,
|
|
@@ -573,6 +568,23 @@ _.vscode/settings.json_:
|
|
|
573
568
|
unicorn?: boolean | {
|
|
574
569
|
overrides?: Overrides,
|
|
575
570
|
},
|
|
571
|
+
useBaseline?: boolean | {
|
|
572
|
+
baseline?: number | 'newly' | 'widely',
|
|
573
|
+
css?: {
|
|
574
|
+
allowedAtRules?: AllowedAtRules,
|
|
575
|
+
allowedFunctions?: AllowedFunctions,
|
|
576
|
+
allowedMediaConditions?: AllowedMediaConditions,
|
|
577
|
+
allowedProperties?: AllowedProperties,
|
|
578
|
+
allowedPropertyValues?: AllowedPropertyValues,
|
|
579
|
+
allowedSelectors?: AllowedSelectors,
|
|
580
|
+
allowedUnits?: AllowedUnits,
|
|
581
|
+
},
|
|
582
|
+
javascript?: {
|
|
583
|
+
ignoredFeatures?: string[],
|
|
584
|
+
ignoredNodeTypes?: string[],
|
|
585
|
+
},
|
|
586
|
+
overrides?: Overrides,
|
|
587
|
+
},
|
|
576
588
|
vue?: boolean | {
|
|
577
589
|
accessibility?: boolean | {
|
|
578
590
|
accessibleChildComponents?: string[],
|
|
@@ -646,7 +658,7 @@ You can find a list of all available versions and their changelogs on the [relea
|
|
|
646
658
|
|
|
647
659
|
## Roadmap to v1.0.0
|
|
648
660
|
- [x] Add integration for ESLint plugins such as [eslint-plugin-n][plugin-n], [eslint-plugin-unicorn][plugin-unicorn], and more.
|
|
649
|
-
- [
|
|
661
|
+
- [x] Add support for React, Next, Astro, and Markdown.
|
|
650
662
|
- [ ] Develop an interactive starter wizard to quickly scaffold the configurations for ESLint, Prettier, etc.
|
|
651
663
|
|
|
652
664
|
## Contribution Guide
|
|
@@ -671,20 +683,21 @@ This project was inspired by the work of [Anthony Fu][antfu], whose generous con
|
|
|
671
683
|
|
|
672
684
|
<!-- ESLint Plugins -->
|
|
673
685
|
[plugin-astro]: https://ota-meshi.github.io/eslint-plugin-astro
|
|
686
|
+
[plugin-baseline]: https://baselinejs.vercel.app
|
|
674
687
|
[plugin-css]: https://github.com/eslint/css
|
|
675
688
|
[plugin-cypress]: https://github.com/cypress-io/eslint-plugin-cypress
|
|
676
689
|
[plugin-html]: https://html-eslint.org
|
|
690
|
+
[plugin-html-react]: https://html-eslint.org/docs/react/getting-started
|
|
677
691
|
[plugin-import-x]: https://github.com/un-ts/eslint-plugin-import-x
|
|
678
692
|
[plugin-jsx-a11y]: https://github.com/jsx-eslint/eslint-plugin-jsx-a11y
|
|
679
693
|
[plugin-md]: https://github.com/eslint/markdown
|
|
680
694
|
[plugin-n]: https://github.com/eslint-community/eslint-plugin-n
|
|
681
|
-
[plugin-next]: https://
|
|
695
|
+
[plugin-next]: https://github.com/vercel/next.js/tree/HEAD/packages/eslint-plugin-next
|
|
682
696
|
[plugin-package-json]: https://github.com/JoshuaKGoldberg/eslint-plugin-package-json
|
|
683
697
|
[plugin-perfectionist]: https://perfectionist.dev
|
|
684
698
|
[plugin-playwright]: https://github.com/mskelton/eslint-plugin-playwright
|
|
685
699
|
[plugin-promise]: https://github.com/eslint-community/eslint-plugin-promise
|
|
686
700
|
[plugin-react]: https://eslint-react.xyz
|
|
687
|
-
[plugin-react-hooks]: https://react.dev/reference/eslint-plugin-react-hooks
|
|
688
701
|
[plugin-storybook]: https://storybook.js.org/docs/configure/integration/eslint-plugin
|
|
689
702
|
[plugin-stylistic]: https://eslint.style
|
|
690
703
|
[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
14
|
files: [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
|
@@ -12,7 +12,8 @@ const globs = {
|
|
|
12
12
|
vueServerComponents: `**/*.server.${vueExtensions}`,
|
|
13
13
|
vueAppErrorLayoutsPages: `**/{{app,error},{layouts,pages}/**/*}.${vueExtensions}`,
|
|
14
14
|
storybook: `**/*.(story|stories).${srcExtensions}`,
|
|
15
|
-
test: `**/{__tests__/*,*.{test,spec,cy,bench?(mark)}.${srcExtensions}
|
|
15
|
+
test: `**/{__tests__/*,*.{test,spec,cy,bench?(mark)}.${srcExtensions}`,
|
|
16
|
+
coverage: "**/coverage/**"
|
|
16
17
|
};
|
|
17
18
|
//#endregion
|
|
18
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", "✔")} ESLint integrations enabled via dependency detection:`, detectedPackages.map((packageName) => styleText("blue", packageName)).join(", "));
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
13
|
function isPackageDetected(packageName, options) {
|
|
@@ -1,7 +1,7 @@
|
|
|
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
7
|
project: {
|
|
@@ -40,14 +40,9 @@ const defaultOptions = {
|
|
|
40
40
|
maxNestedCallbacks: 3,
|
|
41
41
|
overrides: {}
|
|
42
42
|
},
|
|
43
|
-
css: {
|
|
44
|
-
allowedRelativeFontUnits: ["rem", "em"],
|
|
45
|
-
useBaseline: false,
|
|
46
|
-
overrides: {}
|
|
47
|
-
},
|
|
43
|
+
css: { overrides: {} },
|
|
48
44
|
html: {
|
|
49
45
|
idNamingConvention: "snake_case",
|
|
50
|
-
useBaseline: false,
|
|
51
46
|
overrides: {}
|
|
52
47
|
},
|
|
53
48
|
importX: { overrides: {} },
|
|
@@ -57,6 +52,7 @@ const defaultOptions = {
|
|
|
57
52
|
language: "gfm",
|
|
58
53
|
overrides: {}
|
|
59
54
|
},
|
|
55
|
+
next: { overrides: {} },
|
|
60
56
|
node: { overrides: {} },
|
|
61
57
|
nuxt: {
|
|
62
58
|
icon: { component: "Icon" },
|
|
@@ -69,6 +65,32 @@ const defaultOptions = {
|
|
|
69
65
|
overrides: {}
|
|
70
66
|
},
|
|
71
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
|
+
},
|
|
72
94
|
stylistic: {
|
|
73
95
|
arrowParens: "always",
|
|
74
96
|
indent: 2,
|
|
@@ -79,7 +101,7 @@ const defaultOptions = {
|
|
|
79
101
|
memberDelimiterStyle: "comma",
|
|
80
102
|
quotes: "single",
|
|
81
103
|
semi: "always",
|
|
82
|
-
|
|
104
|
+
selfCloseVoidHtmlElements: "always",
|
|
83
105
|
trailingComma: "always-multiline",
|
|
84
106
|
overrides: {}
|
|
85
107
|
},
|
|
@@ -107,6 +129,23 @@ const defaultOptions = {
|
|
|
107
129
|
overrides: {}
|
|
108
130
|
},
|
|
109
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
|
+
},
|
|
110
149
|
vue: {
|
|
111
150
|
accessibility: {
|
|
112
151
|
accessibleChildComponents: [
|
|
@@ -5,6 +5,8 @@ function enableDetectedConfigs(options) {
|
|
|
5
5
|
typescript: isPackageDetected("typescript", options),
|
|
6
6
|
zod: isPackageDetected("zod", options),
|
|
7
7
|
astro: isPackageDetected("astro", options),
|
|
8
|
+
react: isPackageDetected("react", options),
|
|
9
|
+
next: isPackageDetected("next", options),
|
|
8
10
|
vue: isPackageDetected("vue", options),
|
|
9
11
|
nuxt: isPackageDetected("nuxt", options),
|
|
10
12
|
nuxtUI: isPackageDetected("@nuxt/ui", options),
|
|
@@ -27,11 +29,14 @@ function enableDetectedConfigs(options) {
|
|
|
27
29
|
options.configs.importX ??= true;
|
|
28
30
|
options.configs.stylistic ??= true;
|
|
29
31
|
options.configs.perfectionist ??= true;
|
|
32
|
+
options.configs.useBaseline ??= options.env === "browser";
|
|
30
33
|
options.configs.typescript ??= autoDetectedDeps.typescript;
|
|
31
34
|
options.configs.zod ??= autoDetectedDeps.zod;
|
|
35
|
+
options.configs.astro ??= autoDetectedDeps.astro;
|
|
32
36
|
options.configs.vue ??= autoDetectedDeps.vue;
|
|
33
37
|
options.configs.nuxt ??= autoDetectedDeps.nuxt;
|
|
34
|
-
options.configs.
|
|
38
|
+
options.configs.react ??= autoDetectedDeps.react;
|
|
39
|
+
options.configs.next ??= autoDetectedDeps.next;
|
|
35
40
|
options.configs.test.vitest ??= autoDetectedDeps.vitest;
|
|
36
41
|
options.configs.test.cypress ??= autoDetectedDeps.cypress;
|
|
37
42
|
options.configs.test.storybook ??= autoDetectedDeps.storybook;
|
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";
|
|
@@ -70,7 +73,7 @@ function defineConfig(...args) {
|
|
|
70
73
|
configs = secondArgument ?? [];
|
|
71
74
|
}
|
|
72
75
|
const mergedOptions = mergeWithDefaults(options);
|
|
73
|
-
const { gitignore, project: { rules, ignores, settings, linterOptions }, configs: { css, vue, zod, html, node, nuxt, astro, unicorn, importX, promise, markdown, tailwind, stylistic, typescript, packageJson, perfectionist, test: { vitest, cypress, storybook, playwright } } } = mergedOptions;
|
|
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;
|
|
74
77
|
const ignorePatterns = getIgnorePatterns({
|
|
75
78
|
gitignore,
|
|
76
79
|
patterns: ignores
|
|
@@ -90,14 +93,17 @@ function defineConfig(...args) {
|
|
|
90
93
|
isEnabled(importX) && getImportXConfig(mergedOptions),
|
|
91
94
|
isEnabled(stylistic) && getStylisticConfig(mergedOptions),
|
|
92
95
|
isEnabled(perfectionist) && getPerfectionistConfig(mergedOptions),
|
|
96
|
+
isEnabled(useBaseline) && getBaselineConfig(mergedOptions),
|
|
93
97
|
isEnabled(node) && getNodeConfig(mergedOptions),
|
|
94
98
|
isEnabled(packageJson) && getPackageJsonConfig(mergedOptions),
|
|
95
99
|
isEnabled(markdown) && getMarkdownConfig(mergedOptions),
|
|
96
|
-
isEnabled(html) &&
|
|
97
|
-
isEnabled(css) &&
|
|
100
|
+
isEnabled(html) && getHtmlConfig(mergedOptions),
|
|
101
|
+
isEnabled(css) && getCssConfig(mergedOptions),
|
|
98
102
|
isEnabled(tailwind) && getTailwindConfig(mergedOptions),
|
|
99
103
|
isEnabled(zod) && getZodConfig(mergedOptions),
|
|
100
104
|
isEnabled(astro) && getAstroConfig(mergedOptions),
|
|
105
|
+
isEnabled(react) && getReactConfig(mergedOptions),
|
|
106
|
+
isEnabled(next) && getNextConfig(mergedOptions),
|
|
101
107
|
isEnabled(vue) && getVueConfig(mergedOptions),
|
|
102
108
|
isEnabled(vue) && getVueComponentNamesConfig(),
|
|
103
109
|
isEnabled(vue) && isEnabled(nuxt) && getVueServerComponentsConfig(),
|
package/dist/prettier.config.mjs
CHANGED
package/dist/rules/astro.mjs
CHANGED
|
@@ -16,6 +16,7 @@ const astroRules = {
|
|
|
16
16
|
"astro/no-unsafe-inline-scripts": "warn",
|
|
17
17
|
"astro/no-set-text-directive": "warn",
|
|
18
18
|
"astro/no-unused-css-selector": "warn",
|
|
19
|
+
"astro/no-omitted-end-tags": "warn",
|
|
19
20
|
"astro/prefer-class-list-directive": "warn",
|
|
20
21
|
"astro/prefer-split-class-list": "warn",
|
|
21
22
|
"astro/jsx-a11y/alt-text": "error",
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { isEnabled } from "../utils/isEnabled.mjs";
|
|
2
|
+
import { defaultOptions } from "../helpers/options/defaultOptions.mjs";
|
|
3
|
+
//#region src/rules/baseline.ts
|
|
4
|
+
function getBaselineRules(options) {
|
|
5
|
+
const { useBaseline } = options.configs;
|
|
6
|
+
const { baseline, javascript: { ignoredFeatures: userIgnoredFeatures, ignoredNodeTypes: userIgnoredNodeTypes } } = isEnabled(useBaseline) ? useBaseline : defaultOptions.configs.useBaseline;
|
|
7
|
+
return {
|
|
8
|
+
"baseline-js/no-atomics-pause": "warn",
|
|
9
|
+
"baseline-js/no-bigint64array": "warn",
|
|
10
|
+
"baseline-js/no-function-caller-arguments": "warn",
|
|
11
|
+
"baseline-js/no-math-sum-precise": "warn",
|
|
12
|
+
"baseline-js/no-temporal": "warn",
|
|
13
|
+
"baseline-js/use-baseline": ["warn", {
|
|
14
|
+
baseline,
|
|
15
|
+
includeWebApis: { preset: "auto" },
|
|
16
|
+
includeJsBuiltins: { preset: "auto" },
|
|
17
|
+
ignoreFeatures: userIgnoredFeatures,
|
|
18
|
+
ignoreNodeTypes: userIgnoredNodeTypes
|
|
19
|
+
}]
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
export { getBaselineRules };
|