@vp-tw/eslint-config 0.0.9 → 0.0.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 (58) hide show
  1. package/README.md +32 -1
  2. package/dist/configs/mdx.d.ts +22 -4
  3. package/dist/configs/mdx.js +72 -18
  4. package/dist/configs/prettier.d.ts +18 -1
  5. package/dist/configs/prettier.js +27 -4
  6. package/dist/configs/storybook.d.ts +24 -1
  7. package/dist/configs/storybook.js +68 -24
  8. package/dist/eslint-typegen.js +1 -1
  9. package/dist/esm/configs/mdx.d.ts +22 -4
  10. package/dist/esm/configs/mdx.mjs +82 -18
  11. package/dist/esm/configs/prettier.d.ts +18 -1
  12. package/dist/esm/configs/prettier.mjs +27 -3
  13. package/dist/esm/configs/storybook.d.ts +24 -1
  14. package/dist/esm/configs/storybook.mjs +72 -14
  15. package/dist/esm/eslint-typegen.mjs +1 -1
  16. package/dist/esm/extends/_utils.d.ts +2 -0
  17. package/dist/esm/extends/_utils.mjs +2 -0
  18. package/dist/esm/extends/imports.d.ts +25 -0
  19. package/dist/esm/extends/imports.mjs +87 -0
  20. package/dist/esm/extends/javascript.d.ts +21 -0
  21. package/dist/esm/extends/javascript.mjs +51 -0
  22. package/dist/esm/extends/jsonc.d.ts +30 -0
  23. package/dist/esm/extends/jsonc.mjs +149 -0
  24. package/dist/esm/extends/react.d.ts +21 -0
  25. package/dist/esm/extends/react.mjs +58 -0
  26. package/dist/esm/extends/typescript.d.ts +21 -0
  27. package/dist/esm/extends/typescript.mjs +52 -0
  28. package/dist/esm/extends/yaml.d.ts +25 -0
  29. package/dist/esm/extends/yaml.mjs +71 -0
  30. package/dist/esm/globs.d.ts +6 -0
  31. package/dist/esm/globs.mjs +12 -0
  32. package/dist/esm/types.d.ts +35 -1
  33. package/dist/esm/utils/extendsConfig.d.ts +4 -0
  34. package/dist/esm/utils/extendsConfig.mjs +56 -0
  35. package/dist/esm/vdustr.d.ts +21 -4
  36. package/dist/esm/vdustr.mjs +37 -141
  37. package/dist/extends/_utils.d.ts +2 -0
  38. package/dist/extends/_utils.js +7 -0
  39. package/dist/extends/imports.d.ts +25 -0
  40. package/dist/extends/imports.js +71 -0
  41. package/dist/extends/javascript.d.ts +21 -0
  42. package/dist/extends/javascript.js +53 -0
  43. package/dist/extends/jsonc.d.ts +30 -0
  44. package/dist/extends/jsonc.js +135 -0
  45. package/dist/extends/react.d.ts +21 -0
  46. package/dist/extends/react.js +60 -0
  47. package/dist/extends/typescript.d.ts +21 -0
  48. package/dist/extends/typescript.js +56 -0
  49. package/dist/extends/yaml.d.ts +25 -0
  50. package/dist/extends/yaml.js +66 -0
  51. package/dist/globs.d.ts +6 -0
  52. package/dist/globs.js +11 -0
  53. package/dist/types.d.ts +35 -1
  54. package/dist/utils/extendsConfig.d.ts +4 -0
  55. package/dist/utils/extendsConfig.js +53 -0
  56. package/dist/vdustr.d.ts +21 -4
  57. package/dist/vdustr.js +30 -132
  58. package/package.json +6 -3
