@vp-tw/eslint-config 0.0.3 → 0.0.5

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.
@@ -4,8 +4,8 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.mdx = void 0;
7
- var _eslintConfig = require("@antfu/eslint-config");
8
7
  var mdxPlugin = _interopRequireWildcard(require("eslint-plugin-mdx"));
8
+ var _renameRules = require("../utils/renameRules");
9
9
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
10
10
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
11
11
  const mdx = ({
@@ -19,9 +19,9 @@ const mdx = ({
19
19
  ...mdxPlugin.flat,
20
20
  ...options,
21
21
  rules: {
22
- ...(0, _eslintConfig.renameRules)({
22
+ ...(0, _renameRules.renameRules)({
23
23
  ...mdxPlugin.flat.rules
24
- }, _eslintConfig.defaultPluginRenaming),
24
+ }),
25
25
  ...options.rules
26
26
  },
27
27
  processor: mdxPlugin.createRemarkProcessor({
@@ -36,9 +36,9 @@ const mdx = ({
36
36
  ...mdxPlugin.flatCodeBlocks,
37
37
  ...flatCodeBlocksOptions,
38
38
  rules: {
39
- ...(0, _eslintConfig.renameRules)({
39
+ ...(0, _renameRules.renameRules)({
40
40
  ...mdxPlugin.flatCodeBlocks.rules
41
- }, _eslintConfig.defaultPluginRenaming),
41
+ }),
42
42
  ...flatCodeBlocksOptions.rules
43
43
  }
44
44
  }])];
@@ -1,5 +1,5 @@
1
- import { defaultPluginRenaming, renameRules } from "@antfu/eslint-config";
2
1
  import * as mdxPlugin from "eslint-plugin-mdx";
2
+ import { renameRules } from "../utils/renameRules.mjs";
3
3
  const mdx = ({
4
4
  flatCodeBlocks = true,
5
5
  processorOptions,
@@ -12,12 +12,9 @@ const mdx = ({
12
12
  ...mdxPlugin.flat,
13
13
  ...options,
14
14
  rules: {
15
- ...renameRules(
16
- {
17
- ...mdxPlugin.flat.rules
18
- },
19
- defaultPluginRenaming
20
- ),
15
+ ...renameRules({
16
+ ...mdxPlugin.flat.rules
17
+ }),
21
18
  ...options.rules
22
19
  },
23
20
  processor: mdxPlugin.createRemarkProcessor({
@@ -34,12 +31,9 @@ const mdx = ({
34
31
  ...mdxPlugin.flatCodeBlocks,
35
32
  ...flatCodeBlocksOptions,
36
33
  rules: {
37
- ...renameRules(
38
- {
39
- ...mdxPlugin.flatCodeBlocks.rules
40
- },
41
- defaultPluginRenaming
42
- ),
34
+ ...renameRules({
35
+ ...mdxPlugin.flatCodeBlocks.rules
36
+ }),
43
37
  ...flatCodeBlocksOptions.rules
44
38
  }
45
39
  }
@@ -1,13 +1,9 @@
1
- declare module "eslint-plugin-react-compiler" {
2
- type Plugin = import("eslint").ESLint.Plugin;
3
- type LegacyConfig = import("eslint").Linter.LegacyConfig;
4
- interface ReactCompiler extends Plugin {
5
- rules: NonNullable<Plugin["rules"]>;
6
- configs: {
7
- recommended: LegacyConfig;
8
- };
9
- }
10
- const rules: ReactCompiler["rules"];
11
- const configs: ReactCompiler["configs"];
12
- export { configs, rules };
1
+ import type { ESLint, Linter } from "eslint";
2
+ interface ReactCompiler extends ESLint.Plugin {
3
+ rules: NonNullable<ESLint.Plugin["rules"]>;
4
+ configs: {
5
+ recommended: Linter.LegacyConfig;
6
+ };
13
7
  }
8
+ declare const reactCompilerInternal: ReactCompiler;
9
+ export { reactCompilerInternal as reactCompiler };
@@ -0,0 +1,3 @@
1
+ import * as reactCompiler from "eslint-plugin-react-compiler";
2
+ const reactCompilerInternal = reactCompiler.default ?? reactCompiler;
3
+ export { reactCompilerInternal as reactCompiler };
@@ -1,10 +1,10 @@
1
1
  import antfu from "@antfu/eslint-config";
2
2
  import packageJson from "eslint-plugin-package-json/configs/recommended";
3
- import * as reactCompilerPlugin from "eslint-plugin-react-compiler";
4
3
  import { isPackageExists } from "local-pkg";
5
4
  import { mdx } from "./configs/mdx.mjs";
6
5
  import { prettier } from "./configs/prettier.mjs";
7
6
  import { storybook } from "./configs/storybook.mjs";
7
+ import { reactCompiler } from "./lib/eslint-plugin-react-compiler.mjs";
8
8
  const vdustr = (options, ...userConfigs) => {
9
9
  const typescriptEnabled = isPackageExists("typescript");
10
10
  const jsoncEnabled = Boolean(options?.jsonc ?? true);
@@ -122,7 +122,7 @@ const vdustr = (options, ...userConfigs) => {
122
122
  ...config2,
123
123
  plugins: {
124
124
  ...config2.plugins,
125
- "react-compiler": reactCompilerPlugin
125
+ "react-compiler": reactCompiler
126
126
  },
127
127
  rules: {
128
128
  ...config2.rules,
@@ -1,13 +1,9 @@
1
- declare module "eslint-plugin-react-compiler" {
2
- type Plugin = import("eslint").ESLint.Plugin;
3
- type LegacyConfig = import("eslint").Linter.LegacyConfig;
4
- interface ReactCompiler extends Plugin {
5
- rules: NonNullable<Plugin["rules"]>;
6
- configs: {
7
- recommended: LegacyConfig;
8
- };
9
- }
10
- const rules: ReactCompiler["rules"];
11
- const configs: ReactCompiler["configs"];
12
- export { configs, rules };
1
+ import type { ESLint, Linter } from "eslint";
2
+ interface ReactCompiler extends ESLint.Plugin {
3
+ rules: NonNullable<ESLint.Plugin["rules"]>;
4
+ configs: {
5
+ recommended: Linter.LegacyConfig;
6
+ };
13
7
  }
8
+ declare const reactCompilerInternal: ReactCompiler;
9
+ export { reactCompilerInternal as reactCompiler };
@@ -1 +1,10 @@
1
- "use strict";
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.reactCompiler = void 0;
7
+ var reactCompiler = _interopRequireWildcard(require("eslint-plugin-react-compiler"));
8
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
9
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
10
+ const reactCompilerInternal = exports.reactCompiler = reactCompiler.default ?? reactCompiler;
package/dist/vdustr.js CHANGED
@@ -6,13 +6,11 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.vdustr = void 0;
7
7
  var _eslintConfig = _interopRequireDefault(require("@antfu/eslint-config"));
8
8
  var _recommended = _interopRequireDefault(require("eslint-plugin-package-json/configs/recommended"));
9
- var reactCompilerPlugin = _interopRequireWildcard(require("eslint-plugin-react-compiler"));
10
9
  var _localPkg = require("local-pkg");
11
10
  var _mdx = require("./configs/mdx");
12
11
  var _prettier = require("./configs/prettier");
13
12
  var _storybook = require("./configs/storybook");
14
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
15
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
13
+ var _eslintPluginReactCompiler = require("./lib/eslint-plugin-react-compiler");
16
14
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
17
15
  const vdustr = (options, ...userConfigs) => {
18
16
  const typescriptEnabled = (0, _localPkg.isPackageExists)("typescript");
@@ -119,7 +117,7 @@ const vdustr = (options, ...userConfigs) => {
119
117
  ...config2,
120
118
  plugins: {
121
119
  ...config2.plugins,
122
- "react-compiler": reactCompilerPlugin
120
+ "react-compiler": _eslintPluginReactCompiler.reactCompiler
123
121
  },
124
122
  rules: {
125
123
  ...config2.rules,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vp-tw/eslint-config",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "description": "ViPro's ESLint configuration",
5
5
  "homepage": "https://github.com/vdustr/eslint-config",
6
6
  "author": {
@@ -1,12 +1,12 @@
1
1
  import type { ESLint } from "eslint";
2
2
  import { rules as mdxRules } from "eslint-plugin-mdx/lib/rules";
3
- // eslint-disable-next-line import/no-namespace -- This is a cjs module.
4
- import * as reactCompiler from "eslint-plugin-react-compiler";
3
+
5
4
  import storybook from "eslint-plugin-storybook";
6
5
  import { pluginsToRulesDTS } from "eslint-typegen/core";
7
6
  import fs from "fs-extra";
8
7
  import path from "pathe";
9
8
  import { packageDirectory } from "pkg-dir";
9
+ import { reactCompiler } from "../src/lib/eslint-plugin-react-compiler";
10
10
 
11
11
  (async () => {
12
12
  const pkgDir = await packageDirectory();
@@ -1,13 +1,16 @@
1
- declare module "eslint-plugin-react-compiler" {
2
- type Plugin = import("eslint").ESLint.Plugin;
3
- type LegacyConfig = import("eslint").Linter.LegacyConfig;
4
- interface ReactCompiler extends Plugin {
5
- rules: NonNullable<Plugin["rules"]>;
6
- configs: {
7
- recommended: LegacyConfig;
8
- };
9
- }
10
- const rules: ReactCompiler["rules"];
11
- const configs: ReactCompiler["configs"];
12
- export { configs, rules };
1
+ import type { ESLint, Linter } from "eslint";
2
+ // @ts-expect-error -- Untyped library.
3
+ // eslint-disable-next-line import/no-namespace -- `react-compiler` exports the plugin as a namespace.
4
+ import * as reactCompiler from "eslint-plugin-react-compiler";
5
+
6
+ interface ReactCompiler extends ESLint.Plugin {
7
+ rules: NonNullable<ESLint.Plugin["rules"]>;
8
+ configs: {
9
+ recommended: Linter.LegacyConfig;
10
+ };
13
11
  }
12
+
13
+ const reactCompilerInternal: ReactCompiler =
14
+ reactCompiler.default ?? reactCompiler;
15
+
16
+ export { reactCompilerInternal as reactCompiler };
package/src/vdustr.ts CHANGED
@@ -4,12 +4,12 @@ import type { Config } from "./types";
4
4
  import antfu from "@antfu/eslint-config";
5
5
 
6
6
  import packageJson from "eslint-plugin-package-json/configs/recommended";
7
- // eslint-disable-next-line import/no-namespace -- This is a cjs module.
8
- import * as reactCompilerPlugin from "eslint-plugin-react-compiler";
7
+
9
8
  import { isPackageExists } from "local-pkg";
10
9
  import { mdx } from "./configs/mdx";
11
10
  import { prettier } from "./configs/prettier";
12
11
  import { storybook } from "./configs/storybook";
12
+ import { reactCompiler } from "./lib/eslint-plugin-react-compiler";
13
13
 
14
14
  type Options = NonNullable<Parameters<typeof antfu>[0]> & {
15
15
  mdx?: boolean | mdx.Options;
@@ -21,14 +21,37 @@ const vdustr = (options?: Options, ...userConfigs: Array<Config>) => {
21
21
  const jsoncEnabled: boolean = Boolean(options?.jsonc ?? true);
22
22
  const reactEnabled: boolean = Boolean(options?.react ?? false);
23
23
  const storybookEnabled: boolean = Boolean(options?.storybook ?? false);
24
- const mdxOptions = options?.mdx ?? true;
24
+ const mdxEnabled: boolean = Boolean(options?.mdx ?? false);
25
+ const mdxOptions: Extract<Options["mdx"], Record<PropertyKey, any>> = {
26
+ ...(typeof options?.mdx !== "object" ? null : options.mdx),
27
+ };
28
+ const mdxFlatCodeBlocksEnabled: boolean = Boolean(
29
+ mdxOptions?.flatCodeBlocks ?? true,
30
+ );
31
+ const mdxFlatCodeBlocksOptions: Extract<
32
+ (typeof mdxOptions)["flatCodeBlocks"],
33
+ Record<PropertyKey, any>
34
+ > = {
35
+ ...(typeof mdxOptions?.flatCodeBlocks !== "object"
36
+ ? null
37
+ : mdxOptions.flatCodeBlocks),
38
+ };
25
39
  type Config = NonNullable<Parameters<typeof antfu>[1]>;
26
40
  const defaultConfigs: Array<Config> = [
27
41
  ...(!jsoncEnabled ? [] : [packageJson]),
28
- ...(!mdxOptions
42
+ ...(!mdxEnabled
29
43
  ? []
30
44
  : mdx({
31
- ...(typeof mdxOptions !== "object" ? null : mdxOptions),
45
+ ...mdxOptions,
46
+ flatCodeBlocks: !mdxFlatCodeBlocksEnabled
47
+ ? false
48
+ : {
49
+ ...mdxFlatCodeBlocksOptions,
50
+ rules: {
51
+ "import/no-default-export": "off",
52
+ ...mdxFlatCodeBlocksOptions?.rules,
53
+ },
54
+ },
32
55
  })),
33
56
  ...(!storybookEnabled ? [] : storybook),
34
57
  prettier,
@@ -155,7 +178,7 @@ const vdustr = (options?: Options, ...userConfigs: Array<Config>) => {
155
178
  ...config,
156
179
  plugins: {
157
180
  ...config.plugins,
158
- "react-compiler": reactCompilerPlugin,
181
+ "react-compiler": reactCompiler,
159
182
  },
160
183
  rules: {
161
184
  ...config.rules,