@debbl/eslint-config 2.4.1 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,9 +1,81 @@
1
1
  import { ParserOptions } from '@typescript-eslint/parser';
2
- import { RequiredOptions } from 'prettier';
3
2
  import { FlatESLintConfig } from 'eslint-define-config';
3
+ import { RequiredOptions } from 'prettier';
4
+
5
+ type ReactConfig = (options: {
6
+ next?: boolean;
7
+ } & OptionsOverrides) => ReturnType<ConfigFn>;
8
+
9
+ declare function comments(): Promise<ConfigItem[]>;
10
+
11
+ type IgnoresConfig = (options: {
12
+ enableGitignore?: boolean | {
13
+ ignorePath: string;
14
+ };
15
+ files?: ((files: string[]) => string[]) | string[];
16
+ }) => ReturnType<ConfigFn>;
17
+ declare const ignores: IgnoresConfig;
18
+
19
+ declare function imports(): Promise<ConfigItem[]>;
20
+
21
+ type JavascriptConfig = ConfigFn;
22
+ declare const javascript: JavascriptConfig;
23
+
24
+ declare function jsdoc(): Promise<ConfigItem[]>;
25
+
26
+ type JsoncConfig = ConfigFn;
27
+ declare const jsonc: JsoncConfig;
28
+
29
+ type MarkdownConfig = (options: {
30
+ componentExts?: string[];
31
+ } & OptionsOverrides) => ReturnType<ConfigFn>;
32
+ declare const markdown: MarkdownConfig;
33
+
34
+ declare function node(): Promise<ConfigItem[]>;
35
+
36
+ /**
37
+ * Sort package.json
38
+ *
39
+ * Requires `jsonc` config
40
+ */
41
+ declare function sortPackageJson(): Promise<ConfigItem[]>;
42
+ /**
43
+ * Sort tsconfig.json
44
+ *
45
+ * Requires `jsonc` config
46
+ */
47
+ declare function sortTsconfig(): Promise<ConfigItem[]>;
48
+
49
+ type TypeScriptConfig = (options?: OptionsComponentExts & OptionsTypeScriptWithTypes & OptionsTypeScriptParserOptions & OptionsOverrides) => ReturnType<ConfigFn>;
50
+ declare const typescript: TypeScriptConfig;
51
+
52
+ declare function unicorn(): Promise<ConfigItem[]>;
53
+
54
+ type VueConfig = (options: OptionsHasTypeScript & OptionsOverrides) => ReturnType<ConfigFn>;
55
+ declare const vue: VueConfig;
56
+
57
+ type YmlConfig = (options: OptionsOverrides) => ReturnType<ConfigFn>;
58
+ declare const yml: YmlConfig;
59
+
60
+ type TomlConfig = ConfigFn;
61
+ declare const toml: TomlConfig;
62
+
63
+ type TestConfig = ConfigFn;
64
+ declare const test: TestConfig;
65
+
66
+ /**
67
+ * Optional sort-keys plugin
68
+ *
69
+ * @see https://github.com/azat-io/eslint-plugin-perfectionist/
70
+ */
71
+ declare function perfectionist(): Promise<ConfigItem[]>;
4
72
 
5
73
  type PrettierRequiredOptions = Partial<RequiredOptions>;
74
+ type PrettierConfig = (options: PrettierRequiredOptions) => Promise<ConfigItem[]>;
75
+ declare const prettier: PrettierConfig;
76
+
6
77
  type Awaitable<T> = T | Promise<T>;
78
+ type GetConfigOption<T extends (...args: any) => any> = Parameters<T>[0];
7
79
  interface ConfigItem extends FlatESLintConfig {
8
80
  /**
9
81
  * Custom name of each config item
@@ -16,6 +88,10 @@ interface ConfigItem extends FlatESLintConfig {
16
88
  */
17
89
  plugins?: Record<string, any>;
18
90
  }