@@ -0,0 +1,71 @@
1
+ import { omit } from "es-toolkit";
2
+ import eslintPluginYml from "eslint-plugin-yml";
3
+ import { GLOB_PNPM_WORKSPACE_YAML } from "../globs.mjs";
4
+ import { extendsConfig } from "../utils/extendsConfig.mjs";
5
+ import { renameRules } from "../utils/renameRules.mjs";
6
+ import { ignoreKeys } from "./_utils.mjs";
7
+ const configNamesMapSource = {
8
+ rules: "vdustr/yaml/rules",
9
+ sortKeys: "vdustr/yaml/sortKeys"
10
+ };
11
+ const yamlInternal = (composer, options) => {
12
+ extendsConfig(composer, "antfu/yaml/rules", (config) => [
13
+ config,
14
+ {
15
+ /**
16
+ * Inherited.
17
+ */
18
+ ...omit(config, ignoreKeys),
19
+ /**
20
+ * Default.
21
+ */
22
+ name: configNamesMapSource.rules,
23
+ /**
24
+ * Overridable.
25
+ */
26
+ ...options,
27
+ rules: {
28
+ /**
29
+ * Inherited from `eslint-plugin-yml`.
30
+ */
31
+ ...renameRules({
32
+ ...Object.fromEntries([
33
+ ...eslintPluginYml.configs["flat/recommended"].flatMap(
34
+ (config2) => Object.entries(config2.rules ?? {})
35
+ ),
36
+ ...eslintPluginYml.configs["flat/prettier"].flatMap(
37
+ (config2) => Object.entries(config2.rules ?? {})
38
+ )
39
+ ])
40
+ }),
41
+ /**
42
+ * Overridable.
43
+ */
44
+ ...options?.yaml?.rules
45
+ }
46
+ },
47
+ {
48
+ /**
49
+ * Inherited.
50
+ */
51
+ ...config,
52
+ /**
53
+ * Default.
54
+ */
55
+ name: configNamesMapSource.sortKeys,
56
+ /**
57
+ * Overridable.
58
+ */
59
+ ...options?.sortKeys,
60
+ files: [GLOB_PNPM_WORKSPACE_YAML, ...options?.sortKeys?.files ?? []],
61
+ rules: {
62
+ "yaml/sort-keys": ["error", "asc"],
63
+ ...options?.sortKeys?.rules
64
+ }
65
+ }
66
+ ]);
67
+ };
68
+ const yaml = Object.assign(yamlInternal, {
69
+ configNamesMapSource
70
+ });
71
+ export { yaml };
@@ -0,0 +1,6 @@
1
+ declare const GLOB_CODE_WORKSPACE: string;
2
+ declare const GLOB_PACKAGE_JSON: string;
3
+ declare const GLOB_PNPM_WORKSPACE_YAML: string;
4
+ declare const GLOB_CSPELL_JSON: string;
5
+ declare const GLOB_CONFIG_JS: string;
6
+ export { GLOB_CODE_WORKSPACE, GLOB_CONFIG_JS, GLOB_CSPELL_JSON, GLOB_PACKAGE_JSON, GLOB_PNPM_WORKSPACE_YAML, };
@@ -0,0 +1,12 @@
1
+ const GLOB_CODE_WORKSPACE = "**/*.code-workspace";
2
+ const GLOB_PACKAGE_JSON = "**/package.json";
3
+ const GLOB_PNPM_WORKSPACE_YAML = "**/pnpm-workspace.y?(a)ml";
4
+ const GLOB_CSPELL_JSON = "**/cspell.json";
5
+ const GLOB_CONFIG_JS = "**/*.config.?([cm])([jt])s";
6
+ export {
7
+ GLOB_CODE_WORKSPACE,
8
+ GLOB_CONFIG_JS,
9
+ GLOB_CSPELL_JSON,
10
+ GLOB_PACKAGE_JSON,
11
+ GLOB_PNPM_WORKSPACE_YAML
12
+ };
@@ -1,3 +1,37 @@
1
+ import type { TypedFlatConfigItem } from "@antfu/eslint-config";
1
2
  import type antfu from "@antfu/eslint-config";
3
+ import type { DistributiveOmit } from "@mui/types";
2
4
  type Config = NonNullable<Parameters<typeof antfu>[1]>;
