@vp-tw/eslint-config 0.0.18 → 0.0.20

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 (52) hide show
  1. package/README.md +0 -31
  2. package/dist/configs/mdx.d.ts +2 -21
  3. package/dist/configs/mdx.js +6 -14
  4. package/dist/configs/prettier.d.ts +2 -15
  5. package/dist/configs/prettier.js +3 -8
  6. package/dist/configs/reactCompiler.d.ts +9 -0
  7. package/dist/configs/reactCompiler.js +25 -0
  8. package/dist/configs/storybook.d.ts +2 -19
  9. package/dist/configs/storybook.js +5 -12
  10. package/dist/eslint-typegen.d.ts +4 -7
  11. package/dist/esm/configs/mdx.d.ts +2 -21
  12. package/dist/esm/configs/mdx.mjs +5 -14
  13. package/dist/esm/configs/prettier.d.ts +2 -15
  14. package/dist/esm/configs/prettier.mjs +2 -8
  15. package/dist/esm/configs/reactCompiler.d.ts +9 -0
  16. package/dist/esm/configs/reactCompiler.mjs +18 -0
  17. package/dist/esm/configs/storybook.d.ts +2 -19
  18. package/dist/esm/configs/storybook.mjs +4 -12
  19. package/dist/esm/eslint-typegen.d.ts +4 -7
  20. package/dist/esm/extends/imports.d.ts +2 -18
  21. package/dist/esm/extends/imports.mjs +3 -10
  22. package/dist/esm/extends/javascript.d.ts +2 -16
  23. package/dist/esm/extends/javascript.mjs +2 -8
  24. package/dist/esm/extends/jsonc.d.ts +2 -22
  25. package/dist/esm/extends/jsonc.mjs +5 -14
  26. package/dist/esm/extends/react.d.ts +5 -22
  27. package/dist/esm/extends/react.mjs +10 -32
  28. package/dist/esm/extends/typescript.d.ts +2 -16
  29. package/dist/esm/extends/typescript.mjs +2 -8
  30. package/dist/esm/extends/yaml.d.ts +2 -18
  31. package/dist/esm/extends/yaml.mjs +3 -10
  32. package/dist/esm/types.d.ts +14 -29
  33. package/dist/esm/vdustr.d.ts +2 -5
  34. package/dist/esm/vdustr.mjs +1 -2
  35. package/dist/extends/imports.d.ts +2 -18
  36. package/dist/extends/imports.js +4 -10
  37. package/dist/extends/javascript.d.ts +2 -16
  38. package/dist/extends/javascript.js +3 -8
  39. package/dist/extends/jsonc.d.ts +2 -22
  40. package/dist/extends/jsonc.js +6 -14
  41. package/dist/extends/react.d.ts +5 -22
  42. package/dist/extends/react.js +8 -23
  43. package/dist/extends/typescript.d.ts +2 -16
  44. package/dist/extends/typescript.js +3 -8
  45. package/dist/extends/yaml.d.ts +2 -18
  46. package/dist/extends/yaml.js +4 -10
  47. package/dist/types.d.ts +14 -29
  48. package/dist/vdustr.d.ts +2 -5
  49. package/dist/vdustr.js +1 -2
  50. package/package.json +14 -16
  51. package/dist/eslint-typegen.js +0 -2
  52. package/dist/esm/eslint-typegen.mjs +0 -1
@@ -1,28 +1,11 @@
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 react: "vdustr/react/rules";
6
- readonly reactCompilerSetup: "vdustr/react/react-compiler/setup";
7
- readonly reactCompilerRules: "vdustr/react/react-compiler/rules";
8
- };
9
- declare module "../types" {
10
- interface ConfigNamesMap extends ResolveConfigNamesMap<react.ConfigNamesMapSource> {
11
- }
12
- }
1
+ import type { ConfigOverrides, VpComposer } from "../types";
2
+ import { reactCompiler } from "../configs/reactCompiler";
13
3
  declare namespace react {
14
- type ConfigNamesMapSource = typeof configNamesMapSource;
15
4
  interface Options {
16
5
  react?: ConfigOverrides;
17
- reactCompilerSetup?: ConfigOverrides;
18
- reactCompilerRules?: ConfigOverrides;
6
+ reactCompiler?: reactCompiler.Options["reactCompiler"];
7
+ reactCompilerSetup?: reactCompiler.Options["setup"];
19
8
  }
20
9
  }
