hkx-eslint-config 2.0.1 → 2.0.2

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 (2) hide show
  1. package/README.md +40 -29
  2. package/package.json +54 -7
package/README.md CHANGED
@@ -8,55 +8,66 @@ HKX 代码规范,基于 ESLint 9 Flat Config。
8
8
  pnpm add -D eslint hkx-eslint-config
9
9
  ```
10
10
 
11
- 要求 **ESLint ^9.32.0**(peerDependency)。
11
+ - **ESLint**:^9.32.0peerDependency
12
+ - **TypeScript 配置**(`standard-ts` / `node-ts` / `react-ts` / `vue-ts`):需在项目中安装 `typescript`,且 type-aware 规则依赖 `tsconfig.json`
12
13
 
13
- ## 用法
14
+ ## 两种用法
14
15
 
15
- 在项目根目录新建 `eslint.config.js`(或 `eslint.config.mjs` / `eslint.config.ts`),按项目类型选用对应 config 并展开:
16
+ ### 1. 使用 config(开箱即用)
17
+
18
+ 直接使用预设配置,已包含解析器、extends、语言选项等:
16
19
 
17
20
  ```js
18
21
  import { defineConfig } from 'eslint/config';
19
- import hkx from 'hkx-eslint-config';
22
+ import nodeTs from 'hkx-eslint-config/node-ts';
20
23
 
21
24
  export default defineConfig([
22
- ...hkx.configs.ts, // 按需换成 js / node / react / vue / vueTs / reactTs / nodeTs
23
- {
24
- ignores: ['**/node_modules/**', '**/dist/**'],
25
- },
25
+ ...nodeTs,
26
+ { ignores: ['**/node_modules/**', '**/dist/**'] },
26
27
  ]);
27
28
  ```
28
29
 
29
- ### 可选配置
30
+ | 子路径 | 说明 |
31
+ |--------|------|
32
+ | `hkx-eslint-config/standard` | 纯 JavaScript |
33
+ | `hkx-eslint-config/standard-ts` | TypeScript |
34
+ | `hkx-eslint-config/node` | Node.js (JS) |
35
+ | `hkx-eslint-config/node-ts` | Node.js (TS) |
36
+ | `hkx-eslint-config/react` | React (JS) |
37
+ | `hkx-eslint-config/react-ts` | React (TS) |
38
+ | `hkx-eslint-config/vue` | Vue (JS) |
39
+ | `hkx-eslint-config/vue-ts` | Vue (TS) |
30
40
 
31
- | 名称 | 说明 |
32
- |----------|----------------|
33
- | `js` | 纯 JavaScript |
34
- | `ts` | TypeScript |
35
- | `node` | Node.js (JS) |
36
- | `nodeTs` | Node.js (TS) |
37
- | `react` | React (JS) |
38
- | `reactTs`| React (TS) |
39
- | `vue` | Vue (JS) |
40
- | `vueTs` | Vue (TS) |
41
+ ### 2. 仅使用规则,自配解析器等
41
42
 
42
- 多种场景可组合多段 config(如先 `...hkx.configs.ts` `...hkx.configs.vueTs`),或按 `files` 在各自 config 里区分。
43
-
44
- ## 以插件形式使用
45
-
46
- 可挂载自带的 plugin,通过 `extends` 使用内置规则(plugin 提供 `js` / `ts` / `node` / `react` / `vue`):
43
+ 只引入规则集(`Linter.Config`),自行配置 parser、languageOptions、plugins 等:
47
44
 
48
45
  ```js
49
46
  import { defineConfig } from 'eslint/config';
50
- import hkx from 'hkx-eslint-config';
47
+ import recommendedTypescript from 'hkx-eslint-config/rules/recommended-typescript';
48
+ import node from 'hkx-eslint-config/rules/node';
49
+ import tseslint from 'typescript-eslint';
50
+ import globals from 'globals';
51
51
 
