@nemigo/configs 1.3.0 → 1.4.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.
@@ -1,55 +1,70 @@
1
+ import type { ConfigWithExtendsArray } from "../types.js";
1
2
  import { convertIgnorePatternToMinimatch, includeIgnoreFile } from "@eslint/compat";
2
3
  import type { Config } from "@sveltejs/kit";
3
4
  import type { Linter } from "eslint";
4
- import type { ConfigWithExtendsArray } from "./types.js";
5
5
  export { includeIgnoreFile, convertIgnorePatternToMinimatch as convertIgnorePattern };
6
6
  /**
7
- * Опции конфигурации для {@link defineEslintConfig}
7
+ * Опции создания конфигураций для {@link defineEslintConfig}
8
8
  */
9
9
  export interface EslintConfigOptions {
10
10
  /**
11
- * Конфиг Svelte для его линтинга
12
- *
13
- * @see https://sveltejs.github.io/eslint-plugin-svelte
11
+ * Конфиг {@link https://svelte.dev/docs/kit/configuration Svelte} для его линтинга с помощью {@link https://sveltejs.github.io/eslint-plugin-svelte eslint-plugin-svelte}
14
12
  */
15
13
  svelte?: Config;
16
14
  /**
17
- * Использование strict-правил typescript-eslint
18
- *
19
- * @default false
20
- * @see https://typescript-eslint.io/users/configs/#strict
15
+ * Использование {@link https://typescript-eslint.io/users/configs/#strict strict-правил} из {@link https://typescript-eslint.io typescript-eslint}
21
16
  */
22
17
  strict?: boolean;
23
18
  /**
24
- * Путь к проекту (`import.meta.dirname`) для typed-linting
19
+ * Путь к проекту для {@link https://typescript-eslint.io/getting-started/typed-linting typed-linting} из {@link https://typescript-eslint.io typescript-eslint}
25
20
  *
26
- * @see https://typescript-eslint.io/getting-started/typed-linting
21
+ * @example
22
+ * ```typescript
23
+ * import.meta.dirname
24
+ * ```
27
25
  */
28
26
  service?: string;
29
27
  /**
30
- * Путь к альтернативному файлу `.eslint.ignore`
31
- *
32
- * @see https://github.com/eslint/rewrite/tree/main/packages/compat#readme
28
+ * Путь к иному файлу для {@link includeIgnoreFile} из {@link https://www.npmjs.com/package/@eslint/compat @eslint/compat}
33
29
  */
34
30
  ignore?: string;
35
31
  }
36
32
  /**
37
- * Создает готовый flat-конфиг для **ESLint**
33
+ * ## Создает flat-конфигурации для {@link https://eslint.org ESLint}
34
+ *
35
+ * ### Включает в себя:
36
+ * - Глобусы исключений из **.eslint.ignore** пакета (или иного файла) с помощью {@link includeIgnoreFile} из {@link https://www.npmjs.com/package/@eslint/compat @eslint/compat}
37
+ * - Глобалы из {@link https://www.npmjs.com/package/globals globals}
38
+ * - Рекомендованные правила из {@link https://www.npmjs.com/package/@eslint/js @eslint/js}
39
+ * - Рекомендованные (или strict) правила из {@link https://typescript-eslint.io typescript-eslint}
40
+ * - **Отключение** различных правил из {@link https://typescript-eslint.io typescript-eslint} и {@link https://sveltejs.github.io/eslint-plugin-svelte eslint-plugin-svelte}, которые обычно только мешают
41
+ *
42
+ * ### Опционально:
43
+ * - Линтинг для {@link https://svelte.dev Svelte} с помощью {@link https://sveltejs.github.io/eslint-plugin-svelte eslint-plugin-svelte}
44
+ * - Сервис {@link https://typescript-eslint.io/getting-started/typed-linting typed-linting} для {@link https://typescript-eslint.io typescript-eslint}
45
+ *
46
+ * ---
38
47
  *
39
- * Включает в себя:
40
- * - Глобусы исключений из `.eslint.ignore` пакета или иного
41
- * - Глобальные переменные для браузера и Node.js (globals)
42
- * - Рекомендованные правила из `@eslint/js`
43
- * - Рекомендованные или strict правила из `typescript-eslint`
44
- * - Опционально: конфигурацию для Svelte
45
- * - Опционально: typed-linting из `typescript-eslint`
48
+ * @example
49
+ * ```typescript
50
+ * import { defineEslintConfig } from "@nemigo/configs";
46
51
  *
47
- * Отключены различные правила TypeScript, которые только мешают.
52
+ * export default defineEslintConfig({
53
+ * strict: true,
54
+ * service: import.meta.dirname,
55
+ * });
56
+ * ```
48
57
  *
49
- * @param {EslintConfigOptions} [options] - Опции конфигурации
50
- * @param {...ConfigWithExtendsArray} [rest] - Дополнительные конфигурации ESLint для расширения
51
- * @returns {Linter.Config[]} Массив flat-конфигов ESLint
58
+ * @example
59
+ * ```typescript
60
+ * import { defineEslintConfig } from "@nemigo/configs";
61
+ * import svelte from "./svelte.config.js";
52
62
  *
53
- * @see https://eslint.org/docs/latest/use/configure/configuration-files
63
+ * export default defineEslintConfig({
64
+ * svelte,
65
+ * strict: true,
66
+ * service: import.meta.dirname,
67
+ * });
68
+ * ```
54
69
  */
55
70
  export declare const defineEslintConfig: (options?: EslintConfigOptions, ...rest: ConfigWithExtendsArray) => Linter.Config[];
@@ -7,23 +7,42 @@ import { join } from "node:path";
7
7
  import tslint from "typescript-eslint";
8
8
  export { includeIgnoreFile, convertIgnorePatternToMinimatch as convertIgnorePattern };
