@july_cm/eslint-config 2.4.2 → 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/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,58 +1,69 @@
1
1
  {
2
2
  "name": "@july_cm/eslint-config",
3
- "version": "2.4.2",
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",
13
+ "homepage": "https://github.com/JxJuly/eslint-config/blob/main/README.md",
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "https://github.com/JxJuly/eslint-config.git"
17
+ },
18
+ "bugs": {
19
+ "url": "https://github.com/JxJuly/eslint-config/issues"
20
+ },
21
+ "type": "module",
22
+ "engines": {
23
+ "node": ">=18.18.0"
24
+ },
25
+ "packageManager": "pnpm@10.26.1",
5
26
  "exports": {
6
27
  ".": {
7
- "require": "./lib/index.cjs",
8
- "import": "./lib/index.mjs"
28
+ "import": "./dist/index.js",
29
+ "require": "./dist/index.cjs"
9
30
  }
10
31
  },
11
- "main": "./lib/index.cjs",
12
- "type": "module",
32
+ "main": "./dist/index.cjs",
33
+ "module": "./dist/index.js",
13
34
  "files": [
14
35
  "README.md",
15
- "lib",
16
- "package.json"
36
+ "dist"
17
37
  ],
18
38
  "scripts": {
19
39
  "build": "vite build",
20
40
  "test": "vitest run",
21
- "test:cov": "vitest run --coverage",
22
- "release": "release-it -ci"
41
+ "test:cov": "vitest run --coverage"
23
42
  },
24
- "packageManager": "pnpm@10.26.1",
25
43
  "dependencies": {
26
- "@eslint/css": "^0.14.1",
27
- "@eslint/js": "^9.39.1",
44
+ "@eslint/css": "^1.0.0",
45
+ "@eslint/js": "^10.0.1",
28
46
  "eslint-config-prettier": "^10.1.8",
29
- "eslint-import-resolver-node": "^0.3.9",
30
- "eslint-import-resolver-typescript": "^4.4.4",
31
- "eslint-plugin-import": "^2.32.0",
32
47
  "eslint-plugin-jsonc": "^2.21.0",
33
48
  "eslint-plugin-prettier": "^5.5.4",
34
- "tailwind-csstree": "^0.1.4",
35
- "typescript-eslint": "^8.49.0"
49
+ "eslint-plugin-simple-import-sort": "^12.1.1",
50
+ "tailwind-csstree": "^0.3.0",
51
+ "typescript-eslint": "^8.57.2"
36
52
  },
37
53
  "devDependencies": {
38
- "@release-it/conventional-changelog": "^10.0.3",
39
- "@vitest/coverage-v8": "^4.0.15",
40
- "eslint": "^9.39.1",
41
- "release-it": "^19.1.0",
54
+ "@vitest/coverage-v8": "^4.1.1",
55
+ "eslint": "^10.1.0",
42
56
  "typescript": "^5.9.3",
43
- "vite": "^7.2.7",
44
- "vitest": "^4.0.15"
57
+ "vite": "^8.0.2",
58
+ "vitest": "^4.1.1"
45
59
  },
