@july_cm/eslint-config 2.5.0 → 2.5.1
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 +66 -57
- package/README.zh-CN.md +67 -58
- package/dist/index.cjs +274 -0
- package/dist/index.js +237 -0
- package/package.json +27 -13
- package/lib/index.cjs +0 -163
- package/lib/index.mjs +0 -163
package/README.md
CHANGED
|
@@ -6,25 +6,18 @@
|
|
|
6
6
|
[](https://www.npmjs.com/package/@july_cm/eslint-config)
|
|
7
7
|
[](https://codecov.io/gh/JxJuly/eslint-config)
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Shared ESLint config for July's projects.
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
❌ [legacy configuration](https://eslint.org/docs/latest/use/configure/configuration-files-deprecated) (legacy: `.eslintrc*`)
|
|
14
|
-
|
|
15
|
-
✅ [flat configuration](https://eslint.org/docs/latest/use/configure/configuration-files-new) (new: `eslint.config.js`)
|
|
11
|
+
Requires ESLint v10 or later, only compatible with [flat configuration](https://eslint.org/docs/latest/use/configure/configuration-files-new) (`eslint.config.js`).
|
|
16
12
|
|
|
17
13
|
## Features
|
|
18
14
|
|
|
19
|
-
- ✅ Out-of-the-box
|
|
20
|
-
|
|
21
|
-
- ✅ Out-of-the-box
|
|
22
|
-
|
|
23
|
-
- ✅
|
|
24
|
-
|
|
25
|
-
- ✅ Support for package.json field sorting, especially dependencies and other fields
|
|
26
|
-
|
|
27
|
-
- ✅ Code style checking with Prettier rules
|
|
15
|
+
- ✅ Out-of-the-box JavaScript ESLint configuration
|
|
16
|
+
- ✅ Out-of-the-box TypeScript ESLint configuration
|
|
17
|
+
- ✅ Out-of-the-box CSS ESLint configuration (with Tailwind CSS v4 support)
|
|
18
|
+
- ✅ Comprehensive `package.json` field sorting (all npm standard fields + sub-field ordering)
|
|
19
|
+
- ✅ Automatic import/export sorting via `eslint-plugin-simple-import-sort`
|
|
20
|
+
- ✅ Integrated Prettier formatting rules (no need for a separate Prettier extension)
|
|
28
21
|
|
|
29
22
|
## Installation
|
|
30
23
|
|
|
@@ -32,17 +25,17 @@ It depends on ESLint v9 or later and is only compatible with Flat Configuration.
|
|
|
32
25
|
npm install --save-dev eslint @july_cm/eslint-config
|
|
33
26
|
```
|
|
34
27
|
|
|
35
|
-
`@july_cm/eslint-config` does not install ESLint for you. You must install
|
|
28
|
+
`@july_cm/eslint-config` does not install ESLint for you. You must install it yourself.
|
|
36
29
|
|
|
37
30
|
## Quick Start
|
|
38
31
|
|
|
39
|
-
|
|
32
|
+
You can use individual language configurations or the `recommended` preset directly.
|
|
40
33
|
|
|
41
|
-
When using `recommended
|
|
34
|
+
When using `recommended`, you don't need to worry about `.ts` files being matched by `javascript` rules — rules are internally isolated per language.
|
|
42
35
|
|
|
43
36
|
```javascript
|
|
44
37
|
// eslint.config.js
|
|
45
|
-
|
|
38
|
+
import * as config from '@july_cm/eslint-config';
|
|
46
39
|
|
|
47
40
|
// only javascript
|
|
48
41
|
export default config.javascript;
|
|
@@ -50,86 +43,102 @@ export default config.javascript;
|
|
|
50
43
|
// only typescript
|
|
51
44
|
export default config.typescript;
|
|
52
45
|
|
|
46
|
+
// only css
|
|
47
|
+
export default config.css;
|
|
48
|
+
|
|
49
|
+
// only package.json sorting
|
|
50
|
+
export default config.packageJson;
|
|
51
|
+
|
|
53
52
|
/**
|
|
54
|
-
* recommended
|
|
53
|
+
* recommended (includes all of the above)
|
|
55
54
|
* - javascript
|
|
56
55
|
* - typescript
|
|
56
|
+
* - css
|
|
57
57
|
* - package.json
|
|
58
58
|
*/
|
|
59
59
|
export default config.recommended;
|
|
60
60
|
```
|
|
61
61
|
|
|
62
|
-
⚠️
|
|
62
|
+
⚠️ If the `type` field in `package.json` is not set to `"module"`, rename the config file to `eslint.config.mjs`.
|
|
63
63
|
|
|
64
64
|
## Custom Rules
|
|
65
65
|
|
|
66
|
-
|
|
66
|
+
You can extend or override rules using ESLint's `defineConfig`:
|
|
67
67
|
|
|
68
68
|
```javascript
|
|
69
69
|
// eslint.config.js
|
|
70
70
|
import { recommended } from '@july_cm/eslint-config';
|
|
71
|
-
import { defineConfig } from 'eslint/config';
|
|
72
|
-
|
|
73
|
-
export default defineConfig(
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
71
|
+
import { defineConfig, globalIgnores } from 'eslint/config';
|
|
72
|
+
|
|
73
|
+
export default defineConfig(
|
|
74
|
+
globalIgnores(['dist']),
|
|
75
|
+
recommended,
|
|
76
|
+
{
|
|
77
|
+
rules: {
|
|
78
|
+
// your custom rules
|
|
79
|
+
},
|
|
80
|
+
}
|
|
81
|
+
);
|
|
77
82
|
```
|
|
78
83
|
|
|
84
|
+
## Included Configurations
|
|
79
85
|
|
|
80
|
-
|
|
86
|
+
### JavaScript
|
|
81
87
|
|
|
82
|
-
|
|
88
|
+
- Extends `@eslint/js` recommended rules
|
|
89
|
+
- Auto-sorts imports and exports
|
|
90
|
+
- Prettier formatting (single quotes, semicolons, 80 char width, ES5 trailing commas)
|
|
91
|
+
- Files: `**/*.{js,mjs,cjs,jsx}`
|
|
83
92
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
```
|
|
93
|
+
### TypeScript
|
|
94
|
+
|
|
95
|
+
- Extends `@eslint/js` recommended + `typescript-eslint` recommended rules
|
|
96
|
+
- Enforces `type` imports (`@typescript-eslint/consistent-type-imports`)
|
|
97
|
+
- Auto-sorts imports and exports
|
|
98
|
+
- Prettier formatting
|
|
99
|
+
- Files: `**/*.{ts,tsx}`
|
|
100
|
+
|
|
101
|
+
### CSS
|
|
102
|
+
|
|
103
|
+
- Powered by `@eslint/css` with Tailwind CSS v4 custom syntax support
|
|
104
|
+
- Prettier formatting
|
|
105
|
+
- Files: `**/*.css`
|
|
98
106
|
|
|
99
|
-
|
|
107
|
+
### package.json
|
|
100
108
|
|
|
101
|
-
|
|
109
|
+
- Sorts all npm standard fields into logical groups: metadata → environment → entries → scripts → dependencies → publish
|
|
110
|
+
- Sub-field ordering for `exports`, `repository`, `bugs`, `engines`, `scripts`, etc.
|
|
111
|
+
- Dependencies sorted alphabetically
|
|
102
112
|
|
|
103
|
-
|
|
113
|
+
## With Visual Studio Code
|
|
114
|
+
|
|
115
|
+
1. Install the [VS Code ESLint extension](https://github.com/microsoft/vscode-eslint).
|
|
116
|
+
|
|
117
|
+
Make sure ESLint is set as the default formatter:
|
|
104
118
|
|
|
105
119
|
```json
|
|
106
120
|
{
|
|
107
|
-
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
|
|
121
|
+
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
|
|
108
122
|
}
|
|
109
123
|
```
|
|
110
124
|
|
|
111
|
-
If the Prettier extension is
|
|
112
|
-
|
|
113
|
-
`@july_cm/eslint-config` has already integrated `eslint-plugin-prettier`, ensuring that both can work simultaneously without conflict.
|
|
114
|
-
|
|
125
|
+
If the Prettier extension is active in this workspace, disable it — `@july_cm/eslint-config` already integrates `eslint-plugin-prettier` so both work together without conflict.
|
|
115
126
|
|
|
116
|
-
2.
|
|
127
|
+
2. Enable fix on save:
|
|
117
128
|
|
|
118
129
|
```json
|
|
119
130
|
{
|
|
120
131
|
"editor.codeActionsOnSave": {
|
|
121
132
|
"source.fixAll.eslint": "explicit"
|
|
122
133
|
},
|
|
123
|
-
// ESLint does not validate css, json, jsonc by default, needs to be added manually
|
|
124
134
|
"eslint.validate": ["css", "json", "jsonc", "javascript", "javascriptreact", "typescript", "typescriptreact"]
|
|
125
135
|
}
|
|
126
136
|
```
|
|
127
137
|
|
|
128
|
-
3. Debug
|
|
138
|
+
3. Debug:
|
|
129
139
|
|
|
130
|
-
Open
|
|
140
|
+
Open the Command Palette (Ctrl + Shift + P / Cmd + Shift + P) and run:
|
|
131
141
|
|
|
132
142
|
```
|
|
133
143
|
ESLint: Show Output Channel
|
|
134
144
|
```
|
|
135
|
-
Fix errors if they exist.
|
package/README.zh-CN.md
CHANGED
|
@@ -6,25 +6,18 @@
|
|
|
6
6
|
[](https://www.npmjs.com/package/@july_cm/eslint-config)
|
|
7
7
|
[](https://codecov.io/gh/JxJuly/eslint-config)
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
July 的通用 ESLint 配置。
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
❌ [传统配置](https://eslint.org/docs/latest/use/configure/configuration-files-deprecated) (legacy: `.eslintrc*`)
|
|
14
|
-
|
|
15
|
-
✅ [扁平化配置](https://eslint.org/docs/latest/use/configure/configuration-files-new) (new: `eslint.config.js`)
|
|
11
|
+
依赖 ESLint v10 或更高版本,仅兼容[扁平化配置](https://eslint.org/docs/latest/use/configure/configuration-files-new)(`eslint.config.js`)。
|
|
16
12
|
|
|
17
13
|
## 功能
|
|
18
14
|
|
|
19
|
-
- ✅
|
|
20
|
-
|
|
21
|
-
- ✅
|
|
22
|
-
|
|
23
|
-
- ✅
|
|
24
|
-
|
|
25
|
-
- ✅ 支持 package.json 字段的排序,尤其是 dependencies 等字段
|
|
26
|
-
|
|
27
|
-
- ✅ 搭配 Prettier 规则的代码风格检查
|
|
15
|
+
- ✅ 开箱即用的 JavaScript ESLint 配置
|
|
16
|
+
- ✅ 开箱即用的 TypeScript ESLint 配置
|
|
17
|
+
- ✅ 开箱即用的 CSS ESLint 配置(支持 Tailwind CSS v4)
|
|
18
|
+
- ✅ 全面的 `package.json` 字段排序(覆盖所有 npm 标准字段 + 子字段排序)
|
|
19
|
+
- ✅ 通过 `eslint-plugin-simple-import-sort` 自动排序 import/export
|
|
20
|
+
- ✅ 集成 Prettier 格式化规则(无需单独安装 Prettier 扩展)
|
|
28
21
|
|
|
29
22
|
## 安装
|
|
30
23
|
|
|
@@ -32,104 +25,120 @@
|
|
|
32
25
|
npm install --save-dev eslint @july_cm/eslint-config
|
|
33
26
|
```
|
|
34
27
|
|
|
35
|
-
`@july_cm/eslint-config` 不会为你安装 ESLint
|
|
28
|
+
`@july_cm/eslint-config` 不会为你安装 ESLint,你必须自行安装。
|
|
36
29
|
|
|
37
30
|
## 快速开始
|
|
38
31
|
|
|
39
|
-
|
|
32
|
+
可以使用单独的语言配置,也可以直接使用 `recommended` 预设。
|
|
40
33
|
|
|
41
|
-
|
|
34
|
+
使用 `recommended` 时无需担心 `.ts` 文件被 `javascript` 规则命中——规则已按语言做了内部隔离。
|
|
42
35
|
|
|
43
36
|
```javascript
|
|
44
37
|
// eslint.config.js
|
|
45
|
-
|
|
38
|
+
import * as config from '@july_cm/eslint-config';
|
|
46
39
|
|
|
47
|
-
//
|
|
40
|
+
// 仅 JavaScript
|
|
48
41
|
export default config.javascript;
|
|
49
42
|
|
|
50
|
-
//
|
|
43
|
+
// 仅 TypeScript
|
|
51
44
|
export default config.typescript;
|
|
52
45
|
|
|
46
|
+
// 仅 CSS
|
|
47
|
+
export default config.css;
|
|
48
|
+
|
|
49
|
+
// 仅 package.json 排序
|
|
50
|
+
export default config.packageJson;
|
|
51
|
+
|
|
53
52
|
/**
|
|
54
|
-
* recommended
|
|
53
|
+
* recommended(包含以上所有配置)
|
|
55
54
|
* - javascript
|
|
56
55
|
* - typescript
|
|
56
|
+
* - css
|
|
57
57
|
* - package.json
|
|
58
58
|
*/
|
|
59
59
|
export default config.recommended;
|
|
60
60
|
```
|
|
61
61
|
|
|
62
|
-
⚠️
|
|
62
|
+
⚠️ 若 `package.json` 中的 `type` 字段未设置为 `"module"`,需要将配置文件名改为 `eslint.config.mjs`。
|
|
63
63
|
|
|
64
64
|
## 自定义规则
|
|
65
65
|
|
|
66
|
-
|
|
66
|
+
可以使用 ESLint 的 `defineConfig` 扩展或覆盖规则:
|
|
67
67
|
|
|
68
68
|
```javascript
|
|
69
69
|
// eslint.config.js
|
|
70
70
|
import { recommended } from '@july_cm/eslint-config';
|
|
71
|
-
import { defineConfig } from 'eslint/config';
|
|
72
|
-
|
|
73
|
-
export default defineConfig(
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
71
|
+
import { defineConfig, globalIgnores } from 'eslint/config';
|
|
72
|
+
|
|
73
|
+
export default defineConfig(
|
|
74
|
+
globalIgnores(['dist']),
|
|
75
|
+
recommended,
|
|
76
|
+
{
|
|
77
|
+
rules: {
|
|
78
|
+
// 你的自定义规则
|
|
79
|
+
},
|
|
80
|
+
}
|
|
81
|
+
);
|
|
77
82
|
```
|
|
78
83
|
|
|
84
|
+
## 包含的配置
|
|
79
85
|
|
|
80
|
-
|
|
86
|
+
### JavaScript
|
|
81
87
|
|
|
82
|
-
|
|
88
|
+
- 继承 `@eslint/js` recommended 规则
|
|
89
|
+
- 自动排序 import 和 export
|
|
90
|
+
- Prettier 格式化(单引号、分号、80 字符宽度、ES5 尾逗号)
|
|
91
|
+
- 匹配文件:`**/*.{js,mjs,cjs,jsx}`
|
|
83
92
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
```
|
|
93
|
+
### TypeScript
|
|
94
|
+
|
|
95
|
+
- 继承 `@eslint/js` recommended + `typescript-eslint` recommended 规则
|
|
96
|
+
- 强制使用 `type` 导入(`@typescript-eslint/consistent-type-imports`)
|
|
97
|
+
- 自动排序 import 和 export
|
|
98
|
+
- Prettier 格式化
|
|
99
|
+
- 匹配文件:`**/*.{ts,tsx}`
|
|
100
|
+
|
|
101
|
+
### CSS
|
|
102
|
+
|
|
103
|
+
- 基于 `@eslint/css`,支持 Tailwind CSS v4 自定义语法
|
|
104
|
+
- Prettier 格式化
|
|
105
|
+
- 匹配文件:`**/*.css`
|
|
98
106
|
|
|
99
|
-
|
|
107
|
+
### package.json
|
|
108
|
+
|
|
109
|
+
- 将所有 npm 标准字段按逻辑分组排序:metadata → environment → entries → scripts → dependencies → publish
|
|
110
|
+
- 子字段排序:`exports`、`repository`、`bugs`、`engines`、`scripts` 等
|
|
111
|
+
- 依赖按字母升序排列
|
|
112
|
+
|
|
113
|
+
## 配合 Visual Studio Code 使用
|
|
100
114
|
|
|
101
115
|
1. 安装 [VS Code ESLint 扩展](https://github.com/microsoft/vscode-eslint)。
|
|
102
116
|
|
|
103
|
-
|
|
117
|
+
确保 ESLint 被设置为默认格式化程序:
|
|
104
118
|
|
|
105
119
|
```json
|
|
106
120
|
{
|
|
107
|
-
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
|
|
121
|
+
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
|
|
108
122
|
}
|
|
109
123
|
```
|
|
110
124
|
|
|
111
|
-
如果 Prettier
|
|
112
|
-
|
|
113
|
-
`@july_cm/eslint-config` 已经集成了 `eslint-plugin-prettier`,确保两者可以同时工作而不会冲突。
|
|
114
|
-
|
|
125
|
+
如果 Prettier 扩展在此工作区中处于活动状态,请禁用它——`@july_cm/eslint-config` 已集成 `eslint-plugin-prettier`,两者可以协同工作而不会冲突。
|
|
115
126
|
|
|
116
|
-
2.
|
|
127
|
+
2. 保存时自动修复:
|
|
117
128
|
|
|
118
129
|
```json
|
|
119
130
|
{
|
|
120
131
|
"editor.codeActionsOnSave": {
|
|
121
132
|
"source.fixAll.eslint": "explicit"
|
|
122
133
|
},
|
|
123
|
-
// ESLint 默认不对 css, json, jsonc 进行校验,需要手动添加
|
|
124
134
|
"eslint.validate": ["css", "json", "jsonc", "javascript", "javascriptreact", "typescript", "typescriptreact"]
|
|
125
135
|
}
|
|
126
136
|
```
|
|
127
137
|
|
|
128
|
-
3.
|
|
138
|
+
3. 调试:
|
|
129
139
|
|
|
130
|
-
|
|
140
|
+
打开命令面板(Ctrl + Shift + P / Cmd + Shift + P)并运行:
|
|
131
141
|
|
|
132
142
|
```
|
|
133
143
|
ESLint: Show Output Channel
|
|
134
144
|
```
|
|
135
|
-
如果存在错误,请修复它们。
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
+
});
|
|
5
|
+
//#region \0rolldown/runtime.js
|
|
6
|
+
var __create = Object.create;
|
|
7
|
+
var __defProp = Object.defineProperty;
|
|
8
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
9
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
10
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
11
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
14
|
+
key = keys[i];
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
16
|
+
get: ((k) => from[k]).bind(null, key),
|
|
17
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
+
value: mod,
|
|
24
|
+
enumerable: true
|
|
25
|
+
}) : target, mod));
|
|
26
|
+
//#endregion
|
|
27
|
+
let eslint_config = require("eslint/config");
|
|
28
|
+
let _eslint_css = require("@eslint/css");
|
|
29
|
+
_eslint_css = __toESM(_eslint_css);
|
|
30
|
+
let eslint_plugin_prettier = require("eslint-plugin-prettier");
|
|
31
|
+
eslint_plugin_prettier = __toESM(eslint_plugin_prettier);
|
|
32
|
+
let tailwind_csstree = require("tailwind-csstree");
|
|
33
|
+
let _eslint_js = require("@eslint/js");
|
|
34
|
+
_eslint_js = __toESM(_eslint_js);
|
|
35
|
+
let eslint_plugin_simple_import_sort = require("eslint-plugin-simple-import-sort");
|
|
36
|
+
eslint_plugin_simple_import_sort = __toESM(eslint_plugin_simple_import_sort);
|
|
37
|
+
let eslint_plugin_prettier_recommended = require("eslint-plugin-prettier/recommended");
|
|
38
|
+
eslint_plugin_prettier_recommended = __toESM(eslint_plugin_prettier_recommended);
|
|
39
|
+
let eslint_plugin_jsonc = require("eslint-plugin-jsonc");
|
|
40
|
+
eslint_plugin_jsonc = __toESM(eslint_plugin_jsonc);
|
|
41
|
+
let typescript_eslint = require("typescript-eslint");
|
|
42
|
+
//#region src/configs/css.ts
|
|
43
|
+
var cssConfig = (0, eslint_config.defineConfig)([{
|
|
44
|
+
files: ["**/*.css"],
|
|
45
|
+
plugins: {
|
|
46
|
+
css: _eslint_css.default,
|
|
47
|
+
prettier: eslint_plugin_prettier.default
|
|
48
|
+
},
|
|
49
|
+
language: "css/css",
|
|
50
|
+
languageOptions: { customSyntax: tailwind_csstree.tailwind4 },
|
|
51
|
+
rules: {
|
|
52
|
+
"css/no-empty-blocks": "error",
|
|
53
|
+
"prettier/prettier": [
|
|
54
|
+
"warn",
|
|
55
|
+
{ tabWidth: 2 },
|
|
56
|
+
{ usePrettierrc: false }
|
|
57
|
+
]
|
|
58
|
+
}
|
|
59
|
+
}]);
|
|
60
|
+
//#endregion
|
|
61
|
+
//#region src/configs/prettier.ts
|
|
62
|
+
/**
|
|
63
|
+
* prettier config 作为具体语言的公共配置
|
|
64
|
+
* prettier 本身可以作为 js、ts、json、css、markdown 等多种语言的格式化工具,这里不做语言限制
|
|
65
|
+
*/
|
|
66
|
+
var prettierConfig = [eslint_plugin_prettier_recommended.default, { rules: { "prettier/prettier": [
|
|
67
|
+
"warn",
|
|
68
|
+
{
|
|
69
|
+
singleQuote: true,
|
|
70
|
+
printWidth: 80,
|
|
71
|
+
semi: true,
|
|
72
|
+
trailingComma: "es5"
|
|
73
|
+
},
|
|
74
|
+
{ usePrettierrc: false }
|
|
75
|
+
] } }];
|
|
76
|
+
//#endregion
|
|
77
|
+
//#region src/configs/javascript.ts
|
|
78
|
+
/**
|
|
79
|
+
* defineConfig 会 flat 一层 extends,并且将 files 字段赋值给所有 extends
|
|
80
|
+
* 可以借助这个函数为所有插件添加 files 约束,防止语言之间的污染
|
|
81
|
+
*/
|
|
82
|
+
var javascriptConfig = (0, eslint_config.defineConfig)({
|
|
83
|
+
extends: [_eslint_js.default.configs.recommended, prettierConfig],
|
|
84
|
+
plugins: { "simple-import-sort": eslint_plugin_simple_import_sort.default },
|
|
85
|
+
files: ["**/*.{js,mjs,cjs,jsx}"],
|
|
86
|
+
languageOptions: { ecmaVersion: "latest" },
|
|
87
|
+
rules: {
|
|
88
|
+
"simple-import-sort/imports": "error",
|
|
89
|
+
"simple-import-sort/exports": "error"
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
//#endregion
|
|
93
|
+
//#region src/configs/package-json.ts
|
|
94
|
+
/**
|
|
95
|
+
* defineConfig 会 flat 一层 extends,并且将 files 字段赋值给所有 extends
|
|
96
|
+
* 可以借助这个函数为所有插件添加 files 约束,防止语言之间的污染
|
|
97
|
+
*/
|
|
98
|
+
var packageJsonConfig = (0, eslint_config.defineConfig)({
|
|
99
|
+
extends: [...eslint_plugin_jsonc.default.configs["flat/prettier"]],
|
|
100
|
+
files: ["package.json"],
|
|
101
|
+
rules: { "jsonc/sort-keys": [
|
|
102
|
+
"warn",
|
|
103
|
+
{
|
|
104
|
+
pathPattern: "^$",
|
|
105
|
+
order: [
|
|
106
|
+
"name",
|
|
107
|
+
"version",
|
|
108
|
+
"private",
|
|
109
|
+
"description",
|
|
110
|
+
"keywords",
|
|
111
|
+
"license",
|
|
112
|
+
"author",
|
|
113
|
+
"contributors",
|
|
114
|
+
"funding",
|
|
115
|
+
"homepage",
|
|
116
|
+
"repository",
|
|
117
|
+
"bugs",
|
|
118
|
+
"type",
|
|
119
|
+
"engines",
|
|
120
|
+
"packageManager",
|
|
121
|
+
"os",
|
|
122
|
+
"cpu",
|
|
123
|
+
"devEngines",
|
|
124
|
+
"exports",
|
|
125
|
+
"main",
|
|
126
|
+
"module",
|
|
127
|
+
"browser",
|
|
128
|
+
"types",
|
|
129
|
+
"bin",
|
|
130
|
+
"man",
|
|
131
|
+
"directories",
|
|
132
|
+
"files",
|
|
133
|
+
"scripts",
|
|
134
|
+
"config",
|
|
135
|
+
"dependencies",
|
|
136
|
+
"devDependencies",
|
|
137
|
+
"peerDependencies",
|
|
138
|
+
"peerDependenciesMeta",
|
|
139
|
+
"optionalDependencies",
|
|
140
|
+
"bundleDependencies",
|
|
141
|
+
"overrides",
|
|
142
|
+
"publishConfig",
|
|
143
|
+
"workspaces"
|
|
144
|
+
]
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies(?:Meta)?$",
|
|
148
|
+
order: { type: "asc" }
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
pathPattern: "^(?:overrides|resolutions)$",
|
|
152
|
+
order: { type: "asc" }
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
pathPattern: "^exports(?:\\..+)?$",
|
|
156
|
+
order: [
|
|
157
|
+
"types",
|
|
158
|
+
"import",
|
|
159
|
+
"require",
|
|
160
|
+
"default"
|
|
161
|
+
]
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
pathPattern: "^publishConfig$",
|
|
165
|
+
order: [
|
|
166
|
+
"registry",
|
|
167
|
+
"access",
|
|
168
|
+
"tag"
|
|
169
|
+
]
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
pathPattern: "^repository$",
|
|
173
|
+
order: [
|
|
174
|
+
"type",
|
|
175
|
+
"url",
|
|
176
|
+
"directory"
|
|
177
|
+
]
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
pathPattern: "^bugs$",
|
|
181
|
+
order: ["url", "email"]
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
pathPattern: "^engines$",
|
|
185
|
+
order: [
|
|
186
|
+
"node",
|
|
187
|
+
"npm",
|
|
188
|
+
"pnpm"
|
|
189
|
+
]
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
pathPattern: "^(?:devEngines)$",
|
|
193
|
+
order: [
|
|
194
|
+
"runtime",
|
|
195
|
+
"packageManager",
|
|
196
|
+
"os",
|
|
197
|
+
"cpu",
|
|
198
|
+
"libc"
|
|
199
|
+
]
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
pathPattern: "^directories$",
|
|
203
|
+
order: [
|
|
204
|
+
"bin",
|
|
205
|
+
"man",
|
|
206
|
+
"lib",
|
|
207
|
+
"doc",
|
|
208
|
+
"test"
|
|
209
|
+
]
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
pathPattern: "^scripts$",
|
|
213
|
+
order: [
|
|
214
|
+
"preinstall",
|
|
215
|
+
"install",
|
|
216
|
+
"postinstall",
|
|
217
|
+
"prepare",
|
|
218
|
+
"prepack",
|
|
219
|
+
"postpack",
|
|
220
|
+
"prepublishOnly",
|
|
221
|
+
"dev",
|
|
222
|
+
"build",
|
|
223
|
+
"start",
|
|
224
|
+
"test",
|
|
225
|
+
"lint"
|
|
226
|
+
]
|
|
227
|
+
}
|
|
228
|
+
] }
|
|
229
|
+
});
|
|
230
|
+
//#endregion
|
|
231
|
+
//#region src/configs/typescript.ts
|
|
232
|
+
/**
|
|
233
|
+
* defineConfig 会 flat 一层 extends,并且将 files 字段赋值给所有 extends
|
|
234
|
+
* 可以借助这个函数为所有插件添加 files 约束,防止语言之间的污染
|
|
235
|
+
*/
|
|
236
|
+
var typescriptConfig = (0, eslint_config.defineConfig)({
|
|
237
|
+
extends: [
|
|
238
|
+
_eslint_js.default.configs.recommended,
|
|
239
|
+
typescript_eslint.configs.recommended,
|
|
240
|
+
prettierConfig
|
|
241
|
+
],
|
|
242
|
+
plugins: { "simple-import-sort": eslint_plugin_simple_import_sort.default },
|
|
243
|
+
files: ["**/*.{ts,tsx}"],
|
|
244
|
+
rules: {
|
|
245
|
+
"simple-import-sort/imports": "error",
|
|
246
|
+
"simple-import-sort/exports": "error",
|
|
247
|
+
"@typescript-eslint/consistent-type-imports": ["error", {
|
|
248
|
+
disallowTypeAnnotations: true,
|
|
249
|
+
prefer: "type-imports"
|
|
250
|
+
}],
|
|
251
|
+
"@typescript-eslint/no-explicit-any": ["warn"]
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
//#endregion
|
|
255
|
+
//#region src/index.ts
|
|
256
|
+
var recommended = (0, eslint_config.defineConfig)(javascriptConfig, typescriptConfig, packageJsonConfig, cssConfig);
|
|
257
|
+
var javascript = javascriptConfig;
|
|
258
|
+
var typescript = typescriptConfig;
|
|
259
|
+
var packageJson = packageJsonConfig;
|
|
260
|
+
var css = cssConfig;
|
|
261
|
+
var src_default = {
|
|
262
|
+
recommended,
|
|
263
|
+
javascript,
|
|
264
|
+
typescript,
|
|
265
|
+
packageJson,
|
|
266
|
+
css
|
|
267
|
+
};
|
|
268
|
+
//#endregion
|
|
269
|
+
exports.css = css;
|
|
270
|
+
exports.default = src_default;
|
|
271
|
+
exports.javascript = javascript;
|
|
272
|
+
exports.packageJson = packageJson;
|
|
273
|
+
exports.recommended = recommended;
|
|
274
|
+
exports.typescript = typescript;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import { defineConfig } from "eslint/config";
|
|
2
|
+
import css$1 from "@eslint/css";
|
|
3
|
+
import prettier from "eslint-plugin-prettier";
|
|
4
|
+
import { tailwind4 } from "tailwind-csstree";
|
|
5
|
+
import eslintJs from "@eslint/js";
|
|
6
|
+
import simpleImportSort from "eslint-plugin-simple-import-sort";
|
|
7
|
+
import recommended$1 from "eslint-plugin-prettier/recommended";
|
|
8
|
+
import eslintPluginJsonc from "eslint-plugin-jsonc";
|
|
9
|
+
import { configs } from "typescript-eslint";
|
|
10
|
+
//#region src/configs/css.ts
|
|
11
|
+
var cssConfig = defineConfig([{
|
|
12
|
+
files: ["**/*.css"],
|
|
13
|
+
plugins: {
|
|
14
|
+
css: css$1,
|
|
15
|
+
prettier
|
|
16
|
+
},
|
|
17
|
+
language: "css/css",
|
|
18
|
+
languageOptions: { customSyntax: tailwind4 },
|
|
19
|
+
rules: {
|
|
20
|
+
"css/no-empty-blocks": "error",
|
|
21
|
+
"prettier/prettier": [
|
|
22
|
+
"warn",
|
|
23
|
+
{ tabWidth: 2 },
|
|
24
|
+
{ usePrettierrc: false }
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
}]);
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region src/configs/prettier.ts
|
|
30
|
+
/**
|
|
31
|
+
* prettier config 作为具体语言的公共配置
|
|
32
|
+
* prettier 本身可以作为 js、ts、json、css、markdown 等多种语言的格式化工具,这里不做语言限制
|
|
33
|
+
*/
|
|
34
|
+
var prettierConfig = [recommended$1, { rules: { "prettier/prettier": [
|
|
35
|
+
"warn",
|
|
36
|
+
{
|
|
37
|
+
singleQuote: true,
|
|
38
|
+
printWidth: 80,
|
|
39
|
+
semi: true,
|
|
40
|
+
trailingComma: "es5"
|
|
41
|
+
},
|
|
42
|
+
{ usePrettierrc: false }
|
|
43
|
+
] } }];
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region src/configs/javascript.ts
|
|
46
|
+
/**
|
|
47
|
+
* defineConfig 会 flat 一层 extends,并且将 files 字段赋值给所有 extends
|
|
48
|
+
* 可以借助这个函数为所有插件添加 files 约束,防止语言之间的污染
|
|
49
|
+
*/
|
|
50
|
+
var javascriptConfig = defineConfig({
|
|
51
|
+
extends: [eslintJs.configs.recommended, prettierConfig],
|
|
52
|
+
plugins: { "simple-import-sort": simpleImportSort },
|
|
53
|
+
files: ["**/*.{js,mjs,cjs,jsx}"],
|
|
54
|
+
languageOptions: { ecmaVersion: "latest" },
|
|
55
|
+
rules: {
|
|
56
|
+
"simple-import-sort/imports": "error",
|
|
57
|
+
"simple-import-sort/exports": "error"
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
//#endregion
|
|
61
|
+
//#region src/configs/package-json.ts
|
|
62
|
+
/**
|
|
63
|
+
* defineConfig 会 flat 一层 extends,并且将 files 字段赋值给所有 extends
|
|
64
|
+
* 可以借助这个函数为所有插件添加 files 约束,防止语言之间的污染
|
|
65
|
+
*/
|
|
66
|
+
var packageJsonConfig = defineConfig({
|
|
67
|
+
extends: [...eslintPluginJsonc.configs["flat/prettier"]],
|
|
68
|
+
files: ["package.json"],
|
|
69
|
+
rules: { "jsonc/sort-keys": [
|
|
70
|
+
"warn",
|
|
71
|
+
{
|
|
72
|
+
pathPattern: "^$",
|
|
73
|
+
order: [
|
|
74
|
+
"name",
|
|
75
|
+
"version",
|
|
76
|
+
"private",
|
|
77
|
+
"description",
|
|
78
|
+
"keywords",
|
|
79
|
+
"license",
|
|
80
|
+
"author",
|
|
81
|
+
"contributors",
|
|
82
|
+
"funding",
|
|
83
|
+
"homepage",
|
|
84
|
+
"repository",
|
|
85
|
+
"bugs",
|
|
86
|
+
"type",
|
|
87
|
+
"engines",
|
|
88
|
+
"packageManager",
|
|
89
|
+
"os",
|
|
90
|
+
"cpu",
|
|
91
|
+
"devEngines",
|
|
92
|
+
"exports",
|
|
93
|
+
"main",
|
|
94
|
+
"module",
|
|
95
|
+
"browser",
|
|
96
|
+
"types",
|
|
97
|
+
"bin",
|
|
98
|
+
"man",
|
|
99
|
+
"directories",
|
|
100
|
+
"files",
|
|
101
|
+
"scripts",
|
|
102
|
+
"config",
|
|
103
|
+
"dependencies",
|
|
104
|
+
"devDependencies",
|
|
105
|
+
"peerDependencies",
|
|
106
|
+
"peerDependenciesMeta",
|
|
107
|
+
"optionalDependencies",
|
|
108
|
+
"bundleDependencies",
|
|
109
|
+
"overrides",
|
|
110
|
+
"publishConfig",
|
|
111
|
+
"workspaces"
|
|
112
|
+
]
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies(?:Meta)?$",
|
|
116
|
+
order: { type: "asc" }
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
pathPattern: "^(?:overrides|resolutions)$",
|
|
120
|
+
order: { type: "asc" }
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
pathPattern: "^exports(?:\\..+)?$",
|
|
124
|
+
order: [
|
|
125
|
+
"types",
|
|
126
|
+
"import",
|
|
127
|
+
"require",
|
|
128
|
+
"default"
|
|
129
|
+
]
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
pathPattern: "^publishConfig$",
|
|
133
|
+
order: [
|
|
134
|
+
"registry",
|
|
135
|
+
"access",
|
|
136
|
+
"tag"
|
|
137
|
+
]
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
pathPattern: "^repository$",
|
|
141
|
+
order: [
|
|
142
|
+
"type",
|
|
143
|
+
"url",
|
|
144
|
+
"directory"
|
|
145
|
+
]
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
pathPattern: "^bugs$",
|
|
149
|
+
order: ["url", "email"]
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
pathPattern: "^engines$",
|
|
153
|
+
order: [
|
|
154
|
+
"node",
|
|
155
|
+
"npm",
|
|
156
|
+
"pnpm"
|
|
157
|
+
]
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
pathPattern: "^(?:devEngines)$",
|
|
161
|
+
order: [
|
|
162
|
+
"runtime",
|
|
163
|
+
"packageManager",
|
|
164
|
+
"os",
|
|
165
|
+
"cpu",
|
|
166
|
+
"libc"
|
|
167
|
+
]
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
pathPattern: "^directories$",
|
|
171
|
+
order: [
|
|
172
|
+
"bin",
|
|
173
|
+
"man",
|
|
174
|
+
"lib",
|
|
175
|
+
"doc",
|
|
176
|
+
"test"
|
|
177
|
+
]
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
pathPattern: "^scripts$",
|
|
181
|
+
order: [
|
|
182
|
+
"preinstall",
|
|
183
|
+
"install",
|
|
184
|
+
"postinstall",
|
|
185
|
+
"prepare",
|
|
186
|
+
"prepack",
|
|
187
|
+
"postpack",
|
|
188
|
+
"prepublishOnly",
|
|
189
|
+
"dev",
|
|
190
|
+
"build",
|
|
191
|
+
"start",
|
|
192
|
+
"test",
|
|
193
|
+
"lint"
|
|
194
|
+
]
|
|
195
|
+
}
|
|
196
|
+
] }
|
|
197
|
+
});
|
|
198
|
+
//#endregion
|
|
199
|
+
//#region src/configs/typescript.ts
|
|
200
|
+
/**
|
|
201
|
+
* defineConfig 会 flat 一层 extends,并且将 files 字段赋值给所有 extends
|
|
202
|
+
* 可以借助这个函数为所有插件添加 files 约束,防止语言之间的污染
|
|
203
|
+
*/
|
|
204
|
+
var typescriptConfig = defineConfig({
|
|
205
|
+
extends: [
|
|
206
|
+
eslintJs.configs.recommended,
|
|
207
|
+
configs.recommended,
|
|
208
|
+
prettierConfig
|
|
209
|
+
],
|
|
210
|
+
plugins: { "simple-import-sort": simpleImportSort },
|
|
211
|
+
files: ["**/*.{ts,tsx}"],
|
|
212
|
+
rules: {
|
|
213
|
+
"simple-import-sort/imports": "error",
|
|
214
|
+
"simple-import-sort/exports": "error",
|
|
215
|
+
"@typescript-eslint/consistent-type-imports": ["error", {
|
|
216
|
+
disallowTypeAnnotations: true,
|
|
217
|
+
prefer: "type-imports"
|
|
218
|
+
}],
|
|
219
|
+
"@typescript-eslint/no-explicit-any": ["warn"]
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
//#endregion
|
|
223
|
+
//#region src/index.ts
|
|
224
|
+
var recommended = defineConfig(javascriptConfig, typescriptConfig, packageJsonConfig, cssConfig);
|
|
225
|
+
var javascript = javascriptConfig;
|
|
226
|
+
var typescript = typescriptConfig;
|
|
227
|
+
var packageJson = packageJsonConfig;
|
|
228
|
+
var css = cssConfig;
|
|
229
|
+
var src_default = {
|
|
230
|
+
recommended,
|
|
231
|
+
javascript,
|
|
232
|
+
typescript,
|
|
233
|
+
packageJson,
|
|
234
|
+
css
|
|
235
|
+
};
|
|
236
|
+
//#endregion
|
|
237
|
+
export { css, src_default as default, javascript, packageJson, recommended, typescript };
|
package/package.json
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@july_cm/eslint-config",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.1",
|
|
4
|
+
"description": "Shared ESLint config for July's projects",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"eslint",
|
|
7
|
+
"eslint-config",
|
|
8
|
+
"prettier",
|
|
9
|
+
"typescript"
|
|
10
|
+
],
|
|
11
|
+
"license": "MIT",
|
|
4
12
|
"author": "July",
|
|
5
13
|
"homepage": "https://github.com/JxJuly/eslint-config/blob/main/README.md",
|
|
6
14
|
"repository": {
|
|
@@ -11,30 +19,31 @@
|
|
|
11
19
|
"url": "https://github.com/JxJuly/eslint-config/issues"
|
|
12
20
|
},
|
|
13
21
|
"type": "module",
|
|
22
|
+
"engines": {
|
|
23
|
+
"node": ">=18.18.0"
|
|
24
|
+
},
|
|
25
|
+
"packageManager": "pnpm@10.26.1",
|
|
14
26
|
"exports": {
|
|
15
27
|
".": {
|
|
16
|
-
"import": "./
|
|
17
|
-
"require": "./
|
|
28
|
+
"import": "./dist/index.js",
|
|
29
|
+
"require": "./dist/index.cjs"
|
|
18
30
|
}
|
|
19
31
|
},
|
|
20
|
-
"main": "./
|
|
32
|
+
"main": "./dist/index.cjs",
|
|
33
|
+
"module": "./dist/index.js",
|
|
21
34
|
"files": [
|
|
22
35
|
"README.md",
|
|
23
|
-
"
|
|
24
|
-
"package.json"
|
|
36
|
+
"dist"
|
|
25
37
|
],
|
|
26
38
|
"scripts": {
|
|
27
39
|
"build": "vite build",
|
|
28
40
|
"test": "vitest run",
|
|
29
41
|
"test:cov": "vitest run --coverage"
|
|
30
42
|
},
|
|
31
|
-
"packageManager": "pnpm@10.26.1",
|
|
32
43
|
"dependencies": {
|
|
33
44
|
"@eslint/css": "^1.0.0",
|
|
34
45
|
"@eslint/js": "^10.0.1",
|
|
35
46
|
"eslint-config-prettier": "^10.1.8",
|
|
36
|
-
"eslint-import-resolver-node": "^0.3.9",
|
|
37
|
-
"eslint-import-resolver-typescript": "^4.4.4",
|
|
38
47
|
"eslint-plugin-jsonc": "^2.21.0",
|
|
39
48
|
"eslint-plugin-prettier": "^5.5.4",
|
|
40
49
|
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
@@ -42,14 +51,19 @@
|
|
|
42
51
|
"typescript-eslint": "^8.57.2"
|
|
43
52
|
},
|
|
44
53
|
"devDependencies": {
|
|
45
|
-
"@vitest/coverage-v8": "^4.
|
|
54
|
+
"@vitest/coverage-v8": "^4.1.1",
|
|
46
55
|
"eslint": "^10.1.0",
|
|
47
56
|
"typescript": "^5.9.3",
|
|
48
|
-
"vite": "^
|
|
49
|
-
"vitest": "^4.
|
|
57
|
+
"vite": "^8.0.2",
|
|
58
|
+
"vitest": "^4.1.1"
|
|
50
59
|
},
|
|
51
|
-
"
|
|
60
|
+
"peerDependencies": {
|
|
52
61
|
"eslint": "^10",
|
|
53
62
|
"typescript": "^5"
|
|
63
|
+
},
|
|
64
|
+
"peerDependenciesMeta": {
|
|
65
|
+
"typescript": {
|
|
66
|
+
"optional": true
|
|
67
|
+
}
|
|
54
68
|
}
|
|
55
69
|
}
|
package/lib/index.cjs
DELETED
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
-
const config = require("eslint/config");
|
|
4
|
-
const css$1 = require("@eslint/css");
|
|
5
|
-
const prettier = require("eslint-plugin-prettier");
|
|
6
|
-
const tailwindCsstree = require("tailwind-csstree");
|
|
7
|
-
const eslintJs = require("@eslint/js");
|
|
8
|
-
const simpleImportSort = require("eslint-plugin-simple-import-sort");
|
|
9
|
-
const recommended$1 = require("eslint-plugin-prettier/recommended");
|
|
10
|
-
const eslintPluginJsonc = require("eslint-plugin-jsonc");
|
|
11
|
-
const typescriptEslint = require("typescript-eslint");
|
|
12
|
-
const cssConfig = config.defineConfig([
|
|
13
|
-
{
|
|
14
|
-
files: ["**/*.css"],
|
|
15
|
-
plugins: { css: css$1, prettier },
|
|
16
|
-
language: "css/css",
|
|
17
|
-
languageOptions: {
|
|
18
|
-
customSyntax: tailwindCsstree.tailwind4
|
|
19
|
-
},
|
|
20
|
-
rules: {
|
|
21
|
-
"css/no-empty-blocks": "error",
|
|
22
|
-
"prettier/prettier": [
|
|
23
|
-
"warn",
|
|
24
|
-
{
|
|
25
|
-
tabWidth: 2
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
usePrettierrc: false
|
|
29
|
-
}
|
|
30
|
-
]
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
]);
|
|
34
|
-
const prettierConfig = [
|
|
35
|
-
recommended$1,
|
|
36
|
-
{
|
|
37
|
-
rules: {
|
|
38
|
-
"prettier/prettier": [
|
|
39
|
-
"warn",
|
|
40
|
-
{
|
|
41
|
-
// 优先使用单引号
|
|
42
|
-
singleQuote: true,
|
|
43
|
-
printWidth: 110,
|
|
44
|
-
// 需要分号
|
|
45
|
-
semi: true,
|
|
46
|
-
// 仅在 es5 中有效的结构尾随逗号
|
|
47
|
-
trailingComma: "es5"
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
// 不读取 prettier 配置文件,统一走 eslint 配置
|
|
51
|
-
usePrettierrc: false
|
|
52
|
-
}
|
|
53
|
-
]
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
];
|
|
57
|
-
const javascriptConfig = config.defineConfig({
|
|
58
|
-
extends: [eslintJs.configs.recommended, ...prettierConfig],
|
|
59
|
-
plugins: {
|
|
60
|
-
"simple-import-sort": simpleImportSort
|
|
61
|
-
},
|
|
62
|
-
files: ["**/*.{js,mjs,cjs,jsx}"],
|
|
63
|
-
languageOptions: {
|
|
64
|
-
ecmaVersion: "latest"
|
|
65
|
-
},
|
|
66
|
-
rules: {
|
|
67
|
-
"simple-import-sort/imports": "error",
|
|
68
|
-
"simple-import-sort/exports": "error"
|
|
69
|
-
},
|
|
70
|
-
settings: {
|
|
71
|
-
"import/resolver": {
|
|
72
|
-
node: true,
|
|
73
|
-
/**
|
|
74
|
-
* https://github.com/import-js/eslint-plugin-import/issues/3140
|
|
75
|
-
* eslint-plugin-import-node 解析器不支持 export 字段,所以不得不使用 eslint-plugin-import-typescript
|
|
76
|
-
*/
|
|
77
|
-
typescript: true
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
const packageJsonConfig = config.defineConfig({
|
|
82
|
-
extends: [...eslintPluginJsonc.configs["flat/prettier"]],
|
|
83
|
-
files: ["package.json"],
|
|
84
|
-
rules: {
|
|
85
|
-
"jsonc/sort-keys": [
|
|
86
|
-
"warn",
|
|
87
|
-
{
|
|
88
|
-
pathPattern: "^$",
|
|
89
|
-
order: [
|
|
90
|
-
// basic information
|
|
91
|
-
"name",
|
|
92
|
-
"version",
|
|
93
|
-
"description",
|
|
94
|
-
"author",
|
|
95
|
-
"keywords",
|
|
96
|
-
"homepage",
|
|
97
|
-
"repository",
|
|
98
|
-
"bugs",
|
|
99
|
-
"license",
|
|
100
|
-
// entries and environment
|
|
101
|
-
"type",
|
|
102
|
-
"exports",
|
|
103
|
-
"types",
|
|
104
|
-
"main",
|
|
105
|
-
"bin",
|
|
106
|
-
"scripts",
|
|
107
|
-
"packageManager",
|
|
108
|
-
// dependencies
|
|
109
|
-
"dependencies",
|
|
110
|
-
"devDependencies",
|
|
111
|
-
"peerDependencies",
|
|
112
|
-
"peerDependenciesMeta",
|
|
113
|
-
"optionalDependencies",
|
|
114
|
-
// config
|
|
115
|
-
"publishConfig"
|
|
116
|
-
]
|
|
117
|
-
},
|
|
118
|
-
{
|
|
119
|
-
pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies$",
|
|
120
|
-
order: { type: "asc" }
|
|
121
|
-
},
|
|
122
|
-
{
|
|
123
|
-
pathPattern: "exports",
|
|
124
|
-
// Prefer ESM (import) before CommonJS (require)
|
|
125
|
-
order: ["types", "import", "require"]
|
|
126
|
-
}
|
|
127
|
-
]
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
const typescriptConfig = config.defineConfig({
|
|
131
|
-
extends: [eslintJs.configs.recommended, typescriptEslint.configs.stylistic, prettierConfig],
|
|
132
|
-
plugins: {
|
|
133
|
-
"simple-import-sort": simpleImportSort
|
|
134
|
-
},
|
|
135
|
-
files: ["**/*.{ts,tsx}"],
|
|
136
|
-
rules: {
|
|
137
|
-
"simple-import-sort/imports": "error",
|
|
138
|
-
"simple-import-sort/exports": "error",
|
|
139
|
-
"@typescript-eslint/consistent-type-imports": [
|
|
140
|
-
"error",
|
|
141
|
-
{ disallowTypeAnnotations: true, prefer: "type-imports" }
|
|
142
|
-
],
|
|
143
|
-
"@typescript-eslint/no-explicit-any": ["warn"]
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
const recommended = config.defineConfig(javascriptConfig, typescriptConfig, packageJsonConfig, cssConfig);
|
|
147
|
-
const javascript = javascriptConfig;
|
|
148
|
-
const typescript = typescriptConfig;
|
|
149
|
-
const packageJson = packageJsonConfig;
|
|
150
|
-
const css = cssConfig;
|
|
151
|
-
const index = {
|
|
152
|
-
recommended,
|
|
153
|
-
javascript,
|
|
154
|
-
typescript,
|
|
155
|
-
packageJson,
|
|
156
|
-
css
|
|
157
|
-
};
|
|
158
|
-
exports.css = css;
|
|
159
|
-
exports.default = index;
|
|
160
|
-
exports.javascript = javascript;
|
|
161
|
-
exports.packageJson = packageJson;
|
|
162
|
-
exports.recommended = recommended;
|
|
163
|
-
exports.typescript = typescript;
|
package/lib/index.mjs
DELETED
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from "eslint/config";
|
|
2
|
-
import css$1 from "@eslint/css";
|
|
3
|
-
import prettier from "eslint-plugin-prettier";
|
|
4
|
-
import { tailwind4 } from "tailwind-csstree";
|
|
5
|
-
import eslintJs from "@eslint/js";
|
|
6
|
-
import simpleImportSort from "eslint-plugin-simple-import-sort";
|
|
7
|
-
import recommended$1 from "eslint-plugin-prettier/recommended";
|
|
8
|
-
import eslintPluginJsonc from "eslint-plugin-jsonc";
|
|
9
|
-
import { configs } from "typescript-eslint";
|
|
10
|
-
const cssConfig = defineConfig([
|
|
11
|
-
{
|
|
12
|
-
files: ["**/*.css"],
|
|
13
|
-
plugins: { css: css$1, prettier },
|
|
14
|
-
language: "css/css",
|
|
15
|
-
languageOptions: {
|
|
16
|
-
customSyntax: tailwind4
|
|
17
|
-
},
|
|
18
|
-
rules: {
|
|
19
|
-
"css/no-empty-blocks": "error",
|
|
20
|
-
"prettier/prettier": [
|
|
21
|
-
"warn",
|
|
22
|
-
{
|
|
23
|
-
tabWidth: 2
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
usePrettierrc: false
|
|
27
|
-
}
|
|
28
|
-
]
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
]);
|
|
32
|
-
const prettierConfig = [
|
|
33
|
-
recommended$1,
|
|
34
|
-
{
|
|
35
|
-
rules: {
|
|
36
|
-
"prettier/prettier": [
|
|
37
|
-
"warn",
|
|
38
|
-
{
|
|
39
|
-
// 优先使用单引号
|
|
40
|
-
singleQuote: true,
|
|
41
|
-
printWidth: 110,
|
|
42
|
-
// 需要分号
|
|
43
|
-
semi: true,
|
|
44
|
-
// 仅在 es5 中有效的结构尾随逗号
|
|
45
|
-
trailingComma: "es5"
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
// 不读取 prettier 配置文件,统一走 eslint 配置
|
|
49
|
-
usePrettierrc: false
|
|
50
|
-
}
|
|
51
|
-
]
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
];
|
|
55
|
-
const javascriptConfig = defineConfig({
|
|
56
|
-
extends: [eslintJs.configs.recommended, ...prettierConfig],
|
|
57
|
-
plugins: {
|
|
58
|
-
"simple-import-sort": simpleImportSort
|
|
59
|
-
},
|
|
60
|
-
files: ["**/*.{js,mjs,cjs,jsx}"],
|
|
61
|
-
languageOptions: {
|
|
62
|
-
ecmaVersion: "latest"
|
|
63
|
-
},
|
|
64
|
-
rules: {
|
|
65
|
-
"simple-import-sort/imports": "error",
|
|
66
|
-
"simple-import-sort/exports": "error"
|
|
67
|
-
},
|
|
68
|
-
settings: {
|
|
69
|
-
"import/resolver": {
|
|
70
|
-
node: true,
|
|
71
|
-
/**
|
|
72
|
-
* https://github.com/import-js/eslint-plugin-import/issues/3140
|
|
73
|
-
* eslint-plugin-import-node 解析器不支持 export 字段,所以不得不使用 eslint-plugin-import-typescript
|
|
74
|
-
*/
|
|
75
|
-
typescript: true
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
const packageJsonConfig = defineConfig({
|
|
80
|
-
extends: [...eslintPluginJsonc.configs["flat/prettier"]],
|
|
81
|
-
files: ["package.json"],
|
|
82
|
-
rules: {
|
|
83
|
-
"jsonc/sort-keys": [
|
|
84
|
-
"warn",
|
|
85
|
-
{
|
|
86
|
-
pathPattern: "^$",
|
|
87
|
-
order: [
|
|
88
|
-
// basic information
|
|
89
|
-
"name",
|
|
90
|
-
"version",
|
|
91
|
-
"description",
|
|
92
|
-
"author",
|
|
93
|
-
"keywords",
|
|
94
|
-
"homepage",
|
|
95
|
-
"repository",
|
|
96
|
-
"bugs",
|
|
97
|
-
"license",
|
|
98
|
-
// entries and environment
|
|
99
|
-
"type",
|
|
100
|
-
"exports",
|
|
101
|
-
"types",
|
|
102
|
-
"main",
|
|
103
|
-
"bin",
|
|
104
|
-
"scripts",
|
|
105
|
-
"packageManager",
|
|
106
|
-
// dependencies
|
|
107
|
-
"dependencies",
|
|
108
|
-
"devDependencies",
|
|
109
|
-
"peerDependencies",
|
|
110
|
-
"peerDependenciesMeta",
|
|
111
|
-
"optionalDependencies",
|
|
112
|
-
// config
|
|
113
|
-
"publishConfig"
|
|
114
|
-
]
|
|
115
|
-
},
|
|
116
|
-
{
|
|
117
|
-
pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies$",
|
|
118
|
-
order: { type: "asc" }
|
|
119
|
-
},
|
|
120
|
-
{
|
|
121
|
-
pathPattern: "exports",
|
|
122
|
-
// Prefer ESM (import) before CommonJS (require)
|
|
123
|
-
order: ["types", "import", "require"]
|
|
124
|
-
}
|
|
125
|
-
]
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
const typescriptConfig = defineConfig({
|
|
129
|
-
extends: [eslintJs.configs.recommended, configs.stylistic, prettierConfig],
|
|
130
|
-
plugins: {
|
|
131
|
-
"simple-import-sort": simpleImportSort
|
|
132
|
-
},
|
|
133
|
-
files: ["**/*.{ts,tsx}"],
|
|
134
|
-
rules: {
|
|
135
|
-
"simple-import-sort/imports": "error",
|
|
136
|
-
"simple-import-sort/exports": "error",
|
|
137
|
-
"@typescript-eslint/consistent-type-imports": [
|
|
138
|
-
"error",
|
|
139
|
-
{ disallowTypeAnnotations: true, prefer: "type-imports" }
|
|
140
|
-
],
|
|
141
|
-
"@typescript-eslint/no-explicit-any": ["warn"]
|
|
142
|
-
}
|
|
143
|
-
});
|
|
144
|
-
const recommended = defineConfig(javascriptConfig, typescriptConfig, packageJsonConfig, cssConfig);
|
|
145
|
-
const javascript = javascriptConfig;
|
|
146
|
-
const typescript = typescriptConfig;
|
|
147
|
-
const packageJson = packageJsonConfig;
|
|
148
|
-
const css = cssConfig;
|
|
149
|
-
const index = {
|
|
150
|
-
recommended,
|
|
151
|
-
javascript,
|
|
152
|
-
typescript,
|
|
153
|
-
packageJson,
|
|
154
|
-
css
|
|
155
|
-
};
|
|
156
|
-
export {
|
|
157
|
-
css,
|
|
158
|
-
index as default,
|
|
159
|
-
javascript,
|
|
160
|
-
packageJson,
|
|
161
|
-
recommended,
|
|
162
|
-
typescript
|
|
163
|
-
};
|