@nemigo/configs 0.0.4 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/eslint.d.ts CHANGED
@@ -1,13 +1,26 @@
1
- import { includeIgnoreFile } from "@eslint/compat";
1
+ import { convertIgnorePatternToMinimatch, includeIgnoreFile } from "@eslint/compat";
2
2
  import type { Config } from "@sveltejs/kit";
3
- import type { ConfigArray, InfiniteDepthConfigWithExtends } from "typescript-eslint";
3
+ import type { Linter } from "eslint";
4
+ import type { ConfigWithExtendsArray } from "./eslint.types.js";
5
+ export { includeIgnoreFile, convertIgnorePatternToMinimatch as convertIgnorePattern };
4
6
  export interface EslintConfigOptions {
7
+ /**
8
+ * Конфиг свелта для его линтига
9
+ */
5
10
  svelte?: Config;
11
+ /**
12
+ * Использование strict-правил tslint
13
+ */
6
14
  strict?: boolean;
15
+ /**
16
+ * Обычно `import.meta.dirname`. Для более сложного линтинга типов (TypeChecked)
17
+ */
7
18
  service?: string;
8
- ignore?: false | string;
19
+ /**
20
+ * Путь к своему .eslint.ignore
21
+ */
22
+ ignore?: string;
9
23
  }
10
- export { includeIgnoreFile };
11
24
  /**
12
25
  * Универсальная сборка flat-конфига для 'eslint'.
13
26
  *
@@ -21,4 +34,4 @@ export { includeIgnoreFile };
21
34
  *
22
35
  * @see https://eslint.org/docs/latest/use/configure/configuration-files
23
36
  */
24
- export declare const defineConfig: ({ ignore, svelte, service, strict }?: EslintConfigOptions, ...other: InfiniteDepthConfigWithExtends[]) => ConfigArray;
37
+ export declare const defineConfig: (opts: EslintConfigOptions, ...rest: ConfigWithExtendsArray) => Linter.Config[];
package/dist/eslint.js CHANGED
@@ -1,11 +1,12 @@
1
- import { includeIgnoreFile } from "@eslint/compat";
1
+ import { convertIgnorePatternToMinimatch, includeIgnoreFile } from "@eslint/compat";
2
2
  import jslint from "@eslint/js";
3
3
  // import prettier from "eslint-config-prettier";
4
4
  import { configs as svelteConfigs } from "eslint-plugin-svelte";
5
+ import { defineConfig as eslintDefineConfig } from "eslint/config";
5
6
  import globals from "globals";
6
7
  import { join } from "node:path";
7
8
  import tslint from "typescript-eslint";
8
- export { includeIgnoreFile };
9
+ export { includeIgnoreFile, convertIgnorePatternToMinimatch as convertIgnorePattern };
9
10
  /**
10
11
  * Универсальная сборка flat-конфига для 'eslint'.
11
12
  *
@@ -19,53 +20,31 @@ export { includeIgnoreFile };
19
20
  *
20
21
  * @see https://eslint.org/docs/latest/use/configure/configuration-files
21
22
  */