3
- export type { Config };
5
+ /**
6
+ * A map of config names.
7
+ *
8
+ * @example
9
+ *
10
+ * ```ts
11
+ *
12
+ * ```
13
+ */
14
+ interface ConfigNamesMap {
15
+ }
16
+ type BaseConfigNamesMapSource = Record<string, string>;
17
+ /**
18
+ * Transfroms a config names map source to a config names map.
19
+ *
20
+ * @example
21
+ *
22
+ * ```ts
23
+ * BaseConfigNamesMapSource<{
24
+ * setup: "my-config/setup",
25
+ * rules: "my-config/rules",
26
+ * }> => {
27
+ * "my-config/setup": true,
28
+ * "my-config/rules": true,
29
+ * }
30
+ * ```
31
+ */
32
+ type ResolveConfigNamesMap<TSource extends BaseConfigNamesMapSource> = {
33
+ [K in TSource[keyof TSource]]: true;
34
+ };
35
+ interface ConfigOverrides extends DistributiveOmit<TypedFlatConfigItem, "process"> {
36
+ }
37
+ export type { BaseConfigNamesMapSource, Config, ConfigNamesMap, ConfigOverrides, ResolveConfigNamesMap, };
@@ -0,0 +1,4 @@
1
+ import type { Linter } from "eslint";
2
+ import type { Arrayable, Awaitable, DefaultConfigNamesMap, FlatConfigComposer, StringLiteralUnion } from "eslint-flat-config-utils";
3
+ declare function extendsConfig<T extends object = Linter.Config, ConfigNames extends string = keyof DefaultConfigNamesMap>(composer: FlatConfigComposer<T, ConfigNames>, sourceOrIndex: StringLiteralUnion<ConfigNames, string | number>, config: Awaitable<Arrayable<T>> | ((config: T) => Awaitable<Arrayable<T>>), remove?: Arrayable<StringLiteralUnion<ConfigNames, string | number>>): void;
4
+ export { extendsConfig };
@@ -0,0 +1,56 @@
1
+ function getConfigIndex(configs, nameOrIndex) {
2
+ if (typeof nameOrIndex === "number") {
3
+ if (nameOrIndex < 0 || nameOrIndex >= configs.length)
4
+ throw new Error(
5
+ `ESLintFlatConfigUtils: Failed to locate config at index ${nameOrIndex}
6
+ (${configs.length} configs in total)`
7
+ );
8
+ return nameOrIndex;
9
+ } else {
10
+ const index = configs.findIndex((config) => config.name === nameOrIndex);
11
+ if (index === -1) {
12
+ const named = configs.map((config) => config.name).filter(Boolean);
13
+ const countUnnamed = configs.length - named.length;
14
+ const messages = [
15
+ `Failed to locate config with name "${nameOrIndex}"`,
16
+ `Available names are: ${named.join(", ")}`,
17
+ countUnnamed ? `(${countUnnamed} unnamed configs)` : ""
18
+ ].filter(Boolean).join("\n");
19
+ throw new Error(`ESLintFlatConfigUtils: ${messages}`);
20
+ }
21
+ return index;
22
+ }
23
+ }
24
+ const tryGetConfigIndex = (configs, nameOrIndex) => {
25
+ try {
26
+ return getConfigIndex(configs, nameOrIndex);
27
+ } catch {
28
+ return -1;
29
+ }
30
+ };
31
+ function extendsConfig(composer, sourceOrIndex, config, remove) {
32
+ const operations = (
33
+ // @ts-expect-error -- Hijacking the composer's operations.
34
+ composer._operations
35
+ );
36
+ operations.push(async (items) => {
37
+ const removingTargets = (() => {
38
+ if (!remove) return [];
39
+ const removeSources = Array.isArray(remove) ? remove : [remove];
40
+ return removeSources.flatMap((removeSource) => {
41
+ const index2 = tryGetConfigIndex(items, removeSource);
42
+ return index2 === -1 ? [] : [index2];
43
+ });
44
+ })();
45
+ items = removingTargets.length === 0 ? items : items.filter((_, index2) => !removingTargets.includes(index2));
46
+ const index = tryGetConfigIndex(items, sourceOrIndex);
47
+ const source = items[index];
48
+ if (!source) return items;
49
+ const newConfigs = await (async () => {
50
+ const awaited = typeof config === "function" ? await config(source) : await config;
51
+ return Array.isArray(awaited) ? awaited : [awaited];
52
+ })();
53
+ return [...items.slice(0, index), ...newConfigs, ...items.slice(index + 1)];
54
+ });
55
+ }
56
+ export { extendsConfig };
@@ -1,10 +1,27 @@
1
- import type { Config } from "./types";
1
+ import type { ConfigNames, TypedFlatConfigItem } from "@antfu/eslint-config";
2
+ import type { FlatConfigComposer } from "eslint-flat-config-utils";
3
+ import type { Config, ConfigNamesMap } from "./types";
2
4
  import antfu from "@antfu/eslint-config";
