@nemigo/configs 1.1.0 → 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.
@@ -21,7 +21,7 @@ export interface EslintConfigOptions {
21
21
  */
22
22
  strict?: boolean;
23
23
  /**
24
- * Путь к проекту (`import.meta.dirname`) для typed linting
24
+ * Путь к проекту (`import.meta.dirname`) для typed-linting
25
25
  *
26
26
  * @see https://typescript-eslint.io/getting-started/typed-linting
27
27
  */
@@ -37,11 +37,12 @@ export interface EslintConfigOptions {
37
37
  * Создает готовый flat-конфиг для **ESLint**
38
38
  *
39
39
  * Включает в себя:
40
- * - Конфигурацию из `.eslint.ignore`
40
+ * - Конфигурацию из `.eslint.ignore` пакета или иного
41
41
  * - Глобальные переменные для браузера и Node.js (globals)
42
42
  * - Рекомендованные правила из `@eslint/js`
43
43
  * - Рекомендованные или strict правила из `typescript-eslint`
44
44
  * - Опционально: конфигурацию для Svelte
45
+ * - Опционально: typed-linting из `typescript-eslint`
45
46
  *
46
47
  * Отключены различные правила TypeScript, которые только мешают.
47
48
  *
@@ -10,11 +10,12 @@ export { includeIgnoreFile, convertIgnorePatternToMinimatch as convertIgnorePatt
10
10
  * Создает готовый flat-конфиг для **ESLint**
11
11
  *
12
12
  * Включает в себя:
13
- * - Конфигурацию из `.eslint.ignore`
13
+ * - Конфигурацию из `.eslint.ignore` пакета или иного
14
14
  * - Глобальные переменные для браузера и Node.js (globals)
15
15
  * - Рекомендованные правила из `@eslint/js`
16
16
  * - Рекомендованные или strict правила из `typescript-eslint`
17
17
  * - Опционально: конфигурацию для Svelte
18
+ * - Опционально: typed-linting из `typescript-eslint`
18
19
  *
19
20
  * Отключены различные правила TypeScript, которые только мешают.
20
21
  *
@@ -24,85 +25,102 @@ export { includeIgnoreFile, convertIgnorePatternToMinimatch as convertIgnorePatt
24
25
  *
25
26
  * @see https://eslint.org/docs/latest/use/configure/configuration-files
26
27
  */
27
- export const defineEslintConfig = (options, ...rest) => defineConfig(includeIgnoreFile(options?.ignore || join(import.meta.dirname, "../../.eslint.ignore"), "@nemigo/configs/.eslint.ignore"), jslint.configs.recommended, ...(options?.strict
28
- ? options?.service
29
- ? tslint.configs.strictTypeChecked
30
- : tslint.configs.strict
31
- : options?.service
32
- ? tslint.configs.recommendedTypeChecked
33
- : tslint.configs.recommended), options?.service
34
- ? {
35
- languageOptions: {
36
- parserOptions: {
37
- projectService: true,
38
- tsconfigRootDir: options.service,
28
+ export const defineEslintConfig = (options, ...rest) => {
29
+ const acc = [];
30
+ acc.push(includeIgnoreFile(options?.ignore || join(import.meta.dirname, "../../.eslint.ignore"), "@nemigo/configs/.eslint.ignore"));
31
+ acc.push(jslint.configs.recommended);
32
+ if (options?.strict) {
33
+ if (options?.service) {
34
+ acc.push(tslint.configs.strictTypeChecked);
35
+ }
36
+ else {
37
+ acc.push(tslint.configs.strict);
38
+ }
39
+ }
40
+ else {
41
+ if (options?.service) {
42
+ acc.push(tslint.configs.recommendedTypeChecked);
43
+ }
44
+ else {
45
+ acc.push(tslint.configs.recommended);
46
+ }
47
+ }
48
+ if (options?.service) {
49
+ acc.push({
50
+ languageOptions: {
51
+ parserOptions: {
52
+ projectService: true,
53
+ tsconfigRootDir: options.service,
54
+ },
39
55
  },
40
- },
56
+ });
41
57
  }
42
- : {}, ...(options?.svelte ? svelteConfigs["flat/recommended"] : []),
43
- // prettier,
44
- // ...(svelte ? svelteConfigs["flat/prettier"] : []),
45
- {
46
- languageOptions: {
47
- globals: {
48
- ...globals.browser,
49
- ...globals.node,
50
- },
51
- },
52
- rules: {
53
- "@typescript-eslint/no-confusing-void-expression": 0,
54
- "@typescript-eslint/no-duplicate-type-constituents": 0,
55
- "@typescript-eslint/no-dynamic-delete": 0,
56
- "@typescript-eslint/no-empty-object-type": 0,
57
- "@typescript-eslint/no-explicit-any": 0,
58
- "@typescript-eslint/no-invalid-void-type": 0,
59
- "@typescript-eslint/no-non-null-asserted-optional-chain": 0,
60
- "@typescript-eslint/no-non-null-assertion": 0,
61
- "@typescript-eslint/no-redundant-type-constituents": 0,
62
- "@typescript-eslint/no-this-alias": 0,
63
- "@typescript-eslint/no-unnecessary-type-parameters": 0,
64
- "@typescript-eslint/no-unsafe-argument": 0,
65
- "@typescript-eslint/no-unsafe-assignment": 0,
66
- "@typescript-eslint/no-unsafe-call": 0,
67
- "@typescript-eslint/no-unsafe-function-type": 0,
68
- "@typescript-eslint/no-unsafe-member-access": 0,
69
- "@typescript-eslint/no-unsafe-return": 0,
70
- "@typescript-eslint/no-unused-expressions": 0,
71
- "@typescript-eslint/no-unused-vars": [
72
- "error",
73
- {
74
- args: "all",
75
- argsIgnorePattern: "^_",
76
- caughtErrors: "all",
77
- caughtErrorsIgnorePattern: "^_",
78
- destructuredArrayIgnorePattern: "^_",
79
- varsIgnorePattern: "^_",
80
- ignoreRestSiblings: true,
58
+ if (options?.svelte) {
59
+ acc.push(svelteConfigs["flat/recommended"]);
60
+ acc.push({
61
+ files: [
62
+ "**/*.svelte",
63
+ "**/*.svelte.ts",
64
+ "**/*.svelte.js",
65
+ ],
66
+ languageOptions: {
67
+ parserOptions: {
68
+ projectService: true,
69
+ extraFileExtensions: [".svelte"],
70
+ parser: tslint.parser,
71
+ svelteConfig: options?.svelte,
72
+ },
73
+ },
74
+ rules: {
75
+ "svelte/no-at-html-tags": 0,
76
+ "svelte/no-navigation-without-resolve": 0,
77
+ "svelte/prefer-svelte-reactivity": 0,
81
78
  },
82
- ],
83
- "@typescript-eslint/restrict-plus-operands": 0,
84
- "@typescript-eslint/restrict-template-expressions": 0,
85
- "no-import-assign": 0,
86
- },
87
- }, options?.svelte
88
- ? {
89
- files: [
90
- "**/*.svelte",
91
- "**/*.svelte.ts",
92
- "**/*.svelte.js",
93
- ],
79
+ });
80
+ }
81
+ acc.push({
94
82
  languageOptions: {
95
- parserOptions: {
96
- projectService: true,
97
- extraFileExtensions: [".svelte"],
98
- parser: tslint.parser,
99
- svelteConfig: options?.svelte,
83
+ globals: {
84
+ ...globals.browser,
85
+ ...globals.node,
100
86
  },
101
87
  },
102
88
  rules: {
103
- "svelte/no-at-html-tags": 0,
104
- "svelte/no-navigation-without-resolve": 0,
105
- "svelte/prefer-svelte-reactivity": 0,
89
+ "@typescript-eslint/no-confusing-void-expression": 0,
90
+ "@typescript-eslint/no-duplicate-type-constituents": 0,
91
+ "@typescript-eslint/no-dynamic-delete": 0,
92
+ "@typescript-eslint/no-empty-object-type": 0,
93
+ "@typescript-eslint/no-explicit-any": 0,
94
+ "@typescript-eslint/no-invalid-void-type": 0,
95
+ "@typescript-eslint/no-non-null-asserted-optional-chain": 0,
96
+ "@typescript-eslint/no-non-null-assertion": 0,
97
+ "@typescript-eslint/no-redundant-type-constituents": 0,
98
+ "@typescript-eslint/no-this-alias": 0,
99
+ "@typescript-eslint/no-unnecessary-type-parameters": 0,
100
+ "@typescript-eslint/no-unsafe-argument": 0,
101
+ "@typescript-eslint/no-unsafe-assignment": 0,
102
+ "@typescript-eslint/no-unsafe-call": 0,
103
+ "@typescript-eslint/no-unsafe-function-type": 0,
104
+ "@typescript-eslint/no-unsafe-member-access": 0,
105
+ "@typescript-eslint/no-unsafe-return": 0,
106
+ "@typescript-eslint/no-unused-expressions": 0,
107
+ "@typescript-eslint/no-unused-vars": [
108
+ "error",
109
+ {
110
+ args: "all",
111
+ argsIgnorePattern: "^_",
112
+ caughtErrors: "all",
113
+ caughtErrorsIgnorePattern: "^_",
114
+ destructuredArrayIgnorePattern: "^_",
115
+ varsIgnorePattern: "^_",
116
+ ignoreRestSiblings: true,
117
+ },
118
+ ],
119
+ "@typescript-eslint/restrict-plus-operands": 0,
120
+ "@typescript-eslint/restrict-template-expressions": 0,
121
+ "no-import-assign": 0,
106
122
  },
107
- }
108
- : {}, ...rest);
123
+ });
124
+ acc.push(...rest);
125
+ return defineConfig(acc);
126
+ };
@@ -15,6 +15,7 @@ export interface PrettierConfigOptions {
15
15
  *
16
16
  * @default 3
17
17
  * @alias MultilineArrayOptions.multilineArraysWrapThreshold
18
+ *
18
19
  * @see https://www.npmjs.com/package/prettier-plugin-multiline-arrays
19
20
  */
20
21
  arraysWrapThreshold?: number;
@@ -68,21 +69,18 @@ export declare const definePrettierConfig: (options?: PrettierConfigOptions) =>
68
69
  * // Форматирование TypeScript кода
69
70
  * const formatted = await pretty(`const x=1`, 'typescript');
70
71
  *
71
- * // Форматирование Svelte компонента
72
- * const formatted = await pretty(`<div>hello</div>`, 'svelte');
73
- *
74
- * // Форматирование с кастомными опциями
75
- * const formatted = await pretty(`const x=1`, 'typescript', {
72
+ * // Форматирование Svelte-компонента с кастомными опциями
73
+ * const formatted = await pretty(`<div class="bg-red-500 border border-blue-700">hello</div>`, 'svelte', {
76
74
  * arraysWrapThreshold: 5,
77
75
  * tailwind: { stylesheet: './src/tailwind.css' }
78
76
  * });
79
77
  * ```
80
78
  *
81
79
  * @param {string} content - Исходный код для форматирования
82
- * @param {Options["parser"]} parser - Парсер для определения типа кода
80
+ * @param {Options["parser"] | "svelte"} parser - Парсер для определения типа кода
83
81
  * @param {PrettierConfigOptions} [options] - Дополнительные опции конфигурации
84
82
  * @returns {Promise<string>} Отформатированный код
85
83
  *
86
84
  * @see https://prettier.io/docs/api#format
87
85
  */
88
- export declare const pretty: (content: string, parser: Options["parser"], options?: PrettierConfigOptions) => Promise<string>;
86
+ export declare const pretty: (content: string, parser: Options["parser"] | "svelte", options?: PrettierConfigOptions) => Promise<string>;
@@ -59,18 +59,15 @@ const config = definePrettierConfig();
59
59
  * // Форматирование TypeScript кода
60
60
  * const formatted = await pretty(`const x=1`, 'typescript');
61
61
  *
62
- * // Форматирование Svelte компонента
63
- * const formatted = await pretty(`<div>hello</div>`, 'svelte');
64
- *
65
- * // Форматирование с кастомными опциями
66
- * const formatted = await pretty(`const x=1`, 'typescript', {
62
+ * // Форматирование Svelte-компонента с кастомными опциями
63
+ * const formatted = await pretty(`<div class="bg-red-500 border border-blue-700">hello</div>`, 'svelte', {
67
64
  * arraysWrapThreshold: 5,
68
65
  * tailwind: { stylesheet: './src/tailwind.css' }
69
66
  * });
70
67
  * ```
71
68
  *
72
69
  * @param {string} content - Исходный код для форматирования
73
- * @param {Options["parser"]} parser - Парсер для определения типа кода
70
+ * @param {Options["parser"] | "svelte"} parser - Парсер для определения типа кода
74
71
  * @param {PrettierConfigOptions} [options] - Дополнительные опции конфигурации
75
72
  * @returns {Promise<string>} Отформатированный код
76
73
  *
@@ -14,8 +14,8 @@ export interface SvelteConfigOptions {
14
14
  * Только руны
15
15
  *
16
16
  * @default true
17
- *
18
17
  * @alias Config.compilerOptions.runes
18
+ *
19
19
  * @see https://svelte.dev/docs/svelte/what-are-runes
20
20
  */
21
21
  runes?: boolean;
@@ -8,6 +8,7 @@ export interface SveltePackageConfigOptions {
8
8
  *
9
9
  * @default true
10
10
  * @alias Config.compilerOptions.runes
11
+ *
11
12
  * @see https://svelte.dev/docs/svelte/what-are-runes
12
13
  */
13
14
  runes?: boolean;
@@ -16,6 +17,7 @@ export interface SveltePackageConfigOptions {
16
17
  *
17
18
  * @default true
18
19
  * @alias Config.kit.alias
20
+ *
19
21
  * @see https://svelte.dev/docs/kit/configuration#alias
20
22
  */
21
23
  isolate?: boolean;
@@ -31,6 +33,7 @@ export interface SveltePackageConfigOptions {
31
33
  *
32
34
  * @default "./src"
33
35
  * @alias Config.kit.files.lib
36
+ *
34
37
  * @see https://svelte.dev/docs/kit/configuration#files
35
38
  */
36
39
  path?: string;
@@ -9,6 +9,7 @@ export interface ViteConfigOptions {
9
9
  *
10
10
  * @default false
11
11
  * @alias ViteUserConfig.envDir
12
+ *
12
13
  * @see https://vite.dev/config/shared-options.html#envdir
13
14
  */
14
15
  env?: string | false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nemigo/configs",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "private": false,
5
5
  "author": {
6
6
  "name": "Vlad Logvin",
@@ -80,14 +80,14 @@
80
80
  },
81
81
  "dependencies": {
82
82
  "@eslint/compat": "1.4.0",
83
- "@eslint/js": "9.37.0",
83
+ "@eslint/js": "9.38.0",
84
84
  "@types/eslint": "9.6.1",
85
85
  "eslint-plugin-svelte": "3.12.4",
86
86
  "globals": "16.4.0",
87
87
  "prettier-plugin-css-order": "2.1.2",
88
88
  "prettier-plugin-multiline-arrays": "4.0.3",
89
89
  "prettier-plugin-svelte": "3.4.0",
90
- "prettier-plugin-tailwindcss": "0.7.0",
90
+ "prettier-plugin-tailwindcss": "0.7.1",
91
91
  "typescript-eslint": "8.46.1"
92
92
  }
93
93
  }