@pengzhanbo/eslint-config-react 0.4.2 → 1.0.0

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
@@ -1,28 +1,22 @@
1
1
  # @pengzhanbo/eslint-config-react
2
2
 
3
- ## Install
3
+ ## Documentation
4
4
 
5
- ```sh
6
- pnpm add eslint @pengzhanbo/eslint-config-react
7
- ```
5
+ [Document](https://github.com/pengzhanbo/configs/tree/main/docs/eslint.md)
8
6
 
9
- ## Config
7
+ ## Usage
10
8
 
11
- `.eslintrc`/`.eslintrc.json`
9
+ ## Install
12
10
 
13
- ```json
14
- {
15
- "extends": "@pengzhanbo"
16
- }
11
+ ```bash
12
+ pnpm add @pengzhanbo/eslint-config-react
17
13
  ```
18
14
 
19
- **package.json**
15
+ ## Configuration
16
+
17
+ `eslint.config.js`
18
+ ```js
19
+ import eslintConfig from '@pengzhanbo/eslint-config-react'
20
20
 
21
- ```json
22
- {
23
- "scripts": {
24
- "lint": "eslint .",
25
- "lint:fix": "eslint . --fix"
26
- }
27
- }
21
+ export default eslintConfig()
28
22
  ```
package/dist/index.cjs CHANGED
@@ -1,20 +1,148 @@
1
- 'use strict';
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
+
31
+ // src/index.ts
32
+ var src_exports = {};
33
+ __export(src_exports, {
34
+ default: () => src_default,
35
+ react: () => react,
36
+ reactPreset: () => reactPreset
37
+ });
38
+ module.exports = __toCommonJS(src_exports);
2
39
 
3
- const index = {
4
- extends: [
5
- "plugin:react/recommended",
6
- "plugin:react-hooks/recommended",
7
- "@pengzhanbo/eslint-config"
8
- ],
9
- settings: {
10
- react: {
11
- version: "17.0"
40
+ // src/factory.ts
41
+ var import_eslint_config2 = require("@pengzhanbo/eslint-config");
42
+
43
+ // src/react.ts
44
+ var import_local_pkg = require("local-pkg");
45
+ var import_eslint_config = require("@pengzhanbo/eslint-config");
46
+ var ReactRefreshAllowConstantExportPackages = [
47
+ "vite"
48
+ ];
49
+ async function react(options = {}) {
50
+ const {
51
+ files = [import_eslint_config.GLOB_JSX, import_eslint_config.GLOB_TSX],
52
+ overrides = {},
53
+ typescript = true
54
+ } = options;
55
+ const [
56
+ pluginReact,
57
+ pluginReactHooks,
58
+ pluginReactRefresh
59
+ ] = await Promise.all([
60
+ (0, import_eslint_config.interopDefault)(import("eslint-plugin-react")),
61
+ (0, import_eslint_config.interopDefault)(import("eslint-plugin-react-hooks")),
62
+ (0, import_eslint_config.interopDefault)(import("eslint-plugin-react-refresh"))
63
+ ]);
64
+ const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some(
65
+ (i) => (0, import_local_pkg.isPackageExists)(i)
66
+ );
67
+ return [
68
+ {
69
+ name: "antfu:react:setup",
70
+ plugins: {
71
+ "react": pluginReact,
72
+ "react-hooks": pluginReactHooks,
73
+ "react-refresh": pluginReactRefresh
74
+ }
75
+ },
76
+ {
77
+ files,
78
+ languageOptions: {
79
+ parserOptions: {
80
+ ecmaFeatures: {
81
+ jsx: true
82
+ }
83
+ }
84
+ },
85
+ name: "antfu:react:rules",
86
+ rules: {
87
+ // recommended rules react-hooks
88
+ "react-hooks/exhaustive-deps": "warn",
89
+ "react-hooks/rules-of-hooks": "error",
90
+ // react refresh
91
+ "react-refresh/only-export-components": [
92
+ "warn",
93
+ { allowConstantExport: isAllowConstantExport }
94
+ ],
95
+ // recommended rules react
96
+ "react/display-name": "error",
97
+ "react/jsx-key": "error",
98
+ "react/jsx-no-comment-textnodes": "error",
99
+ "react/jsx-no-duplicate-props": "error",
100
+ "react/jsx-no-target-blank": "error",
101
+ "react/jsx-no-undef": "error",
102
+ "react/jsx-uses-react": "error",
103
+ "react/jsx-uses-vars": "error",
104
+ "react/no-children-prop": "error",
105
+ "react/no-danger-with-children": "error",
106
+ "react/no-deprecated": "error",
107
+ "react/no-direct-mutation-state": "error",
108
+ "react/no-find-dom-node": "error",
109
+ "react/no-is-mounted": "error",
110
+ "react/no-render-return-value": "error",
111
+ "react/no-string-refs": "error",
112
+ "react/no-unescaped-entities": "error",
113
+ "react/no-unknown-property": "error",
114
+ "react/no-unsafe": "off",
115
+ "react/prop-types": "error",
116
+ "react/react-in-jsx-scope": "off",
117
+ "react/require-render-return": "error",
118
+ ...typescript ? {
119
+ "react/jsx-no-undef": "off",
120
+ "react/prop-type": "off"
121
+ } : {},
122
+ // overrides
123
+ ...overrides
124
+ }
12
125
  }
13
- },
14
- rules: {
15
- "jsx-quotes": ["error", "prefer-double"],
16
- "react/react-in-jsx-scope": "off"
17
- }
126
+ ];
127
+ }
128
+
129
+ // src/preset.ts
130
+ var reactPreset = (options) => {
131
+ return [react({
132
+ overrides: options.overrides.react,
133
+ typescript: !!options.typescript
134
+ })];
18
135
  };
19
136
 
20
- module.exports = index;
137
+ // src/factory.ts
138
+ var eslintReactConfig = (0, import_eslint_config2.createConfig)(reactPreset);
139
+
140
+ // src/index.ts
141
+ __reExport(src_exports, require("@pengzhanbo/eslint-config"), module.exports);
142
+ var src_default = eslintReactConfig;
143
+ // Annotate the CommonJS export names for ESM import in node:
144
+ 0 && (module.exports = {
145
+ react,
146
+ reactPreset,
147
+ ...require("@pengzhanbo/eslint-config")
148
+ });
@@ -0,0 +1,11 @@
1
+ import * as _pengzhanbo_eslint_config from '@pengzhanbo/eslint-config';
2
+ import { OptionsHasTypeScript, OptionsOverrides, OptionsFiles, FlatConfigItem, PresetItem } from '@pengzhanbo/eslint-config';
3
+ export * from '@pengzhanbo/eslint-config';
4
+
5
+ declare const eslintReactConfig: typeof _pengzhanbo_eslint_config.default;
6
+
7
+ declare function react(options?: OptionsHasTypeScript & OptionsOverrides & OptionsFiles): Promise<FlatConfigItem[]>;
8
+
9
+ declare const reactPreset: PresetItem;
10
+
11
+ export { eslintReactConfig as default, react, reactPreset };
package/dist/index.d.ts CHANGED
@@ -1,14 +1,11 @@
1
- declare const _default: {
2
- extends: string[];
3
- settings: {
4
- react: {
5
- version: string;
6
- };
7
- };
8
- rules: {
9
- 'jsx-quotes': string[];
10
- 'react/react-in-jsx-scope': string;
11
- };
12
- };
13
-
14
- export { _default as default };
1
+ import * as _pengzhanbo_eslint_config from '@pengzhanbo/eslint-config';
2
+ import { OptionsHasTypeScript, OptionsOverrides, OptionsFiles, FlatConfigItem, PresetItem } from '@pengzhanbo/eslint-config';
3
+ export * from '@pengzhanbo/eslint-config';
4
+
5
+ declare const eslintReactConfig: typeof _pengzhanbo_eslint_config.default;
6
+
7
+ declare function react(options?: OptionsHasTypeScript & OptionsOverrides & OptionsFiles): Promise<FlatConfigItem[]>;
8
+
9
+ declare const reactPreset: PresetItem;
10
+
11
+ export { eslintReactConfig as default, react, reactPreset };
package/dist/index.js ADDED
@@ -0,0 +1,108 @@
1
+ // src/factory.ts
2
+ import { createConfig } from "@pengzhanbo/eslint-config";
3
+
4
+ // src/react.ts
5
+ import { isPackageExists } from "local-pkg";
6
+ import { GLOB_JSX, GLOB_TSX, interopDefault } from "@pengzhanbo/eslint-config";
7
+ var ReactRefreshAllowConstantExportPackages = [
8
+ "vite"
9
+ ];
10
+ async function react(options = {}) {
11
+ const {
12
+ files = [GLOB_JSX, GLOB_TSX],
13
+ overrides = {},
14
+ typescript = true
15
+ } = options;
16
+ const [
17
+ pluginReact,
18
+ pluginReactHooks,
19
+ pluginReactRefresh
20
+ ] = await Promise.all([
21
+ interopDefault(import("eslint-plugin-react")),
22
+ interopDefault(import("eslint-plugin-react-hooks")),
23
+ interopDefault(import("eslint-plugin-react-refresh"))
24
+ ]);
25
+ const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some(
26
+ (i) => isPackageExists(i)
27
+ );
28
+ return [
29
+ {
30
+ name: "antfu:react:setup",
31
+ plugins: {
32
+ "react": pluginReact,
33
+ "react-hooks": pluginReactHooks,
34
+ "react-refresh": pluginReactRefresh
35
+ }
36
+ },
37
+ {
38
+ files,
39
+ languageOptions: {
40
+ parserOptions: {
41
+ ecmaFeatures: {
42
+ jsx: true
43
+ }
44
+ }
45
+ },
46
+ name: "antfu:react:rules",
47
+ rules: {
48
+ // recommended rules react-hooks
49
+ "react-hooks/exhaustive-deps": "warn",
50
+ "react-hooks/rules-of-hooks": "error",
51
+ // react refresh
52
+ "react-refresh/only-export-components": [
53
+ "warn",
54
+ { allowConstantExport: isAllowConstantExport }
55
+ ],
56
+ // recommended rules react
57
+ "react/display-name": "error",
58
+ "react/jsx-key": "error",
59
+ "react/jsx-no-comment-textnodes": "error",
60
+ "react/jsx-no-duplicate-props": "error",
61
+ "react/jsx-no-target-blank": "error",
62
+ "react/jsx-no-undef": "error",
63
+ "react/jsx-uses-react": "error",
64
+ "react/jsx-uses-vars": "error",
65
+ "react/no-children-prop": "error",
66
+ "react/no-danger-with-children": "error",
67
+ "react/no-deprecated": "error",
68
+ "react/no-direct-mutation-state": "error",
69
+ "react/no-find-dom-node": "error",
70
+ "react/no-is-mounted": "error",
71
+ "react/no-render-return-value": "error",
72
+ "react/no-string-refs": "error",
73
+ "react/no-unescaped-entities": "error",
74
+ "react/no-unknown-property": "error",
75
+ "react/no-unsafe": "off",
76
+ "react/prop-types": "error",
77
+ "react/react-in-jsx-scope": "off",
78
+ "react/require-render-return": "error",
79
+ ...typescript ? {
80
+ "react/jsx-no-undef": "off",
81
+ "react/prop-type": "off"
82
+ } : {},
83
+ // overrides
84
+ ...overrides
85
+ }
86
+ }
87
+ ];
88
+ }
89
+
90
+ // src/preset.ts
91
+ var reactPreset = (options) => {
92
+ return [react({
93
+ overrides: options.overrides.react,
94
+ typescript: !!options.typescript
95
+ })];
96
+ };
97
+
98
+ // src/factory.ts
99
+ var eslintReactConfig = createConfig(reactPreset);
100
+
101
+ // src/index.ts
102
+ export * from "@pengzhanbo/eslint-config";
103
+ var src_default = eslintReactConfig;
104
+ export {
105
+ src_default as default,
106
+ react,
107
+ reactPreset
108
+ };
package/package.json CHANGED
@@ -1,73 +1,55 @@
1
1
  {
2
2
  "name": "@pengzhanbo/eslint-config-react",
3
- "version": "0.4.2",
4
- "keywords": [
5
- "eslint-config",
6
- "react",
7
- "typescript"
8
- ],
3
+ "type": "module",
4
+ "version": "1.0.0",
5
+ "author": "pengzhanbo <q942450674@outlook.com> (https://github/pengzhanbo/)",
6
+ "license": "MIT",
9
7
  "homepage": "https://github.com/pengzhanbo/configs#readme",
10
8
  "repository": {
11
9
  "type": "git",
12
10
  "url": "git@github.com:pengzhanbo/configs.git",
13
11
  "directory": "packages/eslint-config-react"
14
12
  },
15
- "license": "MIT",
16
- "author": "pengzhanbo <q942450674@outlook.com> (https://github/pengzhanbo/)",
17
- "type": "module",
13
+ "keywords": [
14
+ "eslint-config",
15
+ "react"
16
+ ],
18
17
  "exports": {
19
18
  ".": {
20
- "require": "./dist/index.cjs",
21
- "import": "./dist/index.mjs"
19
+ "import": {
20
+ "types": "./dist/index.d.ts",
21
+ "default": "./dist/index.js"
22
+ },
23
+ "require": {
24
+ "types": "./dist/index.d.ts",
25
+ "default": "./dist/index.cjs"
26
+ }
22
27
  },
23
28
  "./package.json": "./package.json"
24
29
  },
25
- "main": "dist/index.cjs",
26
- "module": "dist/index.mjs",
30
+ "main": "dist/index.js",
27
31
  "types": "dist/index.d.ts",
28
32
  "files": [
29
33
  "dist"
30
34
  ],
31
- "unbuild": {
32
- "entries": [
33
- "./src/index"
34
- ],
35
- "declaration": true,
36
- "clean": true,
37
- "rollup": {
38
- "emitCJS": true
39
- }
35
+ "peerDependencies": {
36
+ "eslint": ">=8.40.0"
40
37
  },
41
38
  "dependencies": {
42
- "@typescript-eslint/eslint-plugin": "^6.2.0",
43
- "@typescript-eslint/parser": "^6.2.0",
44
- "eslint-config-prettier": "^8.9.0",
45
- "eslint-config-standard": "^17.1.0",
46
- "eslint-plugin-eslint-comments": "^3.2.0",
47
- "eslint-plugin-html": "^7.1.0",
48
- "eslint-plugin-import": "^2.28.0",
49
- "eslint-plugin-jsonc": "^2.9.0",
50
- "eslint-plugin-n": "^16.0.1",
51
- "eslint-plugin-promise": "^6.1.1",
52
- "eslint-plugin-react": "^7.33.1",
39
+ "eslint-plugin-react": "^7.33.2",
53
40
  "eslint-plugin-react-hooks": "^4.6.0",
54
- "eslint-plugin-unicorn": "^48.0.1",
55
- "eslint-plugin-yml": "^1.8.0",
56
- "jsonc-eslint-parser": "^2.3.0",
57
- "yaml-eslint-parser": "^1.2.2",
58
- "@pengzhanbo/eslint-config": "0.4.2"
41
+ "eslint-plugin-react-refresh": "^0.4.4",
42
+ "local-pkg": "^0.5.0",
43
+ "@pengzhanbo/eslint-config": "1.0.0"
59
44
  },
60
45
  "devDependencies": {
61
- "eslint": "^8.46.0",
62
- "react": "^18.2.0",
63
- "typescript": "^5.1.6",
64
- "unbuild": "^1.2.1"
65
- },
66
- "peerDependencies": {
67
- "eslint": ">=7.4.0"
46
+ "eslint": "^8.54.0",
47
+ "eslint-flat-config-viewer": "^0.1.3",
48
+ "tsup": "^8.0.1"
68
49
  },
69
50
  "scripts": {
70
- "build": "unbuild",
71
- "stub": "unbuild --stub"
51
+ "dev": "tsup src/index.ts --format esm --watch & eslint-flat-config-viewer",
52
+ "build": "tsup src/index.ts --format esm,cjs --clean --dts --shims",
53
+ "stub": "tsup src/index.ts --format esm"
72
54
  }
73
55
  }
package/dist/index.mjs DELETED
@@ -1,18 +0,0 @@
1
- const index = {
2
- extends: [
3
- "plugin:react/recommended",
4
- "plugin:react-hooks/recommended",
5
- "@pengzhanbo/eslint-config"
6
- ],
7
- settings: {
8
- react: {
9
- version: "17.0"
10
- }
11
- },
12
- rules: {
13
- "jsx-quotes": ["error", "prefer-double"],
14
- "react/react-in-jsx-scope": "off"
15
- }
16
- };
17
-
18
- export { index as default };