3
5
  import { mdx } from "./configs/mdx";
6
+ import { prettier } from "./configs/prettier";
7
+ import { storybook } from "./configs/storybook";
8
+ import { imports } from "./extends/imports";
9
+ import { javascript } from "./extends/javascript";
10
+ import { jsonc } from "./extends/jsonc";
11
+ import { react } from "./extends/react";
12
+ import { typescript } from "./extends/typescript";
13
+ import { yaml } from "./extends/yaml";
4
14
  import "./eslint-typegen";
5
- type Options = Omit<NonNullable<Parameters<typeof antfu>[0]>, "stylistic"> & {
15
+ type Options = NonNullable<Parameters<typeof antfu>[0]> & {
16
+ javascriptExtends?: javascript.Options;
17
+ importsExtends?: imports.Options;
18
+ typescriptExtends?: typescript.Options;
19
+ jsoncExtends?: jsonc.Options;
20
+ yamlExtends?: yaml.Options;
21
+ reactExtends?: react.Options;
6
22
  mdx?: boolean | mdx.Options;
7
- storybook?: boolean;
23
+ storybook?: boolean | storybook.Options;
24
+ prettier?: boolean | prettier.Options;
8
25
  };
9
- declare const vdustr: (options?: Options, ...userConfigs: Array<Config>) => import("eslint-flat-config-utils/index").FlatConfigComposer<import("@antfu/eslint-config").TypedFlatConfigItem, import("@antfu/eslint-config").ConfigNames>;
26
+ declare const vdustr: (options?: Options, ...userConfigs: Array<Config>) => FlatConfigComposer<TypedFlatConfigItem, ConfigNames | keyof ConfigNamesMap>;
10
27
  export { vdustr };
@@ -1,32 +1,15 @@
1
- import antfu, {
2
- GLOB_ASTRO_TS,
3
- GLOB_JS,
4
- GLOB_JSX,
5
- GLOB_TS,
6
- GLOB_TSX
7
- } from "@antfu/eslint-config";
8
- import packageJson from "eslint-plugin-package-json/configs/recommended";
9
- import { isPackageExists } from "local-pkg";
1
+ import antfu from "@antfu/eslint-config";
10
2
  import { mdx } from "./configs/mdx.mjs";
11
3
  import { prettier } from "./configs/prettier.mjs";
12
4
  import { storybook } from "./configs/storybook.mjs";
13
- import { reactCompiler } from "./lib/eslint-plugin-react-compiler.mjs";
14
- import "./eslint-typegen";
5
+ import { imports } from "./extends/imports.mjs";
6
+ import { javascript } from "./extends/javascript.mjs";
7
+ import { jsonc } from "./extends/jsonc.mjs";
8
+ import { react } from "./extends/react.mjs";
9
+ import { typescript } from "./extends/typescript.mjs";
10
+ import { yaml } from "./extends/yaml.mjs";
11
+ import "./eslint-typegen.mjs";
15
12
  const vdustr = (options, ...userConfigs) => {
16
- const typescriptEnabled = isPackageExists("typescript");
17
- const jsoncEnabled = Boolean(options?.jsonc ?? true);
18
- const reactEnabled = Boolean(options?.react ?? false);
19
- const storybookEnabled = Boolean(options?.storybook ?? false);
20
- const mdxEnabled = Boolean(options?.mdx ?? false);
21
- const mdxOptions = {
22
- ...typeof options?.mdx !== "object" ? null : options.mdx
23
- };
24
- const mdxFlatCodeBlocksEnabled = Boolean(
25
- mdxOptions?.flatCodeBlocks ?? true
26
- );
27
- const mdxFlatCodeBlocksOptions = {
28
- ...typeof mdxOptions?.flatCodeBlocks !== "object" ? null : mdxOptions.flatCodeBlocks
29
- };
30
13
  let config = antfu(
31
14
  {
32
15
  // We use `prettier`.
@@ -35,127 +18,34 @@ const vdustr = (options, ...userConfigs) => {
35
18
  },
36
19
  ...userConfigs
37
20
  );
38
- config = config.override("antfu/javascript/rules", (config2) => ({
39
- ...config2,
40
- rules: {
41
- ...config2.rules,
42
- /**
43
- * Some callbacks are purposefully named to make the code self-documenting.
44
- */
45
- "prefer-arrow-callback": "off",
46
- /**
47
- * This rule does not integrate well with JSDoc `@link` tags. It's advised
48
- * to verify its behavior with TypeScript instead.
49
- */
50
- "no-unused-vars": "off",
51
- "unused-imports/no-unused-vars": "off",
52
- "unused-imports/no-unused-imports-ts": "off",
53
- "unused-imports/no-unused-vars-ts": "off",
54
- "unused-imports/no-unused-imports": "off"
55
- }
56
- })).override("antfu/imports/rules", (config2) => ({
57
- ...config2,
58
- rules: {
59
- ...config2.rules,
60
- /**
61
- * Forbid `import {} from "module"`.
62
- */
63
- "import/no-empty-named-blocks": "error",
64
- /**
65
- * Wildcard imports can prevent tree shaking and cause name conflicts.
66
- * Consider using named imports instead.
67
- */
68
- "import/no-namespace": "error"
69
- }
70
- })).insertAfter("antfu/imports/rules", {
71
- name: "vdustr/no-default-export",
72
- rules: {
73
- /**
74
- * Enforcing named exports improves consistency, enhances auto-completion and refactoring, and avoids issues
75
- * with default export renaming. Additionally, default exports might lead to different behavior when transformed
76
- * to CJS.
77
- */
78
- "import/no-default-export": "error"
79
- },
80
- files: [GLOB_JS, GLOB_JSX, GLOB_TS, GLOB_TSX],
81
- ignores: [
82
- // Configuration files
83
- "**/*.config.*",
84
- GLOB_ASTRO_TS
85
- ]
86
- });
87
- if (typescriptEnabled) {
88
- config = config.override("antfu/typescript/rules", (config2) => ({
89
- ...config2,
90
- rules: {
91
- ...config2.rules,
92
- "ts/array-type": ["error", { default: "generic" }],
93
- /**
94
- * Namespaces are useful for centralizing the management of types. Just avoid
95
- * overusing them with runtime code.
96
- *
97
- * - References:
98
- * - <https://x.com/mattpocockuk/status/1805606072167940167>
99
- */
100
- "ts/no-namespace": "off",
101
- "ts/no-redeclare": "off",
102
- /**
103
- * Check for unused variables in TypeScript.
104
- */
105
- "ts/no-unused-vars": "off"
106
- }
107
- }));
108
- }
109
- if (jsoncEnabled) {
110
- config = config.override("antfu/jsonc/rules", (config2) => ({
111
- ...config2,
112
- rules: {
113
- ...config2.rules,
114
- "jsonc/sort-keys": "error"
115
- },
116
- files: [...config2.files ?? [], "**/*.code-workspace"],
117
- ignores: [
118
- ...config2.ignores ?? [],
119
- /**
120
- * Lint `package.json` files with `eslint-plugin-package-json` instead.
121
- */
122
- "**/package.json"
123
- ]
124
- })).insertAfter("antfu/jsonc/rules", packageJson).remove("antfu/sort/package-json").remove("antfu/sort/tsconfig-json");
125
- }
126
- if (reactEnabled) {
127
- config = config.override("antfu/react/rules", async (config2) => {
128
- return {
129
- ...config2,
130
- plugins: {
131
- ...config2.plugins,
132
- "react-compiler": await reactCompiler()
133
- },
134
- rules: {
135
- ...config2.rules,
136
- "react-compiler/react-compiler": "error",
137
- /**
138
- * Not all destructuring assignments are more readable than their alternatives.
139
- */
140
- "react/prefer-destructuring-assignment": "off"
141
- }
142
- };
143
- });
144
- }
21
+ javascript(config, options?.javascriptExtends);
22
+ imports(config, options?.importsExtends);
23
+ typescript(config, options?.typescriptExtends);
24
+ jsonc(config, options?.jsoncExtends);
25
+ yaml(config, options?.yamlExtends);
26
+ react(config, options?.reactExtends);
27
+ const storybookEnabled = Boolean(options?.storybook ?? false);
145
28
  if (storybookEnabled) {
146
- config = config.append(storybook()).override("storybook:csf:stories-rules", (config2) => ({
147
- ...config2,
148
- rules: {
149
- ...config2.rules,
150
- "import/no-default-export": "off"
151
- }
152
- }));
29
+ const storybookOptions = typeof options?.storybook !== "object" ? void 0 : options.storybook;
30
+ config = config.append(
31
+ storybook(...!storybookOptions ? [] : [storybookOptions])
32
+ );
153
33
  }
34
+ const mdxEnabled = Boolean(options?.mdx ?? false);
154
35
  if (mdxEnabled) {
36
+ const mdxOptions = {
37
+ ...typeof options?.mdx !== "object" ? null : options.mdx
38
+ };
39
+ const mdxFlatCodeBlocksEnabled = Boolean(
40
+ mdxOptions?.codeBlocks ?? true
41
+ );
42
+ const mdxFlatCodeBlocksOptions = {
43
+ ...typeof mdxOptions?.codeBlocks !== "object" ? null : mdxOptions.codeBlocks
44
+ };
155
45
  config = config.append(
156
46
  mdx({
157
47
  ...mdxOptions,
158
- flatCodeBlocks: !mdxFlatCodeBlocksEnabled ? false : {
48
+ codeBlocks: !mdxFlatCodeBlocksEnabled ? false : {
159
49
  ...mdxFlatCodeBlocksOptions,
160
50
  rules: {
161
51
  "import/no-default-export": "off",
@@ -165,7 +55,13 @@ const vdustr = (options, ...userConfigs) => {
165
55
  })
166
56
  );
167
57
  }
168
- config = config.append(prettier());
58
+ const prettierEnabled = Boolean(options?.prettier ?? true);
59
+ if (prettierEnabled) {
60
+ const prettierOptions = typeof options?.prettier !== "object" ? void 0 : options.prettier;
61
+ config = config.append(
62
+ prettier(...!prettierOptions ? [] : [prettierOptions])
63
+ );
64
+ }
169
65
  return config;
170
66
  };
171
67
  export { vdustr };
@@ -0,0 +1,2 @@
1
+ declare const ignoreKeys: ("plugins" | "rules")[];
2
+ export { ignoreKeys };
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ignoreKeys = void 0;
7
+ const ignoreKeys = exports.ignoreKeys = ["plugins", "rules"];
@@ -0,0 +1,25 @@
1
+ import type { ConfigNames, TypedFlatConfigItem } from "@antfu/eslint-config";
2
+ import type { FlatConfigComposer } from "eslint-flat-config-utils";
3
+ import type { ConfigOverrides, ResolveConfigNamesMap } from "../types";
4
+ declare const configNamesMapSource: {
5
+ readonly imports: "vdustr/imports/rules";
6
+ readonly noDefaultExport: "vdustr/no-default-export/rules";
7
+ };
8
+ declare module "../types" {
9
+ interface ConfigNamesMap extends ResolveConfigNamesMap<imports.ConfigNamesMapSource> {
10
+ }
11
+ }
12
+ declare namespace imports {
13
+ type ConfigNamesMapSource = typeof configNamesMapSource;
14
+ interface Options {
15
+ imports?: ConfigOverrides;
16
+ noDefaultExport: ConfigOverrides;
17
+ }
18
+ }
19
+ declare const imports: ((composer: FlatConfigComposer<TypedFlatConfigItem, ConfigNames>, options?: imports.Options) => void) & {
20
+ configNamesMapSource: {
21
+ readonly imports: "vdustr/imports/rules";
22
+ readonly noDefaultExport: "vdustr/no-default-export/rules";
23
+ };
24
+ };
25
+ export { imports };
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.imports = void 0;
7
+ var _eslintConfig = require("@antfu/eslint-config");
8
+ var _esToolkit = require("es-toolkit");
9
+ var _globs = require("../globs");
10
+ var _extendsConfig = require("../utils/extendsConfig");
11
+ var _utils = require("./_utils");
12
+ const configNamesMapSource = {
13
+ imports: "vdustr/imports/rules",
14
+ noDefaultExport: "vdustr/no-default-export/rules"
15
+ };
16
+ const importsInternal = (composer, options) => {
17
+ (0, _extendsConfig.extendsConfig)(composer, "antfu/imports/rules", config => [config, {
18
+ /**
19
+ * Inherited.
20
+ */
21
+ ...(0, _esToolkit.omit)(config, _utils.ignoreKeys),
22
+ /**
23
+ * Default.
24
+ */
25
+ name: configNamesMapSource.imports,
26
+ /**
27
+ * Overridable.
28
+ */
29
+ ...options?.imports,
30
+ rules: {
31
+ /**
32
+ * Default.
33
+ */
34
+ /**
35
+ * Forbid `import {} from "module"`.
36
+ */
37
+ "import/no-empty-named-blocks": "error",
38
+ /**
39
+ * Wildcard imports can prevent tree shaking and cause name conflicts.
40
+ * Consider using named imports instead.
41
+ */
42
+ "import/no-namespace": "error",
43
+ /**
44
+ * Overridable.
45
+ */
46
+ ...options?.imports?.rules
47
+ }
48
+ }, {
49
+ name: configNamesMapSource.noDefaultExport,
50
+ /**
51
+ * Overridable.
52
+ */
53
+ ...options?.noDefaultExport,
54
+ rules: {
55
+ /**
56
+ * Enforcing named exports improves consistency, enhances auto-completion and refactoring, and avoids issues
57
+ * with default export renaming. Additionally, default exports might lead to different behavior when transformed
58
+ * to CJS.
59
+ */
60
+ "import/no-default-export": "error",
61
+ ...options?.noDefaultExport?.rules
62
+ },
63
+ files: [_eslintConfig.GLOB_JS, _eslintConfig.GLOB_JSX, _eslintConfig.GLOB_TS, _eslintConfig.GLOB_TSX, ...(options?.noDefaultExport?.files || [])],
64
+ ignores: [
65
+ // Configuration files
66
+ _globs.GLOB_CONFIG_JS, _eslintConfig.GLOB_MARKDOWN_CODE, _eslintConfig.GLOB_ASTRO_TS, ...(options?.noDefaultExport?.ignores || [])]
67
+ }]);
68
+ };
69
+ const imports = exports.imports = Object.assign(importsInternal, {
70
+ configNamesMapSource
71
+ });
@@ -0,0 +1,21 @@
1
+ import type { ConfigNames, TypedFlatConfigItem } from "@antfu/eslint-config";
2
+ import type { FlatConfigComposer } from "eslint-flat-config-utils";
3
+ import type { ConfigOverrides, ResolveConfigNamesMap } from "../types";
4
+ declare const configNamesMapSource: {
5
+ readonly rules: "vdustr/javascript/rules";
6
+ };
7
+ declare module "../types" {
8
+ interface ConfigNamesMap extends ResolveConfigNamesMap<javascript.ConfigNamesMapSource> {
9
+ }
10
+ }
11
+ declare namespace javascript {
12
+ type ConfigNamesMapSource = typeof configNamesMapSource;
13
+ interface Options extends ConfigOverrides {
14
+ }
15
+ }
16
+ declare const javascript: ((composer: FlatConfigComposer<TypedFlatConfigItem, ConfigNames>, options?: javascript.Options) => void) & {
17
+ configNamesMapSource: {
18
+ readonly rules: "vdustr/javascript/rules";
19
+ };
20
+ };
21
+ export { javascript };
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.javascript = void 0;
7
+ var _esToolkit = require("es-toolkit");
8
+ var _extendsConfig = require("../utils/extendsConfig");
9
+ var _utils = require("./_utils");
10
+ const configNamesMapSource = {
11
+ rules: "vdustr/javascript/rules"
12
+ };
13
+ const javascriptInternal = (composer, options) => {
14
+ (0, _extendsConfig.extendsConfig)(composer, "antfu/javascript/rules", config => [config, {
15
+ /**
16
+ * Inherited.
17
+ */
18
+ ...(0, _esToolkit.omit)(config, _utils.ignoreKeys),
19
+ /**
20
+ * Default.
21
+ */
22
+ name: configNamesMapSource.rules,
23
+ /**
24
+ * Overridable.
25
+ */
26
+ ...options,
27
+ rules: {
28
+ /**
29
+ * Default.
30
+ */
31
+ /**
32
+ * Some callbacks are purposefully named to make the code self-documenting.
33
+ */
34
+ "prefer-arrow-callback": "off",
35
+ /**
36
+ * This rule does not integrate well with JSDoc `@link` tags. It's advised
37
+ * to verify its behavior with TypeScript instead.
38
+ */
39
+ "no-unused-vars": "off",
40
+ "unused-imports/no-unused-vars": "off",
41
+ "unused-imports/no-unused-imports-ts": "off",
42
+ "unused-imports/no-unused-vars-ts": "off",
43
+ "unused-imports/no-unused-imports": "off",
44
+ /**
45
+ * Overridable.
46
+ */
47
+ ...options?.rules
48
+ }
49
+ }]);
50
+ };
51
+ const javascript = exports.javascript = Object.assign(javascriptInternal, {
52
+ configNamesMapSource
53
+ });
@@ -0,0 +1,30 @@
1
+ import type { ConfigNames, TypedFlatConfigItem } from "@antfu/eslint-config";
2
+ import type { FlatConfigComposer } from "eslint-flat-config-utils";
3
+ import type { ConfigOverrides, ResolveConfigNamesMap } from "../types";
4
+ declare const configNamesMapSource: {
5
+ readonly rules: "vdustr/jsonc/rules";
6
+ readonly sortArrayValues: "vdustr/jsonc/sortArrayValues";
7
+ readonly packageJsonSetup: "vdustr/package-json/setup";
8
+ readonly packageJsonRules: "vdustr/package-json/rules";
9
+ };
10
+ declare module "../types" {
11
+ interface ConfigNamesMap extends ResolveConfigNamesMap<jsonc.ConfigNamesMapSource> {
12
+ }
13
+ }
14
+ declare namespace jsonc {
15
+ type ConfigNamesMapSource = typeof configNamesMapSource;
16
+ interface Options {
17
+ jsonc?: ConfigOverrides;
18
+ packageJson?: ConfigOverrides;
19
+ sortArrayValues: ConfigOverrides;
20
+ }
21
+ }
22
+ declare const jsonc: ((composer: FlatConfigComposer<TypedFlatConfigItem, ConfigNames>, options?: jsonc.Options) => void) & {
23
+ configNamesMapSource: {
24
+ readonly rules: "vdustr/jsonc/rules";
25
+ readonly sortArrayValues: "vdustr/jsonc/sortArrayValues";
26
+ readonly packageJsonSetup: "vdustr/package-json/setup";
27
+ readonly packageJsonRules: "vdustr/package-json/rules";
28
+ };
29
+ };
30
+ export { jsonc };