@aiou/eslint-config 3.0.2 → 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 ADDED
@@ -0,0 +1,131 @@
1
+ # @aiou/eslint-config
2
+
3
+ [![npm](https://img.shields.io/npm/v/@aiou/eslint-config)](https://www.npmjs.com/package/@aiou/eslint-config) [![GitHub](https://img.shields.io/npm/l/@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
- ["^\\u0000"],
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
- ["^@?\\w"],
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
- ["^", "^\\.", "^@/\\w", "^~/\\w"],
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["dom"].rules, { "@eslint-react": "react-dom" }),
833
- ...renameRules(pluginReact.configs["x"].rules, { "@eslint-react": "react-hooks-extra" }),
834
- ...renameRules(pluginReact.configs["x"].rules, { "@eslint-react": "react-naming-convention" }),
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.2",
3
+ "version": "3.1.0",
4
4
  "type": "module",
5
5
  "description": "eslint config for JW",
6
6
  "keywords": [],
package/readme.md DELETED
@@ -1,77 +0,0 @@
1
- # @aiou/eslint-config
2
- *my flat eslint config*
3
-
4
- [![npm](https://img.shields.io/npm/v/@aiou/eslint-config)](https://www.npmjs.com/package/@aiou/eslint-config) [![GitHub](https://img.shields.io/npm/l/@aiou/eslint-config)](https://github.com/JiangWeixian/eslint-config/tree/master/packages/default)
5
-
6
- ## features
7
-
8
- - Common ignore patterns from [nodejs's gitignore](https://github.com/github/gitignore/blob/master/Node.gitignore)
9
- - Support typescript, yaml, jsonc, markdown, etc..
10
- - Built-in best practices react rules, react-refresh and ssr-friendly rules...
11
- - Friendly fix reporter
12
-
13
- <div align='center'>
14
-
15
- <img src="https://user-images.githubusercontent.com/6839576/148364688-6a9fa8ac-94a3-4897-89fc-a3b64606e93c.png" width="400px" />
16
-
17
- *▲ @aiou/eslint-plugin-progress*
18
-
19
- </div>
20
-
21
- ## install
22
-
23
- ```console
24
- npm install @aiou/eslint-config --save-dev
25
- ```
26
-
27
- ## usage
28
-
29
- in `eslint.config.mjs`
30
-
31
- ```js
32
- import { aiou } from '@aiou/eslint-config'
33
-
34
- export default await aiou()
35
- ```
36
-
37
- ### options
38
-
39
- #### `options.ssr`
40
-
41
- - default: `true`
42
-
43
- enabled ssr-friendly rules
44
-
45
- #### `options.regexp`
46
-
47
- - default: `true`
48
-
49
- enabled regexp rules
50
-
51
- ## rules
52
-
53
- extends from
54
-
55
- ```console
56
- eslint-config-standard
57
- @eslint-community/eslint-plugin-eslint-comments
58
- eslint-plugin-html
59
- eslint-plugin-import-x
60
- eslint-plugin-regexp (configured when regexp enabled)
61
- eslint-plugin-markdown
62
- eslint-plugin-simple-import-sort
63
- eslint-plugin-import-newlines
64
- eslint-plugin-unused-imports
65
- eslint-plugin-jsonc
66
- eslint-plugin-n (forked eslint-plugin-node)
67
- eslint-plugin-promise
68
- eslint-plugin-unicorn
69
- eslint-plugin-yml
70
- @eslint-react/eslint-plugin
71
- eslint-plugin-react-refresh
72
- @next/eslint-plugin-next (enabled when next found)
73
- eslint-plugin-react-hooks
74
- eslint-plugin-tailwindcss
75
- @typescript-eslint/eslint-plugin
76
- @stylistic/eslint-plugin
77
- ```