22
- export const defineConfig = ({ ignore, svelte, service, strict } = {}, ...other) => tslint.config(ignore === false ? {} : includeIgnoreFile(ignore || join(import.meta.dirname, "../.eslint.ignore")), jslint.configs.recommended, ...(strict
23
- ? service
23
+ export const defineConfig = (opts, ...rest) => eslintDefineConfig(includeIgnoreFile(opts.ignore || join(import.meta.dirname, "../.eslint.ignore"), "@nemigo/configs/.eslint.ignore"), jslint.configs.recommended, ...(opts.strict
24
+ ? opts.service
24
25
  ? tslint.configs.strictTypeChecked
25
26
  : tslint.configs.strict
26
- : service
27
+ : opts.service
27
28
  ? tslint.configs.recommendedTypeChecked
28
- : tslint.configs.recommended), ...(svelte ? svelteConfigs["flat/recommended"] : []),
29
- // prettier,
30
- // ...(svelte ? svelteConfigs["flat/prettier"] : []),
31
- service
29
+ : tslint.configs.recommended), opts.service
32
30
  ? {
33
31
  languageOptions: {
34
32
  parserOptions: {
35
33
  projectService: true,
36
- tsconfigRootDir: service,
34
+ tsconfigRootDir: opts.service,
37
35
  },
38
36
  },
39
37
  }
40
- : {}, {
38
+ : {}, ...(opts.svelte ? svelteConfigs["flat/recommended"] : []),
39
+ // prettier,
40
+ // ...(svelte ? svelteConfigs["flat/prettier"] : []),
41
+ {
41
42
  languageOptions: {
42
43
  globals: {
43
44
  ...globals.browser,
44
45
  ...globals.node,
45
46
  },
46
47
  },
47
- }, svelte
48
- ? {
49
- files: [
50
- "./**/*.svelte",
51
- "./**/*.svelte.{ts,js}",
52
- "./**/*.svelte.{test,spec}.{ts,js}",
53
- ],
54
- languageOptions: {
55
- parserOptions: {
56
- projectService: true,
57
- extraFileExtensions: [".svelte"],
58
- parser: tslint.parser,
59
- svelteConfig: svelte,
60
- },
61
- },
62
- rules: {
63
- "svelte/no-at-html-tags": 0,
64
- "svelte/no-navigation-without-resolve": 0,
65
- "svelte/prefer-svelte-reactivity": 0,
66
- },
67
- }
68
- : {}, {
69
48
  rules: {
70
49
  "@typescript-eslint/no-confusing-void-expression": 0,
71
50
  "@typescript-eslint/no-duplicate-type-constituents": 0,
@@ -101,4 +80,25 @@ service
101
80
  "@typescript-eslint/restrict-template-expressions": 0,
102
81
  "no-import-assign": 0,
103
82
  },
104
- }, ...other);
83
+ }, opts.svelte
84
+ ? {
85
+ files: [
86
+ "**/*.svelte",
87
+ "**/*.svelte.ts",
88
+ "**/*.svelte.js",
89
+ ],
90
+ languageOptions: {
91
+ parserOptions: {
92
+ projectService: true,
93
+ extraFileExtensions: [".svelte"],
94
+ parser: tslint.parser,
95
+ svelteConfig: opts.svelte,
96
+ },
97
+ },
98
+ rules: {
99
+ "svelte/no-at-html-tags": 0,
100
+ "svelte/no-navigation-without-resolve": 0,
101
+ "svelte/prefer-svelte-reactivity": 0,
102
+ },
103
+ }
104
+ : {}, ...rest);
@@ -0,0 +1,8 @@
1
+ import type { Linter } from "eslint";
2
+ export type InfiniteArray<T> = T | InfiniteArray<T>[];
3
+ export type SimpleExtendsElement = string | Linter.Config;
4
+ export type ExtendsElement = SimpleExtendsElement | InfiniteArray<Linter.Config>;
5
+ export interface ConfigWithExtends extends Linter.Config {
6
+ extends?: ExtendsElement[];
7
+ }
8
+ export type ConfigWithExtendsArray = InfiniteArray<ConfigWithExtends>[];
@@ -0,0 +1,4 @@
1
+ /*
2
+ Взято из @eslint/config-helpers/types (0.3.1), т.к. этот файл не экспортируется пакетом
3
+ */
4
+ export {};
@@ -1,3 +1,13 @@
1
1
  import type { Config, Options } from "prettier";
