@alexlit/lint-kit 214.3.0 → 215.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (155) hide show
  1. package/README.md +27 -22
  2. package/eslint.config.js +23 -56
  3. package/lint-staged.config.js +2 -2
  4. package/linthtml.config.js +2 -2
  5. package/package.json +3 -2
  6. package/packages/config-eslint/README.md +156 -106
  7. package/packages/config-eslint/base.js +5 -3
  8. package/packages/config-eslint/index.d.ts +112 -0
  9. package/packages/config-eslint/index.js +79 -23
  10. package/packages/config-eslint/package.json +21 -18
  11. package/packages/config-eslint/plugins/de-morgan.js +9 -4
  12. package/packages/config-eslint/plugins/import-x.js +50 -37
  13. package/packages/config-eslint/plugins/javascript.js +96 -85
  14. package/packages/config-eslint/plugins/jsdoc.js +24 -17
  15. package/packages/config-eslint/plugins/json.js +31 -24
  16. package/packages/config-eslint/plugins/perfectionist.js +108 -95
  17. package/packages/config-eslint/plugins/pinia.js +17 -10
  18. package/packages/config-eslint/plugins/prettier.js +24 -10
  19. package/packages/config-eslint/plugins/regexp.js +16 -9
  20. package/packages/config-eslint/plugins/sonar.js +19 -12
  21. package/packages/config-eslint/plugins/stylistic.js +107 -100
  22. package/packages/config-eslint/plugins/tailwindcss.js +17 -6
  23. package/packages/config-eslint/plugins/tanstack-query.js +16 -9
  24. package/packages/config-eslint/plugins/typescript-type-checked.js +38 -33
  25. package/packages/config-eslint/plugins/typescript.js +23 -14
  26. package/packages/config-eslint/plugins/unicorn.js +73 -64
  27. package/packages/config-eslint/plugins/unocss.js +12 -5
  28. package/packages/config-eslint/plugins/vitest.js +20 -13
  29. package/packages/config-eslint/plugins/vue-accessibility.js +22 -13
  30. package/packages/config-eslint/plugins/vue-i18n.js +38 -31
  31. package/packages/config-eslint/plugins/vue.js +255 -242
  32. package/packages/config-eslint/plugins/zod.js +17 -10
  33. package/packages/config-eslint/rules/typescript.js +1 -1
  34. package/packages/config-hooks/README.md +119 -37
  35. package/packages/config-hooks/index.d.ts +19 -0
  36. package/packages/config-hooks/lint-staged.js +8 -6
  37. package/packages/config-hooks/package.json +3 -1
  38. package/packages/config-htmllint/README.md +50 -22
  39. package/packages/config-htmllint/index.d.ts +13 -0
  40. package/packages/config-htmllint/index.js +15 -7
  41. package/packages/config-htmllint/package.json +4 -2
  42. package/packages/config-markdownlint/README.md +40 -5
  43. package/packages/config-markdownlint/index.json +0 -2
  44. package/packages/config-markdownlint/package.json +1 -1
  45. package/packages/config-npmlint/README.md +48 -5
  46. package/packages/config-npmlint/package.json +3 -3
  47. package/packages/config-prettier/README.md +106 -23
  48. package/packages/config-prettier/index.d.ts +92 -0
  49. package/packages/config-prettier/index.js +60 -74
  50. package/packages/config-prettier/package.json +5 -4
  51. package/packages/config-prettier/plugins/jsdoc.js +12 -3
  52. package/packages/config-prettier/plugins/mdc.js +12 -3
  53. package/packages/config-prettier/plugins/packagejson.js +12 -3
  54. package/packages/config-prettier/plugins/php.js +12 -3
  55. package/packages/config-prettier/plugins/pug.js +12 -3
  56. package/packages/config-prettier/plugins/ruby.js +10 -10
  57. package/packages/config-prettier/plugins/sh.js +12 -3
  58. package/packages/config-prettier/plugins/solidity.js +12 -3
  59. package/packages/config-prettier/plugins/sort-json.js +12 -3
  60. package/packages/config-prettier/plugins/sql.js +12 -3
  61. package/packages/config-prettier/plugins/tailwindcss.js +12 -3
  62. package/packages/config-prettier/plugins/xml.js +12 -3
  63. package/packages/config-stylelint/README.md +131 -44
  64. package/packages/config-stylelint/index.d.ts +52 -0
  65. package/packages/config-stylelint/index.js +169 -165
  66. package/packages/config-stylelint/package.json +3 -1
  67. package/packages/config-stylelint/plugins/a11y.js +24 -11
  68. package/packages/config-stylelint/plugins/bem.js +10 -3
  69. package/packages/config-stylelint/plugins/color-format.js +14 -4
  70. package/packages/config-stylelint/plugins/declaration-block-no-ignored-properties.js +15 -4
  71. package/packages/config-stylelint/plugins/gamut.js +12 -4
  72. package/packages/config-stylelint/plugins/high-performance-animation.js +12 -3
  73. package/packages/config-stylelint/plugins/logical-css.js +10 -3
  74. package/packages/config-stylelint/plugins/media-use-custom-media.js +12 -4
  75. package/packages/config-stylelint/plugins/no-indistinguishable-colors.js +15 -4
  76. package/packages/config-stylelint/plugins/no-nested-media.js +12 -4
  77. package/packages/config-stylelint/plugins/no-unresolved-module.js +12 -3
  78. package/packages/config-stylelint/plugins/no-unsupported-browser-features.js +12 -3
  79. package/packages/config-stylelint/plugins/order.js +13 -3
  80. package/packages/config-stylelint/plugins/prettier.js +12 -4
  81. package/packages/config-stylelint/plugins/scss.js +13 -3
  82. package/packages/config-stylelint/plugins/selector-no-empty.js +12 -4
  83. package/packages/config-stylelint/plugins/use-nesting.js +15 -4
  84. package/packages/config-stylelint/plugins/vue.js +11 -2
  85. package/prettier.config.js +15 -7
  86. package/scripts/semver.sh +3 -3
  87. package/stylelint.config.js +25 -11
  88. package/packages/config-eslint/_legacy/LICENSE +0 -20
  89. package/packages/config-eslint/_legacy/README.md +0 -48
  90. package/packages/config-eslint/_legacy/constants/allow-boolean-property-list.js +0 -38
  91. package/packages/config-eslint/_legacy/constants/boolean-prefixes.js +0 -11
  92. package/packages/config-eslint/_legacy/constants/english-verbs.js +0 -3368
  93. package/packages/config-eslint/_legacy/dictionaries/index.js +0 -467
  94. package/packages/config-eslint/_legacy/dictionaries/programming/bash.js +0 -25
  95. package/packages/config-eslint/_legacy/dictionaries/programming/django.js +0 -2345
  96. package/packages/config-eslint/_legacy/dictionaries/programming/elixir.js +0 -64
  97. package/packages/config-eslint/_legacy/dictionaries/programming/go.js +0 -7748
  98. package/packages/config-eslint/_legacy/dictionaries/programming/java.js +0 -33527
  99. package/packages/config-eslint/_legacy/dictionaries/programming/latex.js +0 -675
  100. package/packages/config-eslint/_legacy/dictionaries/programming/lua.js +0 -394
  101. package/packages/config-eslint/_legacy/dictionaries/programming/php.js +0 -9788
  102. package/packages/config-eslint/_legacy/dictionaries/programming/python.js +0 -367
  103. package/packages/config-eslint/_legacy/dictionaries/programming/ruby.js +0 -357
  104. package/packages/config-eslint/_legacy/dictionaries/programming/rust.js +0 -115
  105. package/packages/config-eslint/_legacy/dictionaries/programming/scala.js +0 -2755
  106. package/packages/config-eslint/_legacy/dictionaries/specialized/html-symbol-entities.js +0 -1118
  107. package/packages/config-eslint/_legacy/dictionaries/specialized/lorem-ipsum.js +0 -359
  108. package/packages/config-eslint/_legacy/index.js +0 -12
  109. package/packages/config-eslint/_legacy/legacy.js +0 -3
  110. package/packages/config-eslint/_legacy/package.json +0 -97
  111. package/packages/config-eslint/_legacy/plugins/array-func.js +0 -20
  112. package/packages/config-eslint/_legacy/plugins/compat.js +0 -7
  113. package/packages/config-eslint/_legacy/plugins/decorator-position.js +0 -15
  114. package/packages/config-eslint/_legacy/plugins/eslint-comments.js +0 -9
  115. package/packages/config-eslint/_legacy/plugins/etc.js +0 -13
  116. package/packages/config-eslint/_legacy/plugins/ext.js +0 -12
  117. package/packages/config-eslint/_legacy/plugins/filenames.js +0 -38
  118. package/packages/config-eslint/_legacy/plugins/import.js +0 -133
  119. package/packages/config-eslint/_legacy/plugins/jsdoc.js +0 -32
  120. package/packages/config-eslint/_legacy/plugins/jsx-a11y.js +0 -5
  121. package/packages/config-eslint/_legacy/plugins/lit-a11y.js +0 -5
  122. package/packages/config-eslint/_legacy/plugins/lit.js +0 -9
  123. package/packages/config-eslint/_legacy/plugins/more.js +0 -17
  124. package/packages/config-eslint/_legacy/plugins/no-await-in-promise.js +0 -5
  125. package/packages/config-eslint/_legacy/plugins/no-constructor-bind.js +0 -8
  126. package/packages/config-eslint/_legacy/plugins/no-explicit-type-exports.js +0 -7
  127. package/packages/config-eslint/_legacy/plugins/no-loops.js +0 -7
  128. package/packages/config-eslint/_legacy/plugins/no-secrets.js +0 -12
  129. package/packages/config-eslint/_legacy/plugins/no-use-extend-native.js +0 -5
  130. package/packages/config-eslint/_legacy/plugins/node.js +0 -5
  131. package/packages/config-eslint/_legacy/plugins/prettier.js +0 -24
  132. package/packages/config-eslint/_legacy/plugins/promise.js +0 -10
  133. package/packages/config-eslint/_legacy/plugins/regexp.js +0 -7
  134. package/packages/config-eslint/_legacy/plugins/security.js +0 -10
  135. package/packages/config-eslint/_legacy/plugins/simple-import-sort.js +0 -7
  136. package/packages/config-eslint/_legacy/plugins/sonar.js +0 -5
  137. package/packages/config-eslint/_legacy/plugins/sort-class-members.js +0 -298
  138. package/packages/config-eslint/_legacy/plugins/sort-destructure-keys.js +0 -10
  139. package/packages/config-eslint/_legacy/plugins/sort-keys-fix.js +0 -7
  140. package/packages/config-eslint/_legacy/plugins/spellcheck.js +0 -9
  141. package/packages/config-eslint/_legacy/plugins/sql.js +0 -26
  142. package/packages/config-eslint/_legacy/plugins/tanstack-query.js +0 -4
  143. package/packages/config-eslint/_legacy/plugins/testing-library.js +0 -9
  144. package/packages/config-eslint/_legacy/plugins/typescript-sort-keys.js +0 -5
  145. package/packages/config-eslint/_legacy/plugins/typescript.js +0 -157
  146. package/packages/config-eslint/_legacy/plugins/unicorn.js +0 -70
  147. package/packages/config-eslint/_legacy/plugins/unused-imports.js +0 -17
  148. package/packages/config-eslint/_legacy/plugins/vitest.js +0 -16
  149. package/packages/config-eslint/_legacy/plugins/vue-i18n.js +0 -34
  150. package/packages/config-eslint/_legacy/plugins/vue.js +0 -291
  151. package/packages/config-eslint/_legacy/plugins/vuejs-accessibility.js +0 -20
  152. package/packages/config-eslint/_legacy/plugins/wc.js +0 -5
  153. package/packages/config-eslint/_legacy/plugins/write-good-comments.js +0 -7
  154. package/packages/config-eslint/_legacy/utils/create-config.js +0 -377
  155. package/packages/config-eslint/_legacy/utils/extend-spell-checker.js +0 -23