21
- declare const react: ((composer: FlatConfigComposer<TypedFlatConfigItem, ConfigNames>, options?: react.Options) => void) & {
22
- configNamesMapSource: {
23
- readonly react: "vdustr/react/rules";
24
- readonly reactCompilerSetup: "vdustr/react/react-compiler/setup";
25
- readonly reactCompilerRules: "vdustr/react/react-compiler/rules";
26
- };
27
- };
10
+ declare const react: (composer: VpComposer, options?: react.Options) => void;
28
11
  export { react };
@@ -6,40 +6,25 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.react = void 0;
7
7
  var _defu = _interopRequireDefault(require("defu"));
8
8
  var _esToolkit = require("es-toolkit");
9
- var _eslintPluginReactCompiler = require("../lib/eslint-plugin-react-compiler");
9
+ var _reactCompiler = require("../configs/reactCompiler");
10
10
  var _extendsConfig = require("../utils/extendsConfig");
11
11
  var _utils = require("./_utils");
12
12
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
- const configNamesMapSource = {
14
- react: "vdustr/react/rules",
15
- reactCompilerSetup: "vdustr/react/react-compiler/setup",
16
- reactCompilerRules: "vdustr/react/react-compiler/rules"
17
- };
18
- const reactInternal = (composer, options) => {
13
+ const react = (composer, options) => {
19
14
  (0, _extendsConfig.extendsConfig)(composer, "antfu/react/rules", async config => {
20
15
  const modifiedConfig = (0, _defu.default)((0, _esToolkit.pick)(options?.react ?? {}, ["files", "ignores"]), config);
21
16
  const omittedConfig = (0, _esToolkit.omit)(modifiedConfig, _utils.ignoreKeys);
22
17
  const rulesConfig = (0, _defu.default)((0, _esToolkit.omit)(options?.react ?? {}, ["files", "ignores"]), {
23
- name: configNamesMapSource.react,
18
+ name: "vdustr/react/rules",
24
19
  rules: {
25
20
  "react/prefer-destructuring-assignment": "off"
26
21
  }
27
22
  }, omittedConfig);
28
- const reactCompilerSetupConfig = (0, _defu.default)(options?.reactCompilerSetup, {
29
- name: configNamesMapSource.reactCompilerSetup,
30
- plugins: {
31
- "react-compiler": await (0, _eslintPluginReactCompiler.reactCompiler)()
32
- }
23
+ const reactCompilerConfigs = await (0, _reactCompiler.reactCompiler)({
24
+ setup: options?.reactCompilerSetup ?? {},
25
+ reactCompiler: (0, _defu.default)(options?.reactCompiler, (0, _esToolkit.pick)(omittedConfig, ["files", "ignores"]))
33
26
  });
34
- const reactCompilerRulesConfig = (0, _defu.default)(options?.reactCompilerRules, {
35
- name: configNamesMapSource.reactCompilerRules,
36
- rules: {
37
- "react-compiler/react-compiler": "error"
38
- }
39
- }, omittedConfig);
40
- return [modifiedConfig, rulesConfig, reactCompilerSetupConfig, reactCompilerRulesConfig];
27
+ return [modifiedConfig, rulesConfig, ...reactCompilerConfigs];
41
28
  });
42
29
  };
43
- const react = exports.react = Object.assign(reactInternal, {
44
- configNamesMapSource
45
- });
30
+ exports.react = react;
@@ -1,22 +1,8 @@
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 typescript: "vdustr/typescript/rules";
6
- };
7
- declare module "../types" {
8
- interface ConfigNamesMap extends ResolveConfigNamesMap<typescript.ConfigNamesMapSource> {
9
- }
10
- }
1
+ import type { ConfigOverrides, VpComposer } from "../types";
11
2
  declare namespace typescript {
12
- type ConfigNamesMapSource = typeof configNamesMapSource;
13
3
  interface Options {
14
4
  typescript?: ConfigOverrides;
15
5
  }
16
6
  }
17
- declare const typescript: ((composer: FlatConfigComposer<TypedFlatConfigItem, ConfigNames>, options?: typescript.Options) => void) & {
18
- configNamesMapSource: {
19
- readonly typescript: "vdustr/typescript/rules";
20
- };
21
- };
7
+ declare const typescript: (composer: VpComposer, options?: typescript.Options) => void;
22
8
  export { typescript };
@@ -9,15 +9,12 @@ var _esToolkit = require("es-toolkit");
9
9
  var _extendsConfig = require("../utils/extendsConfig");
10
10
  var _utils = require("./_utils");
11
11
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
- const configNamesMapSource = {
13
- typescript: "vdustr/typescript/rules"
14
- };
15
- const typescriptInternal = (composer, options) => {
12
+ const typescript = (composer, options) => {
16
13
  (0, _extendsConfig.extendsConfig)(composer, "antfu/typescript/rules", config => {
17
14
  const modifiedConfig = (0, _defu.default)((0, _esToolkit.pick)(options?.typescript ?? {}, ["files", "ignores"]), config);
18
15
  const omittedConfig = (0, _esToolkit.omit)(modifiedConfig, _utils.ignoreKeys);
19
16
  const rulesConfig = (0, _defu.default)((0, _esToolkit.omit)(options?.typescript ?? {}, ["files", "ignores"]), {
20
- name: configNamesMapSource.typescript,
17
+ name: "vdustr/typescript/rules",
21
18
  rules: {
22
19
  /**
23
20
  * Use `Array<T>` instead of `T[]` for better DX.
@@ -46,6 +43,4 @@ const typescriptInternal = (composer, options) => {
46
43
  return [modifiedConfig, rulesConfig];
47
44
  });
48
45
  };
49
- const typescript = exports.typescript = Object.assign(typescriptInternal, {
50
- configNamesMapSource
51
- });
46
+ exports.typescript = typescript;
@@ -1,25 +1,9 @@
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 yaml: "vdustr/yaml/rules";
6
- readonly sortKeys: "vdustr/yaml/sort-keys/rules";
7
- };
8
- declare module "../types" {
9
- interface ConfigNamesMap extends ResolveConfigNamesMap<yaml.ConfigNamesMapSource> {
10
- }
11
- }
1
+ import type { ConfigOverrides, VpComposer } from "../types";
12
2
  declare namespace yaml {
13
- type ConfigNamesMapSource = typeof configNamesMapSource;
14
3
  interface Options {
15
4
  yaml?: ConfigOverrides;
16
5
  sortKeys?: ConfigOverrides;
17
6
  }
18
7
  }
19
- declare const yaml: ((composer: FlatConfigComposer<TypedFlatConfigItem, ConfigNames>, options?: yaml.Options) => void) & {
20
- configNamesMapSource: {
21
- readonly yaml: "vdustr/yaml/rules";
22
- readonly sortKeys: "vdustr/yaml/sort-keys/rules";
23
- };
24
- };
8
+ declare const yaml: (composer: VpComposer, options?: yaml.Options) => void;
25
9
  export { yaml };
@@ -12,23 +12,19 @@ var _extendsConfig = require("../utils/extendsConfig");
12
12
  var _renameRules = require("../utils/renameRules");
13
13
  var _utils = require("./_utils");
14
14
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
15
- const configNamesMapSource = {
16
- yaml: "vdustr/yaml/rules",
17
- sortKeys: "vdustr/yaml/sort-keys/rules"
18
- };
19
- const yamlInternal = (composer, options) => {
15
+ const yaml = (composer, options) => {
20
16
  (0, _extendsConfig.extendsConfig)(composer, "antfu/yaml/rules", config => {
21
17
  const modifiedConfig = (0, _defu.default)((0, _esToolkit.pick)(options?.yaml ?? {}, ["files", "ignores"]), config);
22
18
  const omittedConfig = (0, _esToolkit.omit)(modifiedConfig, _utils.ignoreKeys);
23
19
  const rulesConfig = (0, _defu.default)((0, _esToolkit.omit)(options?.yaml ?? {}, ["files", "ignores"]), {
24
- name: configNamesMapSource.yaml,
20
+ name: "vdustr/yaml/rules",
25
21
  rules: (0, _renameRules.renameRules)({
26
22
  ...Object.fromEntries([..._eslintPluginYml.default.configs["flat/recommended"].flatMap(config2 => Object.entries(config2.rules ?? {})), ..._eslintPluginYml.default.configs["flat/prettier"].flatMap(config2 => Object.entries(config2.rules ?? {}))])
27
23
  })
28
24
  }, omittedConfig);
29
25
  const sortKeysConfig = (0, _defu.default)(options?.sortKeys, {
30
26
  ...(0, _esToolkit.omit)(omittedConfig, ["files", "ignores"]),
31
- name: configNamesMapSource.sortKeys,
27
+ name: "vdustr/yaml/sort-keys/rules",
32
28
  files: [_globs.GLOB_PNPM_WORKSPACE_YAML],
33
29
  rules: {
34
30
  "yaml/sort-keys": ["error", {
@@ -44,6 +40,4 @@ const yamlInternal = (composer, options) => {
44
40
  return [modifiedConfig, rulesConfig, sortKeysConfig];
45
41
  });
46
42
  };
47
- const yaml = exports.yaml = Object.assign(yamlInternal, {
48
- configNamesMapSource
49
- });
43
+ exports.yaml = yaml;
package/dist/types.d.ts CHANGED
@@ -1,37 +1,22 @@
1
- import type { TypedFlatConfigItem } from "@antfu/eslint-config";
2
1
  import type antfu from "@antfu/eslint-config";
2
+ import type { ConfigNames as AntfuEslintConfigNames, Rules as AntfuEslintRules } from "@antfu/eslint-config";
3
3
  import type { DistributiveOmit } from "@mui/types";
4
+ import type { Linter } from "eslint";
5
+ import type { FlatConfigComposer } from "eslint-flat-config-utils";
6
+ import type { RuleOptions, ConfigNames as VpEslintConfigNames } from "./eslint-typegen";
4
7
  type Config = NonNullable<Parameters<typeof antfu>[1]>;
8
+ type Rules = RuleOptions & AntfuEslintRules;
9
+ type ConfigNames = VpEslintConfigNames | AntfuEslintConfigNames;
5
10
  /**
6
- * A map of config names.
7
- *
8
- * @example
9
- *
10
- * ```ts
11
- *
12
- * ```
11
+ * Learned from <https://github.com/antfu/eslint-config/blob/e283983/src/types.ts#L11-L23>
13
12
  */
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;
13
+ type TypedFlatConfigItem = Omit<Linter.Config<Linter.RulesRecord & Rules>, "plugins"> & {
14
+ plugins?: Record<string, any>;
34
15
  };
35
16
  interface ConfigOverrides extends DistributiveOmit<TypedFlatConfigItem, "process"> {
36
17
  }
37
- export type { BaseConfigNamesMapSource, Config, ConfigNamesMap, ConfigOverrides, ResolveConfigNamesMap, };
18
+ /**
19
+ * Typed composer.
20
+ */
21
+ type VpComposer = FlatConfigComposer<TypedFlatConfigItem, ConfigNames>;
22
+ export type { Config, ConfigNames, ConfigOverrides, TypedFlatConfigItem, VpComposer, };
package/dist/vdustr.d.ts CHANGED
@@ -1,6 +1,4 @@
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";
1
+ import type { Config, VpComposer } from "./types";
4
2
  import antfu from "@antfu/eslint-config";
5
3
  import { mdx } from "./configs/mdx";
6
4
  import { prettier } from "./configs/prettier";
@@ -11,7 +9,6 @@ import { jsonc } from "./extends/jsonc";
11
9
  import { react } from "./extends/react";
12
10
  import { typescript } from "./extends/typescript";
13
11
  import { yaml } from "./extends/yaml";
14
- import "./eslint-typegen";
15
12
  type Options = NonNullable<Parameters<typeof antfu>[0]> & {
16
13
  javascriptExtends?: javascript.Options;
17
14
  importsExtends?: imports.Options;
@@ -23,5 +20,5 @@ type Options = NonNullable<Parameters<typeof antfu>[0]> & {
23
20
  storybook?: boolean | storybook.Options;
24
21
  prettier?: boolean | prettier.Options;
25
22
  };
26
- declare const vdustr: (options?: Options, ...userConfigs: Array<Config>) => FlatConfigComposer<TypedFlatConfigItem, ConfigNames | keyof ConfigNamesMap>;
23
+ declare const vdustr: (options?: Options, ...userConfigs: Array<Config>) => VpComposer;
27
24
  export { vdustr };
package/dist/vdustr.js CHANGED
@@ -14,11 +14,10 @@ var _jsonc = require("./extends/jsonc");
14
14
  var _react = require("./extends/react");
15
15
  var _typescript = require("./extends/typescript");
16
16
  var _yaml = require("./extends/yaml");
17
- require("./eslint-typegen");
18
17
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
19
18
  const vdustr = (options, ...userConfigs) => {
20
19
  let config = (0, _eslintConfig.default)({
21
- // We use `prettier`.
20
+ // Use `prettier` for formatting by default.
22
21
  stylistic: false,
23
22
  ...options
24
23
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vp-tw/eslint-config",
3
- "version": "0.0.18",
3
+ "version": "0.0.20",
4
4
  "description": "ViPro's ESLint configuration",
5
5
  "homepage": "https://github.com/vdustr/eslint-config",
6
6
  "author": {
@@ -9,23 +9,23 @@
9
9
  },
10
10
  "exports": {
11
11
  ".": {
12
- "default": {
13
- "default": "./dist/index.js",
14
- "types": "./dist/index.d.ts"
15
- },
16
12
  "import": {
17
- "default": "./dist/esm/index.mjs",
18
- "types": "./dist/esm/index.d.ts"
13
+ "types": "./dist/esm/index.d.ts",
14
+ "default": "./dist/esm/index.mjs"
15
+ },
16
+ "default": {
17
+ "types": "./dist/index.d.ts",
18
+ "default": "./dist/index.js"
19
19
  }
20
20
  },
21
21
  "./*": {
22
- "default": {
23
- "default": "./dist/*.js",
24
- "types": "./dist/*.d.ts"
25
- },
26
22
  "import": {
27
- "default": "./dist/esm/*.mjs",
28
- "types": "./dist/esm/*.d.ts"
23
+ "types": "./dist/esm/*.d.ts",
24
+ "default": "./dist/esm/*.mjs"
25
+ },
26
+ "default": {
27
+ "types": "./dist/*.d.ts",
28
+ "default": "./dist/*.js"
29
29
  }
30
30
  },
31
31
  "./README.md": "./README.md",
@@ -83,10 +83,8 @@
83
83
  "access": "public"
84
84
  },
85
85
  "scripts": {
86
- "build": "run-s build:unbuild fixEslintTypegenDts",
87
- "build:unbuild": "unbuild",
86
+ "build": "unbuild",
88
87
  "copy": "tsx scripts/copy",
89
- "fixEslintTypegenDts": "tsx scripts/fixEslintTypegenDts",
90
88
  "typegen": "tsx scripts/typegen"
91
89
  }
92
90
  }
@@ -1,2 +0,0 @@
1
- // Placeholder for `eslint-typegen.d.ts`.
2
- "use strict";
@@ -1 +0,0 @@
1
- // Placeholder for `eslint-typegen.d.ts`.