2
- export declare const defineConfig: () => Config;
3
- export declare const pretty: (content: string, parser: Options["parser"]) => Promise<string>;
2
+ /**
3
+ * @param tailwindStylesheet - путь к конфигу Tailwind V4 (`./src/tailwind.css`)
4
+ */
5
+ export declare const defineConfig: (tailwindStylesheet?: string) => Config;
6
+ /**
7
+ * Форматирование с помощью *prettier*
8
+ *
9
+ * @param content - содержимое
10
+ * @param parser - какой парсер
11
+ * @param tailwindStylesheet - путь к конфигу Tailwind V4 (`./src/tailwind.css`)
12
+ */
13
+ export declare const pretty: (content: string, parser: Options["parser"], tailwindStylesheet?: string) => Promise<string>;
package/dist/prettier.js CHANGED
@@ -1,9 +1,13 @@
1
1
  import { format } from "prettier";
2
+ // noinspection TypeScriptCheckImport (у пакетов нет типов)
2
3
  import * as css from "prettier-plugin-css-order";
3
4
  import * as arrays from "prettier-plugin-multiline-arrays";
4
5
  import * as svelte from "prettier-plugin-svelte";
5
6
  import * as tailwind from "prettier-plugin-tailwindcss";
6
- export const defineConfig = () => ({
7
+ /**
8
+ * @param tailwindStylesheet - путь к конфигу Tailwind V4 (`./src/tailwind.css`)
9
+ */
10
+ export const defineConfig = (tailwindStylesheet) => ({
7
11
  tabWidth: 2,
8
12
  useTabs: true,
9
13
  printWidth: 150,
@@ -24,7 +28,15 @@ export const defineConfig = () => ({
24
28
  options: { parser: "svelte" },
25
29
  },
26
30
  ],
31
+ tailwindStylesheet,
27
32
  });
28
33
  //...
29
- const prettier = defineConfig();
30
- export const pretty = (content, parser) => format(content, { ...prettier, parser });
34
+ const config = defineConfig();
35
+ /**
36
+ * Форматирование с помощью *prettier*
37
+ *
38
+ * @param content - содержимое
39
+ * @param parser - какой парсер
40
+ * @param tailwindStylesheet - путь к конфигу Tailwind V4 (`./src/tailwind.css`)
41
+ */
42
+ export const pretty = (content, parser, tailwindStylesheet) => format(content, { ...config, parser, tailwindStylesheet });
@@ -5,6 +5,8 @@ export interface SveltePackageOptions {
5
5
  */
6
6
  runes?: boolean;
7
7
  /**
8
+ * Добавляет алиас `{ "#": "src" }`
9
+ *
8
10
  * @default true
9
11
  */
10
12
  isolate?: boolean;
@@ -24,7 +24,7 @@ export const definePackageConfig = ({ runes = true, isolate = true, alias = {} }
24
24
  */
25
25
  preprocess: vitePreprocess({ script: true }),
26
26
  /**
27
- * Алиас корня пакета и его путь
27
+ * Алиас корня пакета и его путь (+ алиасы от проекта)
28
28
  */
29
29
  kit: {
30
30
  files: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nemigo/configs",
3
- "version": "0.0.4",
3
+ "version": "0.1.0",
4
4
  "private": false,
5
5
  "author": {
6
6
  "name": "Vlad Logvin",
@@ -17,10 +17,17 @@
17
17
  "typescript.json"
18
18
  ],
19
19
  "exports": {
20
+ "./.eslint.ignore": {
21
+ "default": "./.eslint.ignore"
22
+ },
20
23
  "./eslint": {
21
24
  "types": "./dist/eslint.d.ts",
22
25
  "default": "./dist/eslint.js"
23
26
  },
27
+ "./eslint/types": {
28
+ "types": "./dist/eslint/types.d.ts",
29
+ "default": "./dist/eslint/types.js"
30
+ },
24
31
  "./prettier": {
25
32
  "types": "./dist/prettier.d.ts",
26
33
  "default": "./dist/prettier.js"
@@ -31,9 +38,6 @@
31
38
  },
32
39
  "./typescript.json": {
33
40
  "default": "./typescript.json"
34
- },
35
- "./.eslint.ignore": {
36
- "default": "./.eslint.ignore"
37
41
  }
38
42
  },
39
43
  "peerDependencies": {