91
+ interface OptionsOverrides {
92
+ overrides?: ConfigItem["rules"];
93
+ }
94
+ type ConfigFn = (options: OptionsOverrides) => Awaitable<ConfigItem[]>;
19
95
  interface OptionsComponentExts {
20
96
  /**
21
97
  * Additional extensions for components.
@@ -41,18 +117,19 @@ interface OptionsTypeScriptWithTypes {
41
117
  interface OptionsHasTypeScript {
42
118
  typescript?: boolean;
43
119
  }
44
- interface ReactOptions {
45
- next?: boolean;
46
- }
47
120
  interface OptionsConfig extends OptionsComponentExts {
48
121
  /**
49
122
  * Enable gitignore support.
50
123
  * Passing an object to configure the options.
51
124
  * @default true
52
125
  */
53
- gitignore?: boolean | {
54
- ignorePath: string;
55
- };
126
+ ignores?: boolean | GetConfigOption<IgnoresConfig>;
127
+ /**
128
+ * Enable JavaScript support.
129
+ * Passing an object to configure the options.
130
+ * @default true
131
+ */
132
+ javascript?: GetConfigOption<JavascriptConfig>;
56
133
  /**
57
134
  * Enable TypeScript support.
58
135
  *
@@ -60,54 +137,54 @@ interface OptionsConfig extends OptionsComponentExts {
60
137
  *
61
138
  * @default false
62
139
  */
63
- typescript?: boolean | OptionsTypeScriptWithTypes;
140
+ typescript?: boolean | GetConfigOption<TypeScriptConfig>;
64
141
  /**
65
142
  * Enable test support.
66
143
  *
67
144
  * @default true
68
145
  */
69
- test?: boolean;
146
+ test?: boolean | GetConfigOption<TestConfig>;
70
147
  /**
71
148
  * Enable Vue support.
72
149
  *
73
150
  * @default false
74
151
  */
75
- vue?: boolean;
152
+ vue?: boolean | GetConfigOption<VueConfig>;
76
153
  /**
77
154
  * Enable React support, Passing an object to enable Next.js support.
78
155
  *
79
156
  * @default false
80
157
  */
81
- react?: boolean | ReactOptions;
158
+ react?: boolean | GetConfigOption<ReactConfig>;
82
159
  /**
83
160
  * Enable JSONC support.
84
161
  *
85
162
  * @default true
86
163
  */
87
- jsonc?: boolean;
164
+ jsonc?: boolean | GetConfigOption<JsoncConfig>;
88
165
  /**
89
166
  * Enable YML support.
90
167
  *
91
168
  * @default true
92
169
  */
93
- yml?: boolean;
170
+ yml?: boolean | GetConfigOption<YmlConfig>;
94
171
  /**
95
172
  * Enable TOML support.
96
173
  * @default true
97
174
  */
98
- toml?: boolean;
175
+ toml?: boolean | GetConfigOption<TomlConfig>;
99
176
  /**
100
177
  * Enable Markdown support.
101
178
  *
102
179
  * @default true
103
180
  */
104
- markdown?: boolean;
181
+ markdown?: boolean | GetConfigOption<MarkdownConfig>;
105
182
  /**
106
183
  * Enable prettier rules.
107
184
  *
108
185
  * @default true
109
186
  */
110
- prettier?: boolean | PrettierRequiredOptions;
187
+ prettier?: boolean | GetConfigOption<PrettierConfig>;
111
188
  /**
112
189
  * Enable Tailwind CSS support.
113
190
  * @default false
@@ -124,60 +201,6 @@ interface OptionsConfig extends OptionsComponentExts {
124
201
  */
125
202
  declare function config(options?: OptionsConfig): Promise<ConfigItem[]>;
126
203
 
127
- declare function comments(): Promise<ConfigItem[]>;
128
-
129
- declare function ignores(options: {
130
- enableGitignore: boolean | {
131
- ignorePath: string;
132
- };
133
- }): Promise<ConfigItem[]>;
134
-
135
- declare function imports(): Promise<ConfigItem[]>;
136
-
137
- declare function javascript(): Promise<ConfigItem[]>;
138
-
139
- declare function jsdoc(): Promise<ConfigItem[]>;
140
-
141
- declare function jsonc(): Promise<ConfigItem[]>;
142
-
143
- declare function markdown(options?: OptionsComponentExts): Promise<ConfigItem[]>;
144
-
145
- declare function node(): Promise<ConfigItem[]>;
146
-
147
- /**
148
- * Sort package.json
149
- *
150
- * Requires `jsonc` config
151
- */
152
- declare function sortPackageJson(): Promise<ConfigItem[]>;
153
- /**
154
- * Sort tsconfig.json
155
- *
156
- * Requires `jsonc` config
157
- */
158
- declare function sortTsconfig(): Promise<ConfigItem[]>;
159
-
160
- declare function typescript(options?: OptionsComponentExts & OptionsTypeScriptWithTypes & OptionsTypeScriptParserOptions): Promise<ConfigItem[]>;
161
-
162
- declare function unicorn(): Promise<ConfigItem[]>;
163
-
164
- declare function vue(options?: OptionsHasTypeScript): Promise<ConfigItem[]>;
165
-
166
- declare function yml(): Promise<ConfigItem[]>;
167
-
168
- declare function toml(): Promise<ConfigItem[]>;
169
-
170
- declare function test(): Promise<ConfigItem[]>;
171
-
172
- /**
173
- * Optional sort-keys plugin
174
- *
175
- * @see https://github.com/azat-io/eslint-plugin-perfectionist/
176
- */
177
- declare function perfectionist(): Promise<ConfigItem[]>;
178
-
179
- declare function prettier(options: PrettierRequiredOptions): Promise<ConfigItem[]>;
180
-
181
204
  /**
182
205
  * Combine array and non-array configs into a single array.
183
206
  */
@@ -211,4 +234,4 @@ declare const GLOB_TESTS: string[];
211
234
  declare const GLOB_ALL_SRC: string[];
212
235
  declare const GLOB_EXCLUDE: string[];
213
236
 
214
- export { type Awaitable, type ConfigItem, GLOB_ALL_SRC, GLOB_CSS, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MDX, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_YAML, type OptionsComponentExts, type OptionsConfig, type OptionsHasTypeScript, type OptionsTypeScriptParserOptions, type OptionsTypeScriptWithTypes, type PrettierRequiredOptions, type ReactOptions, combine, comments, config, config as default, ignores, imports, interopDefault, javascript, jsdoc, jsonc, markdown, node, perfectionist, prettier, sortPackageJson, sortTsconfig, test, toml, typescript, unicorn, vue, yml };
237
+ export { type Awaitable, type ConfigFn, type ConfigItem, GLOB_ALL_SRC, GLOB_CSS, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MDX, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_YAML, type GetConfigOption, type IgnoresConfig, type JavascriptConfig, type JsoncConfig, type MarkdownConfig, type OptionsComponentExts, type OptionsConfig, type OptionsHasTypeScript, type OptionsOverrides, type OptionsTypeScriptParserOptions, type OptionsTypeScriptWithTypes, type PrettierConfig, type PrettierRequiredOptions, type TestConfig, type TomlConfig, type TypeScriptConfig, type VueConfig, type YmlConfig, combine, comments, config, config as default, ignores, imports, interopDefault, javascript, jsdoc, jsonc, markdown, node, perfectionist, prettier, sortPackageJson, sortTsconfig, test, toml, typescript, unicorn, vue, yml };
package/dist/index.d.ts CHANGED
@@ -1,9 +1,81 @@
1
1
  import { ParserOptions } from '@typescript-eslint/parser';
2
- import { RequiredOptions } from 'prettier';
3
2
  import { FlatESLintConfig } from 'eslint-define-config';
3
+ import { RequiredOptions } from 'prettier';
4
+
5
+ type ReactConfig = (options: {
6
+ next?: boolean;
7
+ } & OptionsOverrides) => ReturnType<ConfigFn>;
8
+
9
+ declare function comments(): Promise<ConfigItem[]>;
10
+
11
+ type IgnoresConfig = (options: {
12
+ enableGitignore?: boolean | {
13
+ ignorePath: string;
14
+ };
15
+ files?: ((files: string[]) => string[]) | string[];
16
+ }) => ReturnType<ConfigFn>;
17
+ declare const ignores: IgnoresConfig;
18
+
19
+ declare function imports(): Promise<ConfigItem[]>;
20
+
21
+ type JavascriptConfig = ConfigFn;
22
+ declare const javascript: JavascriptConfig;
23
+
24
+ declare function jsdoc(): Promise<ConfigItem[]>;
25
+
26
+ type JsoncConfig = ConfigFn;
27
+ declare const jsonc: JsoncConfig;
28
+
29
+ type MarkdownConfig = (options: {
30
+ componentExts?: string[];
31
+ } & OptionsOverrides) => ReturnType<ConfigFn>;
32
+ declare const markdown: MarkdownConfig;
33
+
34
+ declare function node(): Promise<ConfigItem[]>;
35
+
36
+ /**
37
+ * Sort package.json
38
+ *
39
+ * Requires `jsonc` config
40
+ */
41
+ declare function sortPackageJson(): Promise<ConfigItem[]>;
42
+ /**
43
+ * Sort tsconfig.json
44
+ *
45
+ * Requires `jsonc` config
46
+ */
47
+ declare function sortTsconfig(): Promise<ConfigItem[]>;
48
+
49
+ type TypeScriptConfig = (options?: OptionsComponentExts & OptionsTypeScriptWithTypes & OptionsTypeScriptParserOptions & OptionsOverrides) => ReturnType<ConfigFn>;
50
+ declare const typescript: TypeScriptConfig;
51
+
52
+ declare function unicorn(): Promise<ConfigItem[]>;
53
+
54
+ type VueConfig = (options: OptionsHasTypeScript & OptionsOverrides) => ReturnType<ConfigFn>;
55
+ declare const vue: VueConfig;
56
+
57
+ type YmlConfig = (options: OptionsOverrides) => ReturnType<ConfigFn>;
58
+ declare const yml: YmlConfig;
59
+
60
+ type TomlConfig = ConfigFn;
61
+ declare const toml: TomlConfig;
62
+
63
+ type TestConfig = ConfigFn;
64
+ declare const test: TestConfig;
65
+
66
+ /**
67
+ * Optional sort-keys plugin
68
+ *
69
+ * @see https://github.com/azat-io/eslint-plugin-perfectionist/
70
+ */
71
+ declare function perfectionist(): Promise<ConfigItem[]>;
4
72
 
5
73
  type PrettierRequiredOptions = Partial<RequiredOptions>;
74
+ type PrettierConfig = (options: PrettierRequiredOptions) => Promise<ConfigItem[]>;
75
+ declare const prettier: PrettierConfig;
76
+
6
77
  type Awaitable<T> = T | Promise<T>;
78
+ type GetConfigOption<T extends (...args: any) => any> = Parameters<T>[0];
7
79
  interface ConfigItem extends FlatESLintConfig {
8
80
  /**
9
81
  * Custom name of each config item
@@ -16,6 +88,10 @@ interface ConfigItem extends FlatESLintConfig {
16
88
  */
17
89
  plugins?: Record<string, any>;
18
90
  }
91
+ interface OptionsOverrides {
92
+ overrides?: ConfigItem["rules"];
93
+ }
94
+ type ConfigFn = (options: OptionsOverrides) => Awaitable<ConfigItem[]>;
19
95
  interface OptionsComponentExts {
20
96
  /**
21
97
  * Additional extensions for components.
@@ -41,18 +117,19 @@ interface OptionsTypeScriptWithTypes {
41
117
  interface OptionsHasTypeScript {
42
118
  typescript?: boolean;
43
119
  }
44
- interface ReactOptions {
45
- next?: boolean;
46
- }
47
120
  interface OptionsConfig extends OptionsComponentExts {
48
121
  /**
49
122
  * Enable gitignore support.
50
123
  * Passing an object to configure the options.
51
124
  * @default true
52
125
  */
53
- gitignore?: boolean | {
54
- ignorePath: string;
55
- };
126
+ ignores?: boolean | GetConfigOption<IgnoresConfig>;
127
+ /**
128
+ * Enable JavaScript support.
129
+ * Passing an object to configure the options.
130
+ * @default true
131
+ */
132
+ javascript?: GetConfigOption<JavascriptConfig>;
56
133
  /**
57
134
  * Enable TypeScript support.
58
135
  *
@@ -60,54 +137,54 @@ interface OptionsConfig extends OptionsComponentExts {
60
137
  *
61
138
  * @default false
62
139
  */
63
- typescript?: boolean | OptionsTypeScriptWithTypes;
140
+ typescript?: boolean | GetConfigOption<TypeScriptConfig>;
64
141
  /**
65
142
  * Enable test support.
66
143
  *
67
144
  * @default true
68
145
  */
69
- test?: boolean;
146
+ test?: boolean | GetConfigOption<TestConfig>;
70
147
  /**
71
148
  * Enable Vue support.
72
149
  *
73
150
  * @default false
74
151
  */
75
- vue?: boolean;
152
+ vue?: boolean | GetConfigOption<VueConfig>;
76
153
  /**
77
154
  * Enable React support, Passing an object to enable Next.js support.
78
155
  *
79
156
  * @default false
80
157
  */
81
- react?: boolean | ReactOptions;
158
+ react?: boolean | GetConfigOption<ReactConfig>;
82
159
  /**
83
160
  * Enable JSONC support.
84
161
  *
85
162
  * @default true
86
163
  */
87
- jsonc?: boolean;
164
+ jsonc?: boolean | GetConfigOption<JsoncConfig>;
88
165
  /**
89
166
  * Enable YML support.
90
167
  *
91
168
  * @default true
92
169
  */
93
- yml?: boolean;
170
+ yml?: boolean | GetConfigOption<YmlConfig>;
94
171
  /**
95
172
  * Enable TOML support.
96
173
  * @default true
97
174
  */
98
- toml?: boolean;
175
+ toml?: boolean | GetConfigOption<TomlConfig>;
99
176
  /**
100
177
  * Enable Markdown support.
101
178
  *
102
179
  * @default true
103
180
  */
104
- markdown?: boolean;
181
+ markdown?: boolean | GetConfigOption<MarkdownConfig>;
105
182
  /**
106
183
  * Enable prettier rules.
107
184
  *
108
185
  * @default true
109
186
  */
110
- prettier?: boolean | PrettierRequiredOptions;
187
+ prettier?: boolean | GetConfigOption<PrettierConfig>;
111
188
  /**
112
189
  * Enable Tailwind CSS support.
113
190
  * @default false
@@ -124,60 +201,6 @@ interface OptionsConfig extends OptionsComponentExts {
124
201
  */
125
202
  declare function config(options?: OptionsConfig): Promise<ConfigItem[]>;
126
203
 
127
- declare function comments(): Promise<ConfigItem[]>;
128
-
129
- declare function ignores(options: {
130
- enableGitignore: boolean | {
131
- ignorePath: string;
132
- };
133
- }): Promise<ConfigItem[]>;
134
-
135
- declare function imports(): Promise<ConfigItem[]>;
136
-
137
- declare function javascript(): Promise<ConfigItem[]>;
138
-
139
- declare function jsdoc(): Promise<ConfigItem[]>;
140
-
141
- declare function jsonc(): Promise<ConfigItem[]>;
142
-
143
- declare function markdown(options?: OptionsComponentExts): Promise<ConfigItem[]>;
144
-
145
- declare function node(): Promise<ConfigItem[]>;
146
-
147
- /**
148
- * Sort package.json
149
- *
150
- * Requires `jsonc` config
151
- */
152
- declare function sortPackageJson(): Promise<ConfigItem[]>;
153
- /**
154
- * Sort tsconfig.json
155
- *
156
- * Requires `jsonc` config
157
- */
158
- declare function sortTsconfig(): Promise<ConfigItem[]>;
159
-
160
- declare function typescript(options?: OptionsComponentExts & OptionsTypeScriptWithTypes & OptionsTypeScriptParserOptions): Promise<ConfigItem[]>;
161
-
162
- declare function unicorn(): Promise<ConfigItem[]>;
163
-
164
- declare function vue(options?: OptionsHasTypeScript): Promise<ConfigItem[]>;
165
-
166
- declare function yml(): Promise<ConfigItem[]>;
167
-
168
- declare function toml(): Promise<ConfigItem[]>;
169
-
170
- declare function test(): Promise<ConfigItem[]>;
171
-
172
- /**
173
- * Optional sort-keys plugin
174
- *
175
- * @see https://github.com/azat-io/eslint-plugin-perfectionist/
176
- */
177
- declare function perfectionist(): Promise<ConfigItem[]>;
178
-
179
- declare function prettier(options: PrettierRequiredOptions): Promise<ConfigItem[]>;
180
-
181
204
  /**
182
205
  * Combine array and non-array configs into a single array.
183
206
  */
@@ -211,4 +234,4 @@ declare const GLOB_TESTS: string[];
211
234
  declare const GLOB_ALL_SRC: string[];
212
235
  declare const GLOB_EXCLUDE: string[];
213
236
 
214
- export { type Awaitable, type ConfigItem, GLOB_ALL_SRC, GLOB_CSS, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MDX, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_YAML, type OptionsComponentExts, type OptionsConfig, type OptionsHasTypeScript, type OptionsTypeScriptParserOptions, type OptionsTypeScriptWithTypes, type PrettierRequiredOptions, type ReactOptions, combine, comments, config, config as default, ignores, imports, interopDefault, javascript, jsdoc, jsonc, markdown, node, perfectionist, prettier, sortPackageJson, sortTsconfig, test, toml, typescript, unicorn, vue, yml };
237
+ export { type Awaitable, type ConfigFn, type ConfigItem, GLOB_ALL_SRC, GLOB_CSS, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MDX, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_YAML, type GetConfigOption, type IgnoresConfig, type JavascriptConfig, type JsoncConfig, type MarkdownConfig, type OptionsComponentExts, type OptionsConfig, type OptionsHasTypeScript, type OptionsOverrides, type OptionsTypeScriptParserOptions, type OptionsTypeScriptWithTypes, type PrettierConfig, type PrettierRequiredOptions, type TestConfig, type TomlConfig, type TypeScriptConfig, type VueConfig, type YmlConfig, combine, comments, config, config as default, ignores, imports, interopDefault, javascript, jsdoc, jsonc, markdown, node, perfectionist, prettier, sortPackageJson, sortTsconfig, test, toml, typescript, unicorn, vue, yml };