@shayanthenerd/eslint-config 0.29.3 → 0.30.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 +167 -103
- package/dist/configs/astro.mjs +1 -1
- package/dist/configs/{base.mjs → javascript.mjs} +4 -4
- package/dist/configs/typescript.mjs +4 -4
- package/dist/configs/vue.mjs +5 -1
- package/dist/helpers/globs.mjs +9 -9
- package/dist/helpers/options/defaultOptions.mjs +20 -20
- package/dist/helpers/options/enableDetectedConfigs.mjs +4 -4
- package/dist/index.mjs +10 -10
- package/dist/rules/astro.mjs +5 -3
- package/dist/rules/baseline.mjs +2 -2
- package/dist/rules/css.mjs +4 -4
- package/dist/rules/html.mjs +6 -4
- package/dist/rules/importX.mjs +5 -5
- package/dist/rules/javascript.mjs +29 -29
- package/dist/rules/markdown.mjs +1 -1
- package/dist/rules/packageJson.mjs +1 -1
- package/dist/rules/perfectionist.mjs +1 -1
- package/dist/rules/react.mjs +3 -3
- package/dist/rules/tailwind.mjs +3 -3
- package/dist/rules/typescript.mjs +11 -7
- package/dist/rules/unicorn.mjs +2 -2
- package/dist/rules/vue.mjs +42 -42
- package/dist/types/eslint-schema.d.mts +8 -8
- package/dist/types/eslintRules.d.mts +3 -3
- package/dist/types/index.d.mts +13 -13
- package/dist/types/options/react.d.mts +1 -1
- package/dist/types/options/typescript.d.mts +2 -2
- package/package.json +19 -12
package/README.md
CHANGED
|
@@ -57,7 +57,7 @@ Legend:
|
|
|
57
57
|
| [Promises][plugin-promise] | ✅ |
|
|
58
58
|
| [Imports][plugin-import-x] | ✅ |
|
|
59
59
|
| [Unicorn][plugin-unicorn] | ✅ |
|
|
60
|
-
| [Baseline][plugin-baseline]
|
|
60
|
+
| [Baseline][plugin-baseline] ([css/use-baseline], [@html-eslint/use-baseline], [@html-eslint/react/use-baseline]) | 🔍 |
|
|
61
61
|
|
|
62
62
|
## Installation and Configuration
|
|
63
63
|
1. Install the package and ESLint as dev dependencies:
|
|
@@ -78,8 +78,9 @@ Legend:
|
|
|
78
78
|
```json title="package.json"
|
|
79
79
|
{
|
|
80
80
|
"scripts": {
|
|
81
|
-
"lint
|
|
82
|
-
"lint": "eslint --fix --max-warnings=0 --cache --cache-location='node_modules/.cache/.eslintcache'"
|
|
81
|
+
"lint": "eslint --max-warnings=0 --cache --cache-location='node_modules/.cache/.eslintcache'",
|
|
82
|
+
"lint:fix": "eslint --fix --max-warnings=0 --cache --cache-location='node_modules/.cache/.eslintcache'",
|
|
83
|
+
"lint:inspect": "npx @eslint/config-inspector"
|
|
83
84
|
}
|
|
84
85
|
}
|
|
85
86
|
```
|
|
@@ -87,7 +88,8 @@ Legend:
|
|
|
87
88
|
---
|
|
88
89
|
|
|
89
90
|
After installation:
|
|
90
|
-
- Use `npm run lint` to lint
|
|
91
|
+
- Use `npm run lint` to lint files without modifying them (useful for CI).
|
|
92
|
+
- Use `npm run lint:fix` to lint and fix files.
|
|
91
93
|
- Use `npm run lint:inspect` to see a visual breakdown of your configuration.
|
|
92
94
|
- See [IDE Support](#ide-support) for editor integration.
|
|
93
95
|
- See [Customization](#customization) for advanced configuration.
|
|
@@ -108,7 +110,7 @@ export default defineConfig();
|
|
|
108
110
|
export default defineConfig({
|
|
109
111
|
autoDetectDeps: false,
|
|
110
112
|
configs: {
|
|
111
|
-
|
|
113
|
+
storybook: false,
|
|
112
114
|
markdown: {
|
|
113
115
|
language: 'commonmark',
|
|
114
116
|
},
|
|
@@ -134,7 +136,7 @@ export default defineConfig(
|
|
|
134
136
|
typeDefinitionStyle: 'type',
|
|
135
137
|
overrides: {
|
|
136
138
|
rules: {
|
|
137
|
-
'@typescript-eslint/explicit-module-boundary-types': '
|
|
139
|
+
'@typescript-eslint/explicit-module-boundary-types': 'error',
|
|
138
140
|
},
|
|
139
141
|
},
|
|
140
142
|
},
|
|
@@ -174,7 +176,7 @@ PNPM's strict dependency resolution avoids this issue.
|
|
|
174
176
|
> [!NOTE]
|
|
175
177
|
> 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.
|
|
176
178
|
|
|
177
|
-
`configs.
|
|
179
|
+
`configs.baseline` is automatically enabled when `autoDetectDeps: true` and `env: 'browser'` (both are the defaults).
|
|
178
180
|
|
|
179
181
|
To opt out of this behavior, either [globally disable automatic dependency detection](#customization) or manually disable the unwanted integrations that were enabled automatically.
|
|
180
182
|
|
|
@@ -195,7 +197,7 @@ export default defineConfig({
|
|
|
195
197
|
});
|
|
196
198
|
```
|
|
197
199
|
|
|
198
|
-
For editor integration, to avoid inconsistent diagnostics from the [Tailwind CSS IntelliSense VS Code extension][extension-tailwind], add the following settings to _.vscode/settings.json_:
|
|
200
|
+
For editor integration, to reduce noise and avoid inconsistent diagnostics from the [Tailwind CSS IntelliSense VS Code extension][extension-tailwind], add the following settings to _.vscode/settings.json_:
|
|
199
201
|
```json title=".vscode/settings.json"
|
|
200
202
|
{
|
|
201
203
|
"tailwindCSS.lint.cssConflict": "ignore",
|
|
@@ -220,7 +222,7 @@ Markdown linting is powered by [@eslint/markdown][plugin-md].
|
|
|
220
222
|
By default, the plugin uses GitHub Flavored Markdown (GFM). You can [switch to CommonMark](#customization) if you prefer, but rules related to tables, label references, and other GFM syntax will be disabled because CommonMark doesn't support them.
|
|
221
223
|
|
|
222
224
|
> [!NOTE]
|
|
223
|
-
> Fenced code blocks inside Markdown files are not linted
|
|
225
|
+
> Fenced code blocks inside Markdown files are not linted.
|
|
224
226
|
|
|
225
227
|
### Node.js
|
|
226
228
|
Some rules depend on the specified Node.js version. Visit the documentation for [version-resolution options and project-specific configurations](https://github.com/eslint-community/eslint-plugin-n#configured-nodejs-version-range).
|
|
@@ -241,7 +243,7 @@ You can also add the following to your _.vscode/settings.json_:
|
|
|
241
243
|
/* Enforce Unix-like line endings (LF). */
|
|
242
244
|
"files.eol": "\n",
|
|
243
245
|
|
|
244
|
-
/* Enforce 2 spaces for indentation. */
|
|
246
|
+
/* Enforce 2 spaces for indentation, even when using the Tab key (`⇥`). */
|
|
245
247
|
"editor.tabSize": 2,
|
|
246
248
|
"editor.insertSpaces": true,
|
|
247
249
|
"editor.detectIndentation": false,
|
|
@@ -272,7 +274,7 @@ You can also add the following to your _.vscode/settings.json_:
|
|
|
272
274
|
"vue"
|
|
273
275
|
],
|
|
274
276
|
|
|
275
|
-
/*
|
|
277
|
+
/* If the Stylistic integration is enabled, use these settings to silently auto-fix the corresponding rules. */
|
|
276
278
|
"eslint.rules.customizations": [
|
|
277
279
|
{ "rule": "*styl*", "severity": "off", "fixable": true },
|
|
278
280
|
{ "rule": "*sort*", "severity": "off", "fixable": true },
|
|
@@ -299,82 +301,138 @@ This configuration uses [ESLint Stylistic][plugin-stylistic] to format:
|
|
|
299
301
|
|
|
300
302
|
HTML and Vue's `<template>` blocks are formatted with [@html-eslint/eslint-plugin][plugin-html] and [eslint-plugin-vue][plugin-vue], respectively.
|
|
301
303
|
|
|
302
|
-
For file types
|
|
304
|
+
For file types that ESLint Stylistic does not handle—such as CSS, JSON, YAML, and Markdown—you can use [Prettier][prettier] instead. To make setup easier, this package also provides a customizable [shared Prettier configuration][prettier-shared-config] with the same defaults as the Stylistic integration.
|
|
303
305
|
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
306
|
+
### Using Prettier Alongside ESLint Stylistic
|
|
307
|
+
<details>
|
|
308
|
+
<summary>
|
|
309
|
+
In this setup, Prettier should only target files that ESLint Stylistic doesn't handle.
|
|
310
|
+
</summary>
|
|
311
|
+
|
|
312
|
+
<br />
|
|
313
|
+
|
|
314
|
+
1. Install Prettier as a dev dependency:
|
|
315
|
+
```shell
|
|
316
|
+
npm i -D prettier
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
2. Create a Prettier config file in the root of your project (_prettier.config.js_):
|
|
320
|
+
```js title="prettier.config.js"
|
|
321
|
+
import prettierConfig from '@shayanthenerd/eslint-config/prettier';
|
|
322
|
+
|
|
323
|
+
/** @type {import('prettier').Config} */
|
|
324
|
+
export default {
|
|
325
|
+
...prettierConfig,
|
|
326
|
+
semi: false, // Override `semi` from the shared config
|
|
327
|
+
};
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
Or if you prefer using TypeScript (_prettier.config.ts_):
|
|
331
|
+
```ts title="prettier.config.ts"
|
|
332
|
+
import type { Config } from 'prettier';
|
|
333
|
+
|
|
334
|
+
import prettierConfig from '@shayanthenerd/eslint-config/prettier';
|
|
335
|
+
|
|
336
|
+
export default {
|
|
337
|
+
...prettierConfig,
|
|
338
|
+
semi: false, // Override `semi` from the shared config
|
|
339
|
+
} satisfies Config;
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
3. Add the following script to _package.json_:
|
|
343
|
+
```json title="package.json"
|
|
344
|
+
{
|
|
345
|
+
"scripts": {
|
|
346
|
+
"format": "prettier --write . '!**/*.{js,cjs,mjs,jsx,ts,cts,mts,tsx,html,vue,astro}' --cache"
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
4. Add the following settings to _.vscode/settings.json_:
|
|
352
|
+
```json title=".vscode/settings.json"
|
|
353
|
+
{
|
|
354
|
+
"editor.formatOnSave": true,
|
|
355
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
|
356
|
+
"[javascript][typescript][javascriptreact][typescriptreact][html][vue][astro][{**/package.json}]": {
|
|
357
|
+
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
|
|
358
|
+
},
|
|
359
|
+
}
|
|
360
|
+
```
|
|
361
|
+
</details>
|
|
353
362
|
|
|
354
363
|
### Using Prettier Alone
|
|
355
|
-
|
|
364
|
+
<details>
|
|
365
|
+
<summary>
|
|
366
|
+
If you prefer to use Prettier as the only formatter, disable the Stylistic integration and let Prettier handle all formatting.
|
|
367
|
+
</summary>
|
|
368
|
+
|
|
369
|
+
<br />
|
|
370
|
+
|
|
371
|
+
1. Disable the Stylistic rules in _eslint.config.js_:
|
|
372
|
+
```js title="eslint.config.js"
|
|
373
|
+
import { defineConfig } from '@shayanthenerd/eslint-config';
|
|
374
|
+
|
|
375
|
+
export default defineConfig({
|
|
376
|
+
configs: {
|
|
377
|
+
stylistic: false,
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* The following rules remain enabled when the Stylistic integration is disabled.
|
|
381
|
+
* Disable them manually if you use the corresponding Prettier plugins, such as:
|
|
382
|
+
* - prettier-plugin-packagejson
|
|
383
|
+
* - prettier-plugin-sort-imports
|
|
384
|
+
* - prettier-plugin-tailwindcss
|
|
385
|
+
*/
|
|
386
|
+
packageJson: {
|
|
387
|
+
overrides: {
|
|
388
|
+
rules: {
|
|
389
|
+
'package-json/order-properties': 'off',
|
|
390
|
+
},
|
|
391
|
+
},
|
|
392
|
+
},
|
|
393
|
+
perfectionist: {
|
|
394
|
+
overrides: {
|
|
395
|
+
rules: {
|
|
396
|
+
'perfectionist/sort-imports': 'off',
|
|
397
|
+
'perfectionist/sort-named-imports': 'off',
|
|
398
|
+
},
|
|
399
|
+
},
|
|
400
|
+
},
|
|
401
|
+
tailwind: {
|
|
402
|
+
overrides: {
|
|
403
|
+
rules: {
|
|
404
|
+
'better-tailwindcss/enforce-consistent-class-order': 'off',
|
|
405
|
+
},
|
|
406
|
+
},
|
|
407
|
+
},
|
|
408
|
+
},
|
|
409
|
+
});
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
2. Add the following settings to _.vscode/settings.json_:
|
|
413
|
+
```json title=".vscode/settings.json"
|
|
414
|
+
{
|
|
415
|
+
"editor.formatOnSave": true,
|
|
416
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
|
417
|
+
|
|
418
|
+
/* This runs before the formatter and doesn't cause conflicts. */
|
|
419
|
+
"editor.codeActionsOnSave": {
|
|
420
|
+
"source.fixAll.eslint": "explicit"
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
```
|
|
424
|
+
|
|
425
|
+
3. Add the following script to _package.json_:
|
|
426
|
+
```json title="package.json"
|
|
427
|
+
{
|
|
428
|
+
"scripts": {
|
|
429
|
+
"format": "prettier --write . --cache",
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
```
|
|
433
|
+
To avoid conflicts, do not run the `format` and the `lint:fix` scripts on the same files simultaneously.
|
|
434
|
+
</details>
|
|
356
435
|
|
|
357
|
-
_package.json_:
|
|
358
|
-
```json title="package.json"
|
|
359
|
-
{
|
|
360
|
-
"scripts": {
|
|
361
|
-
"format": "prettier --write . --cache",
|
|
362
|
-
"lint": "eslint --fix --max-warnings=0 --cache --cache-location='node_modules/.cache/.eslintcache'"
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
```
|
|
366
|
-
_.vscode/settings.json_:
|
|
367
|
-
```json title=".vscode/settings.json"
|
|
368
|
-
{
|
|
369
|
-
"editor.formatOnSave": true,
|
|
370
|
-
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
|
371
|
-
|
|
372
|
-
/* On file save, code actions are run before format, so the following doesn't cause conflicts. */
|
|
373
|
-
"editor.codeActionsOnSave": {
|
|
374
|
-
"source.fixAll.eslint": "explicit"
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
```
|
|
378
436
|
|
|
379
437
|
## API Reference
|
|
380
438
|
<details>
|
|
@@ -460,9 +518,21 @@ _.vscode/settings.json_:
|
|
|
460
518
|
astro?: boolean | {
|
|
461
519
|
overrides?: Overrides,
|
|
462
520
|
},
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
521
|
+
baseline?: boolean | {
|
|
522
|
+
baseline?: number | 'newly' | 'widely',
|
|
523
|
+
css?: {
|
|
524
|
+
allowedAtRules?: AllowedAtRules,
|
|
525
|
+
allowedFunctions?: AllowedFunctions,
|
|
526
|
+
allowedMediaConditions?: AllowedMediaConditions,
|
|
527
|
+
allowedProperties?: AllowedProperties,
|
|
528
|
+
allowedPropertyValues?: AllowedPropertyValues,
|
|
529
|
+
allowedSelectors?: AllowedSelectors,
|
|
530
|
+
allowedUnits?: AllowedUnits,
|
|
531
|
+
},
|
|
532
|
+
javascript?: {
|
|
533
|
+
ignoredFeatures?: string[],
|
|
534
|
+
ignoredNodeTypes?: string[],
|
|
535
|
+
},
|
|
466
536
|
overrides?: Overrides,
|
|
467
537
|
},
|
|
468
538
|
css?: boolean | {
|
|
@@ -475,6 +545,11 @@ _.vscode/settings.json_:
|
|
|
475
545
|
importX?: boolean | {
|
|
476
546
|
overrides?: Overrides,
|
|
477
547
|
},
|
|
548
|
+
javascript?: {
|
|
549
|
+
maxDepth?: number,
|
|
550
|
+
maxNestedCallbacks?: number,
|
|
551
|
+
overrides?: Overrides,
|
|
552
|
+
},
|
|
478
553
|
markdown?: boolean | {
|
|
479
554
|
allowedHtmlTags?: string[],
|
|
480
555
|
frontmatter?: false | 'json' | 'toml' | 'yaml',
|
|
@@ -580,23 +655,6 @@ _.vscode/settings.json_:
|
|
|
580
655
|
},
|
|
581
656
|
overrides?: Overrides,
|
|
582
657
|
},
|
|
583
|
-
useBaseline?: boolean | {
|
|
584
|
-
baseline?: number | 'newly' | 'widely',
|
|
585
|
-
css?: {
|
|
586
|
-
allowedAtRules?: AllowedAtRules,
|
|
587
|
-
allowedFunctions?: AllowedFunctions,
|
|
588
|
-
allowedMediaConditions?: AllowedMediaConditions,
|
|
589
|
-
allowedProperties?: AllowedProperties,
|
|
590
|
-
allowedPropertyValues?: AllowedPropertyValues,
|
|
591
|
-
allowedSelectors?: AllowedSelectors,
|
|
592
|
-
allowedUnits?: AllowedUnits,
|
|
593
|
-
},
|
|
594
|
-
javascript?: {
|
|
595
|
-
ignoredFeatures?: string[],
|
|
596
|
-
ignoredNodeTypes?: string[],
|
|
597
|
-
},
|
|
598
|
-
overrides?: Overrides,
|
|
599
|
-
},
|
|
600
658
|
vue?: boolean | {
|
|
601
659
|
accessibility?: boolean | {
|
|
602
660
|
accessibleChildComponents?: string[],
|
|
@@ -716,6 +774,11 @@ This project was inspired by the work of [Anthony Fu][antfu], whose generous con
|
|
|
716
774
|
[plugin-vue-a11y]: https://vue-a11y.github.io/eslint-plugin-vuejs-accessibility
|
|
717
775
|
[plugin-zod]: https://github.com/marcalexiei/eslint-zod
|
|
718
776
|
|
|
777
|
+
<!-- ESLint Rules -->
|
|
778
|
+
[@html-eslint/react/use-baseline]: https://github.com/eslint/css/blob/main/docs/rules/use-baseline.md#options
|
|
779
|
+
[@html-eslint/use-baseline]: https://html-eslint.org/docs/rules/use-baseline#options
|
|
780
|
+
[css/use-baseline]: https://github.com/eslint/css/blob/main/docs/rules/use-baseline.md#options
|
|
781
|
+
|
|
719
782
|
<!-- References -->
|
|
720
783
|
[antfu]: https://github.com/antfu
|
|
721
784
|
[contributing]: ./.github/CONTRIBUTING.md
|
|
@@ -724,6 +787,7 @@ This project was inspired by the work of [Anthony Fu][antfu], whose generous con
|
|
|
724
787
|
[eslint-config-ts-setup]: https://eslint.org/docs/latest/use/configure/configuration-files#typescript-configuration-files
|
|
725
788
|
[eslint-nuxt]: https://eslint.nuxt.com
|
|
726
789
|
[local-pkg]: https://github.com/antfu-collective/local-pkg
|
|
790
|
+
[prettier]: https://prettier.io
|
|
727
791
|
[prettier-shared-config]: https://prettier.io/docs/sharing-configurations
|
|
728
792
|
[releases]: https://github.com/ShayanTheNerd/eslint-config/releases
|
|
729
793
|
[semver]: https://semver.org
|
package/dist/configs/astro.mjs
CHANGED
|
@@ -5,9 +5,9 @@ import { getJavaScriptRules } from "../rules/javascript.mjs";
|
|
|
5
5
|
import { mergeConfigs } from "eslint-flat-config-utils";
|
|
6
6
|
import { parser } from "typescript-eslint";
|
|
7
7
|
import globals from "globals";
|
|
8
|
-
//#region src/configs/
|
|
9
|
-
function
|
|
10
|
-
const { env, configs: { vue, astro,
|
|
8
|
+
//#region src/configs/javascript.ts
|
|
9
|
+
function getJavascriptConfig(options) {
|
|
10
|
+
const { env, configs: { vue, astro, javascript: { overrides } }, project: { globals: { bun, node, deno, vitest, worker, browser, commonjs, nodeBuiltin, audioWorklet, webextension, sharedWorker, serviceworker, vue: vueGlobals, astro: astroGlobals, custom: userGlobals } } } = options;
|
|
11
11
|
return mergeConfigs({
|
|
12
12
|
name: "shayanthenerd/base",
|
|
13
13
|
files: [
|
|
@@ -49,4 +49,4 @@ function getBaseConfig(options) {
|
|
|
49
49
|
}, overrides);
|
|
50
50
|
}
|
|
51
51
|
//#endregion
|
|
52
|
-
export {
|
|
52
|
+
export { getJavascriptConfig };
|
|
@@ -2,12 +2,12 @@ import { isTruthy } from "../utils/isTruthy.mjs";
|
|
|
2
2
|
import { globs } from "../helpers/globs.mjs";
|
|
3
3
|
import { isEnabled } from "../utils/isEnabled.mjs";
|
|
4
4
|
import { defaultOptions } from "../helpers/options/defaultOptions.mjs";
|
|
5
|
-
import {
|
|
5
|
+
import { getTypescriptRules } from "../rules/typescript.mjs";
|
|
6
6
|
import { mergeConfigs } from "eslint-flat-config-utils";
|
|
7
7
|
import { parser, plugin } from "typescript-eslint";
|
|
8
8
|
import path from "node:path";
|
|
9
9
|
//#region src/configs/typescript.ts
|
|
10
|
-
function
|
|
10
|
+
function getTypescriptConfig(options) {
|
|
11
11
|
const { tsConfig, configs: { vue, astro, typescript } } = options;
|
|
12
12
|
const { allowedDefaultProjects } = isEnabled(typescript) ? typescript : defaultOptions.configs.typescript;
|
|
13
13
|
const { overrides } = isEnabled(typescript) ? typescript : defaultOptions.configs.typescript;
|
|
@@ -31,8 +31,8 @@ function getTypeScriptConfig(options) {
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
},
|
|
34
|
-
rules:
|
|
34
|
+
rules: getTypescriptRules(options)
|
|
35
35
|
}, overrides);
|
|
36
36
|
}
|
|
37
37
|
//#endregion
|
|
38
|
-
export {
|
|
38
|
+
export { getTypescriptConfig };
|
package/dist/configs/vue.mjs
CHANGED
|
@@ -14,7 +14,11 @@ function getVueConfig(options) {
|
|
|
14
14
|
const isVueAccessibilityEnabled = isEnabled(vue) && isEnabled(vue.accessibility);
|
|
15
15
|
return mergeConfigs({
|
|
16
16
|
name: "shayanthenerd/vue",
|
|
17
|
-
files: [
|
|
17
|
+
files: [
|
|
18
|
+
globs.src,
|
|
19
|
+
globs.jsxTsx,
|
|
20
|
+
globs.vue
|
|
21
|
+
],
|
|
18
22
|
plugins: {
|
|
19
23
|
vue: eslintPluginVue,
|
|
20
24
|
...isVueAccessibilityEnabled && { "vuejs-accessibility": eslintPluginVueAccessibility }
|
package/dist/helpers/globs.mjs
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
//#region src/helpers/globs.ts
|
|
2
|
-
const
|
|
2
|
+
const sourceExtensions = "?([mc])[jt]s";
|
|
3
3
|
const jsxTsxExtensions = "[jt]sx";
|
|
4
|
-
const
|
|
4
|
+
const vueSourceExtensions = `{vue,${sourceExtensions},${jsxTsxExtensions}}`;
|
|
5
5
|
const globs = {
|
|
6
|
-
src: `**/*.${
|
|
6
|
+
src: `**/*.${sourceExtensions}`,
|
|
7
7
|
jsxTsx: `**/*.${jsxTsxExtensions}`,
|
|
8
8
|
packageJson: "**/package.json",
|
|
9
9
|
markdown: "**/*.md",
|
|
10
10
|
html: "**/*.html",
|
|
11
11
|
css: "**/*.css",
|
|
12
12
|
astro: "**/*.astro",
|
|
13
|
-
vue:
|
|
14
|
-
nuxtAppErrorLayoutsPages: `**/{{app,error},{layouts,pages}/**/*}.${
|
|
15
|
-
nuxtServerComponents: `**/*.server.${
|
|
16
|
-
nuxtMiddlewares: `**/middleware?(s)/**/*.${
|
|
17
|
-
storybook: `**/*.(story|stories).{${
|
|
18
|
-
test: `**/{__tests__/*,*.{test,spec,cy,bench?(mark)}.${
|
|
13
|
+
vue: "**/*.vue",
|
|
14
|
+
nuxtAppErrorLayoutsPages: `**/{{app,error},{layouts,pages}/**/*}.${vueSourceExtensions}`,
|
|
15
|
+
nuxtServerComponents: `**/*.server.${vueSourceExtensions}`,
|
|
16
|
+
nuxtMiddlewares: `**/middleware?(s)/**/*.${sourceExtensions}`,
|
|
17
|
+
storybook: `**/*.(story|stories).{${sourceExtensions},${jsxTsxExtensions}}`,
|
|
18
|
+
test: `**/{__tests__/*,*.{test,spec,cy,bench?(mark)}.${sourceExtensions}`,
|
|
19
19
|
coverage: "**/coverage/**"
|
|
20
20
|
};
|
|
21
21
|
//#endregion
|
|
@@ -35,9 +35,21 @@ const defaultOptions = {
|
|
|
35
35
|
},
|
|
36
36
|
configs: {
|
|
37
37
|
astro: { overrides: {} },
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
baseline: {
|
|
39
|
+
baseline: "widely",
|
|
40
|
+
css: {
|
|
41
|
+
allowedAtRules: [],
|
|
42
|
+
allowedFunctions: [],
|
|
43
|
+
allowedMediaConditions: [],
|
|
44
|
+
allowedProperties: [],
|
|
45
|
+
allowedPropertyValues: {},
|
|
46
|
+
allowedSelectors: [],
|
|
47
|
+
allowedUnits: []
|
|
48
|
+
},
|
|
49
|
+
javascript: {
|
|
50
|
+
ignoredFeatures: [],
|
|
51
|
+
ignoredNodeTypes: []
|
|
52
|
+
},
|
|
41
53
|
overrides: {}
|
|
42
54
|
},
|
|
43
55
|
css: { overrides: {} },
|
|
@@ -46,6 +58,11 @@ const defaultOptions = {
|
|
|
46
58
|
overrides: {}
|
|
47
59
|
},
|
|
48
60
|
importX: { overrides: {} },
|
|
61
|
+
javascript: {
|
|
62
|
+
maxDepth: 3,
|
|
63
|
+
maxNestedCallbacks: 3,
|
|
64
|
+
overrides: {}
|
|
65
|
+
},
|
|
49
66
|
markdown: {
|
|
50
67
|
allowedHtmlTags: [],
|
|
51
68
|
frontmatter: "yaml",
|
|
@@ -140,23 +157,6 @@ const defaultOptions = {
|
|
|
140
157
|
},
|
|
141
158
|
overrides: {}
|
|
142
159
|
},
|
|
143
|
-
useBaseline: {
|
|
144
|
-
baseline: "widely",
|
|
145
|
-
css: {
|
|
146
|
-
allowedAtRules: [],
|
|
147
|
-
allowedFunctions: [],
|
|
148
|
-
allowedMediaConditions: [],
|
|
149
|
-
allowedProperties: [],
|
|
150
|
-
allowedPropertyValues: {},
|
|
151
|
-
allowedSelectors: [],
|
|
152
|
-
allowedUnits: []
|
|
153
|
-
},
|
|
154
|
-
javascript: {
|
|
155
|
-
ignoredFeatures: [],
|
|
156
|
-
ignoredNodeTypes: []
|
|
157
|
-
},
|
|
158
|
-
overrides: {}
|
|
159
|
-
},
|
|
160
160
|
vue: {
|
|
161
161
|
accessibility: {
|
|
162
162
|
accessibleChildComponents: [
|
|
@@ -47,7 +47,7 @@ function enableDetectedConfigs(options) {
|
|
|
47
47
|
options.configs.importX ??= true;
|
|
48
48
|
options.configs.stylistic ??= true;
|
|
49
49
|
options.configs.perfectionist ??= true;
|
|
50
|
-
options.configs.
|
|
50
|
+
options.configs.baseline ??= options.env === "browser";
|
|
51
51
|
options.configs.typescript ??= autoDetectedPackages.typescript;
|
|
52
52
|
options.configs.zod ??= autoDetectedPackages.zod;
|
|
53
53
|
options.configs.astro ??= autoDetectedPackages.astro;
|
|
@@ -59,8 +59,8 @@ function enableDetectedConfigs(options) {
|
|
|
59
59
|
options.configs.test.cypress ??= autoDetectedPackages.cypress;
|
|
60
60
|
options.configs.test.storybook ??= autoDetectedPackages.storybook;
|
|
61
61
|
options.configs.test.playwright ??= autoDetectedPackages.playwright;
|
|
62
|
-
const
|
|
63
|
-
if (
|
|
62
|
+
const isTypescriptEnabled = isEnabled(options.configs.typescript);
|
|
63
|
+
if (isTypescriptEnabled) {
|
|
64
64
|
const defaultTsConfigRootDir = options.packageDir ?? defaultOptions.packageDir;
|
|
65
65
|
const defaultTsConfigFilename = "tsconfig.json";
|
|
66
66
|
if (options.tsConfig === void 0) options.tsConfig = {
|
|
@@ -72,7 +72,7 @@ function enableDetectedConfigs(options) {
|
|
|
72
72
|
options.tsConfig.filename ??= defaultTsConfigFilename;
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
|
-
if (
|
|
75
|
+
if (isTypescriptEnabled && options.configs.vue) {
|
|
76
76
|
options.configs.vue = options.configs.vue === true ? {} : options.configs.vue;
|
|
77
77
|
options.configs.vue.blockLang = { script: "ts" };
|
|
78
78
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -3,7 +3,6 @@ import { isEnabled } from "./utils/isEnabled.mjs";
|
|
|
3
3
|
import { getCssConfig } from "./configs/css.mjs";
|
|
4
4
|
import { getVueConfig } from "./configs/vue.mjs";
|
|
5
5
|
import { getZodConfig } from "./configs/zod.mjs";
|
|
6
|
-
import { getBaseConfig } from "./configs/base.mjs";
|
|
7
6
|
import { getHtmlConfig } from "./configs/html.mjs";
|
|
8
7
|
import { getNextConfig } from "./configs/next.mjs";
|
|
9
8
|
import { getNodeConfig } from "./configs/node.mjs";
|
|
@@ -20,8 +19,9 @@ import { getMarkdownConfig } from "./configs/markdown.mjs";
|
|
|
20
19
|
import { getTailwindConfig } from "./configs/tailwind.mjs";
|
|
21
20
|
import { getStorybookConfig } from "./configs/storybook.mjs";
|
|
22
21
|
import { getStylisticConfig } from "./configs/stylistic.mjs";
|
|
22
|
+
import { getJavascriptConfig } from "./configs/javascript.mjs";
|
|
23
23
|
import { getPlaywrightConfig } from "./configs/playwright.mjs";
|
|
24
|
-
import {
|
|
24
|
+
import { getTypescriptConfig } from "./configs/typescript.mjs";
|
|
25
25
|
import { getPackageJsonConfig } from "./configs/packageJson.mjs";
|
|
26
26
|
import { getPerfectionistConfig } from "./configs/perfectionist.mjs";
|
|
27
27
|
import { getIgnorePatterns } from "./helpers/ignores/getIgnorePatterns.mjs";
|
|
@@ -64,15 +64,15 @@ import { defineConfig as defineConfig$1, globalIgnores } from "eslint/config";
|
|
|
64
64
|
*/
|
|
65
65
|
function defineConfig(...args) {
|
|
66
66
|
let options = {};
|
|
67
|
-
let
|
|
67
|
+
let userConfigs = [];
|
|
68
68
|
const [firstArgument, secondArgument] = args;
|
|
69
|
-
if (Array.isArray(firstArgument))
|
|
69
|
+
if (Array.isArray(firstArgument)) userConfigs = firstArgument;
|
|
70
70
|
else if (firstArgument) {
|
|
71
71
|
options = firstArgument;
|
|
72
|
-
|
|
72
|
+
userConfigs = secondArgument ?? [];
|
|
73
73
|
}
|
|
74
74
|
const mergedOptions = mergeWithDefaults(options);
|
|
75
|
-
const { gitignore, project: { rules, ignores, settings, linterOptions }, configs: { css, vue, zod, html, next, node, nuxt, react, astro, unicorn, importX, promise, markdown, tailwind, stylistic, typescript,
|
|
75
|
+
const { gitignore, project: { rules, ignores, settings, linterOptions }, configs: { css, vue, zod, html, next, node, nuxt, react, astro, unicorn, importX, promise, baseline, markdown, tailwind, stylistic, typescript, packageJson, perfectionist, test: { vitest, cypress, storybook, playwright } } } = mergedOptions;
|
|
76
76
|
const ignorePatterns = getIgnorePatterns({
|
|
77
77
|
gitignore,
|
|
78
78
|
patterns: ignores
|
|
@@ -85,14 +85,14 @@ function defineConfig(...args) {
|
|
|
85
85
|
rules
|
|
86
86
|
},
|
|
87
87
|
globalIgnores(ignorePatterns, "shayanthenerd/ignores"),
|
|
88
|
-
|
|
89
|
-
isEnabled(typescript) &&
|
|
88
|
+
getJavascriptConfig(mergedOptions),
|
|
89
|
+
isEnabled(typescript) && getTypescriptConfig(mergedOptions),
|
|
90
90
|
isEnabled(unicorn) && getUnicornConfig(mergedOptions),
|
|
91
91
|
isEnabled(promise) && getPromiseConfig(mergedOptions),
|
|
92
92
|
isEnabled(importX) && getImportXConfig(mergedOptions),
|
|
93
93
|
isEnabled(stylistic) && getStylisticConfig(mergedOptions),
|
|
94
94
|
isEnabled(perfectionist) && getPerfectionistConfig(mergedOptions),
|
|
95
|
-
isEnabled(
|
|
95
|
+
isEnabled(baseline) && getBaselineConfig(mergedOptions),
|
|
96
96
|
isEnabled(node) && getNodeConfig(mergedOptions),
|
|
97
97
|
isEnabled(packageJson) && getPackageJsonConfig(mergedOptions),
|
|
98
98
|
isEnabled(markdown) && getMarkdownConfig(mergedOptions),
|
|
@@ -109,7 +109,7 @@ function defineConfig(...args) {
|
|
|
109
109
|
isEnabled(vitest) && getVitestConfig(mergedOptions),
|
|
110
110
|
isEnabled(cypress) && getCypressConfig(mergedOptions),
|
|
111
111
|
isEnabled(playwright) && getPlaywrightConfig(mergedOptions),
|
|
112
|
-
...
|
|
112
|
+
...userConfigs
|
|
113
113
|
].filter(isTruthy));
|
|
114
114
|
}
|
|
115
115
|
//#endregion
|
package/dist/rules/astro.mjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
+
import { isEnabled } from "../utils/isEnabled.mjs";
|
|
1
2
|
//#region src/rules/astro.ts
|
|
2
3
|
const astroRules = {
|
|
3
|
-
"import-x/exports-last": "off",
|
|
4
|
-
"@stylistic/jsx-one-expression-per-line": "off",
|
|
5
4
|
"astro/missing-client-only-directive-value": "error",
|
|
6
5
|
"astro/no-conflict-set-directives": "error",
|
|
7
6
|
"astro/no-deprecated-astro-canonicalurl": "error",
|
|
@@ -54,7 +53,10 @@ const astroRules = {
|
|
|
54
53
|
"astro/jsx-a11y/scope": "error",
|
|
55
54
|
"astro/jsx-a11y/tabindex-no-positive": "warn"
|
|
56
55
|
};
|
|
57
|
-
function getAstroRules() {
|
|
56
|
+
function getAstroRules(options) {
|
|
57
|
+
const { importX, stylistic } = options.configs;
|
|
58
|
+
if (isEnabled(importX)) astroRules["import-x/exports-last"] = "off";
|
|
59
|
+
if (isEnabled(stylistic)) astroRules["@stylistic/jsx-one-expression-per-line"] = "off";
|
|
58
60
|
return astroRules;
|
|
59
61
|
}
|
|
60
62
|
//#endregion
|