@jsse/eslint-config 0.4.9 → 0.4.11

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.
Files changed (104) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +1 -1
  3. package/dist/cli.js +9 -6
  4. package/dist/index.d.ts +2 -1
  5. package/dist/index.js +29 -123
  6. package/dist/version-Cmu7XVG1.js +39 -0
  7. package/package.json +12 -9
  8. package/dist/esm/cli.d.ts +0 -1
  9. package/dist/esm/cli.js +0 -121
  10. package/dist/esm/config-fns.d.ts +0 -138
  11. package/dist/esm/config-fns.js +0 -161
  12. package/dist/esm/configs/antfu.d.ts +0 -4
  13. package/dist/esm/configs/antfu.js +0 -30
  14. package/dist/esm/configs/command.d.ts +0 -10
  15. package/dist/esm/configs/command.js +0 -17
  16. package/dist/esm/configs/de-morgan.d.ts +0 -2
  17. package/dist/esm/configs/de-morgan.js +0 -9
  18. package/dist/esm/configs/eslint-comments.d.ts +0 -2
  19. package/dist/esm/configs/eslint-comments.js +0 -16
  20. package/dist/esm/configs/gql.d.ts +0 -2
  21. package/dist/esm/configs/gql.js +0 -4
  22. package/dist/esm/configs/ignores.d.ts +0 -2
  23. package/dist/esm/configs/ignores.js +0 -9
  24. package/dist/esm/configs/imports.d.ts +0 -2
  25. package/dist/esm/configs/imports.js +0 -28
  26. package/dist/esm/configs/javascript.d.ts +0 -6
  27. package/dist/esm/configs/javascript.js +0 -262
  28. package/dist/esm/configs/jsdoc.d.ts +0 -2
  29. package/dist/esm/configs/jsdoc.js +0 -31
  30. package/dist/esm/configs/jsonc.d.ts +0 -4
  31. package/dist/esm/configs/jsonc.js +0 -76
  32. package/dist/esm/configs/markdown.d.ts +0 -4
  33. package/dist/esm/configs/markdown.js +0 -122
  34. package/dist/esm/configs/n.d.ts +0 -2
  35. package/dist/esm/configs/n.js +0 -21
  36. package/dist/esm/configs/no-only-tests.d.ts +0 -4
  37. package/dist/esm/configs/no-only-tests.js +0 -31
  38. package/dist/esm/configs/perfectionist.d.ts +0 -7
  39. package/dist/esm/configs/perfectionist.js +0 -60
  40. package/dist/esm/configs/pnpm.d.ts +0 -2
  41. package/dist/esm/configs/pnpm.js +0 -34
  42. package/dist/esm/configs/prettier.d.ts +0 -7
  43. package/dist/esm/configs/prettier.js +0 -126
  44. package/dist/esm/configs/react.d.ts +0 -6
  45. package/dist/esm/configs/react.js +0 -300
  46. package/dist/esm/configs/sort-package-json.d.ts +0 -7
  47. package/dist/esm/configs/sort-package-json.js +0 -102
  48. package/dist/esm/configs/sort-tsconfig.d.ts +0 -14
  49. package/dist/esm/configs/sort-tsconfig.js +0 -135
  50. package/dist/esm/configs/stylistic.d.ts +0 -2
  51. package/dist/esm/configs/stylistic.js +0 -39
  52. package/dist/esm/configs/tailwind.d.ts +0 -1
  53. package/dist/esm/configs/tailwind.js +0 -81
  54. package/dist/esm/configs/toml.d.ts +0 -2
  55. package/dist/esm/configs/toml.js +0 -50
  56. package/dist/esm/configs/ts/parser.d.ts +0 -7
  57. package/dist/esm/configs/ts/parser.js +0 -71
  58. package/dist/esm/configs/ts/requires-type-checking.d.ts +0 -1
  59. package/dist/esm/configs/ts/requires-type-checking.js +0 -61
  60. package/dist/esm/configs/ts/typescript-language-options.d.ts +0 -2
  61. package/dist/esm/configs/ts/typescript-language-options.js +0 -22
  62. package/dist/esm/configs/ts/typescript-rules.d.ts +0 -11
  63. package/dist/esm/configs/ts/typescript-rules.js +0 -379
  64. package/dist/esm/configs/ts/typescript.d.ts +0 -4
  65. package/dist/esm/configs/ts/typescript.js +0 -123
  66. package/dist/esm/configs/tsdoc.d.ts +0 -2
  67. package/dist/esm/configs/tsdoc.js +0 -16
  68. package/dist/esm/configs/unicorn.d.ts +0 -2
  69. package/dist/esm/configs/unicorn.js +0 -114
  70. package/dist/esm/configs/vitest.d.ts +0 -4
  71. package/dist/esm/configs/vitest.js +0 -29
  72. package/dist/esm/configs/yml.d.ts +0 -4
  73. package/dist/esm/configs/yml.js +0 -51
  74. package/dist/esm/const.d.ts +0 -5
  75. package/dist/esm/const.js +0 -25
  76. package/dist/esm/define-config.d.ts +0 -7
  77. package/dist/esm/define-config.js +0 -256
  78. package/dist/esm/dev.d.ts +0 -4
  79. package/dist/esm/dev.js +0 -25
  80. package/dist/esm/fixable.d.ts +0 -2
  81. package/dist/esm/fixable.js +0 -4
  82. package/dist/esm/generated/fixable-rules-map.d.ts +0 -2
  83. package/dist/esm/generated/fixable-rules-map.js +0 -443
  84. package/dist/esm/generated/version.d.ts +0 -1
  85. package/dist/esm/generated/version.js +0 -1
  86. package/dist/esm/globs.d.ts +0 -25
  87. package/dist/esm/globs.js +0 -73
  88. package/dist/esm/index.d.ts +0 -9
  89. package/dist/esm/index.js +0 -8
  90. package/dist/esm/lager.d.ts +0 -32
  91. package/dist/esm/lager.js +0 -87
  92. package/dist/esm/log.d.ts +0 -2
  93. package/dist/esm/log.js +0 -2
  94. package/dist/esm/plugins-all.d.ts +0 -26
  95. package/dist/esm/plugins-all.js +0 -120
  96. package/dist/esm/plugins.d.ts +0 -1570
  97. package/dist/esm/plugins.js +0 -97
  98. package/dist/esm/presets.d.ts +0 -18
  99. package/dist/esm/presets.js +0 -75
  100. package/dist/esm/types.d.ts +0 -287
  101. package/dist/esm/types.js +0 -1
  102. package/dist/esm/utils.d.ts +0 -51
  103. package/dist/esm/utils.js +0 -156
  104. package/dist/version-DNhPWuQE.js +0 -5
