@vp-tw/eslint-config 0.0.4 → 0.0.6

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/README.md CHANGED
@@ -7,9 +7,43 @@ ViPro's ESLint configuration.
7
7
  - [eslint-config-prettier](https://github.com/prettier/eslint-config-prettier)
8
8
  - [eslint-mdx](https://github.com/mdx-js/eslint-mdx).
9
9
  - [eslint-plugin-storybook](https://github.com/storybookjs/eslint-plugin-storybook)
10
+ - [eslint-plugin-react-compiler](https://www.npmjs.com/package/eslint-plugin-react-compiler)
10
11
  - Fine-tuned to provide an opinionated, optimal DX. Please copy the VSCode settings from [eslint-config.code-workspace](https://github.com/VdustR/eslint-config/blob/main/eslint-config.code-workspace).
11
12
 
12
- Click [here](https://vdustr.dev/eslint-config) to preview the ESLint inspection.
13
+ Check [here](https://vdustr.dev/eslint-config) to preview the ESLint inspection.
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ pnpm i -D @vp-tw/eslint-config
19
+ ```
20
+
21
+ ## Usage
22
+
23
+ Simlar to [antfu/eslint-config](https://github.com/antfu/eslint-config) but with additional options:
24
+
25
+ ```ts
26
+ // eslint.config.ts
27
+ import { fileURLToPath } from "node:url";
28
+
29
+ import { includeIgnoreFile } from "@eslint/compat";
30
+ import { vdustr } from "@vp-tw/eslint-config";
31
+ import path from "pathe";
32
+
33
+ const __filename = fileURLToPath(import.meta.url);
34
+ const __dirname = path.dirname(__filename);
35
+ const prettierignorePath = path.resolve(__dirname, ".prettierignore");
36
+
37
+ export default vdustr(
38
+ {
39
+ // `stylistic` has been removed in favor of `prettier`.
40
+ // stylistic: true,
41
+ storybook: true,
42
+ mdx: true,
43
+ },
44
+ includeIgnoreFile(prettierignorePath),
45
+ );
46
+ ```
13
47
 
14
48
  ## License
15
49
 
@@ -1,7 +1,7 @@
1
1
  import type { Config } from "./types";
2
2
  import antfu from "@antfu/eslint-config";
3
3
  import { mdx } from "./configs/mdx";
4
- type Options = NonNullable<Parameters<typeof antfu>[0]> & {
4
+ type Options = Omit<NonNullable<Parameters<typeof antfu>[0]>, "stylistic"> & {
5
5
  mdx?: boolean | mdx.Options;
6
6
  storybook?: boolean;
7
7
  };
@@ -10,11 +10,27 @@ const vdustr = (options, ...userConfigs) => {
10
10
  const jsoncEnabled = Boolean(options?.jsonc ?? true);
11
11
  const reactEnabled = Boolean(options?.react ?? false);
12
12
  const storybookEnabled = Boolean(options?.storybook ?? false);
13
- const mdxOptions = options?.mdx ?? true;
13
+ const mdxEnabled = Boolean(options?.mdx ?? false);
14
+ const mdxOptions = {
15
+ ...typeof options?.mdx !== "object" ? null : options.mdx
16
+ };
17
+ const mdxFlatCodeBlocksEnabled = Boolean(
18
+ mdxOptions?.flatCodeBlocks ?? true
19
+ );
20
+ const mdxFlatCodeBlocksOptions = {
21
+ ...typeof mdxOptions?.flatCodeBlocks !== "object" ? null : mdxOptions.flatCodeBlocks
22
+ };
14
23
  const defaultConfigs = [
15
24
  ...!jsoncEnabled ? [] : [packageJson],
16
- ...!mdxOptions ? [] : mdx({
17
- ...typeof mdxOptions !== "object" ? null : mdxOptions
25
+ ...!mdxEnabled ? [] : mdx({
26
+ ...mdxOptions,
27
+ flatCodeBlocks: !mdxFlatCodeBlocksEnabled ? false : {
28
+ ...mdxFlatCodeBlocksOptions,
29
+ rules: {
30
+ "import/no-default-export": "off",
31
+ ...mdxFlatCodeBlocksOptions?.rules
32
+ }
33
+ }
18
34
  }),
19
35
  ...!storybookEnabled ? [] : storybook,
20
36
  prettier
package/dist/vdustr.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import type { Config } from "./types";
2
2
  import antfu from "@antfu/eslint-config";
3
3
  import { mdx } from "./configs/mdx";
4
- type Options = NonNullable<Parameters<typeof antfu>[0]> & {
4
+ type Options = Omit<NonNullable<Parameters<typeof antfu>[0]>, "stylistic"> & {
5
5
  mdx?: boolean | mdx.Options;
6
6
  storybook?: boolean;
7
7
  };
package/dist/vdustr.js CHANGED
@@ -17,9 +17,23 @@ const vdustr = (options, ...userConfigs) => {
17
17
  const jsoncEnabled = Boolean(options?.jsonc ?? true);
18
18
  const reactEnabled = Boolean(options?.react ?? false);
19
19
  const storybookEnabled = Boolean(options?.storybook ?? false);
20
- const mdxOptions = options?.mdx ?? true;
21
- const defaultConfigs = [...(!jsoncEnabled ? [] : [_recommended.default]), ...(!mdxOptions ? [] : (0, _mdx.mdx)({
22
- ...(typeof mdxOptions !== "object" ? null : mdxOptions)
20
+ const mdxEnabled = Boolean(options?.mdx ?? false);
21
+ const mdxOptions = {
22
+ ...(typeof options?.mdx !== "object" ? null : options.mdx)
23
+ };
24
+ const mdxFlatCodeBlocksEnabled = Boolean(mdxOptions?.flatCodeBlocks ?? true);
25
+ const mdxFlatCodeBlocksOptions = {
26
+ ...(typeof mdxOptions?.flatCodeBlocks !== "object" ? null : mdxOptions.flatCodeBlocks)
27
+ };
28
+ const defaultConfigs = [...(!jsoncEnabled ? [] : [_recommended.default]), ...(!mdxEnabled ? [] : (0, _mdx.mdx)({
29
+ ...mdxOptions,
30
+ flatCodeBlocks: !mdxFlatCodeBlocksEnabled ? false : {
31
+ ...mdxFlatCodeBlocksOptions,
32
+ rules: {
33
+ "import/no-default-export": "off",
34
+ ...mdxFlatCodeBlocksOptions?.rules
35
+ }
36
+ }
23
37
  })), ...(!storybookEnabled ? [] : _storybook.storybook), _prettier.prettier];
24
38
  let config = (0, _eslintConfig.default)({
25
39
  // We use `prettier`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vp-tw/eslint-config",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "description": "ViPro's ESLint configuration",
5
5
  "homepage": "https://github.com/vdustr/eslint-config",
6
6
  "author": {
package/src/vdustr.ts CHANGED
@@ -11,7 +11,7 @@ import { prettier } from "./configs/prettier";
11
11
  import { storybook } from "./configs/storybook";
12
12
  import { reactCompiler } from "./lib/eslint-plugin-react-compiler";
13
13
 
14
- type Options = NonNullable<Parameters<typeof antfu>[0]> & {
14
+ type Options = Omit<NonNullable<Parameters<typeof antfu>[0]>, "stylistic"> & {
15
15
  mdx?: boolean | mdx.Options;
16
16
  storybook?: boolean;
17
17
  };
@@ -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,