@alexlit/config-eslint 161.4.0 → 162.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.
package/README.md CHANGED
@@ -1,135 +1,231 @@
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
18
  ```sh
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
+ Каждый вызов `plugins.*()` - отдельный плагин. Добавьте только то, что нужно
37
+ проекту; полный список - в разделе [Плагины](#плагины).
38
+
39
+ Базовые настройки (`base`) добавляются автоматически и всегда идут первыми:
40
+ набор файлов, общие игнорируемые пути, глобальные переменные браузера и Node.js,
41
+ а также запрет неиспользуемых директив `eslint-disable`.
42
+
43
+ `plugins.prettierConfig()` должен быть последним - он отключает правила,
44
+ конфликтующие с Prettier.
45
+
46
+ Больше плагинов - просто допишите их в массив:
47
+
48
+ ```js
49
+ // eslint.config.js
50
+ import { defineConfig, plugins } from '@alexlit/config-eslint';
51
+
52
+ export default defineConfig([
53
+ // базовые
54
+ plugins.javascript(),
55
+ plugins.deMorgan(),
56
+ plugins.importX(),
57
+ plugins.jsdoc(),
58
+ plugins.json(),
59
+ plugins.perfectionist(),
60
+ plugins.regexp(),
61
+ plugins.sonar(),
62
+ plugins.stylistic(),
63
+ plugins.typescript(),
64
+ plugins.unicorn(),
65
+
66
+ // проектные
67
+ plugins.pinia(),
68
+ plugins.tanstackQuery(),
69
+ plugins.unocss(),
70
+ plugins.vitest(),
71
+ plugins.vue(),
72
+ plugins.vueAccessibility(),
73
+ plugins.vueI18n(),
74
+ plugins.zod(),
75
+
76
+ // стилистика
77
+ plugins.prettierConfig(),
78
+ ]);
79
+ ```
80
+
81
+ ## Настройка
82
+
83
+ ### Правила конкретного плагина
84
+
85
+ Чтобы переопределить правила одного плагина, передайте объект в его вызов. Опции
86
+ добавляются последним блоком и перекрывают правила плагина:
87
+
88
+ ```js
89
+ // eslint.config.js
90
+ import { defineConfig, plugins } from '@alexlit/config-eslint';
91
+
92
+ export default defineConfig([
93
+ plugins.javascript({ rules: { 'no-console': 'off' } }),
94
+ plugins.perfectionist({ rules: { 'perfectionist/sort-imports': 'off' } }),
95
+ ]);
96
+ ```
97
+
98
+ ### Общие настройки
19
99
 
20
- Always start with `base` (it must be first) and finish with `prettierConfig` (it
21
- must be last, it disables the formatting rules).
100
+ Второй аргумент `defineConfig` - общие flat-опции ESLint: собственные правила,
101
+ файлы для игнора, настройки и т.д. Он перебивает настройки всех плагинов:
22
102
 
23
103
  ```js
24
104
  // 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