9
9
  /**
10
- * Создает готовый flat-конфиг для **ESLint**
10
+ * ## Создает flat-конфигурации для {@link https://eslint.org ESLint}
11
11
  *
12
- * Включает в себя:
13
- * - Глобусы исключений из `.eslint.ignore` пакета или иного
14
- * - Глобальные переменные для браузера и Node.js (globals)
15
- * - Рекомендованные правила из `@eslint/js`
16
- * - Рекомендованные или strict правила из `typescript-eslint`
17
- * - Опционально: конфигурацию для Svelte
18
- * - Опционально: typed-linting из `typescript-eslint`
12
+ * ### Включает в себя:
13
+ * - Глобусы исключений из **.eslint.ignore** пакета (или иного файла) с помощью {@link includeIgnoreFile} из {@link https://www.npmjs.com/package/@eslint/compat @eslint/compat}
14
+ * - Глобалы из {@link https://www.npmjs.com/package/globals globals}
15
+ * - Рекомендованные правила из {@link https://www.npmjs.com/package/@eslint/js @eslint/js}
16
+ * - Рекомендованные (или strict) правила из {@link https://typescript-eslint.io typescript-eslint}
17
+ * - **Отключение** различных правил из {@link https://typescript-eslint.io typescript-eslint} и {@link https://sveltejs.github.io/eslint-plugin-svelte eslint-plugin-svelte}, которые обычно только мешают
19
18
  *
20
- * Отключены различные правила TypeScript, которые только мешают.
19
+ * ### Опционально:
20
+ * - Линтинг для {@link https://svelte.dev Svelte} с помощью {@link https://sveltejs.github.io/eslint-plugin-svelte eslint-plugin-svelte}
21
+ * - Сервис {@link https://typescript-eslint.io/getting-started/typed-linting typed-linting} для {@link https://typescript-eslint.io typescript-eslint}
21
22
  *
22
- * @param {EslintConfigOptions} [options] - Опции конфигурации
23
- * @param {...ConfigWithExtendsArray} [rest] - Дополнительные конфигурации ESLint для расширения
24
- * @returns {Linter.Config[]} Массив flat-конфигов ESLint
23
+ * ---
25
24
  *
26
- * @see https://eslint.org/docs/latest/use/configure/configuration-files
25
+ * @example
26
+ * ```typescript
27
+ * import { defineEslintConfig } from "@nemigo/configs";
28
+ *
29
+ * export default defineEslintConfig({
30
+ * strict: true,
31
+ * service: import.meta.dirname,
32
+ * });
33
+ * ```
34
+ *
35
+ * @example
36
+ * ```typescript
37
+ * import { defineEslintConfig } from "@nemigo/configs";
38
+ * import svelte from "./svelte.config.js";
39
+ *
40
+ * export default defineEslintConfig({
41
+ * svelte,
42
+ * strict: true,
43
+ * service: import.meta.dirname,
44
+ * });
45
+ * ```
27
46
  */
