@so1ve/eslint-config 2.0.0 → 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.ts CHANGED
@@ -1,40 +1,8 @@
1
1
  import so1vePlugin from '@so1ve/eslint-plugin';
2
- export { default as pluginSo1ve } from '@so1ve/eslint-plugin';
3
2
  import { ParserOptions } from '@typescript-eslint/utils/ts-eslint';
4
3
  import { FlatGitignoreOptions } from 'eslint-config-flat-gitignore';
5
4
  import { Rules, FlatESLintConfigItem } from 'eslint-define-config';
6
- export { default as pluginComments } from '@eslint-community/eslint-plugin-eslint-comments';
7
- export { default as pluginHtml } from '@html-eslint/eslint-plugin';
8
- export { default as parserHtml } from '@html-eslint/parser';
9
- export { default as pluginSortImports } from '@so1ve/eslint-plugin-sort-imports';
10
- export { default as pluginStylistic } from '@stylistic/eslint-plugin';
11
- export { default as parserMdx } from 'eslint-mdx';
12
- export { default as pluginArrayFunc } from 'eslint-plugin-array-func';
13
- export { default as pluginEtc } from 'eslint-plugin-etc';
14
- export { default as pluginHtmlJsSupport } from 'eslint-plugin-html';
15
- export { default as pluginImport } from 'eslint-plugin-i';
16
- export { default as pluginJestFormatting } from 'eslint-plugin-jest-formatting';
17
- export { default as pluginJsonSchemaValidator } from 'eslint-plugin-json-schema-validator';
18
- export { default as pluginJsonc } from 'eslint-plugin-jsonc';
19
- export { default as pluginMdx } from 'eslint-plugin-mdx';
20
- export { default as pluginNode } from 'eslint-plugin-n';
21
- import * as eslintPluginNoAwaitInPromise from 'eslint-plugin-no-await-in-promise';
22
- export { eslintPluginNoAwaitInPromise as pluginNoAwaitInPromise };
23
- export { default as pluginNoOnlyTests } from 'eslint-plugin-no-only-tests';
24
- export { default as pluginOnlyError } from 'eslint-plugin-only-error';
25
- export { default as pluginPromise } from 'eslint-plugin-promise';
26
- export { default as pluginRegexp } from 'eslint-plugin-regexp';
27
- export { default as pluginSolid } from 'eslint-plugin-solid';
28
- export { default as pluginToml } from 'eslint-plugin-toml';
29
- export { default as pluginUnicorn } from 'eslint-plugin-unicorn';
30
- export { default as pluginUnusedImports } from 'eslint-plugin-unused-imports';
31
- export { default as pluginVitest } from 'eslint-plugin-vitest';
32
- export { default as pluginVue } from 'eslint-plugin-vue';
33
- export { default as pluginYaml } from 'eslint-plugin-yml';
34
- export { default as parserJsonc } from 'jsonc-eslint-parser';
35
- export { default as parserToml } from 'toml-eslint-parser';
36
- export { default as parserVue } from 'vue-eslint-parser';
37
- export { default as parserYaml } from 'yaml-eslint-parser';
5
+ import { FlatConfigComposer } from 'eslint-flat-config-utils';
38
6
 