- ];
105
+ import { defineConfig, plugins } from '@alexlit/config-eslint';
106
+
107
+ export default defineConfig([plugins.javascript()], {
108
+ ignores: ['fixtures/**'],
109
+ rules: { 'no-console': 'off' },
110
+ });
87
111
  ```
88
112
 
89
- Drop what you do not need.
113
+ ### Особые опции
114
+
115
+ У `plugins.tailwindcss()` есть собственная опция `cssConfigPath` - путь к
116
+ CSS-файлу с конфигурацией Tailwind CSS:
90
117
 
91
- ## Type-aware rules (optional)
118
+ ```js
119
+ // eslint.config.js
120
+ import path from 'node:path';
121
+
122
+ import { defineConfig, plugins } from '@alexlit/config-eslint';
123
+
124
+ export default defineConfig([
125
+ plugins.tailwindcss({
126
+ cssConfigPath: path.resolve(import.meta.dirname, 'src/main.css'),
127
+ }),
128
+ ]);
129
+ ```
92
130
 
93
- Type-aware rules (`no-floating-promises`, `no-misused-promises`,
131
+ ## Плагины
132
+
133
+ | Плагин | Что делает | Пакет |
134
+ | --------------------------------- | --------------------------------------------- | ----------------------------------- |
135
+ | `plugins.deMorgan()` | Упрощает логические выражения | `eslint-plugin-de-morgan` |
136
+ | `plugins.importX()` | Проверяет импорты и модули | `eslint-plugin-import-x` |
137
+ | `plugins.javascript()` | Базовые правила JavaScript | `@eslint/js` |
138
+ | `plugins.jsdoc()` | Проверяет JSDoc-комментарии | `eslint-plugin-jsdoc` |
139
+ | `plugins.json()` | Проверяет JSON, JSONC, JSON5 и YAML | `@eslint/json` |
140
+ | `plugins.perfectionist()` | Сортирует импорты, объекты, интерфейсы и типы | `eslint-plugin-perfectionist` |
141
+ | `plugins.pinia()` | Проверяет Pinia-хранилища | `eslint-plugin-pinia` |
142
+ | `plugins.prettier()` | Форматирует код самим Prettier | `eslint-plugin-prettier` |
143
+ | `plugins.prettierConfig()` | Отключает правила, конфликтующие с Prettier | `eslint-config-prettier` |
144
+ | `plugins.regexp()` | Проверяет регулярные выражения | `eslint-plugin-regexp` |
145
+ | `plugins.sonar()` | Проверяет код по правилам SonarJS | `eslint-plugin-sonarjs` |
146
+ | `plugins.stylistic()` | Проверяет форматирование и стиль кода | `@stylistic/eslint-plugin` |
147
+ | `plugins.tailwindcss()` | Проверяет классы Tailwind CSS | `eslint-plugin-tailwindcss` |
148
+ | `plugins.tanstackQuery()` | Проверяет TanStack Query | `@tanstack/eslint-plugin-query` |
149
+ | `plugins.typescript()` | Проверяет TypeScript без анализа типов | `typescript-eslint` |
150
+ | `plugins.typescriptTypeChecked()` | Проверяет TypeScript с анализом типов | `typescript-eslint` |
151
+ | `plugins.unicorn()` | Проверяет код по правилам unicorn | `eslint-plugin-unicorn` |
152
+ | `plugins.unocss()` | Проверяет UnoCSS | `@unocss/eslint-config` |
153
+ | `plugins.vitest()` | Проверяет тесты Vitest | `@vitest/eslint-plugin` |
154
+ | `plugins.vue()` | Проверяет Vue.js-компоненты | `eslint-plugin-vue` |
155
+ | `plugins.vueAccessibility()` | Проверяет доступность Vue.js-компонентов | `eslint-plugin-vuejs-accessibility` |
156
+ | `plugins.vueI18n()` | Проверяет Vue.js I18n | `@intlify/eslint-plugin-vue-i18n` |
157
+ | `plugins.zod()` | Проверяет Zod-схемы | `eslint-plugin-zod` |
158
+
159
+ ## Type-aware правила
160
+
161
+ Type-aware правила (`no-floating-promises`, `no-misused-promises`,
94
162
  `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.
163
+ `no-unnecessary-condition`, …) требуют информации о типах, из-за чего линтинг
164
+ замедляется. По умолчанию они не включены.
97
165
 
98
- To enable them, replace `typescript` with `typescriptTypeChecked`:
166
+ Чтобы их включить, замените `plugins.typescript()` на
167
+ `plugins.typescriptTypeChecked()`:
99
168
 
100
169
  ```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
- ];
170
+ // eslint.config.js
171
+ import { defineConfig, plugins } from '@alexlit/config-eslint';
172
+
173
+ export default defineConfig([
174
+ plugins.javascript(),
175
+ plugins.typescriptTypeChecked(), // вместо plugins.typescript()
176
+ plugins.prettierConfig(),
177
+ ]);
113
178
  ```