@@ -1,97 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-unsafe-assignment,@typescript-eslint/explicit-function-return-type */
2
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
3
- // @ts-nocheck
4
- import { interopDefault } from "./utils.js";
5
- // @ts-expect-error - bad types
6
- export { default as pluginEslintComments } from "@eslint-community/eslint-plugin-eslint-comments";
7
- export { default as pluginTs } from "@typescript-eslint/eslint-plugin";
8
- export * as parserTs from "@typescript-eslint/parser";
9
- export { default as pluginAntfu } from "eslint-plugin-antfu";
10
- export { default as pluginDeMorgan } from "eslint-plugin-de-morgan";
11
- export { default as pluginImportLite } from "eslint-plugin-import-lite";
12
- export { default as pluginN } from "eslint-plugin-n";
13
- export { default as pluginPerfectionist } from "eslint-plugin-perfectionist";
14
- export { default as pluginPnpm } from "eslint-plugin-pnpm";
15
- export { default as pluginUnicorn } from "eslint-plugin-unicorn";
16
- export { default as pluginUnusedImports } from "eslint-plugin-unused-imports";
17
- export async function importPluginUnicorn() {
18
- const pluginUnicorn = await interopDefault(import("eslint-plugin-unicorn"));
19
- return {
20
- pluginUnicorn,
21
- };
22
- }
23
- export async function importPluginReact() {
24
- const pluginReact = await interopDefault(import("eslint-plugin-react"));
25
- return {
26
- pluginReact,
27
- };
28
- }
29
- export async function importPluginReactHooks() {
30
- const pluginReactHooks = await interopDefault(import("eslint-plugin-react-hooks"));
31
- return {
32
- pluginReactHooks,
33
- };
34
- }
35
- export async function importPluginReactRefresh() {
36
- const pluginReactRefresh = await interopDefault(import("eslint-plugin-react-refresh"));
37
- return {
38
- pluginReactRefresh,
39
- };
40
- }
41
- export async function importReactPlugins() {
42
- const [pluginReact, pluginReactHooks, pluginReactRefresh] = await Promise.all([
43
- interopDefault(import("eslint-plugin-react")),
44
- interopDefault(import("eslint-plugin-react-hooks")),
45
- interopDefault(import("eslint-plugin-react-refresh")),
46
- ]);
47
- return { pluginReact, pluginReactHooks, pluginReactRefresh };
48
- }
49
- export async function importParserJsonc() {
50
- const parserJsonc = await interopDefault(import("jsonc-eslint-parser"));
51
- return {
52
- parserJsonc,
53
- };
54
- }
55
- export async function importPluginJsonc() {
56
- const pluginJsonc = await interopDefault(import("eslint-plugin-jsonc"));
57
- return {
58
- pluginJsonc,
59
- };
60
- }
61
- export async function importJsoncLibs() {
62
- const [{ parserJsonc }, { pluginJsonc }] = await Promise.all([
63
- importParserJsonc(),
64
- importPluginJsonc(),
65
- ]);
66
- return { parserJsonc, pluginJsonc };
67
- }
68
- export async function importYmlLibs() {
69
- const [pluginYaml, parserYaml] = await Promise.all([
70
- interopDefault(import("eslint-plugin-yml")),
71
- interopDefault(import("yaml-eslint-parser")),
72
- ]);
73
- return { parserYaml, pluginYaml };
74
- }
75
- export async function importPluginMarkdown() {
76
- const pluginMarkdown = await interopDefault(import("@eslint/markdown"));
77
- return {
78
- pluginMarkdown,
79
- };
80
- }
81
- export async function importPluginJsdoc() {
82
- const pluginJsdoc = await interopDefault(import("eslint-plugin-jsdoc"));
83
- // get the import path
84
- return {
85
- pluginJsdoc,
86
- };
87
- }
88
- export async function importPluginTsdoc() {
89
- const pluginTsdoc = (await interopDefault(import("eslint-plugin-tsdoc")));
90
- return {
91
- pluginTsdoc,
92
- };
93
- }
94
- export async function importPluginStylistic() {
95
- const pluginStylistic = await interopDefault(import("@stylistic/eslint-plugin"));
96
- return { pluginStylistic };
97
- }
@@ -1,18 +0,0 @@
1
- import type { Config } from "./types.js";
2
- import { type DefineConfig } from "./define-config.js";
3
- export declare const jsseReact: DefineConfig;
4
- /** Ignore common files and include javascript support */
5
- export declare const presetJavascript: () => Promise<Config[]>;
6
- /** Includes markdown, yaml + `presetJsonc` support */
7
- export declare const presetLangsExtensions: () => Promise<Config[]>;
8
- /** Includes `presetJavaScript` and typescript support */
9
- export declare const presetBasic: () => Promise<Config[]>;
10
- /**
11
- * Includes
12
- * - `presetBasic` (JS+TS) support
13
- * - `presetLangsExtensions` (markdown, yaml, jsonc) support
14
- * - Vue support
15
- * - UnoCSS support (`uno.config.ts` is required)
16
- * - Prettier support
17
- */
18
- export declare const presetAll: () => Promise<Config[]>;
@@ -1,75 +0,0 @@
1
- import { command, eslintComments, ignores, imports, javascript, jsdoc, jsonc, markdown, n, sortPackageJson, sortTsconfig, typescript, unicorn, yml, } from "./config-fns.js";
2
- import { deMorgan } from "./configs/de-morgan.js";
3
- import { jsse } from "./define-config.js";
4
- const makePresetFn = (cfgFunctions) => {
5
- return async () => {
6
- const results = await Promise.allSettled(cfgFunctions.map((fn) => fn()));
7
- const ok = [];
8
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
9
- const err = [];
10
- for (const result of results) {
11
- if (result.status === "fulfilled") {
12
- ok.push(...result.value);
13
- }
14
- else {
15
- err.push(result.reason);
16
- }
17
- }
18
- if (err.length > 0) {
19
- const errorMessage = `Some preset functions failed: ${err
20
- .map((e) => {
21
- return e instanceof Error ? e.message : JSON.stringify(e);
22
- })
23
- .join(", ")}`;
24
- throw new Error(errorMessage);
25
- }
26
- return ok;
27
- };
28
- };
29
- export const jsseReact = (options, ...configs) => {
30
- return jsse({
31
- react: true,
32
- reactRefresh: true,
33
- typescript: {
34
- tsconfig: ["./tsconfig.json", "./tsconfig.eslint.json"],
35
- },
36
- ...options,
37
- },
38
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
39
- ...configs);
40
- };
41
- /** Ignore common files and include javascript support */
42
- export const presetJavascript = makePresetFn([
43
- ignores,
44
- javascript,
45
- eslintComments,
46
- imports,
47
- unicorn,
48
- n,
49
- jsdoc,
50
- deMorgan,
51
- ]);
52
- /** Includes basic json(c) file support and sorting json keys */
53
- const presetJsonc = makePresetFn([
54
- jsonc,
55
- sortPackageJson,
56
- sortTsconfig,
57
- // ...sortPnpmWorkspace(),
58
- ]);
59
- /** Includes markdown, yaml + `presetJsonc` support */
60
- export const presetLangsExtensions = makePresetFn([markdown, yml, presetJsonc]);
61
- /** Includes `presetJavaScript` and typescript support */
62
- export const presetBasic = makePresetFn([presetJavascript, typescript]);
63
- /**
64
- * Includes
65
- * - `presetBasic` (JS+TS) support
66
- * - `presetLangsExtensions` (markdown, yaml, jsonc) support
67
- * - Vue support
68
- * - UnoCSS support (`uno.config.ts` is required)
69
- * - Prettier support
70
- */
71
- export const presetAll = makePresetFn([
72
- presetBasic,
73
- presetLangsExtensions,
74
- command,
75
- ]);
@@ -1,287 +0,0 @@
1
- import type { ParserOptions } from "@typescript-eslint/parser";
2
- import type { Linter } from "eslint";
3
- import type { FlatGitignoreOptions } from "eslint-config-flat-gitignore";
4
- import type { RuleOptionsUnion as Rules } from "./generated/rule-options.js";
5
- export type Config = Omit<Linter.Config<Linter.RulesRecord & Rules>, "plugins"> & {
6
- /**
7
- * 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.
8
- *
9
- * @see [Using plugins in your configuration](https://eslint.org/docs/latest/user-guide/configuring/configuration-files-new#using-plugins-in-your-configuration)
10
- */
11
- plugins?: Record<string, any>;
12
- };
13
- export type Awaitable<T> = T | Promise<T>;
14
- export type UnPromise<T> = T extends Promise<infer U> ? U : T;
15
- export type LanguageOptions = Linter.Config["languageOptions"];
16
- export type RuleName = keyof Rules;
17
- export type TypedFlatConfigItemWithId = Config & {
18
- name: string;
19
- };
20
- export type OptionsCommon = {
21
- debug?: boolean;
22
- /**
23
- * The prefix for the name of the config item.
24
- *
25
- * @default "jsse"
26
- */
27
- rootName?: string;
28
- /**
29
- * Type of the project. `lib` will enable more strict rules for libraries.
30
- *
31
- * @default 'lib'
32
- */
33
- type?: "app" | "lib";
34
- };
35
- export type OptionsComponentExts = {
36
- /**
37
- * Additional extensions for components.
38
- *
39
- * @example ['vue']
40
- * @default []
41
- */
42
- componentExts?: string[];
43
- };
44
- export type EslintConfigFn<T = undefined> = (options?: T) => Promise<Config[]>;
45
- export type OptionsFiles = {
46
- /**
47
- * Override the `files` option to provide custom globs.
48
- */
49
- files?: string[];
50
- };
51
- export type OptionsTypeScriptParserOptions = {
52
- /**
53
- * Additional parser options for TypeScript.
54
- */
55
- parserOptions?: Partial<ParserOptions>;
56
- /**
57
- * Flag to use `projectService` for type-aware linting (default: `false`).
58
- *
59
- * If `true` use fancy new `projectService` for type-aware linting
60
- * If `false` use classic `project` configuration
61
- */
62
- useProjectService?: boolean;
63
- /**
64
- * Glob patterns for files that should be type aware.
65
- * @default ['**\/*.{ts,tsx}']
66
- */
67
- filesTypeAware?: string[];
68
- /**
69
- * Glob patterns for files that should not be type aware.
70
- * @default ['**\/*.md\/**']
71
- */
72
- ignoresTypeAware?: string[];
73
- };
74
- export type OptionsTypeScriptWithTypes = {
75
- /**
76
- * When this options is provided, type aware rules will be enabled.
77
- * @see https://typescript-eslint.io/linting/typed-linting/
78
- */
79
- tsconfig?: string | string[];
80
- /**
81
- * Override type aware rules.
82
- */
83
- overridesTypeAware?: Config["rules"];
84
- /**
85
- * strict vs recommended configs
86
- * @default false
87
- */
88
- strict?: boolean;
89
- /**
90
- * typeAware
91
- */
92
- typeAware?: boolean;
93
- };
94
- export type OptionsTypescript = (OptionsTypeScriptWithTypes & OptionsOverrides) | (OptionsTypeScriptParserOptions & OptionsOverrides);
95
- export type OptionsHasTypeScript = {
96
- typescript?: boolean;
97
- };
98
- export type OptionsStylistic = {
99
- stylistic?: boolean | StylisticConfig;
100
- };
101
- export type StylisticConfig = {
102
- indent?: number | "tab";
103
- quotes?: "single" | "double";
104
- jsx?: boolean;
105
- };
106
- export type OptionsPrefix = {
107
- prefix?: {
108
- from: string;
109
- to: string;
110
- };
111
- };
112
- export type OptionsOverrides = {
113
- overrides?: Config["rules"];
114
- };
115
- export type OptionsIsInEditor = {
116
- isInEditor?: boolean;
117
- };
118
- export type OptionsReact = {
119
- react?: boolean;
120
- reactRefresh?: boolean;
121
- };
122
- /**
123
- * Tailwind CSS ESLint settings
124
- */
125
- export type TailwindEslintSettings = {
126
- /**
127
- * call expressions to check for tailwind classes
128
- * @default ["classnames", "clsx", "ctl", "cn", "cx", "twMerge", "twJoin"]
129
- */
130
- callees: string[];
131
- classRegex: string;
132
- config: string;
133
- cssFiles: string[];
134
- cssFilesRefreshRate: number;
135
- removeDuplicates: boolean;
136
- skipClassAttribute: boolean;
137
- tags: string[];
138
- whitelist: string[];
139
- };
140
- export type TailwindOptions = Partial<TailwindEslintSettings> | boolean | undefined;
141
- export type OptionsConfig = {
142
- /**
143
- * Enable debug mode.
144
- */
145
- debug?: boolean;
146
- /**
147
- * Enable reporting of unused disable directives.
148
- *
149
- * @default true
150
- */
151
- reportUnusedDisableDirectives?: boolean;
152
- /**
153
- * Array of rules to turn off.
154
- */
155
- off?: string[];
156
- /**
157
- * Enable `eslint-plugin-command`
158
- *
159
- * @default true
160
- */
161
- command?: boolean;
162
- /**
163
- * Enable fast mode.
164
- *
165
- * This will disable some rules to speed up linting.
166
- */
167
- fast?: boolean;
168
- /**
169
- * Enable Prettier config rules to disable conflicting ESLint rules
170
- *
171
- * THIS DOES NOT ENABLE PRETTIER FORMATTING. YOU DO THAT, BUT I
172
- * RECOMMEND USING PRETTIER TO FORMAT AND NOT THE ESLINT PRETTIER
173
- * PLUGIN!.
174
- */
175
- prettier?: boolean;
176
- /**
177
- * Enable eslint-plugin-pnpm.
178
- *
179
- * @default false
180
- */
181
- pnpm?: boolean;
182
- /**
183
- * Enable Tailwind CSS support.
184
- *
185
- * Passing an object to configure the options.
186
- *
187
- * @default true
188
- */
189
- tailwind?: TailwindOptions;
190
- /**
191
- * The prefix for the name of the config item.
192
- * @default "jsse"
193
- */
194
- rootId?: string;
195
- /**
196
- * Optional function to run before the final config is returned.
197
- */
198
- preReturn?: (configs: Config[]) => Config[] | Awaitable<Config[]>;
199
- /**
200
- * Enable gitignore support.
201
- *
202
- * Passing an object to configure the options.
203
- *
204
- * @see https://github.com/antfu/eslint-config-flat-gitignore
205
- * @default true
206
- */
207
- gitignore?: boolean | FlatGitignoreOptions;
208
- tsPrefix?: string;
209
- /**
210
- * Glob patterns for ADDITIONAL tsconfig files to lint (aka sort)
211
- *
212
- * Has nothing to do with `@typescript-eslint/parser` or `typescript-eslint/eslint-plugin`
213
- * @default ['tsconfig.json', 'tsconfig.*.json']
214
- */
215
- extendTsconfigLintGlobs?: string[];
216
- /**
217
- * Enable TypeScript support.
218
- *
219
- * Passing an object to enable TypeScript Language Server support.
220
- *
221
- * @default auto-detect based on the dependencies
222
- */
223
- typescript?: boolean | OptionsTypeScriptWithTypes;
224
- /**
225
- * Forcibly disable type aware rules
226
- */
227
- typeAware?: boolean;
228
- react?: boolean;
229
- reactRefresh?: boolean;
230
- /**
231
- * Enable JSX related rules.
232
- *
233
- * Currently only stylistic rules are included.
234
- *
235
- * @default true
236
- */
237
- jsx?: boolean;
238
- /**
239
- * Enable test support.
240
- *
241
- * @default true
242
- */
243
- test?: boolean;
244
- /**
245
- * Enable JSONC support.
246
- *
247
- * @default true
248
- */
249
- jsonc?: boolean;
250
- /**
251
- * Enable YAML support.
252
- *
253
- * @default true
254
- */
255
- yaml?: boolean;
256
- /**
257
- * Enable Markdown support.
258
- *
259
- * @default true
260
- */
261
- markdown?: boolean;
262
- /**
263
- * Enable stylistic rules.
264
- *
265
- * @default true
266
- */
267
- stylistic?: boolean | StylisticConfig;
268
- /**
269
- * Control to disable some rules in editors.
270
- * @default auto-detect based on the process.env
271
- */
272
- isInEditor?: boolean;
273
- /**
274
- * Provide overrides for rules for each integration.
275
- */
276
- overrides?: {
277
- javascript?: Config["rules"];
278
- typescript?: Config["rules"];
279
- test?: Config["rules"];
280
- jsonc?: Config["rules"];
281
- markdown?: Config["rules"];
282
- yaml?: Config["rules"];
283
- };
284
- } & OptionsComponentExts & OptionsTypeScriptParserOptions;
285
- export type RenamePefix<T extends Record<string, unknown>, FromPref extends string, ToPref extends string> = {
286
- [K in keyof T as K extends `${FromPref}${infer Rest}` ? `${ToPref}${Rest}` : K]: T[K];
287
- };
package/dist/esm/types.js DELETED
@@ -1 +0,0 @@
1
- export {};
@@ -1,51 +0,0 @@
1
- import type { Linter } from "eslint";
2
- import type { Awaitable, Config } from "./types.js";
3
- /**
4
- * Combine array and non-array configs into a single array.
5
- */
6
- export declare function combine(...configs: Awaitable<Config | Config[]>[]): Promise<Config[]>;
7
- /**
8
- * Combine array and non-array configs into a single array.
9
- */
10
- export declare function combineAsync<T>(...configs: Awaitable<T | T[]>[]): Promise<T[]>;
11
- export declare function renameRules<TRule = unknown>(rules: Record<string, TRule>, from: string, to: string): Record<string, TRule>;
12
- export declare function interopDefault<T>(m: Awaitable<T>): Promise<T extends {
13
- default: infer U;
14
- } ? U : T>;
15
- export declare function isCI(): boolean;
16
- export declare function isInEditor(): boolean;
17
- /**
18
- * Make an array of strings unique maintaining order.
19
- * @param strings strings to make unique
20
- * @returns unique strings
21
- */
22
- export declare function uniqueStrings(...strings: (string | string[])[]): string[];
23
- export declare const parserPlain: {
24
- meta: {
25
- name: string;
26
- };
27
- parseForESLint: (code: string) => {
28
- ast: {
29
- body: never[];
30
- comments: never[];
31
- loc: {
32
- end: number;
33
- start: number;
34
- };
35
- range: number[];
36
- tokens: never[];
37
- type: string;
38
- };
39
- scopeManager: undefined;
40
- services: {
41
- isPlain: boolean;
42
- };
43
- visitorKeys: {
44
- Program: never[];
45
- };
46
- };
47
- };
48
- export declare function turnOffRules(configs: Config[], off: string[]): Config[];
49
- export declare function changeRuleEntrySeverity(ruleConfig: Linter.RuleEntry<any>, level: Linter.RuleSeverity): Linter.RuleEntry<any>;
50
- export declare function error2warn<T extends Config>(configs: T[]): T[];
51
- export declare function warn2error<T extends Config>(configs: T[]): T[];
package/dist/esm/utils.js DELETED
@@ -1,156 +0,0 @@
1
- import process from "node:process";
2
- import { log } from "./log.js";
3
- /**
4
- * Combine array and non-array configs into a single array.
5
- */
6
- export async function combine(...configs) {
7
- const resolved = await Promise.all(configs);
8
- return resolved.flat();
9
- }
10
- /**
11
- * Combine array and non-array configs into a single array.
12
- */
13
- export async function combineAsync(...configs) {
14
- const resolved = await Promise.all(configs);
15
- return resolved.flatMap((config) => Array.isArray(config) ? config : [config]);
16
- }
17
- export function renameRules(rules, from, to) {
18
- if (from === to) {
19
- return rules;
20
- }
21
- return Object.fromEntries(Object.entries(rules).map(([key, value]) => {
22
- if (key.startsWith(from)) {
23
- return [to + key.slice(from.length), value];
24
- }
25
- return [key, value];
26
- }));
27
- }
28
- export async function interopDefault(m) {
29
- const resolved = await m;
30
- // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access
31
- return resolved.default || resolved;
32
- }
33
- export function isCI() {
34
- return !!process.env.CI;
35
- }
36
- export function isInEditor() {
37
- return !!((process.env.VSCODE_PID || process.env.JETBRAINS_IDE) && !isCI());
38
- }
39
- /**
40
- * Make an array of strings unique maintaining order.
41
- * @param strings strings to make unique
42
- * @returns unique strings
43
- */
44
- export function uniqueStrings(...strings) {
45
- const set = new Set();
46
- for (const item of strings) {
47
- if (typeof item === "string") {
48
- set.add(item);
49
- }
50
- else {
51
- for (const str of item) {
52
- set.add(str);
53
- }
54
- }
55
- }
56
- return [...set];
57
- }
58
- export const parserPlain = {
59
- meta: {
60
- name: "parser-plain",
61
- },
62
- parseForESLint: (code) => ({
63
- ast: {
64
- body: [],
65
- comments: [],
66
- loc: { end: code.length, start: 0 },
67
- range: [0, code.length],
68
- tokens: [],
69
- type: "Program",
70
- },
71
- scopeManager: undefined,
72
- services: { isPlain: true },
73
- visitorKeys: {
74
- Program: [],
75
- },
76
- }),
77
- };
78
- export function turnOffRules(configs, off) {
79
- if (off.length > 0) {
80
- // turrning off rules
81
- // duplicate off rules
82
- for (const rule of off) {
83
- log.debug(`turning-off: ${rule}`);
84
- }
85
- const currentlyActiveRules = new Set();
86
- for (const config of configs) {
87
- for (const rule of Object.keys(config.rules ?? {}))
88
- currentlyActiveRules.add(rule);
89
- }
90
- // warn if off is not in currentlyActiveRules
91
- for (const rule of off) {
92
- if (!currentlyActiveRules.has(rule)) {
93
- log.info(`Rule \`${rule}\` is not active in the current config, you can remove it from the off list`);
94
- }
95
- }
96
- for (const config of configs) {
97
- // turn off each rule...
98
- const cfgRules = config.rules;
99
- if (cfgRules) {
100
- for (const rule of off) {
101
- if (cfgRules[rule] !== undefined &&
102
- cfgRules[rule] !== "off" &&
103
- cfgRules[rule] !== 0) {
104
- cfgRules[rule] = "off";
105
- }
106
- }
107
- }
108
- }
109
- }
110
- return configs;
111
- }
112
- export function changeRuleEntrySeverity(
113
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
114
- ruleConfig, level) {
115
- if (Array.isArray(ruleConfig)) {
116
- // here its [level, options]
117
- if (ruleConfig[0] !== level) {
118
- ruleConfig[0] = level;
119
- }
120
- return ruleConfig;
121
- }
122
- return level;
123
- }
124
- export function error2warn(configs) {
125
- for (const config of configs) {
126
- if (config.rules) {
127
- config.rules = Object.fromEntries(Object.entries(config.rules).map(([key, value]) => {
128
- if (value === "error" || value === 2) {
129
- return [key, changeRuleEntrySeverity(value, "warn")];
130
- }
131
- if (Array.isArray(value) &&
132
- (value[0] === "error" || value[0] === 2)) {
133
- return [key, changeRuleEntrySeverity(value, "warn")];
134
- }
135
- return [key, value];
136
- }));
137
- }
138
- }
139
- return configs;
140
- }
141
- export function warn2error(configs) {
142
- for (const config of configs) {
143
- if (config.rules) {
144
- config.rules = Object.fromEntries(Object.entries(config.rules).map(([key, value]) => {
145
- if (value === "warn" || value === 1) {
146
- return [key, changeRuleEntrySeverity(value, "error")];
147
- }
148
- if (Array.isArray(value) && (value[0] === "warn" || value[0] === 1)) {
149
- return [key, changeRuleEntrySeverity(value, "error")];
150
- }
151
- return [key, value];
152
- }));
153
- }
154
- }
155
- return configs;
156
- }
@@ -1,5 +0,0 @@
1
- //#region src/generated/version.ts
2
- const VERSION = "0.4.9";
3
-
4
- //#endregion
5
- export { VERSION };