@aiou/eslint-config 3.0.1 → 3.1.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 +131 -0
- package/dist/index.mjs +13 -8
- package/package.json +5 -7
- package/dist/index.cjs +0 -1402
- package/readme.md +0 -77
package/README.md
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
# @aiou/eslint-config
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@aiou/eslint-config) [](https://github.com/JiangWeixian/eslint-config/tree/master/packages/default)
|
|
4
|
+
|
|
5
|
+
Flat ESLint config with TypeScript, React, SSR, and more.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- Common ignore patterns (dist, lib, .next, .nuxt, lock files, etc.)
|
|
10
|
+
- TypeScript, YAML, JSONC, Markdown, TOML support
|
|
11
|
+
- Built-in React rules via `@eslint-react`, react-refresh, and SSR-safe linting
|
|
12
|
+
- Auto-detected framework support (Next.js, Tailwind CSS)
|
|
13
|
+
- Import sorting, unused import removal, and multi-line import enforcement
|
|
14
|
+
- Sorted keys for `package.json` and `tsconfig.json`
|
|
15
|
+
- Visual linting progress reporter
|
|
16
|
+
|
|
17
|
+
<div align='center'>
|
|
18
|
+
|
|
19
|
+
<img src="https://user-images.githubusercontent.com/6839576/148364688-6a9fa8ac-94a3-4897-89fc-a3b64606e93c.png" width="400px" />
|
|
20
|
+
|
|
21
|
+
*▲ @aiou/eslint-plugin-progress*
|
|
22
|
+
|
|
23
|
+
</div>
|
|
24
|
+
|
|
25
|
+
## Install
|
|
26
|
+
|
|
27
|
+
```console
|
|
28
|
+
npm install @aiou/eslint-config --save-dev
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Requires **Node.js >= 20.19** and **ESLint >= 10**.
|
|
32
|
+
|
|
33
|
+
## Usage
|
|
34
|
+
|
|
35
|
+
In `eslint.config.mjs`:
|
|
36
|
+
|
|
37
|
+
```js
|
|
38
|
+
import { aiou } from '@aiou/eslint-config'
|
|
39
|
+
|
|
40
|
+
export default await aiou()
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### With Options
|
|
44
|
+
|
|
45
|
+
```js
|
|
46
|
+
import { aiou } from '@aiou/eslint-config'
|
|
47
|
+
|
|
48
|
+
export default await aiou({
|
|
49
|
+
ssr: true,
|
|
50
|
+
regexp: true,
|
|
51
|
+
})
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### With Custom Overrides
|
|
55
|
+
|
|
56
|
+
```js
|
|
57
|
+
import { aiou } from '@aiou/eslint-config'
|
|
58
|
+
|
|
59
|
+
export default await aiou(
|
|
60
|
+
{ ssr: false },
|
|
61
|
+
{
|
|
62
|
+
ignores: ['**/generated/**'],
|
|
63
|
+
rules: {
|
|
64
|
+
'no-console': 'off',
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
)
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
`aiou()` returns a `FlatConfigComposer` — you can chain `.append()`, `.override()`, etc.
|
|
71
|
+
|
|
72
|
+
## Options
|
|
73
|
+
|
|
74
|
+
| Option | Type | Default | Description |
|
|
75
|
+
|--------|------|---------|-------------|
|
|
76
|
+
| `ssr` | `boolean` | `true` | Enable SSR-safe rules — forbids direct access to `window`, `document`, `navigator`, `location`, `history`, `localStorage` without `typeof` guards |
|
|
77
|
+
| `regexp` | `boolean` | `true` | Enable `eslint-plugin-regexp` recommended rules |
|
|
78
|
+
|
|
79
|
+
## Auto-Detection
|
|
80
|
+
|
|
81
|
+
The following plugins are enabled automatically when their packages are found in your project:
|
|
82
|
+
|
|
83
|
+
| Feature | Package | Plugin |
|
|
84
|
+
|---------|---------|--------|
|
|
85
|
+
| Next.js | `next` | `@next/eslint-plugin-next` |
|
|
86
|
+
| Tailwind CSS | `tailwindcss` | `eslint-plugin-tailwindcss` |
|
|
87
|
+
|
|
88
|
+
## Style Defaults
|
|
89
|
+
|
|
90
|
+
| Setting | Value |
|
|
91
|
+
|---------|-------|
|
|
92
|
+
| Indentation | 2 spaces |
|
|
93
|
+
| Quotes | Single (JS/TS), Double (JSX, YAML) |
|
|
94
|
+
| Semicolons | Never |
|
|
95
|
+
| Trailing commas | `always-multiline` |
|
|
96
|
+
| Arrow parens | `as-needed` |
|
|
97
|
+
| Curly | `all` |
|
|
98
|
+
| File naming | `kebab-case` (via unicorn) |
|
|
99
|
+
| Import sorting | side-effects → `node:` builtins → packages → relative/alias → virtual → types |
|
|
100
|
+
|
|
101
|
+
## Included Plugins
|
|
102
|
+
|
|
103
|
+
| Plugin | Notes |
|
|
104
|
+
|--------|-------|
|
|
105
|
+
| `@typescript-eslint/eslint-plugin` | TypeScript rules, type imports, enum prohibition |
|
|
106
|
+
| `@eslint-react/eslint-plugin` | React rules (recommended-typescript, dom, x, web-api) |
|
|
107
|
+
| `eslint-plugin-react-hooks` | Hooks rules |
|
|
108
|
+
| `eslint-plugin-react-refresh` | React Refresh compatibility |
|
|
109
|
+
| `@stylistic/eslint-plugin` | Formatting rules |
|
|
110
|
+
| `eslint-plugin-import-x` | Import rules |
|
|
111
|
+
| `eslint-plugin-simple-import-sort` | Import sorting |
|
|
112
|
+
| `eslint-plugin-import-newlines` | Multi-line import enforcement |
|
|
113
|
+
| `eslint-plugin-unused-imports` | Unused import/variable removal |
|
|
114
|
+
| `eslint-plugin-unicorn` | Best practice rules |
|
|
115
|
+
| `eslint-plugin-n` | Node.js rules |
|
|
116
|
+
| `eslint-plugin-promise` | Promise rules |
|
|
117
|
+
| `eslint-plugin-jsonc` | JSON/JSONC rules + sorted `package.json`/`tsconfig.json` keys |
|
|
118
|
+
| `eslint-plugin-yml` | YAML rules |
|
|
119
|
+
| `@eslint/markdown` | Markdown linting |
|
|
120
|
+
| `eslint-plugin-toml` | TOML rules |
|
|
121
|
+
| `eslint-plugin-regexp` | RegExp rules (when `regexp: true`) |
|
|
122
|
+
| `@eslint-community/eslint-plugin-eslint-comments` | ESLint directive rules |
|
|
123
|
+
| `eslint-plugin-etc` | TypeScript extras (no single-char type params) |
|
|
124
|
+
| `@next/eslint-plugin-next` | Next.js rules (auto-detected) |
|
|
125
|
+
| `eslint-plugin-tailwindcss` | Tailwind CSS rules (auto-detected) |
|
|
126
|
+
| `@aiou/eslint-plugin-progress` | Visual progress reporter |
|
|
127
|
+
|
|
128
|
+
## Exports
|
|
129
|
+
|
|
130
|
+
- **`aiou(options?, ...userConfigs)`** — Main factory. Returns `FlatConfigComposer`.
|
|
131
|
+
- **`all`** — Full flat config array of all rules (useful for tooling/typegen).
|
package/dist/index.mjs
CHANGED
|
@@ -90,16 +90,16 @@ const imports = () => {
|
|
|
90
90
|
{
|
|
91
91
|
groups: [
|
|
92
92
|
// Side effect imports.
|
|
93
|
-
[
|
|
93
|
+
[String.raw`^\u0000`],
|
|
94
94
|
// Node.js builtins prefixed with `node:`.
|
|
95
95
|
["^node:"],
|
|
96
96
|
// Packages.
|
|
97
97
|
// Things that start with a letter (or digit or underscore), or `@` followed by a letter.
|
|
98
|
-
[
|
|
98
|
+
[String.raw`^@?\w`],
|
|
99
99
|
// Relative imports.
|
|
100
100
|
// Absolute imports and other imports such as `@/foo` or `~/foo`.
|
|
101
101
|
// Anything not matched in another group.
|
|
102
|
-
["^",
|
|
102
|
+
["^", String.raw`^\.`, String.raw`^@/\w`, String.raw`^~/\w`],
|
|
103
103
|
// Virtual modules prefixed with `virtual:` or `virtual-`, rollup & vite favor
|
|
104
104
|
["^virtual:", "^virtual-"],
|
|
105
105
|
// Types
|
|
@@ -752,7 +752,8 @@ const markdown = () => {
|
|
|
752
752
|
"import/no-default-export": "off",
|
|
753
753
|
"import/no-anonymous-default-export": "off",
|
|
754
754
|
"react-refresh/only-export-components": "off",
|
|
755
|
-
"react/jsx-no-undef": "off"
|
|
755
|
+
"react/jsx-no-undef": "off",
|
|
756
|
+
"unicorn/filename-case": "off"
|
|
756
757
|
}
|
|
757
758
|
}
|
|
758
759
|
];
|
|
@@ -829,9 +830,9 @@ const react = () => {
|
|
|
829
830
|
},
|
|
830
831
|
rules: {
|
|
831
832
|
...renameRules(pluginReact.configs["recommended-typescript"].rules, { "@eslint-react": "react" }),
|
|
832
|
-
...renameRules(pluginReact.configs
|
|
833
|
-
...renameRules(pluginReact.configs
|
|
834
|
-
...renameRules(pluginReact.configs
|
|
833
|
+
...renameRules(pluginReact.configs.dom.rules, { "@eslint-react": "react-dom" }),
|
|
834
|
+
...renameRules(pluginReact.configs.x.rules, { "@eslint-react": "react-hooks-extra" }),
|
|
835
|
+
...renameRules(pluginReact.configs.x.rules, { "@eslint-react": "react-naming-convention" }),
|
|
835
836
|
...renameRules(pluginReact.configs["web-api"].rules, { "@eslint-react": "react-web-api" }),
|
|
836
837
|
...pluginReactHooks.configs.flat.recommended.rules,
|
|
837
838
|
"react/no-nested-component-definitions": "warn",
|
|
@@ -1290,7 +1291,11 @@ const unicorn = () => {
|
|
|
1290
1291
|
"unicorn/prefer-number-properties": "error",
|
|
1291
1292
|
"unicorn/prefer-string-starts-ends-with": "error",
|
|
1292
1293
|
"unicorn/prefer-type-error": "error",
|
|
1293
|
-
"unicorn/throw-new-error": "error"
|
|
1294
|
+
"unicorn/throw-new-error": "error",
|
|
1295
|
+
"unicorn/filename-case": ["error", {
|
|
1296
|
+
case: "kebabCase",
|
|
1297
|
+
ignore: [/^[A-Z]+\.md$/, /^[A-Z]+\.yml$/, /^\.?[A-Z]/, /^Dockerfile$/]
|
|
1298
|
+
}]
|
|
1294
1299
|
}
|
|
1295
1300
|
}
|
|
1296
1301
|
];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiou/eslint-config",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "eslint config for JW",
|
|
6
6
|
"keywords": [],
|
|
@@ -26,12 +26,10 @@
|
|
|
26
26
|
"exports": {
|
|
27
27
|
"./package.json": "./package.json",
|
|
28
28
|
".": {
|
|
29
|
-
"import": "./dist/index.mjs"
|
|
30
|
-
"require": "./dist/index.cjs"
|
|
29
|
+
"import": "./dist/index.mjs"
|
|
31
30
|
}
|
|
32
31
|
},
|
|
33
|
-
"main": "dist/index.
|
|
34
|
-
"module": "dist/index.mjs",
|
|
32
|
+
"main": "dist/index.mjs",
|
|
35
33
|
"types": "dts/index.d.ts",
|
|
36
34
|
"publishConfig": {
|
|
37
35
|
"access": "public"
|
|
@@ -67,8 +65,8 @@
|
|
|
67
65
|
"jsonc-eslint-parser": "^3.1.0",
|
|
68
66
|
"local-pkg": "^1.1.2",
|
|
69
67
|
"yaml-eslint-parser": "^2.0.0",
|
|
70
|
-
"@aiou/eslint-
|
|
71
|
-
"@aiou/eslint-
|
|
68
|
+
"@aiou/eslint-ignore": "0.6.0",
|
|
69
|
+
"@aiou/eslint-plugin-progress": "0.4.0"
|
|
72
70
|
},
|
|
73
71
|
"devDependencies": {
|
|
74
72
|
"@rollup/plugin-alias": "4.0.3",
|