114
179
 
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.
180
+ > [!NOTE]
181
+ >
182
+ > `plugins.typescriptTypeChecked()` требует `tsconfig.json` в корне проекта
183
+ > (используется `projectService`, поэтому держите `tsconfig.json` и
184
+ > `tsconfig.node.json` в одном корне, если нужно). Используйте его вместо
185
+ > `plugins.typescript()`, а не вместе с ним.
186
+
187
+ ## Prettier или prettierConfig
188
+
189
+ Оба варианта доступны, и они **не взаимозаменяемы**.
190
+
191
+ | Плагин | Пакет | Что делает |
192
+ | -------------------------- | ------------------------ | ---------------------------------------------------------------- |
193
+ | `plugins.prettierConfig()` | `eslint-config-prettier` | Только отключает форматирующие правила, конфликтующие с Prettier |
194
+ | `plugins.prettier()` | `eslint-plugin-prettier` | Дополнительно запускает сам Prettier как правило ESLint |
195
+
196
+ Используйте `plugins.prettierConfig()`, если Prettier запускается отдельным
197
+ шагом (редактор, CLI `prettier`, Husky). Используйте `plugins.prettier()`, если
198
+ хотите, чтобы ESLint сам сообщал о форматировании и исправлял его за один
199
+ проход - это медленнее и дублирует форматтер.
200
+
201
+ ## Миграция с v161
202
+
203
+ v162 - breaking-релиз: плагины по умолчанию больше нет, всё подключается явно, а
204
+ каждый плагин стал фабрикой.
205
+
206
+ | v161 | v162 |
207
+ | ----------------------------- | -------------------------------------------------- |
208
+ | `import { base } from ...` | `import { defineConfig, plugins } from ...` |
209
+ | `[...base, ...javascript]` | `defineConfig([plugins.javascript()])` |
210
+ | `...javascript` | `plugins.javascript()` |
211
+ | `...prettierConfig` | `plugins.prettierConfig()` (последним) |
212
+ | `...tailwindcss({ ... })` | `plugins.tailwindcss({ ... })` |
213
+ | `{ files: [...], rules: {} }` | `defineConfig([...], { files: [...], rules: {} })` |
119
214
 
120
- ## Formatting: `prettier` vs `prettierConfig`
215
+ Плоские экспорты плагинов (`javascript`, `unicorn`, `vue` и другие) удалены -
216
+ используйте `plugins.<name>()`. Базовые настройки (`base`) добавляются
217
+ автоматически, разворачивать их вручную больше не нужно.
121
218
 
122
- Both are included, and they are **not** interchangeable.
219
+ ## Разработка
123
220
 
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 |
221
+ - Просмотр итоговой конфигурации:
128
222
 
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.
223
+ ```sh
224
+ npm run inspect
225
+ ```
132
226
 
133
- ## Usefull links
227
+ ## Полезные ссылки
134
228
 
