@qstanay/eslint-config 1.0.4 → 1.1.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/CHANGELOG.md +15 -0
- package/README.md +20 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +48 -1
- package/dist/index.mjs.map +1 -1
- package/dist/{nuxt-BOdDS-BM.d.mts → nuxt-Bxa1EDDq.d.mts} +11 -1
- package/dist/nuxt-Bxa1EDDq.d.mts.map +1 -0
- package/dist/{nuxt-CEMZQEXW.mjs → nuxt-oec8_Haa.mjs} +50 -68
- package/dist/nuxt-oec8_Haa.mjs.map +1 -0
- package/dist/nuxt.d.mts +1 -1
- package/dist/nuxt.mjs +1 -1
- package/package.json +9 -3
- package/dist/nuxt-BOdDS-BM.d.mts.map +0 -1
- package/dist/nuxt-CEMZQEXW.mjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project are documented in this file.
|
|
4
4
|
|
|
5
|
+
## [1.1.1] - 2026-08-16
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
|
|
9
|
+
- `/nuxt` no longer registers its own `@typescript-eslint` plugin. It only adds rules on top of the plugin from `@nuxt/eslint`, so consumers do not need pnpm/npm `overrides` to avoid “two instances of plugin `@typescript-eslint`”.
|
|
10
|
+
|
|
11
|
+
## [1.1.0] - 2026-08-08
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- Vitest support via `test` option for `defineConfig()` and `nuxt()`
|
|
16
|
+
- Auto-enabled when `vitest` is installed (`test: false` to disable)
|
|
17
|
+
- Applies `@vitest/eslint-plugin` recommended rules to common test globs
|
|
18
|
+
- Declares Vitest globals (`describe`, `it`, `expect`, `vi`, …) for those files
|
|
19
|
+
|
|
5
20
|
## [1.0.4] - 2026-07-27
|
|
6
21
|
|
|
7
22
|
### Fixed
|
package/README.md
CHANGED
|
@@ -139,6 +139,7 @@ Main entry for Vue / TypeScript projects.
|
|
|
139
139
|
| `vue` | `boolean` | auto (`vue` or `nuxt` installed) | Enable Vue rules |
|
|
140
140
|
| `typescript` | `boolean` | auto (`typescript` installed) | Enable TypeScript rules |
|
|
141
141
|
| `nuxt` | `boolean` | auto (`nuxt` installed) | Enable Nuxt plugin rule(s). Prefer `/nuxt` for Nuxt apps |
|
|
142
|
+
| `test` | `boolean` | auto (`vitest` installed) | Enable Vitest rules/globals for test files |
|
|
142
143
|
| `strict` | `boolean` | `false` | Stricter TS rules (e.g. `no-magic-numbers`) |
|
|
143
144
|
| `stylistic` | `false \| object` | enabled | Formatting rules (see below) |
|
|
144
145
|
| `overrides` | `Linter.RulesRecord` | `{}` | Custom rules merged last over shared rules |
|
|
@@ -165,11 +166,28 @@ Layer for Nuxt apps used with `withNuxt(...nuxt())`.
|
|
|
165
166
|
| Option | Type | Default | Description |
|
|
166
167
|
|---|---|---|---|
|
|
167
168
|
| `stylistic` | `false \| object` | enabled | Formatting rules (see below) |
|
|
169
|
+
| `test` | `boolean` | auto (`vitest` installed) | Enable Vitest rules/globals for test files |
|
|
168
170
|
| `strict` | `boolean` | `false` | Stricter TS rules (e.g. `no-magic-numbers`) |
|
|
169
171
|
| `overrides` | `Linter.RulesRecord` | `{}` | Custom rules merged last over shared rules |
|
|
170
172
|
| `ignores` | `string[]` | `[]` | Extra ignore globs (plus defaults / `.gitignore`) |
|
|
171
173
|
|
|
172
|
-
There are no `vue` / `typescript` flags here — `@nuxt/eslint` already provides that stack. This preset adds shared opinionated rules, Vue opinionated rules, and
|
|
174
|
+
There are no `vue` / `typescript` flags here — `@nuxt/eslint` already provides that stack. This preset adds shared opinionated rules, Vue opinionated rules, stylistic formatting, and optional Vitest support. It does **not** register `@typescript-eslint` or `vue` plugins; a second copy of `@typescript-eslint` would make ESLint reject the config.
|
|
175
|
+
|
|
176
|
+
### `test` (Vitest)
|
|
177
|
+
|
|
178
|
+
Auto-enabled when `vitest` is installed. Applies to common test globs:
|
|
179
|
+
|
|
180
|
+
- `**/*.{test,spec}.{js,ts,…}`
|
|
181
|
+
- `**/__tests__/**`
|
|
182
|
+
- `**/tests/**`, `**/test/**`
|
|
183
|
+
|
|
184
|
+
Includes `@vitest/eslint-plugin` recommended rules and Vitest globals (`describe`, `it`, `expect`, `vi`, …).
|
|
185
|
+
|
|
186
|
+
```js
|
|
187
|
+
defineConfig({ test: true })
|
|
188
|
+
// or disable even if vitest is installed:
|
|
189
|
+
defineConfig({ test: false })
|
|
190
|
+
```
|
|
173
191
|
|
|
174
192
|
### `stylistic`
|
|
175
193
|
|
|
@@ -290,6 +308,7 @@ Disable Prettier for the same file types (or uninstall / disable the Prettier ex
|
|
|
290
308
|
- Import hygiene + autofixable `import/order` via `eslint-plugin-import-x` in `defineConfig` (Nuxt relies on `@nuxt/eslint` for its own import/TS/Vue stack)
|
|
291
309
|
- `overrides` are applied in a trailing config block so they win over shared/Vue rules
|
|
292
310
|
- Optional `strict: true` for noisier TypeScript checks like `no-magic-numbers`
|
|
311
|
+
- Optional Vitest layer (`test`, auto when `vitest` is installed): recommended rules + test globals
|
|
293
312
|
|
|
294
313
|
## Agent / setup checklist
|
|
295
314
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as StylisticOptions, i as OptionsConfig, n as nuxt, o as TypedFlatConfigItem, r as Awaitable } from "./nuxt-
|
|
1
|
+
import { a as StylisticOptions, i as OptionsConfig, n as nuxt, o as TypedFlatConfigItem, r as Awaitable } from "./nuxt-Bxa1EDDq.mjs";
|
|
2
2
|
import { FlatConfigComposer } from "eslint-flat-config-utils";
|
|
3
3
|
//#region src/index.d.ts
|
|
4
4
|
declare function defineConfig(options?: OptionsConfig, ...userConfigs: (Awaitable<TypedFlatConfigItem | TypedFlatConfigItem[]>)[]): FlatConfigComposer<TypedFlatConfigItem, never>;
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;iBA+BgB,aACd,UAAS,kBACN,cAAc,UAAU,sBAAsB,4BAAyB,mBAAA"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as has, c as sourceFiles, d as javascriptRules, f as typescriptRules, i as VUE_FILES, l as test, n as vueRules, o as resolveEnabled, p as ignores, r as TYPESCRIPT_FILES, s as resolveStylisticOptions, t as nuxt, u as stylistic } from "./nuxt-oec8_Haa.mjs";
|
|
2
2
|
import { FlatConfigComposer } from "eslint-flat-config-utils";
|
|
3
3
|
//#region src/configs/imports.ts
|
|
4
4
|
async function imports() {
|
|
@@ -68,6 +68,51 @@ async function nuxt$1() {
|
|
|
68
68
|
}];
|
|
69
69
|
}
|
|
70
70
|
//#endregion
|
|
71
|
+
//#region src/configs/typescript.ts
|
|
72
|
+
function collectRules(configs) {
|
|
73
|
+
return Object.assign({}, ...configs.filter((config) => config.rules).map((config) => config.rules));
|
|
74
|
+
}
|
|
75
|
+
async function loadTypescriptPlugin() {
|
|
76
|
+
const pluginMod = await import("@typescript-eslint/eslint-plugin");
|
|
77
|
+
return pluginMod.default ?? pluginMod;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* TypeScript layer.
|
|
81
|
+
*
|
|
82
|
+
* Important: `@typescript-eslint/parser` is never the root parser for `.vue`.
|
|
83
|
+
* Vue SFCs keep `vue-eslint-parser` as root (from the Vue layer) and use the
|
|
84
|
+
* TS parser only as a nested script parser.
|
|
85
|
+
*
|
|
86
|
+
* Flat config requires the plugin on every object that references
|
|
87
|
+
* `@typescript-eslint/*` rules (see shared-rules / overrides too).
|
|
88
|
+
*/
|
|
89
|
+
async function typescript(options = {}) {
|
|
90
|
+
const parserMod = await import("@typescript-eslint/parser");
|
|
91
|
+
const plugin = await loadTypescriptPlugin();
|
|
92
|
+
const parser = parserMod.default ?? parserMod;
|
|
93
|
+
const rules = collectRules(plugin.configs?.["flat/recommended"] ?? []);
|
|
94
|
+
const configs = [{
|
|
95
|
+
name: "qstanay/typescript",
|
|
96
|
+
files: [...TYPESCRIPT_FILES],
|
|
97
|
+
languageOptions: {
|
|
98
|
+
parser,
|
|
99
|
+
parserOptions: {
|
|
100
|
+
sourceType: "module",
|
|
101
|
+
ecmaVersion: "latest"
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
plugins: { "@typescript-eslint": plugin },
|
|
105
|
+
rules
|
|
106
|
+
}];
|
|
107
|
+
if (options.vue) configs.push({
|
|
108
|
+
name: "qstanay/typescript/vue-rules",
|
|
109
|
+
files: [...VUE_FILES],
|
|
110
|
+
plugins: { "@typescript-eslint": plugin },
|
|
111
|
+
rules
|
|
112
|
+
});
|
|
113
|
+
return configs;
|
|
114
|
+
}
|
|
115
|
+
//#endregion
|
|
71
116
|
//#region src/configs/vue.ts
|
|
72
117
|
/**
|
|
73
118
|
* Vue layer based on the official flat recommended preset.
|
|
@@ -102,6 +147,7 @@ function defineConfig(options = {}, ...userConfigs) {
|
|
|
102
147
|
const enableTs = resolveEnabled(options.typescript, has("typescript"));
|
|
103
148
|
const enableVue = resolveEnabled(options.vue, has("vue") || has("nuxt"));
|
|
104
149
|
const enableNuxt = resolveEnabled(options.nuxt, has("nuxt"));
|
|
150
|
+
const enableTest = resolveEnabled(options.test, has("vitest"));
|
|
105
151
|
const stylisticOptions = resolveStylisticOptions(options.stylistic);
|
|
106
152
|
const files = sourceFiles(enableVue);
|
|
107
153
|
const vueIndent = stylisticOptions ? stylisticOptions.indent ?? 2 : void 0;
|
|
@@ -113,6 +159,7 @@ function defineConfig(options = {}, ...userConfigs) {
|
|
|
113
159
|
if (stylisticOptions) configs.push(stylistic(stylisticOptions));
|
|
114
160
|
if (enableVue) configs.push(vue({ indent: vueIndent }));
|
|
115
161
|
if (enableNuxt) configs.push(nuxt$1());
|
|
162
|
+
if (enableTest) configs.push(test());
|
|
116
163
|
configs.push(Promise.resolve([{
|
|
117
164
|
name: "qstanay/shared-rules",
|
|
118
165
|
files,
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["nuxt","javascriptConfig","typescriptConfig","stylisticConfig","vueConfig","nuxtConfig"],"sources":["../src/configs/imports.ts","../src/configs/javascript.ts","../src/configs/nuxt.ts","../src/configs/vue.ts","../src/index.ts"],"sourcesContent":["import type { TypedFlatConfigItem } from '../types';\n\nexport async function imports(): Promise<TypedFlatConfigItem[]> {\n const mod = await import('eslint-plugin-import-x');\n const plugin = (mod as any).default ?? mod;\n\n return [\n {\n name: 'qstanay/imports',\n plugins: {\n import: plugin,\n },\n rules: {\n 'import/first': 'error',\n 'import/no-duplicates': 'error',\n 'import/no-mutable-exports': 'error',\n 'import/no-named-default': 'error',\n 'import/order': [\n 'error',\n {\n 'groups': [\n 'builtin',\n 'external',\n 'internal',\n ['parent', 'sibling', 'index'],\n 'object',\n 'type',\n ],\n 'newlines-between': 'always',\n 'alphabetize': {\n order: 'asc',\n caseInsensitive: true,\n },\n },\n ],\n },\n },\n ];\n}\n","import type { TypedFlatConfigItem } from '../types';\n\n/**\n * Base JS quality rules from `@eslint/js` recommended.\n * Declares Node + ES2022 globals so `no-undef` does not false-positive on\n * `console`, `process`, and other built-ins.\n * When `browser` is true (Vue apps), also declare browser globals for entry\n * files outside `.vue` SFCs (`main.js`, `app.ts`, etc.).\n */\nexport async function javascript(options: {\n browser?: boolean;\n} = {}): Promise<TypedFlatConfigItem[]> {\n const jsMod = await import('@eslint/js');\n const globalsMod = await import('globals');\n\n const js = (jsMod as any).default ?? jsMod;\n const globals = (globalsMod as any).default ?? globalsMod;\n\n return [\n {\n name: 'qstanay/javascript',\n languageOptions: {\n globals: {\n ...globals.es2022,\n ...globals.nodeBuiltin,\n ...(options.browser ? globals.browser : {}),\n },\n },\n rules: {\n ...(js.configs?.recommended?.rules ?? {}),\n },\n },\n ];\n}\n","import type { TypedFlatConfigItem } from '../types';\n\nexport async function nuxt(): Promise<TypedFlatConfigItem[]> {\n const mod = await import('@nuxt/eslint-plugin');\n const plugin = (mod as any).default ?? mod;\n\n return [\n {\n name: 'qstanay/nuxt',\n plugins: {\n nuxt: plugin,\n },\n rules: {\n // keep this minimal; Nuxt base config already provides most of it\n 'nuxt/prefer-import-meta': 'error',\n },\n },\n ];\n}\n","import { VUE_FILES } from '../utils';\nimport { vueRules } from './vue-rules';\n\nimport type { TypedFlatConfigItem } from '../types';\n\n/**\n * Vue layer based on the official flat recommended preset.\n * Must spread the full array — it includes setup, processor, and rule packs.\n */\nexport async function vue(options: {\n indent?: 2 | 4;\n} = {}): Promise<TypedFlatConfigItem[]> {\n const vuePluginMod = await import('eslint-plugin-vue');\n const globalsMod = await import('globals');\n\n const vuePlugin = (vuePluginMod as any).default ?? vuePluginMod;\n const globals = (globalsMod as any).default ?? globalsMod;\n\n const recommended = (vuePlugin.configs?.['flat/recommended'] ?? []) as TypedFlatConfigItem[];\n\n return [\n ...recommended,\n {\n name: 'qstanay/vue/rules',\n files: [...VUE_FILES],\n languageOptions: {\n globals: {\n ...globals.browser,\n },\n parserOptions: {\n // Keep vue-eslint-parser as the root parser (from recommended),\n // and parse <script lang=\"ts\"> with the TS parser.\n parser: {\n ts: '@typescript-eslint/parser',\n js: 'espree',\n },\n ecmaVersion: 'latest',\n sourceType: 'module',\n extraFileExtensions: ['.vue'],\n },\n },\n rules: {\n ...vueRules({ indent: options.indent }),\n },\n },\n ];\n}\n","import { FlatConfigComposer } from 'eslint-flat-config-utils';\n\nimport { ignores } from './configs/ignores';\nimport { imports } from './configs/imports';\nimport { javascript as javascriptConfig } from './configs/javascript';\nimport { nuxt as nuxtConfig } from './configs/nuxt';\nimport {\n javascriptRules,\n typescriptRules,\n} from './configs/shared-rules';\nimport { stylistic as stylisticConfig } from './configs/stylistic';\nimport {\n loadTypescriptPlugin,\n typescript as typescriptConfig,\n} from './configs/typescript';\nimport { vue as vueConfig } from './configs/vue';\nimport {\n has,\n resolveEnabled,\n resolveStylisticOptions,\n sourceFiles,\n TYPESCRIPT_FILES,\n VUE_FILES,\n} from './utils';\n\nimport type { Awaitable, OptionsConfig, TypedFlatConfigItem } from './types';\n\nexport { nuxt } from './nuxt';\nexport * from './types';\n\nexport function defineConfig(\n options: OptionsConfig = {},\n ...userConfigs: (Awaitable<TypedFlatConfigItem | TypedFlatConfigItem[]>)[]\n) {\n const enableTs = resolveEnabled(options.typescript, has('typescript'));\n const enableVue = resolveEnabled(options.vue, has('vue') || has('nuxt'));\n const enableNuxt = resolveEnabled(options.nuxt, has('nuxt'));\n const stylisticOptions = resolveStylisticOptions(options.stylistic);\n const files = sourceFiles(enableVue);\n const vueIndent = stylisticOptions\n ? (stylisticOptions.indent ?? 2)\n : undefined;\n\n const configs: (Awaitable<TypedFlatConfigItem[]>)[] = [];\n\n // When Vue is off, skip SFCs entirely so espree/TS do not fatal-parse them.\n configs.push(Promise.resolve(ignores([\n ...(options.ignores ?? []),\n ...(!enableVue ? VUE_FILES : []),\n ])));\n configs.push(javascriptConfig({ browser: enableVue }));\n\n if (enableTs) {\n configs.push(typescriptConfig({ vue: enableVue }));\n }\n\n configs.push(imports());\n\n if (stylisticOptions) {\n configs.push(stylisticConfig(stylisticOptions));\n }\n\n if (enableVue) {\n configs.push(vueConfig({ indent: vueIndent }));\n }\n\n if (enableNuxt) {\n configs.push(nuxtConfig());\n }\n\n configs.push(Promise.resolve([\n {\n name: 'qstanay/shared-rules',\n files,\n rules: javascriptRules(),\n },\n ]));\n\n if (enableTs) {\n // TS opinionated rules only on TS sources (+ .vue when Vue is on).\n // Never apply them to plain JS/MJS — that needs type-aware parser services.\n configs.push((async () => {\n const plugin = await loadTypescriptPlugin();\n return [\n {\n name: 'qstanay/shared-rules/typescript',\n files: enableVue\n ? [...TYPESCRIPT_FILES, ...VUE_FILES]\n : [...TYPESCRIPT_FILES],\n plugins: {\n '@typescript-eslint': plugin,\n },\n rules: typescriptRules({ strict: options.strict }),\n },\n ];\n })());\n }\n\n if (options.overrides) {\n // Trailing block so project overrides win over shared/vue/ts packs.\n configs.push((async () => {\n const plugins = enableTs\n ? { '@typescript-eslint': await loadTypescriptPlugin() }\n : undefined;\n\n return [\n {\n name: 'qstanay/overrides',\n files,\n ...(plugins ? { plugins } : {}),\n rules: options.overrides,\n },\n ];\n })());\n }\n\n const composer = new FlatConfigComposer<TypedFlatConfigItem>();\n composer.append(...configs, ...userConfigs as any);\n return composer;\n}\n"],"mappings":";;;AAEA,eAAsB,UAA0C;CAC9D,MAAM,MAAM,MAAM,OAAO;CAGzB,OAAO,CACL;EACE,MAAM;EACN,SAAS,EACP,QANU,IAAY,WAAW,IAOnC;EACA,OAAO;GACL,gBAAgB;GAChB,wBAAwB;GACxB,6BAA6B;GAC7B,2BAA2B;GAC3B,gBAAgB,CACd,SACA;IACE,UAAU;KACR;KACA;KACA;KACA;MAAC;MAAU;MAAW;KAAO;KAC7B;KACA;IACF;IACA,oBAAoB;IACpB,eAAe;KACb,OAAO;KACP,iBAAiB;IACnB;GACF,CACF;EACF;CACF,CACF;AACF;;;;;;;;;;AC7BA,eAAsB,WAAW,UAE7B,CAAC,GAAmC;CACtC,MAAM,QAAQ,MAAM,OAAO;CAC3B,MAAM,aAAa,MAAM,OAAO;CAEhC,MAAM,KAAM,MAAc,WAAW;CACrC,MAAM,UAAW,WAAmB,WAAW;CAE/C,OAAO,CACL;EACE,MAAM;EACN,iBAAiB,EACf,SAAS;GACP,GAAG,QAAQ;GACX,GAAG,QAAQ;GACX,GAAI,QAAQ,UAAU,QAAQ,UAAU,CAAC;EAC3C,EACF;EACA,OAAO,EACL,GAAI,GAAG,SAAS,aAAa,SAAS,CAAC,EACzC;CACF,CACF;AACF;;;AC/BA,eAAsBA,SAAuC;CAC3D,MAAM,MAAM,MAAM,OAAO;CAGz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AiB,EAAE,KAAK,UAAU,CAAC,CAAC;CAGnD,QAAQ,KAAK,QAAQ,CAAC;CAEtB,IAAI,kBACF,QAAQ,KAAKC,UAAgB,gBAAgB,CAAC;CAGhD,IAAI,WACF,QAAQ,KAAKC,IAAU,EAAE,QAAQ,UAAU,CAAC,CAAC;CAG/C,IAAI,YACF,QAAQ,KAAKC,OAAW,CAAC;CAG3B,QAAQ,KAAK,QAAQ,QAAQ,CAC3B;EACE,MAAM;EACN;EACA,OAAO,gBAAgB;CACzB,CACF,CAAC,CAAC;CAEF,IAAI,UAGF,QAAQ,MAAM,YAAY;EACxB,MAAM,SAAS,MAAM,qBAAqB;EAC1C,OAAO,CACL;GACE,MAAM;GACN,OAAO,YACH,CAAC,GAAG,kBAAkB,GAAG,SAAS,IAClC,CAAC,GAAG,gBAAgB;GACxB,SAAS,EACP,sBAAsB,OACxB;GACA,OAAO,gBAAgB,EAAE,QAAQ,QAAQ,OAAO,CAAC;EACnD,CACF;CACF,EAAA,CAAG,CAAC;CAGN,IAAI,QAAQ,WAEV,QAAQ,MAAM,YAAY;EACxB,MAAM,UAAU,WACZ,EAAE,sBAAsB,MAAM,qBAAqB,EAAE,IACrD,KAAA;EAEJ,OAAO,CACL;GACE,MAAM;GACN;GACA,GAAI,UAAU,EAAE,QAAQ,IAAI,CAAC;GAC7B,OAAO,QAAQ;EACjB,CACF;CACF,EAAA,CAAG,CAAC;CAGN,MAAM,WAAW,IAAI,mBAAwC;CAC7D,SAAS,OAAO,GAAG,SAAS,GAAG,WAAkB;CACjD,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["nuxt","javascriptConfig","typescriptConfig","stylisticConfig","vueConfig","nuxtConfig","testConfig"],"sources":["../src/configs/imports.ts","../src/configs/javascript.ts","../src/configs/nuxt.ts","../src/configs/typescript.ts","../src/configs/vue.ts","../src/index.ts"],"sourcesContent":["import type { TypedFlatConfigItem } from '../types';\n\nexport async function imports(): Promise<TypedFlatConfigItem[]> {\n const mod = await import('eslint-plugin-import-x');\n const plugin = (mod as any).default ?? mod;\n\n return [\n {\n name: 'qstanay/imports',\n plugins: {\n import: plugin,\n },\n rules: {\n 'import/first': 'error',\n 'import/no-duplicates': 'error',\n 'import/no-mutable-exports': 'error',\n 'import/no-named-default': 'error',\n 'import/order': [\n 'error',\n {\n 'groups': [\n 'builtin',\n 'external',\n 'internal',\n ['parent', 'sibling', 'index'],\n 'object',\n 'type',\n ],\n 'newlines-between': 'always',\n 'alphabetize': {\n order: 'asc',\n caseInsensitive: true,\n },\n },\n ],\n },\n },\n ];\n}\n","import type { TypedFlatConfigItem } from '../types';\n\n/**\n * Base JS quality rules from `@eslint/js` recommended.\n * Declares Node + ES2022 globals so `no-undef` does not false-positive on\n * `console`, `process`, and other built-ins.\n * When `browser` is true (Vue apps), also declare browser globals for entry\n * files outside `.vue` SFCs (`main.js`, `app.ts`, etc.).\n */\nexport async function javascript(options: {\n browser?: boolean;\n} = {}): Promise<TypedFlatConfigItem[]> {\n const jsMod = await import('@eslint/js');\n const globalsMod = await import('globals');\n\n const js = (jsMod as any).default ?? jsMod;\n const globals = (globalsMod as any).default ?? globalsMod;\n\n return [\n {\n name: 'qstanay/javascript',\n languageOptions: {\n globals: {\n ...globals.es2022,\n ...globals.nodeBuiltin,\n ...(options.browser ? globals.browser : {}),\n },\n },\n rules: {\n ...(js.configs?.recommended?.rules ?? {}),\n },\n },\n ];\n}\n","import type { TypedFlatConfigItem } from '../types';\n\nexport async function nuxt(): Promise<TypedFlatConfigItem[]> {\n const mod = await import('@nuxt/eslint-plugin');\n const plugin = (mod as any).default ?? mod;\n\n return [\n {\n name: 'qstanay/nuxt',\n plugins: {\n nuxt: plugin,\n },\n rules: {\n // keep this minimal; Nuxt base config already provides most of it\n 'nuxt/prefer-import-meta': 'error',\n },\n },\n ];\n}\n","import { TYPESCRIPT_FILES, VUE_FILES } from '../utils';\n\nimport type { TypedFlatConfigItem } from '../types';\nimport type { Linter } from 'eslint';\n\nfunction collectRules(configs: TypedFlatConfigItem[]): Linter.RulesRecord {\n return Object.assign(\n {},\n ...configs\n .filter(config => config.rules)\n .map(config => config.rules),\n );\n}\n\nexport async function loadTypescriptPlugin() {\n const pluginMod = await import('@typescript-eslint/eslint-plugin');\n return (pluginMod as any).default ?? pluginMod;\n}\n\n/**\n * TypeScript layer.\n *\n * Important: `@typescript-eslint/parser` is never the root parser for `.vue`.\n * Vue SFCs keep `vue-eslint-parser` as root (from the Vue layer) and use the\n * TS parser only as a nested script parser.\n *\n * Flat config requires the plugin on every object that references\n * `@typescript-eslint/*` rules (see shared-rules / overrides too).\n */\nexport async function typescript(options: {\n vue?: boolean;\n} = {}): Promise<TypedFlatConfigItem[]> {\n const parserMod = await import('@typescript-eslint/parser');\n const plugin = await loadTypescriptPlugin();\n const parser = (parserMod as any).default ?? parserMod;\n\n const recommended = (plugin.configs?.['flat/recommended'] ?? []) as TypedFlatConfigItem[];\n const rules = collectRules(recommended);\n\n const configs: TypedFlatConfigItem[] = [\n {\n name: 'qstanay/typescript',\n files: [...TYPESCRIPT_FILES],\n languageOptions: {\n parser,\n parserOptions: {\n sourceType: 'module',\n ecmaVersion: 'latest',\n },\n },\n plugins: {\n '@typescript-eslint': plugin,\n },\n rules,\n },\n ];\n\n if (options.vue) {\n configs.push({\n name: 'qstanay/typescript/vue-rules',\n files: [...VUE_FILES],\n plugins: {\n '@typescript-eslint': plugin,\n },\n rules,\n });\n }\n\n return configs;\n}\n","import { VUE_FILES } from '../utils';\nimport { vueRules } from './vue-rules';\n\nimport type { TypedFlatConfigItem } from '../types';\n\n/**\n * Vue layer based on the official flat recommended preset.\n * Must spread the full array — it includes setup, processor, and rule packs.\n */\nexport async function vue(options: {\n indent?: 2 | 4;\n} = {}): Promise<TypedFlatConfigItem[]> {\n const vuePluginMod = await import('eslint-plugin-vue');\n const globalsMod = await import('globals');\n\n const vuePlugin = (vuePluginMod as any).default ?? vuePluginMod;\n const globals = (globalsMod as any).default ?? globalsMod;\n\n const recommended = (vuePlugin.configs?.['flat/recommended'] ?? []) as TypedFlatConfigItem[];\n\n return [\n ...recommended,\n {\n name: 'qstanay/vue/rules',\n files: [...VUE_FILES],\n languageOptions: {\n globals: {\n ...globals.browser,\n },\n parserOptions: {\n // Keep vue-eslint-parser as the root parser (from recommended),\n // and parse <script lang=\"ts\"> with the TS parser.\n parser: {\n ts: '@typescript-eslint/parser',\n js: 'espree',\n },\n ecmaVersion: 'latest',\n sourceType: 'module',\n extraFileExtensions: ['.vue'],\n },\n },\n rules: {\n ...vueRules({ indent: options.indent }),\n },\n },\n ];\n}\n","import { FlatConfigComposer } from 'eslint-flat-config-utils';\n\nimport { ignores } from './configs/ignores';\nimport { imports } from './configs/imports';\nimport { javascript as javascriptConfig } from './configs/javascript';\nimport { nuxt as nuxtConfig } from './configs/nuxt';\nimport {\n javascriptRules,\n typescriptRules,\n} from './configs/shared-rules';\nimport { stylistic as stylisticConfig } from './configs/stylistic';\nimport { test as testConfig } from './configs/test';\nimport {\n loadTypescriptPlugin,\n typescript as typescriptConfig,\n} from './configs/typescript';\nimport { vue as vueConfig } from './configs/vue';\nimport {\n has,\n resolveEnabled,\n resolveStylisticOptions,\n sourceFiles,\n TYPESCRIPT_FILES,\n VUE_FILES,\n} from './utils';\n\nimport type { Awaitable, OptionsConfig, TypedFlatConfigItem } from './types';\n\nexport { nuxt } from './nuxt';\nexport * from './types';\n\nexport function defineConfig(\n options: OptionsConfig = {},\n ...userConfigs: (Awaitable<TypedFlatConfigItem | TypedFlatConfigItem[]>)[]\n) {\n const enableTs = resolveEnabled(options.typescript, has('typescript'));\n const enableVue = resolveEnabled(options.vue, has('vue') || has('nuxt'));\n const enableNuxt = resolveEnabled(options.nuxt, has('nuxt'));\n const enableTest = resolveEnabled(options.test, has('vitest'));\n const stylisticOptions = resolveStylisticOptions(options.stylistic);\n const files = sourceFiles(enableVue);\n const vueIndent = stylisticOptions\n ? (stylisticOptions.indent ?? 2)\n : undefined;\n\n const configs: (Awaitable<TypedFlatConfigItem[]>)[] = [];\n\n // When Vue is off, skip SFCs entirely so espree/TS do not fatal-parse them.\n configs.push(Promise.resolve(ignores([\n ...(options.ignores ?? []),\n ...(!enableVue ? VUE_FILES : []),\n ])));\n configs.push(javascriptConfig({ browser: enableVue }));\n\n if (enableTs) {\n configs.push(typescriptConfig({ vue: enableVue }));\n }\n\n configs.push(imports());\n\n if (stylisticOptions) {\n configs.push(stylisticConfig(stylisticOptions));\n }\n\n if (enableVue) {\n configs.push(vueConfig({ indent: vueIndent }));\n }\n\n if (enableNuxt) {\n configs.push(nuxtConfig());\n }\n\n if (enableTest) {\n configs.push(testConfig());\n }\n\n configs.push(Promise.resolve([\n {\n name: 'qstanay/shared-rules',\n files,\n rules: javascriptRules(),\n },\n ]));\n\n if (enableTs) {\n // TS opinionated rules only on TS sources (+ .vue when Vue is on).\n // Never apply them to plain JS/MJS — that needs type-aware parser services.\n configs.push((async () => {\n const plugin = await loadTypescriptPlugin();\n return [\n {\n name: 'qstanay/shared-rules/typescript',\n files: enableVue\n ? [...TYPESCRIPT_FILES, ...VUE_FILES]\n : [...TYPESCRIPT_FILES],\n plugins: {\n '@typescript-eslint': plugin,\n },\n rules: typescriptRules({ strict: options.strict }),\n },\n ];\n })());\n }\n\n if (options.overrides) {\n // Trailing block so project overrides win over shared/vue/ts packs.\n configs.push((async () => {\n const plugins = enableTs\n ? { '@typescript-eslint': await loadTypescriptPlugin() }\n : undefined;\n\n return [\n {\n name: 'qstanay/overrides',\n files,\n ...(plugins ? { plugins } : {}),\n rules: options.overrides,\n },\n ];\n })());\n }\n\n const composer = new FlatConfigComposer<TypedFlatConfigItem>();\n composer.append(...configs, ...userConfigs as any);\n return composer;\n}\n"],"mappings":";;;AAEA,eAAsB,UAA0C;CAC9D,MAAM,MAAM,MAAM,OAAO;CAGzB,OAAO,CACL;EACE,MAAM;EACN,SAAS,EACP,QANU,IAAY,WAAW,IAOnC;EACA,OAAO;GACL,gBAAgB;GAChB,wBAAwB;GACxB,6BAA6B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ACjD,OAAO;AACT"}
|
|
@@ -26,6 +26,11 @@ interface OptionsConfig {
|
|
|
26
26
|
* Off by default to keep app/UI code quiet.
|
|
27
27
|
*/
|
|
28
28
|
strict?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Enable Vitest rules/globals for test files.
|
|
31
|
+
* Auto-enabled when `vitest` is installed unless explicitly set.
|
|
32
|
+
*/
|
|
33
|
+
test?: boolean;
|
|
29
34
|
stylistic?: boolean | StylisticOptions;
|
|
30
35
|
/**
|
|
31
36
|
* Extra ignores appended to defaults.
|
|
@@ -44,6 +49,11 @@ interface NuxtPresetOptions {
|
|
|
44
49
|
* Enable stricter opinionated TypeScript rules (e.g. `no-magic-numbers`).
|
|
45
50
|
*/
|
|
46
51
|
strict?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Enable Vitest rules/globals for test files.
|
|
54
|
+
* Auto-enabled when `vitest` is installed unless explicitly set.
|
|
55
|
+
*/
|
|
56
|
+
test?: boolean;
|
|
47
57
|
overrides?: Linter.RulesRecord;
|
|
48
58
|
/**
|
|
49
59
|
* Extra ignores appended to defaults / `.gitignore`.
|
|
@@ -60,4 +70,4 @@ interface NuxtPresetOptions {
|
|
|
60
70
|
declare function nuxt(options?: NuxtPresetOptions): Promise<TypedFlatConfigItem[]>[];
|
|
61
71
|
//#endregion
|
|
62
72
|
export { StylisticOptions as a, OptionsConfig as i, nuxt as n, TypedFlatConfigItem as o, Awaitable as r, NuxtPresetOptions as t };
|
|
63
|
-
//# sourceMappingURL=nuxt-
|
|
73
|
+
//# sourceMappingURL=nuxt-Bxa1EDDq.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nuxt-Bxa1EDDq.d.mts","names":[],"sources":["../src/types.ts","../src/nuxt.ts"],"mappings":";;KAEY,UAAU,KAAK,IAAI,QAAQ;KAE3B,sBAAsB,OAAO;UAExB;EACf;EACA;EACA;EACA;;UAGe;;;;EAIf;;;;EAIA;;;;EAIA;;;;;EAKA;;;;;EAKA;EACA,sBAAsB;;;;EAItB;;;;EAIA,YAAY,OAAO;;;;UCxBJ;EACf,sBAAsB;;;;EAItB;;;;;EAKA;EACA,YAAY,OAAO;;;;EAInB;;;;;;;;;iBAUc,KAAK,UAAS,oBAAsB,QAAA"}
|
|
@@ -96,6 +96,35 @@ async function stylistic(options = {}) {
|
|
|
96
96
|
}];
|
|
97
97
|
}
|
|
98
98
|
//#endregion
|
|
99
|
+
//#region src/configs/test.ts
|
|
100
|
+
const TEST_FILES = [
|
|
101
|
+
"**/__tests__/**/*.{js,mjs,cjs,jsx,ts,tsx,cts,mts}",
|
|
102
|
+
"**/*.{test,spec}.{js,mjs,cjs,jsx,ts,tsx,cts,mts}",
|
|
103
|
+
"**/tests/**/*.{js,mjs,cjs,jsx,ts,tsx,cts,mts}",
|
|
104
|
+
"**/test/**/*.{js,mjs,cjs,jsx,ts,tsx,cts,mts}"
|
|
105
|
+
];
|
|
106
|
+
/**
|
|
107
|
+
* Vitest layer: recommended rules + test globals for common test globs.
|
|
108
|
+
*/
|
|
109
|
+
async function test() {
|
|
110
|
+
const mod = await import("@vitest/eslint-plugin");
|
|
111
|
+
const vitest = mod.default ?? mod;
|
|
112
|
+
const globalsMod = await import("globals");
|
|
113
|
+
const globals = globalsMod.default ?? globalsMod;
|
|
114
|
+
const recommended = vitest.configs?.recommended ?? {};
|
|
115
|
+
const env = vitest.configs?.env ?? {};
|
|
116
|
+
return [{
|
|
117
|
+
name: "qstanay/test",
|
|
118
|
+
files: [...TEST_FILES],
|
|
119
|
+
plugins: { vitest },
|
|
120
|
+
languageOptions: { globals: {
|
|
121
|
+
...globals.vitest,
|
|
122
|
+
...env.languageOptions?.globals ?? {}
|
|
123
|
+
} },
|
|
124
|
+
rules: { ...recommended.rules ?? {} }
|
|
125
|
+
}];
|
|
126
|
+
}
|
|
127
|
+
//#endregion
|
|
99
128
|
//#region src/utils.ts
|
|
100
129
|
function resolveEnabled(explicit, detected) {
|
|
101
130
|
return explicit ?? detected;
|
|
@@ -122,51 +151,6 @@ function sourceFiles(vueEnabled) {
|
|
|
122
151
|
/** Files that receive shared / override rule packs when Vue is enabled. */
|
|
123
152
|
const SOURCE_FILES = ["**/*.{js,mjs,cjs,jsx,ts,tsx,cts,mts,vue}"];
|
|
124
153
|
//#endregion
|
|
125
|
-
//#region src/configs/typescript.ts
|
|
126
|
-
function collectRules(configs) {
|
|
127
|
-
return Object.assign({}, ...configs.filter((config) => config.rules).map((config) => config.rules));
|
|
128
|
-
}
|
|
129
|
-
async function loadTypescriptPlugin() {
|
|
130
|
-
const pluginMod = await import("@typescript-eslint/eslint-plugin");
|
|
131
|
-
return pluginMod.default ?? pluginMod;
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* TypeScript layer.
|
|
135
|
-
*
|
|
136
|
-
* Important: `@typescript-eslint/parser` is never the root parser for `.vue`.
|
|
137
|
-
* Vue SFCs keep `vue-eslint-parser` as root (from the Vue layer) and use the
|
|
138
|
-
* TS parser only as a nested script parser.
|
|
139
|
-
*
|
|
140
|
-
* Flat config requires the plugin on every object that references
|
|
141
|
-
* `@typescript-eslint/*` rules (see shared-rules / overrides too).
|
|
142
|
-
*/
|
|
143
|
-
async function typescript(options = {}) {
|
|
144
|
-
const parserMod = await import("@typescript-eslint/parser");
|
|
145
|
-
const plugin = await loadTypescriptPlugin();
|
|
146
|
-
const parser = parserMod.default ?? parserMod;
|
|
147
|
-
const rules = collectRules(plugin.configs?.["flat/recommended"] ?? []);
|
|
148
|
-
const configs = [{
|
|
149
|
-
name: "qstanay/typescript",
|
|
150
|
-
files: [...TYPESCRIPT_FILES],
|
|
151
|
-
languageOptions: {
|
|
152
|
-
parser,
|
|
153
|
-
parserOptions: {
|
|
154
|
-
sourceType: "module",
|
|
155
|
-
ecmaVersion: "latest"
|
|
156
|
-
}
|
|
157
|
-
},
|
|
158
|
-
plugins: { "@typescript-eslint": plugin },
|
|
159
|
-
rules
|
|
160
|
-
}];
|
|
161
|
-
if (options.vue) configs.push({
|
|
162
|
-
name: "qstanay/typescript/vue-rules",
|
|
163
|
-
files: [...VUE_FILES],
|
|
164
|
-
plugins: { "@typescript-eslint": plugin },
|
|
165
|
-
rules
|
|
166
|
-
});
|
|
167
|
-
return configs;
|
|
168
|
-
}
|
|
169
|
-
//#endregion
|
|
170
154
|
//#region src/configs/vue-rules.ts
|
|
171
155
|
function vueRules(options = {}) {
|
|
172
156
|
const rules = {
|
|
@@ -200,30 +184,28 @@ function vueRules(options = {}) {
|
|
|
200
184
|
*/
|
|
201
185
|
function nuxt(options = {}) {
|
|
202
186
|
const stylisticOptions = resolveStylisticOptions(options.stylistic);
|
|
187
|
+
const enableTest = resolveEnabled(options.test, has("vitest"));
|
|
203
188
|
const vueIndent = stylisticOptions ? stylisticOptions.indent ?? 2 : void 0;
|
|
204
189
|
const configs = [Promise.resolve(ignores(options.ignores))];
|
|
205
190
|
if (stylisticOptions) configs.push(stylistic(stylisticOptions));
|
|
206
|
-
configs.push((
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
}
|
|
225
|
-
];
|
|
226
|
-
})());
|
|
191
|
+
if (enableTest) configs.push(test());
|
|
192
|
+
configs.push(Promise.resolve([
|
|
193
|
+
{
|
|
194
|
+
name: "qstanay/nuxt/shared-rules",
|
|
195
|
+
files: [...SOURCE_FILES],
|
|
196
|
+
rules: javascriptRules()
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
name: "qstanay/nuxt/shared-rules/typescript",
|
|
200
|
+
files: [...TYPESCRIPT_FILES, ...VUE_FILES],
|
|
201
|
+
rules: typescriptRules({ strict: options.strict })
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
name: "qstanay/nuxt/vue-rules",
|
|
205
|
+
files: [...VUE_FILES],
|
|
206
|
+
rules: { ...vueRules({ indent: vueIndent }) }
|
|
207
|
+
}
|
|
208
|
+
]));
|
|
227
209
|
if (options.overrides) configs.push(Promise.resolve([{
|
|
228
210
|
name: "qstanay/nuxt/overrides",
|
|
229
211
|
files: [...SOURCE_FILES],
|
|
@@ -232,6 +214,6 @@ function nuxt(options = {}) {
|
|
|
232
214
|
return configs;
|
|
233
215
|
}
|
|
234
216
|
//#endregion
|
|
235
|
-
export {
|
|
217
|
+
export { has as a, sourceFiles as c, javascriptRules as d, typescriptRules as f, VUE_FILES as i, test as l, vueRules as n, resolveEnabled as o, ignores as p, TYPESCRIPT_FILES as r, resolveStylisticOptions as s, nuxt as t, stylistic as u };
|
|
236
218
|
|
|
237
|
-
//# sourceMappingURL=nuxt-
|
|
219
|
+
//# sourceMappingURL=nuxt-oec8_Haa.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nuxt-oec8_Haa.mjs","names":["stylisticConfig","testConfig"],"sources":["../src/configs/ignores.ts","../src/configs/shared-rules.ts","../src/configs/stylistic.ts","../src/configs/test.ts","../src/utils.ts","../src/configs/vue-rules.ts","../src/nuxt.ts"],"sourcesContent":["import gitignore from 'eslint-config-flat-gitignore';\n\nimport type { TypedFlatConfigItem } from '../types';\n\nexport function ignores(extraIgnores: string[] = []): TypedFlatConfigItem[] {\n return [\n // Prefer project .gitignore when present; do not fail if missing.\n gitignore({ strict: false }),\n {\n name: 'qstanay/ignores',\n ignores: [\n '**/node_modules/**',\n '**/dist/**',\n '**/.output/**',\n '**/.nuxt/**',\n '**/.nitro/**',\n '**/coverage/**',\n ...extraIgnores,\n ],\n },\n ];\n}\n","import type { Linter } from 'eslint';\n\nexport function javascriptRules(): Linter.RulesRecord {\n return {\n 'no-console': ['error', { allow: ['warn', 'error'] }],\n 'no-debugger': 'error',\n 'eqeqeq': ['error', 'always'],\n 'object-shorthand': ['error', 'always'],\n 'prefer-template': 'error',\n 'curly': ['error', 'all'],\n 'arrow-body-style': ['error', 'as-needed'],\n };\n}\n\nexport function typescriptRules(options: { strict?: boolean } = {}): Linter.RulesRecord {\n const rules: Linter.RulesRecord = {\n // Disable base rules that conflict with TypeScript-aware variants.\n 'no-unused-vars': 'off',\n 'no-undef': 'off',\n\n '@typescript-eslint/no-unused-vars': [\n 'error',\n {\n argsIgnorePattern: '^_',\n varsIgnorePattern: '^_',\n caughtErrorsIgnorePattern: '^_',\n destructuredArrayIgnorePattern: '^_',\n },\n ],\n '@typescript-eslint/consistent-type-imports': [\n 'error',\n { prefer: 'type-imports', disallowTypeAnnotations: false },\n ],\n '@typescript-eslint/no-explicit-any': 'warn',\n '@typescript-eslint/no-non-null-assertion': 'error',\n '@typescript-eslint/no-empty-function': ['error', { allow: ['arrowFunctions'] }],\n };\n\n if (options.strict) {\n rules['@typescript-eslint/no-magic-numbers'] = [\n 'warn',\n {\n ignore: [-1, 0, 1, 2, 1000],\n ignoreEnums: true,\n ignoreArrayIndexes: true,\n ignoreDefaultValues: true,\n ignoreClassFieldInitialValues: true,\n ignoreReadonlyClassProperties: true,\n },\n ];\n }\n\n return rules;\n}\n\n/**\n * Shared opinionated rules.\n * TypeScript rules are included only when `typescript` is true,\n * so JS-only projects do not reference a missing plugin.\n */\nexport function sharedRules(options: {\n typescript?: boolean;\n strict?: boolean;\n} = {}): Linter.RulesRecord {\n return {\n ...javascriptRules(),\n ...(options.typescript\n ? typescriptRules({ strict: options.strict })\n : {}),\n };\n}\n","import type { TypedFlatConfigItem, StylisticOptions } from '../types';\n\nasync function loadStylistic() {\n const mod = await import('@stylistic/eslint-plugin');\n return mod.default ?? mod;\n}\n\nexport async function stylistic(\n options: StylisticOptions = {},\n): Promise<TypedFlatConfigItem[]> {\n const {\n indent = 2,\n quotes = 'single',\n semi = true,\n maxLen = 100,\n } = options;\n\n const plugin = await loadStylistic();\n\n // `customize()` gives us a coherent bundle of stylistic rules.\n // Plugin name is fixed to `style` for stable rule IDs.\n const config = plugin.configs.customize({\n indent,\n quotes,\n semi,\n jsx: false,\n pluginName: 'style',\n }) as TypedFlatConfigItem;\n\n return [\n {\n name: 'qstanay/stylistic',\n plugins: {\n style: plugin,\n },\n rules: {\n ...(config.rules ?? {}),\n // Keep max line length aligned across all projects.\n 'style/max-len': [\n 'warn',\n {\n code: maxLen,\n ignoreUrls: true,\n ignoreStrings: true,\n ignoreTemplateLiterals: true,\n ignoreComments: true,\n ignoreTrailingComments: true,\n ignoreRegExpLiterals: true,\n },\n ],\n },\n },\n ];\n}\n","import type { TypedFlatConfigItem } from '../types';\n\nexport const TEST_FILES = [\n '**/__tests__/**/*.{js,mjs,cjs,jsx,ts,tsx,cts,mts}',\n '**/*.{test,spec}.{js,mjs,cjs,jsx,ts,tsx,cts,mts}',\n '**/tests/**/*.{js,mjs,cjs,jsx,ts,tsx,cts,mts}',\n '**/test/**/*.{js,mjs,cjs,jsx,ts,tsx,cts,mts}',\n] as const;\n\n/**\n * Vitest layer: recommended rules + test globals for common test globs.\n */\nexport async function test(): Promise<TypedFlatConfigItem[]> {\n const mod = await import('@vitest/eslint-plugin');\n const vitest = (mod as any).default ?? mod;\n const globalsMod = await import('globals');\n const globals = (globalsMod as any).default ?? globalsMod;\n\n const recommended = vitest.configs?.recommended ?? {};\n const env = vitest.configs?.env ?? {};\n\n return [\n {\n name: 'qstanay/test',\n files: [...TEST_FILES],\n plugins: {\n vitest,\n },\n languageOptions: {\n globals: {\n ...globals.vitest,\n ...(env.languageOptions?.globals ?? {}),\n },\n },\n rules: {\n ...(recommended.rules ?? {}),\n },\n },\n ];\n}\n","import { isPackageExists } from 'local-pkg';\n\nimport type { StylisticOptions } from './types';\n\nexport function resolveEnabled(explicit: boolean | undefined, detected: boolean) {\n return explicit ?? detected;\n}\n\nexport function has(pkg: string) {\n return isPackageExists(pkg);\n}\n\nexport function resolveStylisticOptions(\n stylistic: boolean | StylisticOptions | undefined,\n): false | StylisticOptions {\n if (stylistic === false) {\n return false;\n }\n\n if (typeof stylistic === 'object') {\n return stylistic;\n }\n\n return {};\n}\n\nconst SCRIPT_FILES = [\n '**/*.{js,mjs,cjs,jsx,ts,tsx,cts,mts}',\n] as const;\n\nexport const VUE_FILES = ['**/*.vue'] as const;\n\n/** TypeScript sources — never includes `.vue` (Vue keeps its own root parser). */\nexport const TYPESCRIPT_FILES = [\n '**/*.{ts,tsx,cts,mts}',\n] as const;\n\n/**\n * Files that receive shared / override rule packs.\n * `.vue` is included only when Vue support is enabled.\n */\nexport function sourceFiles(vueEnabled: boolean): string[] {\n return vueEnabled\n ? [...SCRIPT_FILES, ...VUE_FILES]\n : [...SCRIPT_FILES];\n}\n\n/** Files that receive shared / override rule packs when Vue is enabled. */\nexport const SOURCE_FILES = [\n '**/*.{js,mjs,cjs,jsx,ts,tsx,cts,mts,vue}',\n] as const;\n","import type { Linter } from 'eslint';\n\nexport function vueRules(options: {\n indent?: 2 | 4;\n} = {}): Linter.RulesRecord {\n const rules: Linter.RulesRecord = {\n 'vue/html-self-closing': [\n 'error',\n {\n html: {\n void: 'always',\n normal: 'always',\n component: 'always',\n },\n svg: 'always',\n math: 'always',\n },\n ],\n 'vue/attributes-order': 'error',\n 'vue/padding-line-between-tags': [\n 'error',\n [\n {\n blankLine: 'always',\n prev: '*',\n next: '*',\n },\n ],\n ],\n };\n\n if (options.indent !== undefined) {\n // Keep template indent in sync with @stylistic script indent.\n rules['vue/html-indent'] = ['error', options.indent];\n }\n\n return rules;\n}\n","import { ignores } from './configs/ignores';\nimport {\n javascriptRules,\n typescriptRules,\n} from './configs/shared-rules';\nimport { stylistic as stylisticConfig } from './configs/stylistic';\nimport { test as testConfig } from './configs/test';\nimport { vueRules } from './configs/vue-rules';\nimport {\n has,\n resolveEnabled,\n resolveStylisticOptions,\n SOURCE_FILES,\n TYPESCRIPT_FILES,\n VUE_FILES,\n} from './utils';\n\nimport type { StylisticOptions, TypedFlatConfigItem } from './types';\nimport type { Linter } from 'eslint';\n\nexport interface NuxtPresetOptions {\n stylistic?: boolean | StylisticOptions;\n /**\n * Enable stricter opinionated TypeScript rules (e.g. `no-magic-numbers`).\n */\n strict?: boolean;\n /**\n * Enable Vitest rules/globals for test files.\n * Auto-enabled when `vitest` is installed unless explicitly set.\n */\n test?: boolean;\n overrides?: Linter.RulesRecord;\n /**\n * Extra ignores appended to defaults / `.gitignore`.\n */\n ignores?: string[];\n}\n\n/**\n * Opinionated layer for Nuxt apps.\n *\n * Intended to be used with `@nuxt/eslint` + `withNuxt()`:\n * Nuxt already provides TypeScript/Vue/import plugins, so this preset\n * only adds stylistic formatting and shared opinionated rules.\n */\nexport function nuxt(options: NuxtPresetOptions = {}) {\n const stylisticOptions = resolveStylisticOptions(options.stylistic);\n const enableTest = resolveEnabled(options.test, has('vitest'));\n const vueIndent = stylisticOptions\n ? (stylisticOptions.indent ?? 2)\n : undefined;\n\n const configs: Promise<TypedFlatConfigItem[]>[] = [\n Promise.resolve(ignores(options.ignores)),\n ];\n\n if (stylisticOptions) {\n configs.push(stylisticConfig(stylisticOptions));\n }\n\n if (enableTest) {\n configs.push(testConfig());\n }\n\n // Rules only — do not register `@typescript-eslint` / `vue`.\n // `@nuxt/eslint` already provides those plugins; a second instance\n // (common with pnpm) makes ESLint reject the config.\n configs.push(Promise.resolve([\n {\n name: 'qstanay/nuxt/shared-rules',\n files: [...SOURCE_FILES],\n rules: javascriptRules(),\n },\n {\n name: 'qstanay/nuxt/shared-rules/typescript',\n files: [...TYPESCRIPT_FILES, ...VUE_FILES],\n rules: typescriptRules({ strict: options.strict }),\n },\n {\n name: 'qstanay/nuxt/vue-rules',\n files: [...VUE_FILES],\n rules: {\n ...vueRules({ indent: vueIndent }),\n },\n },\n ]));\n\n if (options.overrides) {\n // Dedicated trailing block so overrides always win over vue/shared rules.\n configs.push(Promise.resolve([\n {\n name: 'qstanay/nuxt/overrides',\n files: [...SOURCE_FILES],\n rules: options.overrides,\n },\n ]));\n }\n\n return configs;\n}\n"],"mappings":";;;AAIA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G,YAAY;EACvB,OAAO,QAAQ;CACjB,CACF,CAAC,CAAC;CAGJ,OAAO;AACT"}
|
package/dist/nuxt.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as nuxt, t as NuxtPresetOptions } from "./nuxt-
|
|
1
|
+
import { n as nuxt, t as NuxtPresetOptions } from "./nuxt-Bxa1EDDq.mjs";
|
|
2
2
|
export { NuxtPresetOptions, nuxt };
|
package/dist/nuxt.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as nuxt } from "./nuxt-
|
|
1
|
+
import { t as nuxt } from "./nuxt-oec8_Haa.mjs";
|
|
2
2
|
export { nuxt };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qstanay/eslint-config",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "Opinionated ESLint flat config for Nuxt, Vue and TypeScript",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -36,7 +36,8 @@
|
|
|
36
36
|
"nuxt",
|
|
37
37
|
"vue",
|
|
38
38
|
"typescript",
|
|
39
|
-
"stylistic"
|
|
39
|
+
"stylistic",
|
|
40
|
+
"vitest"
|
|
40
41
|
],
|
|
41
42
|
"author": "Denis Lapshin",
|
|
42
43
|
"license": "MIT",
|
|
@@ -53,11 +54,15 @@
|
|
|
53
54
|
],
|
|
54
55
|
"peerDependencies": {
|
|
55
56
|
"eslint": "^9.0.0 || ^10.0.0",
|
|
56
|
-
"typescript": ">=4.9.0"
|
|
57
|
+
"typescript": ">=4.9.0",
|
|
58
|
+
"vitest": "*"
|
|
57
59
|
},
|
|
58
60
|
"peerDependenciesMeta": {
|
|
59
61
|
"typescript": {
|
|
60
62
|
"optional": true
|
|
63
|
+
},
|
|
64
|
+
"vitest": {
|
|
65
|
+
"optional": true
|
|
61
66
|
}
|
|
62
67
|
},
|
|
63
68
|
"dependencies": {
|
|
@@ -66,6 +71,7 @@
|
|
|
66
71
|
"@stylistic/eslint-plugin": "^5.10.0",
|
|
67
72
|
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
68
73
|
"@typescript-eslint/parser": "^8.0.0",
|
|
74
|
+
"@vitest/eslint-plugin": "^1.6.26",
|
|
69
75
|
"eslint-config-flat-gitignore": "^2.3.0",
|
|
70
76
|
"eslint-flat-config-utils": "^3.2.0",
|
|
71
77
|
"eslint-plugin-import-x": "^4.0.0",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"nuxt-BOdDS-BM.d.mts","names":[],"sources":["../src/types.ts","../src/nuxt.ts"],"mappings":";;KAEY,UAAU,KAAK,IAAI,QAAQ;KAE3B,sBAAsB,OAAO;UAExB;EACf;EACA;EACA;EACA;;UAGe;;;;EAIf;;;;EAIA;;;;EAIA;;;;;EAKA;EACA,sBAAsB;;;;EAItB;;;;EAIA,YAAY,OAAO;;;;UCrBJ;EACf,sBAAsB;;;;EAItB;EACA,YAAY,OAAO;;;;EAInB;;;;;;;;;iBAUc,KAAK,UAAS,oBAAsB,QAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"nuxt-CEMZQEXW.mjs","names":["stylisticConfig"],"sources":["../src/configs/ignores.ts","../src/configs/shared-rules.ts","../src/configs/stylistic.ts","../src/utils.ts","../src/configs/typescript.ts","../src/configs/vue-rules.ts","../src/nuxt.ts"],"sourcesContent":["import gitignore from 'eslint-config-flat-gitignore';\n\nimport type { TypedFlatConfigItem } from '../types';\n\nexport function ignores(extraIgnores: string[] = []): TypedFlatConfigItem[] {\n return [\n // Prefer project .gitignore when present; do not fail if missing.\n gitignore({ strict: false }),\n {\n name: 'qstanay/ignores',\n ignores: [\n '**/node_modules/**',\n '**/dist/**',\n '**/.output/**',\n '**/.nuxt/**',\n '**/.nitro/**',\n '**/coverage/**',\n ...extraIgnores,\n ],\n },\n ];\n}\n","import type { Linter } from 'eslint';\n\nexport function javascriptRules(): Linter.RulesRecord {\n return {\n 'no-console': ['error', { allow: ['warn', 'error'] }],\n 'no-debugger': 'error',\n 'eqeqeq': ['error', 'always'],\n 'object-shorthand': ['error', 'always'],\n 'prefer-template': 'error',\n 'curly': ['error', 'all'],\n 'arrow-body-style': ['error', 'as-needed'],\n };\n}\n\nexport function typescriptRules(options: { strict?: boolean } = {}): Linter.RulesRecord {\n const rules: Linter.RulesRecord = {\n // Disable base rules that conflict with TypeScript-aware variants.\n 'no-unused-vars': 'off',\n 'no-undef': 'off',\n\n '@typescript-eslint/no-unused-vars': [\n 'error',\n {\n argsIgnorePattern: '^_',\n varsIgnorePattern: '^_',\n caughtErrorsIgnorePattern: '^_',\n destructuredArrayIgnorePattern: '^_',\n },\n ],\n '@typescript-eslint/consistent-type-imports': [\n 'error',\n { prefer: 'type-imports', disallowTypeAnnotations: false },\n ],\n '@typescript-eslint/no-explicit-any': 'warn',\n '@typescript-eslint/no-non-null-assertion': 'error',\n '@typescript-eslint/no-empty-function': ['error', { allow: ['arrowFunctions'] }],\n };\n\n if (options.strict) {\n rules['@typescript-eslint/no-magic-numbers'] = [\n 'warn',\n {\n ignore: [-1, 0, 1, 2, 1000],\n ignoreEnums: true,\n ignoreArrayIndexes: true,\n ignoreDefaultValues: true,\n ignoreClassFieldInitialValues: true,\n ignoreReadonlyClassProperties: true,\n },\n ];\n }\n\n return rules;\n}\n\n/**\n * Shared opinionated rules.\n * TypeScript rules are included only when `typescript` is true,\n * so JS-only projects do not reference a missing plugin.\n */\nexport function sharedRules(options: {\n typescript?: boolean;\n strict?: boolean;\n} = {}): Linter.RulesRecord {\n return {\n ...javascriptRules(),\n ...(options.typescript\n ? typescriptRules({ strict: options.strict })\n : {}),\n };\n}\n","import type { TypedFlatConfigItem, StylisticOptions } from '../types';\n\nasync function loadStylistic() {\n const mod = await import('@stylistic/eslint-plugin');\n return mod.default ?? mod;\n}\n\nexport async function stylistic(\n options: StylisticOptions = {},\n): Promise<TypedFlatConfigItem[]> {\n const {\n indent = 2,\n quotes = 'single',\n semi = true,\n maxLen = 100,\n } = options;\n\n const plugin = await loadStylistic();\n\n // `customize()` gives us a coherent bundle of stylistic rules.\n // Plugin name is fixed to `style` for stable rule IDs.\n const config = plugin.configs.customize({\n indent,\n quotes,\n semi,\n jsx: false,\n pluginName: 'style',\n }) as TypedFlatConfigItem;\n\n return [\n {\n name: 'qstanay/stylistic',\n plugins: {\n style: plugin,\n },\n rules: {\n ...(config.rules ?? {}),\n // Keep max line length aligned across all projects.\n 'style/max-len': [\n 'warn',\n {\n code: maxLen,\n ignoreUrls: true,\n ignoreStrings: true,\n ignoreTemplateLiterals: true,\n ignoreComments: true,\n ignoreTrailingComments: true,\n ignoreRegExpLiterals: true,\n },\n ],\n },\n },\n ];\n}\n","import { isPackageExists } from 'local-pkg';\n\nimport type { StylisticOptions } from './types';\n\nexport function resolveEnabled(explicit: boolean | undefined, detected: boolean) {\n return explicit ?? detected;\n}\n\nexport function has(pkg: string) {\n return isPackageExists(pkg);\n}\n\nexport function resolveStylisticOptions(\n stylistic: boolean | StylisticOptions | undefined,\n): false | StylisticOptions {\n if (stylistic === false) {\n return false;\n }\n\n if (typeof stylistic === 'object') {\n return stylistic;\n }\n\n return {};\n}\n\nconst SCRIPT_FILES = [\n '**/*.{js,mjs,cjs,jsx,ts,tsx,cts,mts}',\n] as const;\n\nexport const VUE_FILES = ['**/*.vue'] as const;\n\n/** TypeScript sources — never includes `.vue` (Vue keeps its own root parser). */\nexport const TYPESCRIPT_FILES = [\n '**/*.{ts,tsx,cts,mts}',\n] as const;\n\n/**\n * Files that receive shared / override rule packs.\n * `.vue` is included only when Vue support is enabled.\n */\nexport function sourceFiles(vueEnabled: boolean): string[] {\n return vueEnabled\n ? [...SCRIPT_FILES, ...VUE_FILES]\n : [...SCRIPT_FILES];\n}\n\n/** Files that receive shared / override rule packs when Vue is enabled. */\nexport const SOURCE_FILES = [\n '**/*.{js,mjs,cjs,jsx,ts,tsx,cts,mts,vue}',\n] as const;\n","import { TYPESCRIPT_FILES, VUE_FILES } from '../utils';\n\nimport type { TypedFlatConfigItem } from '../types';\nimport type { Linter } from 'eslint';\n\nfunction collectRules(configs: TypedFlatConfigItem[]): Linter.RulesRecord {\n return Object.assign(\n {},\n ...configs\n .filter(config => config.rules)\n .map(config => config.rules),\n );\n}\n\nexport async function loadTypescriptPlugin() {\n const pluginMod = await import('@typescript-eslint/eslint-plugin');\n return (pluginMod as any).default ?? pluginMod;\n}\n\n/**\n * TypeScript layer.\n *\n * Important: `@typescript-eslint/parser` is never the root parser for `.vue`.\n * Vue SFCs keep `vue-eslint-parser` as root (from the Vue layer) and use the\n * TS parser only as a nested script parser.\n *\n * Flat config requires the plugin on every object that references\n * `@typescript-eslint/*` rules (see shared-rules / overrides too).\n */\nexport async function typescript(options: {\n vue?: boolean;\n} = {}): Promise<TypedFlatConfigItem[]> {\n const parserMod = await import('@typescript-eslint/parser');\n const plugin = await loadTypescriptPlugin();\n const parser = (parserMod as any).default ?? parserMod;\n\n const recommended = (plugin.configs?.['flat/recommended'] ?? []) as TypedFlatConfigItem[];\n const rules = collectRules(recommended);\n\n const configs: TypedFlatConfigItem[] = [\n {\n name: 'qstanay/typescript',\n files: [...TYPESCRIPT_FILES],\n languageOptions: {\n parser,\n parserOptions: {\n sourceType: 'module',\n ecmaVersion: 'latest',\n },\n },\n plugins: {\n '@typescript-eslint': plugin,\n },\n rules,\n },\n ];\n\n if (options.vue) {\n configs.push({\n name: 'qstanay/typescript/vue-rules',\n files: [...VUE_FILES],\n plugins: {\n '@typescript-eslint': plugin,\n },\n rules,\n });\n }\n\n return configs;\n}\n","import type { Linter } from 'eslint';\n\nexport function vueRules(options: {\n indent?: 2 | 4;\n} = {}): Linter.RulesRecord {\n const rules: Linter.RulesRecord = {\n 'vue/html-self-closing': [\n 'error',\n {\n html: {\n void: 'always',\n normal: 'always',\n component: 'always',\n },\n svg: 'always',\n math: 'always',\n },\n ],\n 'vue/attributes-order': 'error',\n 'vue/padding-line-between-tags': [\n 'error',\n [\n {\n blankLine: 'always',\n prev: '*',\n next: '*',\n },\n ],\n ],\n };\n\n if (options.indent !== undefined) {\n // Keep template indent in sync with @stylistic script indent.\n rules['vue/html-indent'] = ['error', options.indent];\n }\n\n return rules;\n}\n","import { ignores } from './configs/ignores';\nimport {\n javascriptRules,\n typescriptRules,\n} from './configs/shared-rules';\nimport { stylistic as stylisticConfig } from './configs/stylistic';\nimport { loadTypescriptPlugin } from './configs/typescript';\nimport { vueRules } from './configs/vue-rules';\nimport {\n resolveStylisticOptions,\n SOURCE_FILES,\n TYPESCRIPT_FILES,\n VUE_FILES,\n} from './utils';\n\nimport type { StylisticOptions, TypedFlatConfigItem } from './types';\nimport type { Linter } from 'eslint';\n\nexport interface NuxtPresetOptions {\n stylistic?: boolean | StylisticOptions;\n /**\n * Enable stricter opinionated TypeScript rules (e.g. `no-magic-numbers`).\n */\n strict?: boolean;\n overrides?: Linter.RulesRecord;\n /**\n * Extra ignores appended to defaults / `.gitignore`.\n */\n ignores?: string[];\n}\n\n/**\n * Opinionated layer for Nuxt apps.\n *\n * Intended to be used with `@nuxt/eslint` + `withNuxt()`:\n * Nuxt already provides TypeScript/Vue/import plugins, so this preset\n * only adds stylistic formatting and shared opinionated rules.\n */\nexport function nuxt(options: NuxtPresetOptions = {}) {\n const stylisticOptions = resolveStylisticOptions(options.stylistic);\n const vueIndent = stylisticOptions\n ? (stylisticOptions.indent ?? 2)\n : undefined;\n\n const configs: Promise<TypedFlatConfigItem[]>[] = [\n Promise.resolve(ignores(options.ignores)),\n ];\n\n if (stylisticOptions) {\n configs.push(stylisticConfig(stylisticOptions));\n }\n\n configs.push((async () => {\n // Register plugin explicitly so the preset also works when tested standalone.\n // In real Nuxt apps `@nuxt/eslint` already provides it (duplicate name is fine).\n const plugin = await loadTypescriptPlugin();\n\n return [\n {\n name: 'qstanay/nuxt/shared-rules',\n files: [...SOURCE_FILES],\n rules: javascriptRules(),\n },\n {\n name: 'qstanay/nuxt/shared-rules/typescript',\n files: [...TYPESCRIPT_FILES, ...VUE_FILES],\n plugins: {\n '@typescript-eslint': plugin,\n },\n rules: typescriptRules({ strict: options.strict }),\n },\n {\n name: 'qstanay/nuxt/vue-rules',\n files: [...VUE_FILES],\n rules: {\n ...vueRules({ indent: vueIndent }),\n },\n },\n ];\n })());\n\n if (options.overrides) {\n // Dedicated trailing block so overrides always win over vue/shared rules.\n configs.push(Promise.resolve([\n {\n name: 'qstanay/nuxt/overrides',\n files: [...SOURCE_FILES],\n rules: options.overrides,\n },\n ]));\n }\n\n return configs;\n}\n"],"mappings":";;;AAIA,SAAgB,QAAQ,eAAyB,CAAC,GAA0B;CAC1E,OAAO,CAEL,UAAU,EAAE,QAAQ,MAAM,CAAC,GAC3B;EACE,MAAM;EACN,SAAS;GACP;GACA;GACA;GACA;GACA;GACA;GACA,GAAG;EACL;CACF,CACF;AACF;;;ACnBA,SAAgB,kBAAsC;CACpD,OAAO;EACL,cAAc,CAAC,SAAS,EAAE,OAAO,CAAC,QAAQ,OAAO,EAAE,CAAC;EACpD,eAAe;EACf,UAAU,CAAC,SAAS,QAAQ;EAC5B,oBAAoB,CAAC,SAAS,QAAQ;EACtC,mBAAmB;EACnB,SAAS,CAAC,SAAS,KAAK;EACxB,oBAAoB,CAAC,SAAS,WAAW;CAC3C;AACF;AAEA,SAAgB,gBAAgB,UAAgC,CAAC,GAAuB;CACtF,MAAM,QAA4B;EAEhC,kBAAkB;EAClB,YAAY;EAEZ,qCAAqC,CACnC,SACA;GACE,mBAAmB;GACnB,mBAAmB;GACnB,2BAA2B;GAC3B,gCAAgC;EAClC,CACF;EACA,8CAA8C,CAC5C,SACA;GAAE,QAAQ;GAAgB,yBAAyB;EAAM,CAC3D;EACA,sCAAsC;EACtC,4CAA4C;EAC5C,wCAAwC,CAAC,SAAS,EAAE,OAAO,CAAC,gBAAgB,EAAE,CAAC;CACjF;CAEA,IAAI,QAAQ,QACV,MAAM,yCAAyC,CAC7C,QACA;EAC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