52
52
  export default defineConfig([
53
53
  {
54
- plugins: {
55
- hkx: hkx.plugin,
54
+ files: ['**/*.ts'],
55
+ extends: [recommendedTypescript, node],
56
+ languageOptions: {
57
+ parser: tseslint.parser,
58
+ parserOptions: { projectService: true },
59
+ globals: { ...globals.node },
56
60
  },
57
- extends: ['hkx/ts'],
58
61
  },
59
62
  ]);
60
63
  ```
61
64
 
62
- 推荐直接展开 `hkx.configs.xxx`,按需组合、可配合 `files` `ignores`。
65
+ | 子路径 | 说明 |
66
+ |--------|------|
67
+ | `hkx-eslint-config/rules/recommended-javascript` | JS 基础规则集 |
68
+ | `hkx-eslint-config/rules/recommended-typescript` | TS 基础规则集 |
69
+ | `hkx-eslint-config/rules/node` | Node 规则集 |
70
+ | `hkx-eslint-config/rules/react` | React 规则集 |
71
+ | `hkx-eslint-config/rules/vue` | Vue 规则集 |
72
+
73
+ 可任意组合 rules,再自行设置 parser、globals、plugins 等。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hkx-eslint-config",
3
- "version": "2.0.1",
3
+ "version": "2.0.2",
4
4
  "description": "HKX 代码规范",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -12,14 +12,60 @@
12
12
  "author": "withAthree <huangkaixiang8462@163.com>",
13
13
  "license": "ISC",
14
14
  "exports": {
15
- ".": {
16
- "types": "./dist/index.d.ts",
17
- "import": "./dist/index.js"
15
+ "./node": {
16
+ "types": "./dist/config/node-js.d.ts",
17
+ "import": "./dist/config/node-js.js"
18
+ },
19
+ "./node-ts": {
20
+ "types": "./dist/config/node-ts.d.ts",
21
+ "import": "./dist/config/node-ts.js"
22
+ },
23
+ "./react": {
24
+ "types": "./dist/config/react-js.d.ts",
25
+ "import": "./dist/config/react-js.js"
26
+ },
27
+ "./react-ts": {
28
+ "types": "./dist/config/react-ts.d.ts",
29
+ "import": "./dist/config/react-ts.js"
30
+ },
31
+ "./standard": {
32
+ "types": "./dist/config/standard-js.d.ts",
33
+ "import": "./dist/config/standard-js.js"
34
+ },
35
+ "./standard-ts": {
36
+ "types": "./dist/config/standard-ts.d.ts",
37
+ "import": "./dist/config/standard-ts.js"
38
+ },
39
+ "./vue": {
40
+ "types": "./dist/config/vue-js.d.ts",
41
+ "import": "./dist/config/vue-js.js"
42
+ },
43
+ "./vue-ts": {
44
+ "types": "./dist/config/vue-ts.d.ts",
45
+ "import": "./dist/config/vue-ts.js"
46
+ },
47
+ "./rules/recommended-javascript": {
48
+ "types": "./dist/rules/recommended-javascript.d.ts",
49
+ "import": "./dist/rules/recommended-javascript.js"
50
+ },
51
+ "./rules/recommended-typescript": {
52
+ "types": "./dist/rules/recommended-typescript.d.ts",
53
+ "import": "./dist/rules/recommended-typescript.js"
54
+ },
55
+ "./rules/node": {
56
+ "types": "./dist/rules/node.d.ts",
57
+ "import": "./dist/rules/node.js"
58
+ },
59
+ "./rules/react": {
60
+ "types": "./dist/rules/react.d.ts",
61
+ "import": "./dist/rules/react.js"
62
+ },
63
+ "./rules/vue": {
64
+ "types": "./dist/rules/vue.d.ts",
65
+ "import": "./dist/rules/vue.js"
18
66
  },
19
67
  "./package.json": "./package.json"
20
68
  },
21
- "main": "./dist/index.js",
22
- "types": "./dist/index.d.ts",
23
69
  "directories": {
24
70
  "test": "__tests__"
25
71
  },
@@ -54,5 +100,6 @@
54
100
  },
55
101
  "resolutions": {
56
102
  "eslint": "^9.32.0"
57
- }
103
+ },
104
+ "gitHead": "15a59a83e5b512dfb00628eb6520b0b1ac93a5ed"
58
105
  }