39
7
  interface OptionsComponentExts {
40
8
  /**
@@ -68,6 +36,10 @@ interface Options extends OptionsComponentExts {
68
36
  * Core rules. Can't be disabled.
69
37
  */
70
38
  javascript?: OptionsOverrides;
39
+ /**
40
+ * Enable HTML support.
41
+ */
42
+ html?: boolean;
71
43
  /**
72
44
  * Enable TypeScript support.
73
45
  *
@@ -153,25 +125,27 @@ type MergeIntersection<T extends Record<any, any>> = {
153
125
  };
154
126
  type RenamedRules = MergeIntersection<Rules & RenamePrefix<Rules, "@typescript-eslint/", "ts/"> & RenamePrefix<Rules, "yml/", "yaml/"> & RenamePrefix<Rules, "n/", "node/"> & Prefix<Partial<(typeof so1vePlugin)["rules"]>, "so1ve/">>;
155
127
  type ConfigItem = Omit<FlatESLintConfigItem, "plugins" | "rules"> & {
128
+ name?: string;
156
129
  plugins?: Record<string, any>;
157
130
  rules?: RenamedRules | Record<string, any>;
158
131
  };
132
+ type Awaitable<T> = T | Promise<T>;
159
133
 
160
134
  declare const comments: () => ConfigItem[];
161
135
 
162
- declare const formatting: (options: Options) => ConfigItem[];
136
+ declare function formatting(options: Options): Promise<ConfigItem[]>;
163
137
 
164
- declare const html: () => ConfigItem[];
138
+ declare function html(): Promise<ConfigItem[]>;
165
139
 
166
140
  declare const ignores: () => ConfigItem[];
167
141
 
168
142
  declare const imports: (options?: Options) => ConfigItem[];
169
143
 
170
- declare const javascript: ({ overrides, }?: OptionsOverrides) => ConfigItem[];
144
+ declare function javascript({ overrides }?: OptionsOverrides): Promise<ConfigItem[]>;
171
145
 
172
- declare const jsonc: () => ConfigItem[];
146
+ declare function jsonc(): Promise<ConfigItem[]>;
173
147
 
174
- declare const mdx: ({ componentExts, overrides, }?: OptionsComponentExts & OptionsOverrides) => ConfigItem[];
148
+ declare function mdx({ componentExts, overrides, }?: OptionsComponentExts & OptionsOverrides): Promise<ConfigItem[]>;
175
149
 
176
150
  declare const node: () => ConfigItem[];
177
151
 
@@ -179,26 +153,34 @@ declare const onlyError: () => ConfigItem[];
179
153
 
180
154
  declare const promise: () => ConfigItem[];
181
155
 
182
- declare const solid: ({ overrides, typescript, }?: OptionsHasTypeScript & OptionsOverrides) => ConfigItem[];
156
+ declare function solid({ overrides, typescript, }?: OptionsHasTypeScript & OptionsOverrides): Promise<ConfigItem[]>;
183
157
 
184
158
  declare const sortImports: () => ConfigItem[];
185
159
 
186
- declare const test: ({ overrides }?: OptionsOverrides) => ConfigItem[];
160
+ declare function test({ overrides }?: OptionsOverrides): Promise<ConfigItem[]>;
187
161
 
188
- declare const toml: ({ overrides }?: OptionsOverrides) => ConfigItem[];
162
+ declare function toml({ overrides }?: OptionsOverrides): Promise<ConfigItem[]>;
189
163
 
190
- declare function typescript({ componentExts, parserOptions, overrides, }?: OptionsTypeScriptParserOptions & OptionsComponentExts & OptionsOverrides): ConfigItem[];
164
+ declare function typescript({ componentExts, parserOptions, overrides, }?: OptionsTypeScriptParserOptions & OptionsComponentExts & OptionsOverrides): Promise<ConfigItem[]>;
191
165
 
192
166
  declare const unicorn: () => ConfigItem[];
193
167
 
194
- declare const vue: ({ overrides, typescript, }?: OptionsHasTypeScript & OptionsOverrides) => ConfigItem[];
168
+ declare function vue({ overrides, typescript, }?: OptionsHasTypeScript & OptionsOverrides): Promise<ConfigItem[]>;
195
169
 
196
- declare const yaml: ({ overrides }?: OptionsOverrides) => ConfigItem[];
170
+ declare function yaml({ overrides }?: OptionsOverrides): Promise<ConfigItem[]>;
197
171
 
172
+ declare const defaultPluginRenaming: {
173
+ "@stylistic": string;
174
+ "@typescript-eslint": string;
175
+ "@html-eslint": string;
176
+ "import-x": string;
177
+ n: string;
178
+ yml: string;
179
+ };
198
180
  /**
199
181
  * Construct an array of ESLint flat config items.
200
182
  */
201
- declare function so1ve(options?: Options & ConfigItem, ...userConfigs: (ConfigItem | ConfigItem[])[]): ConfigItem[];
183
+ declare function so1ve(options?: Options & ConfigItem, ...userConfigs: (ConfigItem | ConfigItem[])[]): FlatConfigComposer<any, any>;
202
184
  type ResolvedOptions<T> = T extends boolean ? never : NonNullable<T>;
203
185
  declare const resolveSubOptions: <K extends keyof Options>(options: Options & ConfigItem, key: K) => ResolvedOptions<Options[K]>;
204
186
  declare function getOverrides<K extends keyof Options>(options: Options, key: K): any;
@@ -230,11 +212,31 @@ declare const GLOB_TESTS: string[];
230
212
  declare const GLOB_ALL_SRC: string[];
231
213
  declare const GLOB_EXCLUDE: string[];
232
214
 
233
- declare const renameRules: (rules: Record<string, any>, from: string, to: string) => {
215
+ /**
216
+ * Rename plugin prefixes in a rule object. Accepts a map of prefixes to rename.
217
+ *
218
+ * @example
219
+ *
220
+ * ```ts
221
+ * import { renameRules } from "@antfu/eslint-config";
222
+ *
223
+ * export default [
224
+ * {
225
+ * rules: renameRules(
226
+ * {
227
+ * "@typescript-eslint/indent": "error",
228
+ * },
229
+ * { "@typescript-eslint": "ts" },
230
+ * ),
231
+ * },
232
+ * ];
233
+ * ```
234
+ */
235
+ declare const renameRules: (rules: Record<string, any>, map: Record<string, string>) => {
234
236
  [k: string]: any;
235
237
  };
236
- declare function recordRulesStateConfigs(configs: ConfigItem[]): ConfigItem[];
237
- declare function recordRulesState(rules: ConfigItem["rules"]): ConfigItem["rules"];
238
- declare function warnUnnecessaryOffRules(): void;
238
+ declare function interopDefault<T>(m: Awaitable<T>): Promise<T extends {
239
+ default: infer U;
240
+ } ? U : T>;
239
241
 
240
- export { type ConfigItem, GLOB_ALL_SRC, GLOB_CSS, GLOB_DTS, GLOB_ESLINTRC, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_PACKAGEJSON, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSCONFIG, GLOB_TSX, GLOB_VUE, GLOB_YAML, type Options, type OptionsComponentExts, type OptionsHasTypeScript, type OptionsOverrides, type OptionsTypeScriptParserOptions, type RenamedRules, type ResolvedOptions, comments, formatting, getOverrides, html, ignores, imports, javascript, jsonc, mdx, node, onlyError, promise, recordRulesState, recordRulesStateConfigs, renameRules, resolveSubOptions, so1ve, solid, sortImports, test, toml, typescript, unicorn, vue, warnUnnecessaryOffRules, yaml };
242
+ export { type Awaitable, type ConfigItem, GLOB_ALL_SRC, GLOB_CSS, GLOB_DTS, GLOB_ESLINTRC, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_PACKAGEJSON, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSCONFIG, GLOB_TSX, GLOB_VUE, GLOB_YAML, type Options, type OptionsComponentExts, type OptionsHasTypeScript, type OptionsOverrides, type OptionsTypeScriptParserOptions, type RenamedRules, type ResolvedOptions, comments, defaultPluginRenaming, formatting, getOverrides, html, ignores, imports, interopDefault, javascript, jsonc, mdx, node, onlyError, promise, renameRules, resolveSubOptions, so1ve, solid, sortImports, test, toml, typescript, unicorn, vue, yaml };