package/README.md CHANGED
@@ -1,32 +1,37 @@
1
- # Lint Kit
1
+ [![version](https://npmx.dev/api/registry/badge/version/@alexlit/lint-kit)](https://www.npmjs.com/package/@alexlit/lint-kit)
2
+ [![downloads](https://npmx.dev/api/registry/badge/downloads/@alexlit/lint-kit)](https://npmx.dev/package/@alexlit/lint-kit)
3
+ [![license](https://npmx.dev/api/registry/badge/license/@alexlit/lint-kit)](LICENSE)
2
4
 
3
- Presets of configuration files and dependencies for linting web applications
4
- (designed for [Vue.js](https://vuejs.org) with
5
- [TypeScript](https://www.typescriptlang.org/))
5
+ # Lint Kit
6
6
 
7
- ## Usage
7
+ Набор пакетов с конфигурациями для линтинга и форматирования кода Vue +
8
+ TypeScript проектов.
8
9
 
9
- ### Instal all linters
10
+ ## Пакеты
10
11
 
11
- ```sh
12
- npm i @alexlit/config-commitlint @alexlit/config-eslint @alexlit/config-hooks @alexlit/config-htmllint @alexlit/config-markdownlint @alexlit/config-npmlint @alexlit/config-prettier @alexlit/config-stylelint --legacy-peer-deps -D
13
- ```
12
+ | Пакет | Назначение |
13
+ | :----------------------------------------------------- | :--------------------------------- |
14
+ | [eslint](packages/config-eslint/README.md) | Линтинг JavaScript и TypeScript |
15
+ | [hooks](packages/config-hooks/README.md) | Git-хуки (commitlint, lint-staged) |
16
+ | [htmllint](packages/config-htmllint/README.md) | Линтинг HTML |
17
+ | [markdownlint](packages/config-markdownlint/README.md) | Линтинг Markdown |
18
+ | [npmlint](packages/config-npmlint/README.md) | Линтинг `package.json` |
19
+ | [prettier](packages/config-prettier/README.md) | Форматирование кода |
20
+ | [stylelint](packages/config-stylelint/README.md) | Линтинг CSS |
14
21
 
15
- ### Configuration
22
+ ## Установка
16
23
 
17
- - [commitlint](https://github.com/alex-lit/lint-kit/blob/master/packages/config-commitlint/README.md)
18
- - [eslint](https://github.com/alex-lit/lint-kit/blob/master/packages/config-eslint/README.md)
19
- - [hooks](https://github.com/alex-lit/lint-kit/blob/master/packages/config-hooks/README.md)
20
- - [htmllint](https://github.com/alex-lit/lint-kit/blob/master/packages/config-htmllint/README.md)
21
- - [markdownlint](https://github.com/alex-lit/lint-kit/blob/master/packages/config-markdownlint/README.md)
22
- - [npmlint](https://github.com/alex-lit/lint-kit/blob/master/packages/config-npmlint/README.md)
23
- - [prettier](https://github.com/alex-lit/lint-kit/blob/master/packages/config-prettier/README.md)
24
- - [stylelint](https://github.com/alex-lit/lint-kit/blob/master/packages/config-stylelint/README.md)
24
+ Рекомендуется устанавливать необходимые пакеты по отдельности - так вы
25
+ подключаете только те линтеры, которые необходимы и сможете управлять их
26
+ версиями.
25
27
 
26
- ## Dev mode
28
+ Инструкции по настройке каждого пакета приведены в его README (см. ссылки в
29
+ разделе [«Пакеты»](#пакеты)).
27
30
 
28
- ### Installation
31
+ ```bash
32
+ # установка необходимого пакета
33
+ npm install --save-dev @alexlit/config-<PACKAGE_NAME>
29
34
 
30
- ```sh
31
- npm run i
35
+ # или все сразу одной командой
36
+ npm install --save-dev @alexlit/lint-kit
32
37
  ```
package/eslint.config.js CHANGED
@@ -1,65 +1,32 @@
1
- import {
2
- base,
3
- deMorgan,
4
- importX,
5
- javascript,
6
- jsdoc,
7
- json,
8
- perfectionist,
9
- prettierConfig,
10
- regexp,
11
- sonar,
12
- stylistic,
13
- tailwindcss,
14
- tanstackQuery,
15
- typescriptTypeChecked,
16
- unicorn,
17
- vitest,
18
- vue,
19
- vueAccessibility,
20
- vueI18n,
21
- zod,
22
- } from '@alexlit/config-eslint';
1
+ import { defineConfig, plugins } from '@alexlit/config-eslint';
23
2
  import path from 'node:path';
24
3
 
25
- export default [
26
- ...base, // must be first
27
-
28
- ...javascript,
29
- ...deMorgan,
30
- ...importX,
31
- ...jsdoc,
32
- ...json,
33
- ...perfectionist,
34
- ...regexp,
35
- ...sonar,
36
- ...stylistic,
37
- ...typescriptTypeChecked,
38
- ...unicorn,
39
- ...vue,
40
- ...vueAccessibility,
41
- ...vueI18n,
42
-
43
- ...tanstackQuery,
44
- ...vitest,
45
- ...zod,
46
-
47
- ...tailwindcss({
4
+ export default defineConfig([
5
+ ...plugins.javascript(),
6
+ ...plugins.deMorgan(),
7
+ ...plugins.importX(),
8
+ ...plugins.jsdoc(),
9
+ ...plugins.json(),
10
+ ...plugins.perfectionist(),
11
+ ...plugins.regexp(),
12
+ ...plugins.sonar(),
13
+ ...plugins.stylistic(),
14
+ ...plugins.typescriptTypeChecked(),
15
+ ...plugins.unicorn(),
16
+ ...plugins.vue(),
17
+ ...plugins.vueAccessibility(),
18
+ ...plugins.vueI18n(),
19
+ ...plugins.tanstackQuery(),
20
+ ...plugins.vitest(),
21
+ ...plugins.zod(),
22
+ ...plugins.tailwindcss({
48
23
  cssConfigPath: path.resolve(
49
24
  import.meta.dirname,
50
25
  'examples/css.tailwind.css',
51
26
  ),
52
27
  }),
53
28
 
54
- ...prettierConfig, // must be last
55
-
56
- { ignores: ['**/packages/config-eslint/_legacy/**'] },
29
+ { files: ['**/*.js'], rules: { 'no-restricted-imports': 'off' } },
57
30
 
58
- {
59
- files: ['**/*.js'],
60
- rules: {
61
- 'no-restricted-imports': 'off',
62
- 'unicorn/comment-content': ['warn'],
63
- },
64
- },
65
- ];
31
+ ...plugins.prettierConfig(),
32
+ ]);
@@ -1,3 +1,3 @@
1
- import { createLintStagedConfig } from '@alexlit/config-hooks';
1
+ import { defineConfig } from '@alexlit/config-hooks';
2
2
 
3
- export default createLintStagedConfig();
3
+ export default defineConfig();
@@ -1,3 +1,3 @@
1
- import { createConfig } from '@alexlit/config-htmllint';
1
+ import { defineConfig } from '@alexlit/config-htmllint';
2
2
 
3
- export default createConfig();
3
+ export default defineConfig();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alexlit/lint-kit",
3
- "version": "214.3.0",
3
+ "version": "215.0.0",
4
4
  "private": false,
5
5
  "description": "Preset of configuration files and dependencies for linting web applications (designed for Vue.js with TypeScript)",
6
6
  "keywords": [
@@ -73,6 +73,7 @@
73
73
  "commit-msg": "npx commitlint --edit"
74
74
  },
75
75
  "devDependencies": {
76
- "changelogen": "^0.6.2"
76
+ "changelogen": "^0.6.2",
77
+ "radash": "^12.1.1"
77
78
  }
78
79
  }
@@ -1,135 +1,185 @@
1
+ [![version](https://npmx.dev/api/registry/badge/version/@alexlit/config-eslint)](https://www.npmjs.com/package/@alexlit/config-eslint)
2
+ [![downloads](https://npmx.dev/api/registry/badge/downloads/@alexlit/config-eslint)](https://npmx.dev/package/@alexlit/config-eslint)
3
+ [![license](https://npmx.dev/api/registry/badge/license/@alexlit/config-eslint)](LICENSE)
4
+
1
5
  # ESLint Configuration
2
6
 
3
- > [!WARNING]
4
- > For **eslint version < 9** use
5
- > [@alexlit/config-eslint@90](https://www.npmjs.com/package/@alexlit/config-eslint?activeTab=versions)
6
- > or lower.
7
+ Готовая конфигурация [ESLint](https://eslint.org/) в формате flat config:
8
+ настроенные правила для JavaScript, TypeScript, Vue.js, JSON, YAML, импортов,
9
+ Prettier и не только - всё, что обычно приходится настраивать вручную. Вместо
10
+ того чтобы подключать и настраивать каждый плагин по отдельности, соберите
11
+ конфигурацию из готовых модулей.
7
12
 
8
- There are no presets: `base` only provides the shared file scope, ignore
9
- patterns and globals. Every plugin is enabled explicitly, so you pay only for
10
- what you use.
13
+ Плагины модульные: по умолчанию ничего не включено - вы сами перечисляете нужные
14
+ в `defineConfig`.
11
15
 
12
- ## Installation
16
+ ## Установка
13
17
 
14
- ```sh
18
+ ```bash
15
19
  npm i @alexlit/config-eslint -D
16
20
  ```
17
21
 
18
- ## Connection
22
+ ## Быстрый старт
23
+
24
+ ```js
25
+ // eslint.config.js
26
+ import { defineConfig, plugins } from '@alexlit/config-eslint';
27
+
28
+ export default defineConfig([
29
+ ...plugins.javascript(),
30
+ ...plugins.typescript(),
31
+ ...plugins.unicorn(),
32
+ ...plugins.prettierConfig(),
33
+ ]);
34
+ ```
35
+
36
+ Каждый плагин возвращает массив блоков конфигурации, поэтому его нужно
37
+ развернуть оператором spread (`...`). Добавьте только то, что нужно проекту;
38
+ полный список - в разделе [Плагины](#плагины).
39
+
40
+ > [!NOTE]
41
+ >
42
+ > `plugins.prettierConfig()` должен быть последним - он отключает правила,
43
+ > конфликтующие с Prettier.
44
+
45
+ Больше плагинов - просто допишите их в массив. Пример:
46
+
47
+ ```js
48
+ // eslint.config.js
49
+ import { defineConfig, plugins } from '@alexlit/config-eslint';
50
+
51
+ export default defineConfig([
52
+ // базовые
53
+ ...plugins.deMorgan(),
54
+ ...plugins.importX(),
55
+ ...plugins.javascript(),
56
+ ...plugins.jsdoc(),
57
+ ...plugins.json(),
58
+ ...plugins.perfectionist(),
59
+ ...plugins.regexp(),
60
+ ...plugins.sonar(),
61
+ ...plugins.stylistic(),
62
+ ...plugins.typescript(),
63
+ ...plugins.unicorn(),
64
+
65
+ // проектные
66
+ ...plugins.pinia(),
67
+ ...plugins.tanstackQuery(),
68
+ ...plugins.unocss(),
69
+ ...plugins.vitest(),
70
+ ...plugins.vue(),
71
+ ...plugins.vueAccessibility(),
72
+ ...plugins.vueI18n(),
73
+ ...plugins.zod(),
74
+
75
+ // дополнительные правила
76
+ { ignores: ['fixtures/**'], rules: { 'no-console': 'off' } },
77
+
78
+ // стилистика
79
+ ...plugins.prettierConfig(),
80
+ ]);
81
+ ```
19
82
 
20
- Always start with `base` (it must be first) and finish with `prettierConfig` (it
21
- must be last, it disables the formatting rules).
83
+ ## Плагины
84
+
85
+ | Плагин | Что делает | Пакет |
86
+ | --------------------------------- | --------------------------------------------- | ----------------------------------- |
87
+ | `plugins.deMorgan()` | Упрощает логические выражения | `eslint-plugin-de-morgan` |
88
+ | `plugins.importX()` | Проверяет импорты и модули | `eslint-plugin-import-x` |
89
+ | `plugins.javascript()` | Базовые правила JavaScript | `@eslint/js` |
90
+ | `plugins.jsdoc()` | Проверяет JSDoc-комментарии | `eslint-plugin-jsdoc` |
91
+ | `plugins.json()` | Проверяет JSON, JSONC, JSON5 и YAML | `@eslint/json` |
92
+ | `plugins.perfectionist()` | Сортирует импорты, объекты, интерфейсы и типы | `eslint-plugin-perfectionist` |
93
+ | `plugins.pinia()` | Проверяет Pinia-хранилища | `eslint-plugin-pinia` |
94
+ | `plugins.prettier()` | Форматирует код самим Prettier | `eslint-plugin-prettier` |
95
+ | `plugins.prettierConfig()` | Отключает правила, конфликтующие с Prettier | `eslint-config-prettier` |
96
+ | `plugins.regexp()` | Проверяет регулярные выражения | `eslint-plugin-regexp` |
97
+ | `plugins.sonar()` | Проверяет код по правилам SonarJS | `eslint-plugin-sonarjs` |
98
+ | `plugins.stylistic()` | Проверяет форматирование и стиль кода | `@stylistic/eslint-plugin` |
99
+ | `plugins.tailwindcss()` | Проверяет классы Tailwind CSS | `eslint-plugin-tailwindcss` |
100
+ | `plugins.tanstackQuery()` | Проверяет TanStack Query | `@tanstack/eslint-plugin-query` |
101
+ | `plugins.typescript()` | Проверяет TypeScript без анализа типов | `typescript-eslint` |
102
+ | `plugins.typescriptTypeChecked()` | Проверяет TypeScript с анализом типов | `typescript-eslint` |
103
+ | `plugins.unicorn()` | Проверяет код по правилам unicorn | `eslint-plugin-unicorn` |
104
+ | `plugins.unocss()` | Проверяет UnoCSS | `@unocss/eslint-config` |
105
+ | `plugins.vitest()` | Проверяет тесты Vitest | `@vitest/eslint-plugin` |
106
+ | `plugins.vue()` | Проверяет Vue.js-компоненты | `eslint-plugin-vue` |
107
+ | `plugins.vueAccessibility()` | Проверяет доступность Vue.js-компонентов | `eslint-plugin-vuejs-accessibility` |
108
+ | `plugins.vueI18n()` | Проверяет Vue.js I18n | `@intlify/eslint-plugin-vue-i18n` |
109
+ | `plugins.zod()` | Проверяет Zod-схемы | `eslint-plugin-zod` |
110
+
111
+ ## Настройки Tailwind CSS
112
+
113
+ У `plugins.tailwindcss()` есть собственные настройки плагина - путь к CSS-файлу
114
+ с конфигурацией Tailwind CSS (`cssConfigPath`):
22
115
 
23
116
  ```js
24
117
  // eslint.config.js
25
- import {
26
- // foundation
27
- base,
28
-
29
- // plugins
30
- deMorgan,
31
- importX,
32
- javascript,
33
- jsdoc,
34
- json,
35
- perfectionist,
36
- prettierConfig,
37
- regexp,
38
- sonar,
39
- stylistic,
40
- typescript,
41
- unicorn,
42
-
43
- // framework plugins
44
- pinia,
45
- tailwindcss,
46
- tanstackQuery,
47
- unocss,
48
- vitest,
49
- vue,
50
- vueAccessibility,
51
- vueI18n,
52
- zod,
53
- } from '@alexlit/config-eslint';
54
-
55
- export default [
56
- ...base, // must be first
57
-
58
- ...deMorgan,
59
- ...importX,
60
- ...javascript,
61
- ...jsdoc,
62
- ...json,
63
- ...perfectionist,
64
- ...regexp,
65
- ...sonar,
66
- ...stylistic,
67
- ...typescript,
68
- ...unicorn,
69
-
70
- ...pinia,
71
- ...tanstackQuery,
72
- ...unocss,
73
- ...vitest,
74
- ...vue,
75
- ...vueAccessibility,
76
- ...vueI18n,
77
- ...zod,
78
-
79
- // `tailwindcss` is the only plugin exported as a factory, because it needs a path to your CSS entrypoint
80
- ...tailwindcss({ cssConfigPath: './src/assets/css/main.css' }),
81
-
82
- ...prettierConfig, // must be last
83
-
84
- // Custom rules example
85
- // { files: ['**/*.js'], rules: { 'no-console': 'off' } },
86
- ];
118
+ import path from 'node:path';
119
+
120
+ import { defineConfig, plugins } from '@alexlit/config-eslint';
121
+
122
+ export default defineConfig([
123
+ ...plugins.tailwindcss({
124
+ cssConfigPath: path.resolve(import.meta.dirname, 'src/main.css'),
125
+ }),
126
+ ]);
87
127
  ```
88
128
 
89
- Drop what you do not need.
129
+ По умолчанию используется путь `./styles/tailwind.css`.
90
130
 
91
- ## Type-aware rules (optional)
131
+ ## Type-aware правила
92
132
 
93
- Type-aware rules (`no-floating-promises`, `no-misused-promises`,
133
+ Type-aware правила (`no-floating-promises`, `no-misused-promises`,
94
134
  `await-thenable`, `no-unsafe-*`, `switch-exhaustiveness-check`,
95
- `no-unnecessary-condition`, …) require type information, which makes linting
96
- slower. They are not enabled by default.
135
+ `no-unnecessary-condition`, …) требуют информации о типах, из-за чего линтинг
136
+ замедляется. По умолчанию они не включены.
97
137
 
98
- To enable them, replace `typescript` with `typescriptTypeChecked`:
138
+ Чтобы их включить, замените `plugins.typescript()` на
139
+ `plugins.typescriptTypeChecked()`:
99
140
 
100
141
  ```js
101
- import {
102
- base,
103
- typescriptTypeChecked,
104
- prettierConfig,
105
- } from '@alexlit/config-eslint';
106
-
107
- export default [
108
- ...base,
109
- // ...other plugins
110
- ...typescriptTypeChecked, // instead of ...typescript
111
- ...prettierConfig,
112
- ];
142
+ // eslint.config.js
143
+ import { defineConfig, plugins } from '@alexlit/config-eslint';
144
+
145
+ export default defineConfig([
146
+ ...plugins.javascript(),
147
+ ...plugins.typescriptTypeChecked(), // вместо plugins.typescript()
148
+ ...plugins.prettierConfig(),
149
+ ]);
113
150
  ```
114
151
 
115
- > [!NOTE] `typescriptTypeChecked` needs a `tsconfig.json` in your project root
116
- > (`projectService` is used, so keep both `tsconfig.json` and
117
- > `tsconfig.node.json` etc. in a single root if needed). Use it instead of
118
- > `typescript`, not alongside.
152
+ > [!NOTE]
153
+ >
154
+ > `plugins.typescriptTypeChecked()` требует `tsconfig.json` в корне проекта
155
+ > (используется `projectService`, поэтому держите `tsconfig.json` и
156
+ > `tsconfig.node.json` в одном корне, если нужно). Используйте его вместо
157
+ > `plugins.typescript()`, а не вместе с ним.
158
+
159
+ ## Prettier или prettierConfig
160
+
161
+ Оба варианта доступны, и они **не взаимозаменяемы**.
119
162
 
120
- ## Formatting: `prettier` vs `prettierConfig`
163
+ | Плагин | Пакет | Что делает |
164
+ | -------------------------- | ------------------------ | ---------------------------------------------------------------- |
165
+ | `plugins.prettierConfig()` | `eslint-config-prettier` | Только отключает форматирующие правила, конфликтующие с Prettier |
166
+ | `plugins.prettier()` | `eslint-plugin-prettier` | Дополнительно запускает сам Prettier как правило ESLint |
121
167
 
122
- Both are included, and they are **not** interchangeable.
168
+ Используйте `plugins.prettierConfig()`, если Prettier запускается отдельным
169
+ шагом (редактор, CLI `prettier`, Husky). Используйте `plugins.prettier()`, если
170
+ хотите, чтобы ESLint сам сообщал о форматировании и исправлял его за один
171
+ проход - это медленнее и дублирует форматтер.
123
172
 
124
- | Export | From | Effect |
125
- | ---------------- | ------------------------ | ------------------------------------------------ |
126
- | `prettierConfig` | `eslint-config-prettier` | only turns off formatting rules that conflict |
127
- | `prettier` | `eslint-plugin-prettier` | additionally runs Prettier itself as a lint rule |
173
+ ## Разработка
128
174
 
129
- Use `prettierConfig` when Prettier runs as a separate step (editor, `prettier`
130
- CLI, Husky). Use `prettier` if you want ESLint to report and fix formatting in
131
- one pass — it is slower and duplicates the formatter.
175
+ Просмотр итоговой конфигурации:
176
+
177
+ ```bash
178
+ npm run inspect
179
+ ```
132
180
 
133
- ## Usefull links
181
+ ## Полезные ссылки
134
182
 
135
183
  - [Awesome ESLint](https://github.com/dustinspecker/awesome-eslint)
184
+ - [ESLint - Documentation](https://eslint.org/docs/latest/)
185
+ - [ESLint - Configure Flat Config](https://eslint.org/docs/latest/use/configure/configuration-files)
@@ -37,6 +37,7 @@ export const IGNORES = [
37
37
  '**/.*',
38
38
  '**/.*/**',
39
39
  '**/_deprecated/**',
40
+ '**/_legacy/**',
40
41
  '**/build/**',
41
42
  '**/dist/**',
42
43
  '**/docs/**',
@@ -49,12 +50,13 @@ export const IGNORES = [
49
50
  * Base config.
50
51
  *
51
52
  * Provides the file scope, the shared ignore patterns and the global variables.
52
- * Include it first, then the plugins you actually need.
53
+ * It is added automatically by `defineConfig`, so you never spread it
54
+ * yourself.
53
55
  *
54
56
  * @example
55
- * import { base, javascript, unicorn } from '@alexlit/config-eslint';
57
+ * import { defineConfig, plugins } from '@alexlit/config-eslint';
56
58
  *
57
- * export default [...base, ...javascript, ...unicorn];
59
+ * export default defineConfig([plugins.javascript(), plugins.unicorn()]);
58
60
  */
59
61
  export const base = defineConfig([
60
62
  { files: FILES, languageOptions: { globals: globals.browser } },
@@ -0,0 +1,112 @@
1
+ import type { Linter } from 'eslint';
2
+
3
+ /** Flat-конфиг ESLint. */
4
+ export type Config = Linter.Config;
5
+
6
+ /**
7
+ * Фабрики плагинов. Каждый вызов возвращает массив flat-конфигов, который нужно
8
+ * развернуть через spread-оператор: `...plugins.<name>()`.
9
+ */
10
+ export interface Plugins {
11
+ /** @see eslint-plugin-de-morgan */
12
+ deMorgan(): Config[];
13
+ /** @see eslint-plugin-import-x */
14
+ importX(): Config[];
15
+ /** @see eslint */
16
+ javascript(): Config[];
17
+ /** @see eslint-plugin-jsdoc */
18
+ jsdoc(): Config[];
19
+ /** @see ESLint/JSON */
20
+ json(): Config[];
21
+ /** @see eslint-plugin-perfectionist */
22
+ perfectionist(): Config[];
23
+ /** @see eslint-plugin-pinia */
24
+ pinia(): Config[];
25
+ /** @see eslint-plugin-prettier */
26
+ prettier(): Config[];
27
+ /** @see eslint-config-prettier */
28
+ prettierConfig(): Config[];
29
+ /** @see eslint-plugin-regexp */
30
+ regexp(): Config[];
31
+ /** @see eslint-plugin-sonarjs */
32
+ sonar(): Config[];
33
+ /** @see @stylistic/eslint-plugin */
34
+ stylistic(): Config[];
35
+ /** @see eslint-plugin-tailwindcss */
36
+ tailwindcss(settings?: TailwindcssSettings): Config[];
37
+ /** @see @tanstack/query */
38
+ tanstackQuery(): Config[];
39
+ /** @see typescript-eslint */
40
+ typescript(): Config[];
41
+ /** @see typescript-eslint */
42
+ typescriptTypeChecked(): Config[];
43
+ /** @see eslint-plugin-unicorn */
44
+ unicorn(): Config[];
45
+ /** @see @unocss/eslint-config */
46
+ unocss(): Config[];
47
+ /** @see eslint-plugin-vitest */
48
+ vitest(): Config[];
49
+ /** @see eslint-plugin-vue */
50
+ vue(): Config[];
51
+ /** @see eslint-plugin-vuejs-accessibility */
52
+ vueAccessibility(): Config[];
53
+ /** @see eslint-plugin-vue-i18n */
54
+ vueI18n(): Config[];
55
+ /** @see eslint-plugin-zod */
56
+ zod(): Config[];
57
+ }
58
+
59
+ /** Ограничение синтаксиса - сообщение об ошибке и селектор AST. */
60
+ export interface RestrictedSyntax {
61
+ message: string;
62
+ selector: string;
63
+ }
64
+
65
+ /** Настройки eslint-plugin-tailwindcss. */
66
+ export interface TailwindcssSettings {
67
+ [key: string]: unknown;
68
+ /** Путь к CSS-файлу с Tailwind-конфигурацией */
69
+ cssConfigPath?: string;
70
+ }
71
+
72
+ /** Пространство имён фабрик плагинов. */
73
+ export declare const plugins: Plugins;
74
+
75
+ /**
76
+ * Базовый конфиг: область файлов, игнорируемые пути и глобальные переменные.
77
+ * Добавляется автоматически первым блоком в `defineConfig`.
78
+ */
79
+ export declare const base: Config[];
80
+
81
+ export declare const DATA_FILES: string[];
82
+ export declare const DTS_FILES: string[];
83
+ export declare const FILES: string[];
84
+ export declare const IGNORES: string[];
85
+ export declare const JSON_FILES: string[];
86
+ export declare const NO_RESTRICTED_SYNTAX: RestrictedSyntax[];
87
+ export declare const TEST_FILES: string[];
88
+ export declare const TS_FILES: string[];
89
+ export declare const TS_RULES: Record<string, Linter.RuleEntry>;
90
+ export declare const VUE_FILES: string[];
91
+ export declare const YAML_FILES: string[];
92
+
93
+ /**
94
+ * Создать конфигурацию ESLint.
95
+ *
96
+ * Базовые настройки (`base`) добавляются автоматически и всегда идут первыми.
97
+ * Разворачивайте вызовы плагинов через spread-оператор, а переопределения
98
+ * добавляйте прямо в массив.
99
+ *
100
+ * @example
101
+ * import { defineConfig, plugins } from '@alexlit/config-eslint';
102
+ *
103
+ * export default defineConfig([
104
+ * ...plugins.javascript(),
105
+ * ...plugins.unicorn(),
106
+ * ...plugins.prettierConfig(),
107
+ * { rules: { 'no-console': 'off' } },
108
+ * ]);
109
+ *
110
+ * @param configs - Массив flat-конфигов
111
+ */
112
+ export declare function defineConfig(configs?: Config[]): Config[];