@biscuittin/eslint-config 0.0.6 → 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/index.d.cts DELETED
@@ -1,350 +0,0 @@
1
- import { RuleOptions } from '#typegen';
2
- export { ConfigNames } from '#typegen';
3
- import { Linter } from 'eslint';
4
- import { FlatConfigComposer } from 'eslint-flat-config-utils';
5
- import { PackageJson } from '@package-json/types';
6
- export { default as globals } from 'globals';
7
-
8
- /**
9
- * Copied from antfu/eslint-config
10
- * Ref: https://github.com/antfu/eslint-config/blob/5d0c2a5ef25a7bc3a2d6d55c1ce157cc47b0bf55/src/types.ts#L9
11
- */
12
- type Awaitable<T> = T | Promise<T>;
13
- /**
14
- * Copied from antfu/eslint-config
15
- * Ref: https://github.com/antfu/eslint-config/blob/5d0c2a5ef25a7bc3a2d6d55c1ce157cc47b0bf55/src/types.ts#L11C1-L11C32
16
- */
17
- type Rules = RuleOptions;
18
-
19
- /**
20
- * Copied from antfu/eslint-config
21
- * Ref: https://github.com/antfu/eslint-config/blob/5d0c2a5ef25a7bc3a2d6d55c1ce157cc47b0bf55/src/types.ts#L15
22
- */
23
- type TypedFlatConfigItem = Omit<Linter.Config<Linter.RulesRecord & Rules>, 'plugins'> & {
24
- /**
25
- * An object containing a name-value mapping of plugin names to plugin objects. When `files` is specified, these plugins are only available to the matching files.
26
- *
27
- * @see [Using plugins in your configuration](https://eslint.org/docs/latest/user-guide/configuring/configuration-files-new#using-plugins-in-your-configuration)
28
- */
29
- plugins?: Record<string, any>;
30
- };
31
-
32
- declare function comments(): TypedFlatConfigItem[];
33
-
34
- declare function disables(): TypedFlatConfigItem[];
35
-
36
- interface OptionsEnvironment {
37
- env?: {
38
- /**
39
- * Enable browser global variables.
40
- *
41
- * @default true
42
- */
43
- browser?: boolean;
44
- /**
45
- * Custom global variables.
46
- *
47
- * @default undefined
48
- * @see [Configuring global variables](https://eslint.org/docs/latest/user-guide/configuring/configuration-files-new#configuring-global-variables)
49
- */
50
- customGlobals?: Record<string, Linter.GlobalConf> | undefined;
51
- };
52
- }
53
- interface OptionsIsInEditor {
54
- /**
55
- * Set to `true` if the code is running in an editor.
56
- *
57
- * @default false
58
- */
59
- isInEditor?: boolean;
60
- }
61
- interface OptionsExtraFiles {
62
- /**
63
- * Extend the `files` option to provide custom globs.
64
- *
65
- * @default [] (none)
66
- */
67
- extraFiles?: string[];
68
- }
69
- interface StylisticConfig {
70
- /**
71
- * The maximum line length.
72
- *
73
- * @default 120
74
- */
75
- printWidth?: number;
76
- /**
77
- * The number of spaces to use for indentation.
78
- *
79
- * @default 2
80
- */
81
- indentWidth?: number;
82
- /**
83
- * Use tabs instead of spaces.
84
- *
85
- * @default false
86
- */
87
- useTabs?: boolean;
88
- /**
89
- * How semi-colons should be used.
90
- * - `true`: Always uses semi-colons where applicable.
91
- * - `false`: Uses automatic semi-colon insertion.
92
- *
93
- * @default false
94
- */
95
- semi?: boolean;
96
- /**
97
- * The quote style to use.
98
- * - `'single'`: Prefers using double quotes except in scenarios where the
99
- * string contains more double quotes than single quotes.
100
- * - `'double'`: Prefers using single quotes except in scenarios where the
101
- * string contains more single quotes than double quotes.
102
- *
103
- * @default 'single'
104
- */
105
- quotes?: 'single' | 'double';
106
- /**
107
- * The quote style to use for JSX attributes.
108
- * - `'single'`: Prefers using double quotes except in scenarios where the
109
- * string contains more double quotes than single quotes.
110
- * - `'double'`: Prefers using single quotes except in scenarios where the
111
- * string contains more single quotes than double quotes.
112
- *
113
- * @default 'double'
114
- */
115
- jsxQuotes?: 'single' | 'double';
116
- /**
117
- * How trailing commas should be used.
118
- * - `'none'`: Trailing commas should not be used.
119
- * - `'all'`: Trailing commas should always be used.
120
- * - `'multiline'`: Trailing commas should only be used in multi-line scenarios.
121
- *
122
- * @default 'multiline'
123
- */
124
- trailingComma?: 'none' | 'all' | 'multiline';
125
- /**
126
- * The end of line character to use.
127
- * - `'auto'`: For each file, uses the last newline kind found in the file.
128
- * - `'lf'`: Uses the line feed character.
129
- * - `'crlf'`: Uses the carriage return and line feed characters.
130
- * - `'system'`: Uses the system standard (ex. crlf on Windows).
131
- *
132
- * @default 'lf'
133
- */
134
- endOfLine?: 'auto' | 'lf' | 'crlf' | 'system';
135
- }
136
- interface OptionsStylistic {
137
- /**
138
- * Enable stylistic rules.
139
- *
140
- * @default {
141
- * printWidth: 120,
142
- * indentWidth: 2,
143
- * useTabs: false,
144
- * semi: false,
145
- * quotes: 'single',
146
- * jsxQuotes: 'double',
147
- * trailingCommas: 'multiline'
148
- * }
149
- */
150
- stylistic?: boolean | StylisticConfig;
151
- }
152
- interface OptionsJavaScript extends OptionsEnvironment {
153
- /**
154
- * Set JavaScript source type to module.
155
- *
156
- * @default true
157
- */
158
- module?: boolean;
159
- }
160
- interface OptionsTypeScript extends OptionsIsInEditor {
161
- /**
162
- * A path to your project's TSConfig.
163
- * This setting or [projectService](https://typescript-eslint.io/packages/parser/#projectservice)
164
- * are required to use [rules which require type information](https://typescript-eslint.io/getting-started/typed-linting).
165
- * Setting this option to `true` will using [projectService](https://typescript-eslint.io/packages/parser/#projectservice).
166
- *
167
- * @default true
168
- * @see [@typescript-eslint/parser#project](https://typescript-eslint.io/packages/parser/#project)
169
- */
170
- tsconfigPath?: string | string[] | true;
171
- /**
172
- * This option allows you to provide the root directory for relative
173
- * TSConfig paths specified in the project option above. Doing so ensures
174
- * running ESLint from a directory other than the root will still be able
175
- * to find your TSConfig.
176
- *
177
- * @default process.cwd()
178
- * @see [@typescript-eslint/parser#tsconfigRootDir](https://typescript-eslint.io/packages/parser/#tsconfigrootdir)
179
- */
180
- tsconfigRootDir?: string;
181
- /**
182
- * Globs of files to allow running with the default project compiler options
183
- * despite not being matched by the project service. It takes in an array of
184
- * string paths that will be resolved relative to the [tsconfigRootDir](https://typescript-eslint.io/packages/parser/#tsconfigrootdir).
185
- *
186
- * @default [] (none)
187
- * @see [@typescript-eslint/parser#allowDefaultProject](https://typescript-eslint.io/packages/parser/#allowdefaultproject)
188
- */
189
- allowDefaultProject?: string[];
190
- /**
191
- * This option allows you to provide one or more additional file extensions
192
- * which should be considered in the TypeScript Program compilation. The
193
- * default extensions are `['.js', '.mjs', '.cjs', '.jsx', '.ts', '.mts', '.cts', '.tsx']`.
194
- * Add extensions starting with `.`, followed by the file extension. E.g.
195
- * for a `.vue` file use `"extraFileExtensions": [".vue"]`.
196
- *
197
- * @default [] (none)
198
- * @see [@typescript-eslint/parser#extraFileExtensions](https://typescript-eslint.io/packages/parser/#extrafileextensions)
199
- */
200
- extraFileExtensions?: string[];
201
- /**
202
- * Enable [@eslint-react/eslint-plugin](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin) type-checking rules.
203
- *
204
- * @default `true` when `react` is enabled, otherwise `false`
205
- */
206
- reactTypeCheck?: boolean;
207
- }
208
- type OptionsJson = OptionsExtraFiles & OptionsStylistic;
209
- interface OptionsReact {
210
- /**
211
- * Enable stylistic rules.
212
- *
213
- * @default true
214
- */
215
- stylistic?: boolean;
216
- /**
217
- * Enable React Compiler rules.
218
- *
219
- * @default false
220
- */
221
- reactCompiler?: boolean;
222
- }
223
- interface OptionsNodeJs extends OptionsExtraFiles {
224
- /**
225
- * Set JavaScript source type to module.
226
- *
227
- * @default Auto detect by package.json `type` field
228
- */
229
- module?: boolean;
230
- }
231
- interface InternalOptionsFormat {
232
- extraJsonFiles?: string[];
233
- }
234
- interface OptionsFormat extends StylisticConfig {
235
- /**
236
- * Path to the configuration file for `dprint`.
237
- *
238
- * @default 'dprint.json'
239
- */
240
- dprintConfigPath?: string;
241
- }
242
-
243
- declare function formatters(options?: OptionsFormat & InternalOptionsFormat): Promise<TypedFlatConfigItem[]>;
244
-
245
- declare function ignores(userIgnores?: string[]): TypedFlatConfigItem[];
246
-
247
- declare function imports(options?: OptionsTypeScript): TypedFlatConfigItem[];
248
-
249
- declare function javascript(options?: OptionsJavaScript): TypedFlatConfigItem[];
250
-
251
- declare function json(options?: OptionsJson): TypedFlatConfigItem[];
252
-
253
- declare function jsx(): TypedFlatConfigItem[];
254
-
255
- declare function nextJs(): TypedFlatConfigItem[];
256
-
257
- declare function nodeJs(options?: OptionsNodeJs): TypedFlatConfigItem[];
258
-
259
- declare function react(options?: OptionsReact): TypedFlatConfigItem[];
260
-
261
- declare function regexp(): TypedFlatConfigItem[];
262
-
263
- declare function tailwindcss(): TypedFlatConfigItem[];
264
-
265
- declare function typescript(options?: OptionsTypeScript): TypedFlatConfigItem[];
266
-
267
- declare function unicorn(): TypedFlatConfigItem[];
268
-
269
- type UserConfig = TypedFlatConfigItem | TypedFlatConfigItem[] | FlatConfigComposer<TypedFlatConfigItem, string> | Linter.Config | Linter.Config[];
270
- type SharedOptions<T = object> = Omit<T, 'isInEditor' | 'enable'> & {
271
- enable?: boolean;
272
- };
273
- interface ESLintConfigOptions {
274
- ignores?: string[];
275
- format?: SharedOptions<OptionsFormat> | boolean;
276
- javascript?: SharedOptions<OptionsJavaScript> | boolean;
277
- typescript?: SharedOptions<OptionsTypeScript> | boolean;
278
- json?: SharedOptions<OptionsExtraFiles> | boolean;
279
- react?: SharedOptions<OptionsReact> | boolean;
280
- node?: SharedOptions<OptionsNodeJs> | boolean;
281
- }
282
- /**
283
- * Construct an array of ESLint flat config items.
284
- *
285
- * @param options
286
- * The options for generating the ESLint configurations.
287
- * @param userConfigs
288
- * The user configurations to be merged with the generated configurations.
289
- * @returns The merged ESLint configurations.
290
- */
291
- declare function config(options?: ESLintConfigOptions, ...userConfigs: Awaitable<UserConfig>[]): Promise<TypedFlatConfigItem[]>;
292
-
293
- /**
294
- * Combine array and non-array configs into a single array.
295
- * Copied from antfu/eslint-config
296
- * Ref: https://github.com/antfu/eslint-config/blob/e283983d8cb72304424f67090a3e3bdccdf95c0d/src/utils.ts#L32
297
- */
298
- declare function combine(...configs: Awaitable<TypedFlatConfigItem | TypedFlatConfigItem[]>[]): Promise<TypedFlatConfigItem[]>;
299
-
300
- declare function getFlatConfigName<T extends string>(module: T): {
301
- readonly base: `@biscuittin/eslint-config/${T}`;
302
- readonly setup: `@biscuittin/eslint-config/${T}/setup`;
303
- readonly rules: `@biscuittin/eslint-config/${T}/rules`;
304
- readonly stylistic: `@biscuittin/eslint-config/${T}/stylistic`;
305
- readonly commonjs: `@biscuittin/eslint-config/${T}/commonjs`;
306
- readonly module: `@biscuittin/eslint-config/${T}/module`;
307
- readonly script: `@biscuittin/eslint-config/${T}/script`;
308
- };
309
-
310
- /**
311
- * Copied from SukkaW/eslint-config-sukka
312
- * Ref: https://github.com/SukkaW/eslint-config-sukka/blob/3a04c31727e0b5bab98fda1a6440f9932fe42dd8/packages/shared/src/get-package-json.ts#L1
313
- */
314
-
315
- /**
316
- * Gets a `package.json` data.
317
- * The data is cached if found, then it's used after.
318
- *
319
- * @param startPath - A file path to lookup.
320
- * @returns A found `package.json` data or `null`.
321
- * This object have additional property `filePath`.
322
- */
323
- declare function getPackageJson(startPath?: string): PackageJson | null;
324
-
325
- declare function isInEditorEnv(): boolean;
326
-
327
- declare function isInGitHooksOrLintStaged(): boolean;
328
-
329
- declare function loadLocalFile<T = unknown>(name: string | readonly string[], cwd?: string): Promise<T | null>;
330
-
331
- declare global {
332
- var __ESLINT_PLUGIN_MEMO__: Record<string, unknown> | undefined;
333
- }
334
- /**
335
- * Every package manager has this flaw: Even if a pinned, same version of transitive dependency
336
- * is depended on by multiple packages, all npm/pnpm/yarn/bun will not dedupe it, some package
337
- * manager even doesn't have dedupe feature (yes, bun. You are literally wasting my disk space
338
- * for speed).
339
- *
340
- * But if there are multiple copy of the same version of transitive dependency, they will not have
341
- * the same referential identity, which causes ESLint to panic and throw error.
342
- *
343
- * So we have to memoize the plugins and configs to make sure they are the same referential identity.
344
- *
345
- * Copied from SukkaW/eslint-config-sukka
346
- * Ref: https://github.com/SukkaW/eslint-config-sukka/blob/bbca2d568d738a1d287c473804ea8ccbf00d3c86/packages/shared/src/memoize-eslint-plugin.ts#L17
347
- */
348
- declare function memo<T>(function_: NonNullable<T>, key?: string): T;
349
-
350
- export { type Awaitable, type Rules, type TypedFlatConfigItem, combine, comments, config as default, disables, formatters, getFlatConfigName, getPackageJson, ignores, imports, isInEditorEnv, isInGitHooksOrLintStaged, javascript, json, jsx, loadLocalFile, memo, nextJs, nodeJs, react, regexp, tailwindcss, typescript, unicorn };