135
229
  - [Awesome ESLint](https://github.com/dustinspecker/awesome-eslint)
230
+ - [ESLint - Documentation](https://eslint.org/docs/latest/)
231
+ - [ESLint - Configure Flat Config](https://eslint.org/docs/latest/use/configure/configuration-files)
package/base.js CHANGED
@@ -49,12 +49,13 @@ export const IGNORES = [
49
49
  * Base config.
50
50
  *
51
51
  * Provides the file scope, the shared ignore patterns and the global variables.
52
- * Include it first, then the plugins you actually need.
52
+ * It is added automatically by `defineConfig`, so you never spread it
53
+ * yourself.
53
54
  *
54
55
  * @example
55
- * import { base, javascript, unicorn } from '@alexlit/config-eslint';
56
+ * import { defineConfig, plugins } from '@alexlit/config-eslint';
56
57
  *
57
- * export default [...base, ...javascript, ...unicorn];
58
+ * export default defineConfig([plugins.javascript(), plugins.unicorn()]);
58
59
  */
59
60
  export const base = defineConfig([
60
61
  { files: FILES, languageOptions: { globals: globals.browser } },
@@ -66,3 +67,23 @@ export const base = defineConfig([
66
67
 
67
68
  { ignores: IGNORES },
68
69
  ]);
70
+
71
+ /**
72
+ * Создать фабрику плагина.
73
+ *
74
+ * Фабрика возвращает набор flat-конфигов плагина. Переданные опции добавляются
75
+ * последним блоком и перекрывают правила плагина.
76
+ *
77
+ * @param {() => import('eslint').Linter.Config[]} build Конфиги плагина
78
+ *
79
+ * @returns {(
80
+ * options?: import('eslint').Linter.Config,
81
+ * ) => import('eslint').Linter.Config[]}
82
+ */
83
+ export const createPlugin =
84
+ (build) =>
85
+ (options = {}) => {
86
+ const configs = build();
87
+
88
+ return Object.keys(options).length > 0 ? [...configs, options] : configs;
89
+ };
package/index.d.ts ADDED
@@ -0,0 +1,111 @@
1
+ import type { Linter } from 'eslint';
2
+
3
+ /** Flat-конфиг ESLint. */
4
+ export type Config = Linter.Config;
5
+
6
+ /**
7
+ * Опции плагина или общие опции - произвольные flat-опции ESLint (`files`,
8
+ * `ignores`, `rules`, `settings`, `languageOptions` и т.д.).
9
+ */
10
+ export type Options = Linter.Config;
11
+
12
+ /**
13
+ * Фабрики плагинов. Каждый плагин подключается явно: передайте
14
+ * `plugins.<name>()` в `defineConfig`.
15
+ */
16
+ export interface Plugins {
17
+ /** @see eslint-plugin-de-morgan */
18
+ deMorgan(options?: Options): Config[];
19
+ /** @see eslint-plugin-import-x */
20
+ importX(options?: Options): Config[];
21
+ /** @see eslint */
22
+ javascript(options?: Options): Config[];
23
+ /** @see eslint-plugin-jsdoc */
24
+ jsdoc(options?: Options): Config[];
25
+ /** @see ESLint/JSON */
26
+ json(options?: Options): Config[];
27
+ /** @see eslint-plugin-perfectionist */
28
+ perfectionist(options?: Options): Config[];
29
+ /** @see eslint-plugin-pinia */
30
+ pinia(options?: Options): Config[];
31
+ /** @see eslint-plugin-prettier */
32
+ prettier(options?: Options): Config[];
33
+ /** @see eslint-config-prettier */
34
+ prettierConfig(options?: Options): Config[];
35
+ /** @see eslint-plugin-regexp */
36
+ regexp(options?: Options): Config[];
37
+ /** @see eslint-plugin-sonarjs */
38
+ sonar(options?: Options): Config[];
39
+ /** @see @stylistic/eslint-plugin */
40
+ stylistic(options?: Options): Config[];
41
+ /** @see eslint-plugin-tailwindcss */
42
+ tailwindcss(options?: Options & TailwindcssOptions): Config[];
43
+ /** @see @tanstack/query */
44
+ tanstackQuery(options?: Options): Config[];
45
+ /** @see typescript-eslint */
46
+ typescript(options?: Options): Config[];
47
+ /** @see typescript-eslint */
48
+ typescriptTypeChecked(options?: Options): Config[];
49
+ /** @see eslint-plugin-unicorn */
50
+ unicorn(options?: Options): Config[];
51
+ /** @see @unocss/eslint-config */
52
+ unocss(options?: Options): Config[];
53
+ /** @see eslint-plugin-vitest */
54
+ vitest(options?: Options): Config[];
55
+ /** @see eslint-plugin-vue */
56
+ vue(options?: Options): Config[];
57
+ /** @see eslint-plugin-vuejs-accessibility */
58
+ vueAccessibility(options?: Options): Config[];
59
+ /** @see eslint-plugin-vue-i18n */
60
+ vueI18n(options?: Options): Config[];
61
+ /** @see eslint-plugin-zod */
62
+ zod(options?: Options): Config[];
63
+ }
64
+
65
+ /** Ограничение синтаксиса - сообщение об ошибке и селектор AST. */
66
+ export interface RestrictedSyntax {
67
+ message: string;
68
+ selector: string;
69
+ }
70
+
71
+ /** Опции Tailwind CSS. */
72
+ export interface TailwindcssOptions {
73
+ /** Путь к CSS-файлу с Tailwind-конфигурацией */
74
+ cssConfigPath?: string;
75
+ }
76
+
77
+ /** Пространство имён фабрик плагинов. */
78
+ export declare const plugins: Plugins;
79
+
80
+ /**
81
+ * Базовый конфиг: область файлов, игнорируемые пути и глобальные переменные.
82
+ * Добавляется автоматически первым блоком в `defineConfig`.
83
+ */
84
+ export declare const base: Config[];
85
+
86
+ export declare const DATA_FILES: string[];
87
+ export declare const DTS_FILES: string[];
88
+ export declare const FILES: string[];
89
+ export declare const IGNORES: string[];
90
+ export declare const JSON_FILES: string[];
91
+ export declare const NO_RESTRICTED_SYNTAX: RestrictedSyntax[];
92
+ export declare const TEST_FILES: string[];
93
+ export declare const TS_FILES: string[];
94
+ export declare const TS_RULES: Record<string, Linter.RuleEntry>;
95
+ export declare const VUE_FILES: string[];
96
+ export declare const YAML_FILES: string[];
97
+
98
+ /**
99
+ * Создать конфигурацию ESLint.
100
+ *
101
+ * Базовые настройки (`base`) добавляются автоматически и всегда идут первыми.
102
+ * Дальше идут конфиги плагинов в том порядке, в котором вы их перечислили, а
103
+ * последним - общие опции, которые перекрывают правила плагинов.
104
+ *
105
+ * @param pluginConfigs - Конфиги плагинов, напр. `[plugins.javascript()]`
106
+ * @param options - Общие flat-опции, наивысший приоритет
107
+ */
108
+ export declare function defineConfig(
109
+ pluginConfigs?: Config[][],
110
+ options?: Options,
111
+ ): Config[];
package/index.js CHANGED
@@ -1,3 +1,84 @@
1
+ import { defineConfig as defineFlatConfig } from 'eslint/config';
2
+
3
+ import { base } from './base.js';
4
+ import { deMorgan } from './plugins/de-morgan.js';
5
+ import { importX } from './plugins/import-x.js';
6
+ import { javascript } from './plugins/javascript.js';
7
+ import { jsdoc } from './plugins/jsdoc.js';
8
+ import { json } from './plugins/json.js';
9
+ import { perfectionist } from './plugins/perfectionist.js';
10
+ import { pinia } from './plugins/pinia.js';
11
+ import { prettier, prettierConfig } from './plugins/prettier.js';
12
+ import { regexp } from './plugins/regexp.js';
13
+ import { sonar } from './plugins/sonar.js';
14
+ import { stylistic } from './plugins/stylistic.js';
15
+ import { tailwindcss } from './plugins/tailwindcss.js';
16
+ import { tanstackQuery } from './plugins/tanstack-query.js';
17
+ import { typescriptTypeChecked } from './plugins/typescript-type-checked.js';
18
+ import { typescript } from './plugins/typescript.js';
19
+ import { unicorn } from './plugins/unicorn.js';
20
+ import { unocss } from './plugins/unocss.js';
21
+ import { vitest } from './plugins/vitest.js';
22
+ import { vueAccessibility } from './plugins/vue-accessibility.js';
23
+ import { vueI18n } from './plugins/vue-i18n.js';
24
+ import { vue } from './plugins/vue.js';
25
+ import { zod } from './plugins/zod.js';
26
+
27
+ /**
28
+ * Фабрики плагинов. Каждый плагин подключается явно: передайте
29
+ * `plugins.<name>()` в `defineConfig`
30
+ */
31
+ export const plugins = {
32
+ deMorgan,
33
+ importX,
34
+ javascript,
35
+ jsdoc,
36
+ json,
37
+ perfectionist,
38
+ pinia,
39
+ prettier,
40
+ prettierConfig,
41
+ regexp,
42
+ sonar,
43
+ stylistic,
44
+ tailwindcss,
45
+ tanstackQuery,
46
+ typescript,
47
+ typescriptTypeChecked,
48
+ unicorn,
49
+ unocss,
50
+ vitest,
51
+ vue,
52
+ vueAccessibility,
53
+ vueI18n,
54
+ zod,
55
+ };
56
+
57
+ /**
58
+ * Создать конфигурацию ESLint
59
+ *
60
+ * Базовые настройки (`base`) добавляются автоматически и всегда идут первыми.
61
+ * Дальше идут конфиги плагинов в том порядке, в котором вы их перечислили, а
62
+ * последним - общие опции, которые перекрывают правила плагинов.
63
+ *
64
+ * @example
65
+ * import { defineConfig, plugins } from '@alexlit/config-eslint';
66
+ *
67
+ * export default defineConfig(
68
+ * [plugins.javascript(), plugins.unicorn(), plugins.prettierConfig()],
69
+ * { rules: { 'no-console': 'off' } },
70
+ * );
71
+ *
72
+ * @param {import('eslint').Linter.Config[][]} [pluginConfigs] - Конфиги
73
+ * плагинов, напр. `[plugins.javascript()]`
74
+ * @param {import('eslint').Linter.Config} [options] - Общие flat-опции,
75
+ * наивысший приоритет
76
+ *
77
+ * @returns {import('eslint').Linter.Config[]}
78
+ */
79
+ export const defineConfig = (pluginConfigs = [], options = {}) =>
80
+ defineFlatConfig([base, pluginConfigs, options]);
81
+
1
82
  export {
2
83
  base,
3
84
  DATA_FILES,
@@ -10,28 +91,5 @@ export {
10
91
  VUE_FILES,
11
92
  YAML_FILES,
12
93
  } from './base.js';
13
-
14
- export { deMorgan } from './plugins/de-morgan.js';
15
- export { importX } from './plugins/import-x.js';
16
- export { javascript } from './plugins/javascript.js';
17
- export { jsdoc } from './plugins/jsdoc.js';
18
- export { json } from './plugins/json.js';
19
- export { perfectionist } from './plugins/perfectionist.js';
20
- export { pinia } from './plugins/pinia.js';
21
- export { prettier, prettierConfig } from './plugins/prettier.js';
22
- export { regexp } from './plugins/regexp.js';
23
- export { sonar } from './plugins/sonar.js';
24
- export { stylistic } from './plugins/stylistic.js';
25
- export { tailwindcss } from './plugins/tailwindcss.js';
26
- export { tanstackQuery } from './plugins/tanstack-query.js';
27
- export { typescriptTypeChecked } from './plugins/typescript-type-checked.js';
28
- export { typescript } from './plugins/typescript.js';
29
- export { unicorn } from './plugins/unicorn.js';
30
- export { unocss } from './plugins/unocss.js';
31
- export { vitest } from './plugins/vitest.js';
32
- export { vueAccessibility } from './plugins/vue-accessibility.js';
33
- export { vueI18n } from './plugins/vue-i18n.js';
34
- export { vue } from './plugins/vue.js';
35
- export { zod } from './plugins/zod.js';
36
94
  export { NO_RESTRICTED_SYNTAX } from './rules/restricted-syntax.js';
37
95
  export { TS_RULES } from './rules/typescript.js';
package/package.json CHANGED
@@ -1,14 +1,15 @@
1
1
  {
2
2
  "name": "@alexlit/config-eslint",
3
- "version": "161.4.0",
3
+ "version": "162.0.0",
4
4
  "private": false,
5
- "description": "Sharable ESLint configuration",
5
+ "description": "eslint config",
6
6
  "keywords": [
7
+ "code-quality",
8
+ "config",
7
9
  "eslint",
8
10
  "eslint-config",
9
- "lint",
10
- "code-quality",
11
11
  "javascript",
12
+ "lint",
12
13
  "typescript"
13
14
  ],
14
15
  "homepage": "https://github.com/alex-lit/lint-kit/tree/master/packages/config-eslint#readme",
@@ -23,21 +24,23 @@
23
24
  "license": "MIT",
24
25
  "author": "Alexey Litovchenko <alex.lit@outlook.com> (https://github.com/alex-lit)",
25
26
  "type": "module",
26
- "main": "./index.js",
27
+ "main": "index.js",
28
+ "types": "index.d.ts",
27
29
  "files": [
28
- "index.js",
30
+ "README.md",
29
31
  "base.js",
32
+ "index.d.ts",
33
+ "index.js",
30
34
  "plugins/",
31
- "rules/",
32
- "README.md"
35
+ "rules/"
33
36
  ],
34
37
  "scripts": {
35
38
  "inspect": "npx @eslint/config-inspector@latest",
36
39
  "lint": "cd ../../ && ./scripts/lint.eslint.sh",
37
- "ou": "sh ../../scripts/ou.sh",
38
- "release": "sh ../../scripts/release.sh",
39
- "semver": "sh ../../scripts/semver.sh",
40
- "up": "sh ../../scripts/up.sh"
40
+ "ou": "../../scripts/ou.sh",
41
+ "release": "../../scripts/release.sh",
42
+ "semver": "../../scripts/semver.sh",
43
+ "up": "../../scripts/up.sh"
41
44
  },
42
45
  "dependencies": {
43
46
  "@eslint/js": "^10.0.1",