28
47
  export const defineEslintConfig = (options, ...rest) => {
29
48
  const acc = [];
@@ -6,7 +6,8 @@ export interface ConfigWithExtends extends Linter.Config {
6
6
  extends?: ExtendsElement[];
7
7
  }
8
8
  /**
9
- * Взято из @eslint/config-helpers/types (0.3.1), т.к. нужный тип (ConfigWithExtendsArray) не экспортируется пакетом.
10
- * Представляется собой массив flat-конфигов ESLint
9
+ * Массив конфигов для {@link defineConfig} из {@link https://www.npmjs.com/package/eslint/config eslint/config}
10
+ *
11
+ * @remarks Взято из {@link https://www.npmjs.com/package/@eslint/config-helpers @eslint/config-helpers/types (0.3.1)}, т.к. этот тип не экспортируется
11
12
  */
12
13
  export type ConfigWithExtendsArray = InfiniteArray<ConfigWithExtends>[];
@@ -1,68 +1,87 @@
1
- import type { Config, Options } from "prettier";
1
+ import type { Config as PrettierConfig, Options } from "prettier";
2
+ import type { CssOrderPrettierConfig } from "prettier-plugin-css-order";
2
3
  import type { MultilineArrayOptions } from "prettier-plugin-multiline-arrays";
3
- import type { PluginConfig as SveltePrettier } from "prettier-plugin-svelte";
4
- import type { PluginOptions as TailwindPrettier } from "prettier-plugin-tailwindcss";
4
+ import type { PluginConfig as SveltePrettierConfig } from "prettier-plugin-svelte";
5
+ import type { PluginOptions as TailwindPrettierConfig } from "prettier-plugin-tailwindcss";
6
+ export type { PrettierConfig };
7
+ export type { SveltePrettierConfig };
8
+ export type { CssOrderPrettierConfig };
9
+ export type MultilineArrayPrettierConfig = Partial<MultilineArrayOptions>;
10
+ export type { TailwindPrettierConfig };
5
11
  /**
6
- * Объединенный тип конфигурации `prettier`, включающий настройки всех используемых плагинов
12
+ * ## Тип конфигурации из {@link definePrettierConfig}
13
+ *
14
+ * ### Включает в себя:
15
+ * - {@link PrettierConfig} самого {@link https://prettier.io Prettier}
16
+ * - {@link SveltePrettierConfig} для {@link https://www.npmjs.com/package/prettier-plugin-svelte prettier-plugin-svelte}
17
+ * - {@link CssOrderPrettierConfig} для {@link https://www.npmjs.com/package/prettier-plugin-css-order prettier-plugin-css-order}
18
+ * - {@link MultilineArrayPrettierConfig} для {@link https://www.npmjs.com/package/prettier-plugin-multiline-arrays prettier-plugin-multiline-arrays}
19
+ * - {@link TailwindPrettierConfig} для {@link https://www.npmjs.com/package/prettier-plugin-tailwindcss prettier-plugin-tailwindcss}
7
20
  */
8
- export type PrettierConfig = TailwindPrettier & Config & Partial<MultilineArrayOptions> & SveltePrettier;
21
+ export type PrettierExtraConfig = PrettierConfig & SveltePrettierConfig & CssOrderPrettierConfig & MultilineArrayPrettierConfig & TailwindPrettierConfig;
9
22
  /**
10
- * Опции конфигурации для {@link definePrettierConfig}
23
+ * Опции создания конфигурации для {@link definePrettierConfig}
11
24
  */
12
25
  export interface PrettierConfigOptions {
13
26
  /**
14
- * Порог длины для переноса массивов
27
+ * Порог длины для разбиения массивов для {@link https://www.npmjs.com/package/prettier-plugin-multiline-arrays prettier-plugin-multiline-arrays}
15
28
  *
16
- * @default 3
17
- * @alias MultilineArrayOptions.multilineArraysWrapThreshold
29
+ * Аналог к {@link MultilineArrayOptions.multilineArraysWrapThreshold}
18
30
  *
19
- * @see https://www.npmjs.com/package/prettier-plugin-multiline-arrays
31
+ * @default 3
20
32
  */
21
33
  arraysWrapThreshold?: number;
22
34
  /**
23
- * Дополнительные настройки для `prettier-plugin-tailwindcss`
24
- *
25
- * @see https://www.npmjs.com/package/prettier-plugin-tailwindcss
35
+ * Реструктурированная конфигурация для {@link https://www.npmjs.com/package/prettier-plugin-tailwindcss prettier-plugin-tailwindcss}
26
36
  */
27
37
  tailwind?: {
28
38
  /**
29
- * Путь к конфигу Tailwind V4 (например, `./src/tailwind.css`)
39
+ * Путь к конфигу {@link https://tailwindcss.com Tailwind CSS V4} для {@link https://www.npmjs.com/package/prettier-plugin-tailwindcss prettier-plugin-tailwindcss}
40
+ *
41
+ * Аналог к {@link TailwindPrettierConfig.tailwindStylesheet}
30
42
  *
31
- * @alias TailwindPrettier.tailwindStylesheet
32
- * @see https://www.npmjs.com/package/prettier-plugin-tailwindcss
43
+ * @example
44
+ * ```typescript
45
+ * "./src/tailwind.css"
46
+ * ```
33
47
  */
34
48
  stylesheet?: string;
35
49
  };
36
50
  /**
37
- * Переопределение конфига Prettier
51
+ * Переопределение создаваемого конфига
38
52
  */
39
- overload?: PrettierConfig;
53
+ overload?: PrettierExtraConfig;
40
54
  }
41
55
  /**
42
- * Создает готовый конфиг для **Prettier**
56
+ * ## Создает готовый конфиг для {@link https://prettier.io Prettier}
43
57
  *
44
- * Включает в себя плагины:
45
- * - `prettier-plugin-svelte` - поддержка Svelte
46
- * - `prettier-plugin-css-order` - сортировка CSS свойств
47
- * - `prettier-plugin-multiline-arrays` - форматирование массивов
48
- * - `prettier-plugin-tailwindcss` - сортировка классов Tailwind CSS
58
+ * ### Включает в себя плагины:
59
+ * - {@link https://www.npmjs.com/package/prettier-plugin-svelte prettier-plugin-svelte} для {@link https://svelte.dev Svelte}
60
+ * - {@link https://www.npmjs.com/package/prettier-plugin-css-order prettier-plugin-css-order} для сортировки CSS-свойств
61
+ * - {@link https://www.npmjs.com/package/prettier-plugin-multiline-arrays prettier-plugin-multiline-arrays} для массивов
62
+ * - {@link https://www.npmjs.com/package/prettier-plugin-tailwindcss prettier-plugin-tailwindcss} для сортировки классов {@link https://tailwindcss.com Tailwind CSS}
49
63
  *
50
- * Основные настройки:
51
- * - Ширина таба: 2 пробела
52
- * - Использование табов: true
53
- * - Ширина строки: 150 символов
54
- * - Двойные кавычки
55
- * - Запятые в конце (es5)
56
- * - Теги в одной строке с элементами
64
+ * ### Используемые настройки:
65
+ * - Ширина таба в 2 пробела ({@link PrettierConfig.tabWidth}: 2)
66
+ * - Использование табов: ({@link PrettierConfig.useTabs}: true)
67
+ * - Ширина строки в 150 символов ({@link PrettierConfig.printWidth}: 150)
68
+ * - Двойные кавычки ({@link PrettierConfig.singleQuote}: false)
69
+ * - Запятые в конце ({@link PrettierConfig.trailingComma}: es5)
70
+ * - Теги в одной строке с элементами ({@link PrettierConfig.bracketSameLine}: true)
71
+ * - Разбиение массива с порогом в 3 элемента ({@link MultilineArrayOptions.multilineArraysWrapThreshold}: 3)
57
72
  *
58
- * @param {PrettierConfigOptions} [options] - Опции конфигурации
59
- * @returns {PrettierConfig} Готовый конфиг Prettier
73
+ * ---
60
74
  *
61
- * @see https://prettier.io
75
+ * @example
76
+ * ```typescript
77
+ * import { definePrettierConfig } from "@nemigo/configs";
78
+ *
79
+ * export default definePrettierConfig();
80
+ * ```
62
81
  */
63
- export declare const definePrettierConfig: (options?: PrettierConfigOptions) => PrettierConfig;
82
+ export declare const definePrettierConfig: (options?: PrettierConfigOptions) => PrettierExtraConfig;
64
83
  /**
65
- * Форматирование кода с помощью **Prettier** используя конфиг из {@link definePrettierConfig}
84
+ * Форматирование кода с помощью {@link format} из {@link https://www.npmjs.com/package/prettier prettier} используя конфиг из {@link definePrettierConfig}
66
85
  *
67
86
  * @example
68
87
  * ```typescript
@@ -75,12 +94,5 @@ export declare const definePrettierConfig: (options?: PrettierConfigOptions) =>
75
94
  * tailwind: { stylesheet: './src/tailwind.css' }
76
95
  * });
77
96
  * ```
78
- *
79
- * @param {string} content - Исходный код для форматирования
80
- * @param {Options["parser"] | "svelte"} parser - Парсер для определения типа кода
81
- * @param {PrettierConfigOptions} [options] - Дополнительные опции конфигурации
82
- * @returns {Promise<string>} Отформатированный код
83
- *
84
- * @see https://prettier.io/docs/api#format
85
97
  */
86
98
  export declare const pretty: (content: string, parser: Options["parser"] | "svelte", options?: PrettierConfigOptions) => Promise<string>;
@@ -1,30 +1,34 @@
1
1
  import { format } from "prettier";
2
- // noinspection TypeScriptCheckImport (у пакета нет типов)
3
2
  import * as css from "prettier-plugin-css-order";
4
3
  import * as arrays from "prettier-plugin-multiline-arrays";
5
4
  import * as svelte from "prettier-plugin-svelte";
6
5
  import * as tailwind from "prettier-plugin-tailwindcss";
7
6
  /**
8
- * Создает готовый конфиг для **Prettier**
7
+ * ## Создает готовый конфиг для {@link https://prettier.io Prettier}
9
8
  *
10
- * Включает в себя плагины:
11
- * - `prettier-plugin-svelte` - поддержка Svelte
12
- * - `prettier-plugin-css-order` - сортировка CSS свойств
13
- * - `prettier-plugin-multiline-arrays` - форматирование массивов
14
- * - `prettier-plugin-tailwindcss` - сортировка классов Tailwind CSS
9
+ * ### Включает в себя плагины:
10
+ * - {@link https://www.npmjs.com/package/prettier-plugin-svelte prettier-plugin-svelte} для {@link https://svelte.dev Svelte}
11
+ * - {@link https://www.npmjs.com/package/prettier-plugin-css-order prettier-plugin-css-order} для сортировки CSS-свойств
12
+ * - {@link https://www.npmjs.com/package/prettier-plugin-multiline-arrays prettier-plugin-multiline-arrays} для массивов
13
+ * - {@link https://www.npmjs.com/package/prettier-plugin-tailwindcss prettier-plugin-tailwindcss} для сортировки классов {@link https://tailwindcss.com Tailwind CSS}
15
14
  *
16
- * Основные настройки:
17
- * - Ширина таба: 2 пробела
18
- * - Использование табов: true
19
- * - Ширина строки: 150 символов
20
- * - Двойные кавычки
21
- * - Запятые в конце (es5)
22
- * - Теги в одной строке с элементами
15
+ * ### Используемые настройки:
16
+ * - Ширина таба в 2 пробела ({@link PrettierConfig.tabWidth}: 2)
17
+ * - Использование табов: ({@link PrettierConfig.useTabs}: true)
18
+ * - Ширина строки в 150 символов ({@link PrettierConfig.printWidth}: 150)
19
+ * - Двойные кавычки ({@link PrettierConfig.singleQuote}: false)
20
+ * - Запятые в конце ({@link PrettierConfig.trailingComma}: es5)
21
+ * - Теги в одной строке с элементами ({@link PrettierConfig.bracketSameLine}: true)
22
+ * - Разбиение массива с порогом в 3 элемента ({@link MultilineArrayOptions.multilineArraysWrapThreshold}: 3)
23
23
  *
24
- * @param {PrettierConfigOptions} [options] - Опции конфигурации
25
- * @returns {PrettierConfig} Готовый конфиг Prettier
24
+ * ---
26
25
  *
27
- * @see https://prettier.io
26
+ * @example
27
+ * ```typescript
28
+ * import { definePrettierConfig } from "@nemigo/configs";
29
+ *
30
+ * export default definePrettierConfig();
31
+ * ```
28
32
  */
29
33
  export const definePrettierConfig = (options) => ({
30
34
  tabWidth: 2,
@@ -33,7 +37,6 @@ export const definePrettierConfig = (options) => ({
33
37
  singleQuote: false,
34
38
  trailingComma: "es5",
35
39
  bracketSameLine: true,
36
- experimentalTernaries: false,
37
40
  multilineArraysWrapThreshold: options?.arraysWrapThreshold ?? 3,
38
41
  plugins: [
39
42
  svelte,
@@ -50,9 +53,10 @@ export const definePrettierConfig = (options) => ({
50
53
  tailwindStylesheet: options?.tailwind?.stylesheet,
51
54
  ...(options?.overload ?? {}),
52
55
  });
56
+ //...
53
57
  const config = definePrettierConfig();
54
58
  /**
55
- * Форматирование кода с помощью **Prettier** используя конфиг из {@link definePrettierConfig}
59
+ * Форматирование кода с помощью {@link format} из {@link https://www.npmjs.com/package/prettier prettier} используя конфиг из {@link definePrettierConfig}
56
60
  *
57
61
  * @example
58
62
  * ```typescript
@@ -65,13 +69,6 @@ const config = definePrettierConfig();
65
69
  * tailwind: { stylesheet: './src/tailwind.css' }
66
70
  * });
67
71
  * ```
68
- *
69
- * @param {string} content - Исходный код для форматирования
70
- * @param {Options["parser"] | "svelte"} parser - Парсер для определения типа кода
71
- * @param {PrettierConfigOptions} [options] - Дополнительные опции конфигурации
72
- * @returns {Promise<string>} Отформатированный код
73
- *
74
- * @see https://prettier.io/docs/api#format
75
72
  */
76
73
  export const pretty = (content, parser, options) => format(content, {
77
74
  ...config,
@@ -0,0 +1,32 @@
1
+ declare module "prettier-plugin-css-order" {
2
+ export interface CssOrderPrettierConfig {
3
+ /**
4
+ * ### Стратегии сортировки CSS-свойств:
5
+ * - `"alphabetical"` — сортировка по алфавиту от a до z
6
+ * - `"smacss"` — сортировка от наиболее значимых свойств (влияющих на поток и компоновку) к наименее значимым (оформление, детали)
7
+ * - `"concentric-css"` — сортировка от внешних аспектов блока (позиционирование, отступы) к внутренним (размеры, оформление, текст)
8
+ *
9
+ * @default "concentric-css"
10
+ */
11
+ cssDeclarationSorterOrder?: "alphabetical" | "smacss" | "concentric-css";
12
+ /**
13
+ * Сохраняет переопределения свойств (например, `!important`) в исходном порядке, даже если они нарушают стратегию сортировки
14
+ *
15
+ * @default true
16
+ */
17
+ cssDeclarationSorterKeepOverrides?: boolean;
18
+ /**
19
+ * Пользовательский порядок сортировки CSS-свойств.
20
+ * Указывается как массив имён свойств в желаемом порядке
21
+ *
22
+ * Если задан (и не пуст), полностью заменяет поведение {@link CssOrderPrettierConfig.cssDeclarationSorterOrder}`
23
+ *
24
+ * @default []
25
+ */
26
+ cssDeclarationSorterCustomOrder?: string[];
27
+ }
28
+
29
+ export default import("prettier").Plugin;
30
+
31
+ export = import("prettier").Plugin;
32
+ }
@@ -1,98 +1,94 @@
1
1
  import type { Adapter, Config } from "@sveltejs/kit";
2
2
  /**
3
- * Опции конфигурации для {@link defineSvelteConfig}
3
+ * Опции создания конфигурации для {@link defineSvelteConfig}
4
4
  */
5
5
  export interface SvelteConfigOptions {
6
6
  /**
7
- * Адаптер серверной платформы
7
+ * {@link https://svelte.dev/docs/kit/adapters Адаптер} серверной платформы для **SvelteKit**
8
8
  *
9
- * @alias Config.kit.adapter
10
- * @see https://svelte.dev/docs/kit/adapters
9
+ * Аналог к {@link KitConfig.adapter}
11
10
  */
12
11
  adapter: Adapter;
13
12
  /**
14
- * Только руны
13
+ * Только {@link https://svelte.dev/docs/svelte/what-are-runes руны}
15
14
  *
16
- * @default true
17
- * @alias Config.compilerOptions.runes
15
+ * Аналог к {@link CompileOptions.runes}
18
16
  *
19
- * @see https://svelte.dev/docs/svelte/what-are-runes
17
+ * @default true
20
18
  */
21
19
  runes?: boolean;
22
20
  /**
23
- * Проверка источника запроса (CSRF-защита)
21
+ * {@link https://svelte.dev/docs/kit/configuration#alias Алиасы} путей для **SvelteKit** и {@link https://www.npmjs.com/package/@sveltejs/package @sveltejs/package}
24
22
  *
25
- * Отключить, если нужна возможность обращения с локалки на прод-приложения
26
- *
27
- * @alias Config.kit.csrf.checkOrigin
28
- * @see https://svelte.dev/docs/kit/configuration#csrf
29
- * @see https://developer.mozilla.org/en-US/docs/Web/Security/Types_of_attacks#cross-site_request_forgery_csrf
30
- */
31
- csrfCheckOrigin?: boolean;
32
- /**
33
- * Алиасы путей
34
- *
35
- * @alias Config.kit.alias
36
- * @see https://svelte.dev/docs/kit/configuration#alias
23
+ * Аналог к {@link KitConfig.alias}
37
24
  */
38
25
  alias?: Record<string, string>;
39
26
  /**
40
- * Переопределение путей кита
27
+ * Переопределение путей для **SvelteKit**
28
+ *
29
+ * Почти аналог к {@link KitConfig.files}
41
30
  *
42
31
  * @see https://svelte.dev/docs/kit/configuration#files
43
32
  */
44
33
  files?: {
45
34
  /**
46
- * Путь к директории со статическими файлами
35
+ * Путь к директории со статикой для **SvelteKit**
36
+ *
37
+ * Аналог к {@link KitConfig.files.assets}
47
38
  *
48
- * @alias Config.kit.files.assets
49
39
  * @see https://svelte.dev/docs/kit/configuration#files
50
40
  */
51
41
  assets?: string;
52
42
  /**
53
- * Путь к главному `app.html` приложения
43
+ * Путь к `app.html` для **SvelteKit**
44
+ *
45
+ * Аналог к {@link KitConfig.files.appTemplate}
54
46
  *
55
- * @alias Config.kit.files.appTemplate
56
47
  * @see https://svelte.dev/docs/kit/configuration#files
57
48
  */
58
49
  app_html?: string;
59
50
  /**
60
- * Путь к `error.html` приложения
51
+ * Путь к `error.html` для **SvelteKit**
52
+ *
53
+ * Аналог к {@link KitConfig.files.errorTemplate}
61
54
  *
62
- * @alias Config.kit.files.errorTemplate
63
55
  * @see https://svelte.dev/docs/kit/configuration#files
64
56
  */
65
57
  error_html?: string;
66
58
  };
67
59
  /**
68
- * Глобусы включений для tsconfig
60
+ * {@link https://www.typescriptlang.org/tsconfig/#include Глобусы включений} в **tsconfig** внутри **SvelteKit**
69
61
  *
70
- * @alias Config.kit.typescript.config.include
71
- * @see @https://svelte.dev/docs/kit/configuration#typescript
72
- * @see https://www.typescriptlang.org/tsconfig/#include
62
+ * Использует {@link KitConfig.typescript}
63
+ *
64
+ * @see https://svelte.dev/docs/kit/configuration#typescript
73
65
  */
74
66
  include?: string[];
75
67
  /**
76
- * Глобусы исключений для tsconfig
68
+ * {@link https://www.typescriptlang.org/tsconfig/#exclude Глобусы исключений} в **tsconfig** внутри **SvelteKit**
69
+ *
70
+ * Использует {@link KitConfig.typescript}
77
71
  *
78
- * @alias Config.kit.typescript.config.exclude
79
- * @see @https://svelte.dev/docs/kit/configuration#typescript
80
- * @see https://www.typescriptlang.org/tsconfig/#exclude
72
+ * @see https://svelte.dev/docs/kit/configuration#typescript
81
73
  */
82
74
  exclude?: string[];
83
75
  }
84
76
  /**
85
- * Реструктурированная конфигурация приложений на **SvelteKit**
77
+ * ## Реструктурированное создание конфигурации для {@link https://svelte.dev/docs/kit/introduction SvelteKit}
78
+ *
79
+ * ### Особенности:
80
+ * - По умолчанию **только** {@link https://svelte.dev/docs/svelte/what-are-runes руны}
81
+ * - Конфигурация внутреннего {@link https://www.typescriptlang.org/tsconfig tsconfig} аналогичная **typescript.json** пакета
82
+ * - Подключён {@link vitePreprocess} c `({ script: true })` из {@link https://www.npmjs.com/package/@sveltejs/vite-plugin-svelte @sveltejs/vite-plugin-svelte} для {@link https://svelte.dev/docs/kit/integrations#vitePreprocess расширенной поддержки всякого}
86
83
  *
87
- * - По умолчанию **только** руны
88
- * - Подключён VitePreprocess (@sveltejs/vite-plugin-svelte)
89
- * - Иная конфигурация tsconfig-а
84
+ * ---
90
85
  *
91
- * @param {SvelteConfigOptions} options
92
- * @returns {Config}
86
+ * @example
87
+ * ```typescript
88
+ * import { defineConfig } from "@nemigo/configs/svelte";
89
+ * import adapter from "@sveltejs/adapter-node";
93
90
  *
94
- * @see https://svelte.dev/docs/kit/introduction
95
- * @see https://svelte.dev/docs/kit/integrations#vitePreprocess
96
- * @see https://www.typescriptlang.org/tsconfig
91
+ * export default defineConfig({ adapter: adapter() });
92
+ * ```
97
93
  */
98
94
  export declare const defineSvelteConfig: (options: SvelteConfigOptions) => Config;
@@ -5,18 +5,22 @@ const getOptionalObject = (value) => (isObject(value) ? value : {});
5
5
  const getOptionalArray = (value) => (Array.isArray(value) ? value : []);
6
6
  const setifyArray = (array) => Array.from(new Set(array));
7
7
  /**
8
- * Реструктурированная конфигурация приложений на **SvelteKit**
8
+ * ## Реструктурированное создание конфигурации для {@link https://svelte.dev/docs/kit/introduction SvelteKit}
9
9
  *
10
- * - По умолчанию **только** руны
11
- * - Подключён VitePreprocess (@sveltejs/vite-plugin-svelte)
12
- * - Иная конфигурация tsconfig
10
+ * ### Особенности:
11
+ * - По умолчанию **только** {@link https://svelte.dev/docs/svelte/what-are-runes руны}
12
+ * - Конфигурация внутреннего {@link https://www.typescriptlang.org/tsconfig tsconfig} аналогичная **typescript.json** пакета
13
+ * - Подключён {@link vitePreprocess} c `({ script: true })` из {@link https://www.npmjs.com/package/@sveltejs/vite-plugin-svelte @sveltejs/vite-plugin-svelte} для {@link https://svelte.dev/docs/kit/integrations#vitePreprocess расширенной поддержки всякого}
13
14
  *
14
- * @param {SvelteConfigOptions} options
15
- * @returns {Config}
15
+ * ---
16
16
  *
17
- * @see https://svelte.dev/docs/kit/introduction
18
- * @see https://svelte.dev/docs/kit/integrations#vitePreprocess
19
- * @see https://www.typescriptlang.org/tsconfig
17
+ * @example
18
+ * ```typescript
19
+ * import { defineConfig } from "@nemigo/configs/svelte";
20
+ * import adapter from "@sveltejs/adapter-node";
21
+ *
22
+ * export default defineConfig({ adapter: adapter() });
23
+ * ```
20
24
  */
21
25
  export const defineSvelteConfig = (options) => ({
22
26
  /**
@@ -31,17 +35,9 @@ export const defineSvelteConfig = (options) => ({
31
35
  */
32
36
  modernAst: true,
33
37
  },
34
- /**
35
- * Расширение поддержки всякого в svelte (в т.ч. и полной для typescript)
36
- *
37
- * @see https://svelte.dev/docs/kit/integrations#vitePreprocess
38
- */
39
38
  preprocess: vitePreprocess({ script: true }),
40
39
  kit: {
41
40
  adapter: options.adapter,
42
- csrf: {
43
- checkOrigin: options.csrfCheckOrigin,
44
- },
45
41
  alias: options.alias,
46
42
  files: {
47
43
  assets: options.files?.assets,
@@ -49,7 +45,7 @@ export const defineSvelteConfig = (options) => ({
49
45
  errorTemplate: options.files?.error_html,
50
46
  },
51
47
  /**
52
- * Переопределение и дополнения к `tsconfig.json`
48
+ * Переопределение и дополнения к генерируемому `tsconfig.json`
53
49
  *
54
50
  * @see https://svelte.dev/docs/kit/configuration#typescript
55
51
  */
@@ -1,53 +1,58 @@
1
1
  import type { Config } from "@sveltejs/kit";
2
2
  /**
3
- * Опции конфигурации для {@link defineSveltePackageConfig}
3
+ * Опции создания конфигурации для {@link defineSveltePackageConfig}
4
4
  */
5
5
  export interface SveltePackageConfigOptions {
6
6
  /**
7
- * Только руны
7
+ * Только {@link https://svelte.dev/docs/svelte/what-are-runes руны}
8
8
  *
9
- * @default true
10
- * @alias Config.compilerOptions.runes
9
+ * Аналог к {@link CompileOptions.runes}
11
10
  *
12
- * @see https://svelte.dev/docs/svelte/what-are-runes
11
+ * @default true
13
12
  */
14
13
  runes?: boolean;
15
14
  /**
16
- * Добавляет алиас `{ "#": "src" }`
15
+ * Добавляет {@link https://svelte.dev/docs/kit/configuration#alias алиас} `({ "#": "src" })`
17
16
  *
18
- * @default true
19
- * @alias Config.kit.alias
17
+ * Использует {@link KitConfig.alias}
20
18
  *
21
- * @see https://svelte.dev/docs/kit/configuration#alias
19
+ * @default true
22
20
  */
23
21
  isolate?: boolean;
24
22
  /**
25
- * Алиасы путей
23
+ * {@link https://svelte.dev/docs/kit/configuration#alias Алиасы} путей
26
24
  *
27
- * @alias Config.kit.alias
28
- * @see https://svelte.dev/docs/kit/configuration#alias
25
+ * Аналог к {@link KitConfig.alias}
29
26
  */
30
27
  alias?: Record<string, string>;
31
28
  /**
32
29
  * Путь, который транспилер будет считать корневым для пакета
33
30
  *
31
+ * Аналог к {@link KitConfig.files.lib}
32
+ *
34
33
  * @default "./src"
35
- * @alias Config.kit.files.lib
36
34
  *
37
35
  * @see https://svelte.dev/docs/kit/configuration#files
38
36
  */
39
37
  path?: string;
40
38
  }
41
39
  /**
42
- * Реструктурированная конфигурация для **@sveltejs/package**
40
+ * ## Реструктурированное создание конфигурации для транспилера {@link https://www.npmjs.com/package/@sveltejs/package @sveltejs/package}
41
+ *
42
+ * ### Особенности:
43
+ * - По умолчанию **только** {@link https://svelte.dev/docs/svelte/what-are-runes руны}
44
+ * - По умолчанию иной путь к пакету (`"./src/lib" -> "./src"`)
45
+ * - Подключён {@link vitePreprocess} c `({ script: true })` из {@link https://www.npmjs.com/package/@sveltejs/vite-plugin-svelte @sveltejs/vite-plugin-svelte} для {@link https://svelte.dev/docs/kit/integrations#vitePreprocess расширенной поддержки всякого}
46
+ *
47
+ * ---
48
+ *
49
+ * @example
50
+ * ```typescript
51
+ * import { defineSveltePackageConfig } from "@nemigo/configs";
43
52
  *
44
- * - По умолчанию **только** руны.
45
- * - Подключён VitePreprocess (@sveltejs/vite-plugin-svelte).
46
- * - По умолчанию иной путь к пакету ("./src/lib" -> "./src")
53
+ * export default defineSveltePackageConfig();
54
+ * ```
47
55
  *
48
- * @param {SveltePackageConfigOptions} [options]
49
- * @returns {Config}
50
56
  * @see https://svelte.dev/docs/kit/packaging
51
- * @see https://svelte.dev/docs/kit/integrations#vitePreprocess
52
57
  */
53
58
  export declare const defineSveltePackageConfig: (options?: SveltePackageConfigOptions) => Config;
@@ -1,15 +1,22 @@
1
1
  import { vitePreprocess } from "@sveltejs/vite-plugin-svelte";
2
2
  /**
3
- * Реструктурированная конфигурация для **@sveltejs/package**
3
+ * ## Реструктурированное создание конфигурации для транспилера {@link https://www.npmjs.com/package/@sveltejs/package @sveltejs/package}
4
4
  *
5
- * - По умолчанию **только** руны.
6
- * - Подключён VitePreprocess (@sveltejs/vite-plugin-svelte).
7
- * - По умолчанию иной путь к пакету ("./src/lib" -> "./src")
5
+ * ### Особенности:
6
+ * - По умолчанию **только** {@link https://svelte.dev/docs/svelte/what-are-runes руны}
7
+ * - По умолчанию иной путь к пакету (`"./src/lib" -> "./src"`)
8
+ * - Подключён {@link vitePreprocess} c `({ script: true })` из {@link https://www.npmjs.com/package/@sveltejs/vite-plugin-svelte @sveltejs/vite-plugin-svelte} для {@link https://svelte.dev/docs/kit/integrations#vitePreprocess расширенной поддержки всякого}
9
+ *
10
+ * ---
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * import { defineSveltePackageConfig } from "@nemigo/configs";
15
+ *
16
+ * export default defineSveltePackageConfig();
17
+ * ```
8
18
  *
9
- * @param {SveltePackageConfigOptions} [options]
10
- * @returns {Config}
11
19
  * @see https://svelte.dev/docs/kit/packaging
12
- * @see https://svelte.dev/docs/kit/integrations#vitePreprocess
13
20
  */
14
21
  export const defineSveltePackageConfig = (options) => ({
15
22
  /**
@@ -24,17 +31,9 @@ export const defineSveltePackageConfig = (options) => ({
24
31
  */
25
32
  modernAst: true,
26
33
  },
27
- /**
28
- * Расширение поддержки всякого в svelte (в т.ч. и полной для typescript)
29
- *
30
- * @see https://svelte.dev/docs/kit/integrations
31
- */
32
34
  preprocess: vitePreprocess({ script: true }),
33
35
  kit: {
34
36
  files: {
35
- /**
36
- * Путь, который сборщик будет корневым считать для пакета
37
- */
38
37
  lib: options?.path ?? "./src",
39
38
  },
40
39
  alias: {
package/dist/types.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export type { EslintConfigOptions } from "./eslint/index.js";
2
2
  export type { ConfigWithExtendsArray } from "./eslint/types.js";
3
- export type { PrettierConfigOptions, PrettierConfig } from "./prettier/index.js";
3
+ export type { PrettierConfigOptions, PrettierExtraConfig, MultilineArrayPrettierConfig, CssOrderPrettierConfig, SveltePrettierConfig, PrettierConfig, TailwindPrettierConfig, } from "./prettier/index.js";
4
4
  export type { SvelteConfigOptions } from "./svelte/index.js";
5
5
  export type { SveltePackageConfigOptions } from "./svelte/package.js";
6
6
  export type { ViteConfigOptions } from "./vite/index.js";
@@ -1,14 +1,15 @@
1
1
  import type { BuildOptions, PluginOption, ServerOptions } from "vite";
2
2
  import type { ViteUserConfig } from "vitest/config";
3
3
  /**
4
- * Опции конфигурации для {@link defineViteConfig}
4
+ * Опции создания конфигурации для {@link defineViteConfig}
5
5
  */
6
6
  export interface ViteConfigOptions {
7
7
  /**
8
8
  * Путь к директории, где читает .env-файлы. Отключено, так как предполагается использование **dotenv**
9
9
  *
10
+ * Аналог к {@link ViteUserConfig.envDir}
11
+ *
10
12
  * @default false
11
- * @alias ViteUserConfig.envDir
12
13
  *
13
14
  * @see https://vite.dev/config/shared-options.html#envdir
14
15
  */
@@ -51,18 +52,12 @@ export interface ViteConfigOptions {
51
52
  plugins?: PluginOption[];
52
53
  }
53
54
  /**
54
- * Реструктурированная конфигурация для **Vite** через **Vitest**
55
- *
56
- * - По умолчанию отключено чтение env-файлов Vite (предполагается использование **dotenv**)
57
- * - Префикс "PUBLIC_" для публичных env-переменных
58
- * - Строгая конфигурация порта сервера по умолчанию
59
- * - По умолчанию путь к тестам "./src/**_/*.{test,spec}.{ts,js}"
60
- *
61
- * @param {ViteConfigOptions} [options]
62
- * @param {ViteUserConfig["test"]} [test]
63
- * @returns {ViteUserConfig}
55
+ * ## Реструктурированная конфигурация для {@link https://vite.dev Vite} через {@link defineConfig} от {@link https://vitest.dev Vitest}
64
56
  *
65
- * @see https://vite.dev/ Документация Vite
66
- * @see https://vitest.dev/ Документация Vitest
57
+ * ### Особенности:
58
+ * - По умолчанию отключено чтение env-файлов (предполагается использование **dotenv**)
59
+ * - Префикс `"PUBLIC_"` для публичных env-переменных
60
+ * - По умолчанию строгая конфигурация порта сервера
61
+ * - По умолчанию путь к тестам `"./src/**\/*.{test,spec}.{ts,js}"`
67
62
  */
68
63
  export declare const defineViteConfig: (options?: ViteConfigOptions, test?: ViteUserConfig["test"]) => ViteUserConfig;
@@ -1,18 +1,12 @@
1
1
  import { defineConfig } from "vitest/config";
2
2
  /**
3
- * Реструктурированная конфигурация для **Vite** через **Vitest**
3
+ * ## Реструктурированная конфигурация для {@link https://vite.dev Vite} через {@link defineConfig} от {@link https://vitest.dev Vitest}
4
4
  *
5
- * - По умолчанию отключено чтение env-файлов Vite (предполагается использование **dotenv**)
6
- * - Префикс "PUBLIC_" для публичных env-переменных
7
- * - Строгая конфигурация порта сервера по умолчанию
8
- * - По умолчанию путь к тестам "./src/**_/*.{test,spec}.{ts,js}"
9
- *
10
- * @param {ViteConfigOptions} [options]
11
- * @param {ViteUserConfig["test"]} [test]
12
- * @returns {ViteUserConfig}
13
- *
14
- * @see https://vite.dev/ Документация Vite
15
- * @see https://vitest.dev/ Документация Vitest
5
+ * ### Особенности:
6
+ * - По умолчанию отключено чтение env-файлов (предполагается использование **dotenv**)
7
+ * - Префикс `"PUBLIC_"` для публичных env-переменных
8
+ * - По умолчанию строгая конфигурация порта сервера
9
+ * - По умолчанию путь к тестам `"./src/**\/*.{test,spec}.{ts,js}"`
16
10
  */
17
11
  export const defineViteConfig = (options, test) => defineConfig({
18
12
  envDir: options?.env,
@@ -1,18 +1,24 @@
1
1
  import type { ServerOptions } from "vite";
2
2
  /**
3
- * Опции конфигурации для {@link defineViteProxyConfig}
3
+ * Опции создания конфигурации для {@link defineViteProxyConfig}
4
4
  */
5
5
  export interface ViteProxyConfigOptions {
6
6
  /**
7
7
  * URL-адрес сервера, на который будет направляться прокси
8
8
  *
9
- * @example http://localhost:3000
9
+ * @example
10
+ * ```typescript
11
+ * "http://localhost:3000"
12
+ * ```
10
13
  */
11
14
  domain: string;
12
15
  /**
13
16
  * Префикс маршрута, который будет перенаправляться.
14
17
  *
15
- * @example /api/
18
+ * @example
19
+ * ```typescript
20
+ * "/api/"
21
+ * ```
16
22
  */
17
23
  prefix: string;
18
24
  /**
@@ -23,8 +29,7 @@ export interface ViteProxyConfigOptions {
23
29
  changeOrigin?: boolean;
24
30
  }
25
31
  /**
26
- * Создания прокси-конфига для **Vite**.
27
- * Используется для проксирования запросов на основной сервер у приложений
32
+ * Создание конфигурации для проксирования запросов из {@link https://vite.dev Vite}
28
33
  *
29
34
  * @example
30
35
  * ```typescript
@@ -38,9 +43,6 @@ export interface ViteProxyConfigOptions {
38
43
  * });
39
44
  * ```
40
45
  *
41
- * @param {ViteProxyConfigOptions} options
42
- * @returns {ServerOptions["proxy"]}
43
- *
44
46
  * @see https://vite.dev/config/server-options.html#server-proxy
45
47
  */
46
48
  export declare const defineViteProxyConfig: (options: ViteProxyConfigOptions) => ServerOptions["proxy"];
@@ -1,6 +1,5 @@
1
1
  /**
2
- * Создания прокси-конфига для **Vite**.
3
- * Используется для проксирования запросов на основной сервер у приложений
2
+ * Создание конфигурации для проксирования запросов из {@link https://vite.dev Vite}
4
3
  *
5
4
  * @example
6
5
  * ```typescript
@@ -14,9 +13,6 @@
14
13
  * });
15
14
  * ```
16
15
  *
17
- * @param {ViteProxyConfigOptions} options
18
- * @returns {ServerOptions["proxy"]}
19
- *
20
16
  * @see https://vite.dev/config/server-options.html#server-proxy
21
17
  */
22
18
  export const defineViteProxyConfig = (options) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nemigo/configs",
3
- "version": "1.3.0",
3
+ "version": "1.4.1",
4
4
  "private": false,
5
5
  "author": {
6
6
  "name": "Vlad Logvin",
@@ -84,7 +84,7 @@
84
84
  "@eslint/compat": "1.4.0",
85
85
  "@eslint/js": "9.38.0",
86
86
  "@types/eslint": "9.6.1",
87
- "eslint-plugin-svelte": "3.12.4",
87
+ "eslint-plugin-svelte": "3.12.5",
88
88
  "globals": "16.4.0",
89
89
  "prettier-plugin-css-order": "2.1.2",
90
90
  "prettier-plugin-multiline-arrays": "4.0.3",
@@ -93,6 +93,6 @@
93
93
  "typescript-eslint": "8.46.1"
94
94
  },
95
95
  "devDependencies": {
96
- "@nemigo/configs": "1.2.2"
96
+ "@nemigo/configs": "1.4.1"
97
97
  }
98
98
  }