46
- "optionalPeerDependencies": {
47
- "eslint": "^9",
60
+ "peerDependencies": {
61
+ "eslint": "^10",
48
62
  "typescript": "^5"
49
63
  },
50
- "repository": {
51
- "type": "git",
52
- "url": "https://github.com/JxJuly/eslint-config.git"
53
- },
54
- "homepage": "https://github.com/JxJuly/eslint-config/blob/main/README.md",
55
- "bugs": {
56
- "url": "https://github.com/JxJuly/eslint-config/issues"
64
+ "peerDependenciesMeta": {
65
+ "typescript": {
66
+ "optional": true
67
+ }
57
68
  }
58
69
  }
package/lib/index.cjs DELETED
@@ -1,201 +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 eslintPluginImport = require("eslint-plugin-import");
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, eslintPluginImport.flatConfigs.recommended, ...prettierConfig],
59
- files: ["**/*.{js,mjs,cjs,jsx}"],
60
- languageOptions: {
61
- ecmaVersion: "latest"
62
- },
63
- rules: {
64
- "import/order": [
65
- "warn",
66
- {
67
- groups: ["builtin", "external", "internal", ["parent", "sibling"], "object", "type", "index"],
68
- "newlines-between": "always",
69
- pathGroupsExcludedImportTypes: ["builtin"],
70
- alphabetize: { order: "asc", caseInsensitive: true },
71
- pathGroups: [
72
- {
73
- pattern: "react**",
74
- group: "external",
75
- position: "before"
76
- },
77
- {
78
- pattern: "{@/**,@**}",
79
- group: "internal",
80
- position: "before"
81
- },
82
- {
83
- pattern: "**/*.{scss,json,svg,css,less}",
84
- group: "index",
85
- position: "after"
86
- }
87
- ]
88
- }
89
- ]
90
- },
91
- settings: {
92
- "import/resolver": {
93
- node: true,
94
- /**
95
- * https://github.com/import-js/eslint-plugin-import/issues/3140
96
- * eslint-plugin-import-node 解析器不支持 export 字段,所以不得不使用 eslint-plugin-import-typescript
97
- */
98
- typescript: true
99
- }
100
- }
101
- });
102
- const packageJsonConfig = config.defineConfig({
103
- extends: [...eslintPluginJsonc.configs["flat/prettier"]],
104
- files: ["package.json"],
105
- rules: {
106
- "jsonc/sort-keys": [
107
- "warn",
108
- {
109
- pathPattern: "^$",
110
- order: [
111
- "name",
112
- "version",
113
- "author",
114
- "exports",
115
- "types",
116
- "main",
117
- "module",
118
- "scripts",
119
- "dependencies",
120
- "devDependencies"
121
- ]
122
- },
123
- {
124
- pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies$",
125
- order: { type: "asc" }
126
- },
127
- {
128
- pathPattern: "exports",
129
- // Prefer ESM (import) before CommonJS (require)
130
- order: ["types", "import", "require"]
131
- }
132
- ]
133
- }
134
- });
135
- const typescriptConfig = config.defineConfig({
136
- extends: [
137
- eslintJs.configs.recommended,
138
- typescriptEslint.configs.stylistic,
139
- eslintPluginImport.flatConfigs.recommended,
140
- eslintPluginImport.flatConfigs.typescript,
141
- prettierConfig
142
- ],
143
- files: ["**/*.{ts,tsx}"],
144
- rules: {
145
- "import/order": [
146
- "warn",
147
- {
148
- groups: ["builtin", "external", "internal", ["parent", "sibling"], "object", "type", "index"],
149
- "newlines-between": "always",
150
- pathGroupsExcludedImportTypes: ["builtin"],
151
- alphabetize: { order: "asc", caseInsensitive: true },
152
- pathGroups: [
153
- {
154
- pattern: "react**",
155
- group: "external",
156
- position: "before"
157
- },
158
- {
159
- pattern: "{@/**,@**}",
160
- group: "internal",
161
- position: "before"
162
- },
163
- {
164
- pattern: "**/*.{scss,json,svg,css,less}",
165
- group: "index",
166
- position: "after"
167
- }
168
- ]
169
- }
170
- ],
171
- "@typescript-eslint/consistent-type-imports": [
172
- "error",
173
- { disallowTypeAnnotations: true, prefer: "type-imports" }
174
- ],
175
- "@typescript-eslint/no-explicit-any": ["warn"]
176
- },
177
- settings: {
178
- "import/resolver": {
179
- node: true,
180
- typescript: true
181
- }
182
- }
183
- });
184
- const recommended = config.defineConfig(javascriptConfig, typescriptConfig, packageJsonConfig, cssConfig);
185
- const javascript = javascriptConfig;
186
- const typescript = typescriptConfig;
187
- const packageJson = packageJsonConfig;
188
- const css = cssConfig;
189
- const index = {
190
- recommended,
191
- javascript,
192
- typescript,
193
- packageJson,
194
- css
195
- };
196
- exports.css = css;
197
- exports.default = index;
198
- exports.javascript = javascript;
199
- exports.packageJson = packageJson;
200
- exports.recommended = recommended;
201
- exports.typescript = typescript;