@kiid_brian/eslint-config 0.2.1 → 0.2.5
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 +116 -25
- package/dist/configs/base.d.ts +4 -0
- package/dist/configs/base.d.ts.map +1 -0
- package/dist/configs/base.js +216 -0
- package/dist/configs/node.d.ts +4 -0
- package/dist/configs/node.d.ts.map +1 -0
- package/dist/configs/node.js +17 -0
- package/dist/configs/react.d.ts +4 -0
- package/dist/configs/react.d.ts.map +1 -0
- package/dist/configs/react.js +39 -0
- package/dist/configs/strict.d.ts +4 -0
- package/dist/configs/strict.d.ts.map +1 -0
- package/dist/configs/strict.js +20 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +59 -0
- package/dist/presets/minimal.d.ts +4 -0
- package/dist/presets/minimal.d.ts.map +1 -0
- package/dist/presets/minimal.js +58 -0
- package/dist/types/index.d.ts +18 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +4 -0
- package/package.json +63 -26
- package/configs/base.js +0 -171
- package/configs/node.js +0 -22
- package/configs/react.js +0 -37
- package/configs/strict.js +0 -29
- package/index.js +0 -82
package/README.md
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @kiid_brian/eslint-config
|
|
2
2
|
|
|
3
3
|
A comprehensive, flexible ESLint configuration package for TypeScript and JavaScript projects.
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
|
-
- ✅ **
|
|
8
|
-
- ✅ **
|
|
7
|
+
- ✅ **TypeScript First**: Comprehensive type-aware linting out of the box
|
|
8
|
+
- ✅ **Full Type Safety**: Complete TypeScript definitions included
|
|
9
|
+
- ✅ **Flexible Presets**: Choose from minimal, base, React, Node.js, or strict configurations
|
|
9
10
|
- ✅ **React Support**: JSX, accessibility, and React-specific rules
|
|
10
11
|
- ✅ **Import Organization**: Automatic import sorting and validation
|
|
11
12
|
- ✅ **Security Rules**: Built-in security best practices
|
|
@@ -16,36 +17,101 @@ A comprehensive, flexible ESLint configuration package for TypeScript and JavaSc
|
|
|
16
17
|
## Installation
|
|
17
18
|
|
|
18
19
|
```bash
|
|
19
|
-
npm install --save-dev eslint-config
|
|
20
|
+
npm install --save-dev @kiid_brian/eslint-config
|
|
20
21
|
```
|
|
21
22
|
|
|
23
|
+
## Preset Options
|
|
24
|
+
|
|
25
|
+
Choose the right preset for your project needs:
|
|
26
|
+
|
|
27
|
+
### Minimal Preset
|
|
28
|
+
|
|
29
|
+
**For basic TypeScript projects** - Only requires essential dependencies
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npm install --save-dev @kiid_brian/eslint-config
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
```js
|
|
36
|
+
// eslint.config.js
|
|
37
|
+
import {minimal} from "@kiid_brian/eslint-config";
|
|
38
|
+
|
|
39
|
+
export default minimal;
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
**Required peer dependencies:**
|
|
43
|
+
|
|
44
|
+
- `@eslint/js`, `eslint`, `globals`, `typescript-eslint`
|
|
45
|
+
|
|
46
|
+
### Standard Presets (Base, React, Node, Strict)
|
|
47
|
+
|
|
48
|
+
**For full-featured projects** - Includes all optional plugins when available
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
npm install --save-dev @kiid_brian/eslint-config \
|
|
52
|
+
eslint-config-prettier \
|
|
53
|
+
eslint-plugin-import \
|
|
54
|
+
eslint-plugin-prettier \
|
|
55
|
+
# ... other optional plugins
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
```js
|
|
59
|
+
// eslint.config.js
|
|
60
|
+
import {react} from "@kiid_brian/eslint-config";
|
|
61
|
+
|
|
62
|
+
export default react;
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## TypeScript Support
|
|
66
|
+
|
|
67
|
+
This config is **TypeScript-first** with comprehensive type safety:
|
|
68
|
+
|
|
69
|
+
- ✅ **Full type-aware linting** with project analysis
|
|
70
|
+
- ✅ **Modern TypeScript rules** (consistent types, optional chaining, nullish coalescing)
|
|
71
|
+
- ✅ **TypeScript definitions included** - no additional setup required
|
|
72
|
+
- ✅ **Stylistic consistency** (type imports, interface vs type, const assertions)
|
|
73
|
+
- ✅ **Enhanced type checking** (no unnecessary assertions, inferrable types)
|
|
74
|
+
- ✅ **Comprehensive file support** (`.ts`, `.tsx`, `.mts`, `.cts`, `.d.ts`)
|
|
75
|
+
- ✅ **Smart unused variable detection** with TypeScript patterns
|
|
76
|
+
- ✅ **Type-safe configuration API** with IntelliSense support
|
|
77
|
+
|
|
78
|
+
**Note**: Make sure you have a `tsconfig.json` in your project root for optimal type checking.
|
|
79
|
+
|
|
22
80
|
### Peer Dependencies
|
|
23
81
|
|
|
24
|
-
|
|
82
|
+
#### Required (for all presets):
|
|
25
83
|
|
|
26
84
|
```bash
|
|
27
85
|
npm install --save-dev \
|
|
28
86
|
@eslint/js \
|
|
29
87
|
eslint \
|
|
88
|
+
globals \
|
|
89
|
+
typescript-eslint
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
#### Optional (enhance functionality when installed):
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
npm install --save-dev \
|
|
30
96
|
eslint-config-prettier \
|
|
31
97
|
eslint-plugin-import \
|
|
32
|
-
eslint-plugin-jsx-a11y \
|
|
33
98
|
eslint-plugin-jsdoc \
|
|
99
|
+
eslint-plugin-jsx-a11y \
|
|
34
100
|
eslint-plugin-prettier \
|
|
35
101
|
eslint-plugin-react \
|
|
36
102
|
eslint-plugin-security \
|
|
37
|
-
|
|
38
|
-
prettier \
|
|
39
|
-
typescript-eslint
|
|
103
|
+
prettier
|
|
40
104
|
```
|
|
41
105
|
|
|
106
|
+
**Note**: Optional plugins are loaded conditionally - your config works without them, but provides enhanced rules when they're available.
|
|
107
|
+
|
|
42
108
|
## Usage
|
|
43
109
|
|
|
44
110
|
### Basic Usage (Default React Configuration)
|
|
45
111
|
|
|
46
112
|
```js
|
|
47
113
|
// eslint.config.js
|
|
48
|
-
import config from "eslint-config
|
|
114
|
+
import config from "@kiid_brian/eslint-config";
|
|
49
115
|
|
|
50
116
|
export default config;
|
|
51
117
|
```
|
|
@@ -54,7 +120,7 @@ export default config;
|
|
|
54
120
|
|
|
55
121
|
```js
|
|
56
122
|
// eslint.config.js
|
|
57
|
-
import {react} from "eslint-config
|
|
123
|
+
import {react} from "@kiid_brian/eslint-config";
|
|
58
124
|
|
|
59
125
|
export default react;
|
|
60
126
|
```
|
|
@@ -70,7 +136,7 @@ Available presets:
|
|
|
70
136
|
|
|
71
137
|
```js
|
|
72
138
|
// eslint.config.js
|
|
73
|
-
import reactConfig from "eslint-config
|
|
139
|
+
import reactConfig from "@kiid_brian/eslint-config/configs/react.js";
|
|
74
140
|
|
|
75
141
|
export default reactConfig;
|
|
76
142
|
```
|
|
@@ -79,7 +145,7 @@ export default reactConfig;
|
|
|
79
145
|
|
|
80
146
|
```js
|
|
81
147
|
// eslint.config.js
|
|
82
|
-
import {createConfig} from "eslint-config
|
|
148
|
+
import {createConfig} from "@kiid_brian/eslint-config";
|
|
83
149
|
|
|
84
150
|
export default createConfig({
|
|
85
151
|
preset: "base",
|
|
@@ -103,9 +169,15 @@ export default createConfig({
|
|
|
103
169
|
|
|
104
170
|
- Type: `string`
|
|
105
171
|
- Default: `"react"`
|
|
106
|
-
- Options: `"base" | "react" | "node" | "strict"`
|
|
172
|
+
- Options: `"minimal" | "base" | "react" | "node" | "strict"`
|
|
173
|
+
|
|
174
|
+
Choose the base configuration preset:
|
|
107
175
|
|
|
108
|
-
|
|
176
|
+
- `"minimal"`: Essential TypeScript rules only
|
|
177
|
+
- `"base"`: Full TypeScript with optional plugins
|
|
178
|
+
- `"react"`: React + TypeScript + accessibility
|
|
179
|
+
- `"node"`: Node.js optimized configuration
|
|
180
|
+
- `"strict"`: Maximum code quality rules
|
|
109
181
|
|
|
110
182
|
#### `environments`
|
|
111
183
|
|
|
@@ -128,7 +200,7 @@ Custom ESLint configuration objects to merge with the preset.
|
|
|
128
200
|
|
|
129
201
|
```js
|
|
130
202
|
// eslint.config.js
|
|
131
|
-
import config from "eslint-config
|
|
203
|
+
import config from "@kiid_brian/eslint-config";
|
|
132
204
|
|
|
133
205
|
export default config;
|
|
134
206
|
```
|
|
@@ -137,7 +209,7 @@ export default config;
|
|
|
137
209
|
|
|
138
210
|
```js
|
|
139
211
|
// eslint.config.js
|
|
140
|
-
import {node} from "eslint-config
|
|
212
|
+
import {node} from "@kiid_brian/eslint-config";
|
|
141
213
|
|
|
142
214
|
export default node;
|
|
143
215
|
```
|
|
@@ -146,7 +218,7 @@ export default node;
|
|
|
146
218
|
|
|
147
219
|
```js
|
|
148
220
|
// eslint.config.js
|
|
149
|
-
import {strict} from "eslint-config
|
|
221
|
+
import {strict} from "@kiid_brian/eslint-config";
|
|
150
222
|
|
|
151
223
|
export default strict;
|
|
152
224
|
```
|
|
@@ -155,7 +227,7 @@ export default strict;
|
|
|
155
227
|
|
|
156
228
|
```js
|
|
157
229
|
// eslint.config.js
|
|
158
|
-
import {createConfig} from "eslint-config
|
|
230
|
+
import {createConfig} from "@kiid_brian/eslint-config";
|
|
159
231
|
|
|
160
232
|
export default createConfig({
|
|
161
233
|
preset: "react",
|
|
@@ -165,9 +237,26 @@ export default createConfig({
|
|
|
165
237
|
|
|
166
238
|
### Custom Overrides
|
|
167
239
|
|
|
240
|
+
```ts
|
|
241
|
+
// eslint.config.ts (TypeScript)
|
|
242
|
+
import {createConfig} from "@kiid_brian/eslint-config";
|
|
243
|
+
|
|
244
|
+
export default createConfig({
|
|
245
|
+
preset: "base",
|
|
246
|
+
overrides: [
|
|
247
|
+
{
|
|
248
|
+
rules: {
|
|
249
|
+
"no-console": "off",
|
|
250
|
+
"@typescript-eslint/explicit-function-return-type": "warn",
|
|
251
|
+
},
|
|
252
|
+
},
|
|
253
|
+
],
|
|
254
|
+
});
|
|
255
|
+
```
|
|
256
|
+
|
|
168
257
|
```js
|
|
169
|
-
// eslint.config.js
|
|
170
|
-
import {createConfig} from "eslint-config
|
|
258
|
+
// eslint.config.js (JavaScript)
|
|
259
|
+
import {createConfig} from "@kiid_brian/eslint-config";
|
|
171
260
|
|
|
172
261
|
export default createConfig({
|
|
173
262
|
preset: "base",
|
|
@@ -186,10 +275,12 @@ export default createConfig({
|
|
|
186
275
|
|
|
187
276
|
### TypeScript
|
|
188
277
|
|
|
189
|
-
-
|
|
190
|
-
-
|
|
191
|
-
-
|
|
192
|
-
-
|
|
278
|
+
- **Full type-aware linting** with project analysis
|
|
279
|
+
- **Modern TypeScript rules** (consistent types, optional chaining, nullish coalescing)
|
|
280
|
+
- **Stylistic consistency** (type imports, interface vs type, const assertions)
|
|
281
|
+
- **Enhanced type checking** (no unnecessary assertions, inferrable types)
|
|
282
|
+
- **Comprehensive file support** (`.ts`, `.tsx`, `.mts`, `.cts`, `.d.ts`)
|
|
283
|
+
- **Smart unused variable detection** with TypeScript patterns
|
|
193
284
|
|
|
194
285
|
### React
|
|
195
286
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../configs/base.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,QAAQ,CAAC;AAmCnC,QAAA,MAAM,UAAU,EAAE,MAAM,CAAC,MAAM,EA+N9B,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import js from "@eslint/js";
|
|
2
|
+
import ts from "typescript-eslint";
|
|
3
|
+
import globals from "globals";
|
|
4
|
+
let prettierRecommended = {};
|
|
5
|
+
let importPlugin = { flatConfigs: { recommended: {}, typescript: {} } };
|
|
6
|
+
let jsdoc = { configs: { "flat/recommended": {} } };
|
|
7
|
+
let security = { configs: { recommended: {} } };
|
|
8
|
+
try {
|
|
9
|
+
prettierRecommended = require("eslint-plugin-prettier/recommended");
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
}
|
|
13
|
+
try {
|
|
14
|
+
importPlugin = require("eslint-plugin-import");
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
}
|
|
18
|
+
try {
|
|
19
|
+
jsdoc = require("eslint-plugin-jsdoc");
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
}
|
|
23
|
+
try {
|
|
24
|
+
security = require("eslint-plugin-security");
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
}
|
|
28
|
+
const baseConfig = [
|
|
29
|
+
js.configs.recommended,
|
|
30
|
+
...ts.configs.recommended,
|
|
31
|
+
...ts.configs.recommendedTypeChecked,
|
|
32
|
+
...ts.configs.stylisticTypeChecked,
|
|
33
|
+
...(importPlugin.flatConfigs?.recommended
|
|
34
|
+
? [importPlugin.flatConfigs.recommended]
|
|
35
|
+
: []),
|
|
36
|
+
...(importPlugin.flatConfigs?.typescript
|
|
37
|
+
? [importPlugin.flatConfigs.typescript]
|
|
38
|
+
: []),
|
|
39
|
+
...(security.configs?.recommended ? [security.configs.recommended] : []),
|
|
40
|
+
...(jsdoc.configs?.["flat/recommended"]
|
|
41
|
+
? [jsdoc.configs["flat/recommended"]]
|
|
42
|
+
: []),
|
|
43
|
+
{
|
|
44
|
+
languageOptions: {
|
|
45
|
+
globals: {
|
|
46
|
+
...globals.node,
|
|
47
|
+
...globals.browser,
|
|
48
|
+
...globals.es2021,
|
|
49
|
+
},
|
|
50
|
+
parser: ts.parser,
|
|
51
|
+
parserOptions: {
|
|
52
|
+
ecmaVersion: "latest",
|
|
53
|
+
sourceType: "module",
|
|
54
|
+
project: true,
|
|
55
|
+
projectFolderIgnoreList: ["**/node_modules/**"],
|
|
56
|
+
tsconfigRootDir: process.cwd(),
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
files: ["**/*.ts", "**/*.tsx", "**/*.mts", "**/*.cts"],
|
|
60
|
+
plugins: {
|
|
61
|
+
import: importPlugin,
|
|
62
|
+
jsdoc,
|
|
63
|
+
security,
|
|
64
|
+
},
|
|
65
|
+
rules: {
|
|
66
|
+
"no-console": "warn",
|
|
67
|
+
"no-debugger": "error",
|
|
68
|
+
"@typescript-eslint/explicit-function-return-type": "off",
|
|
69
|
+
"@typescript-eslint/no-unused-vars": [
|
|
70
|
+
"error",
|
|
71
|
+
{
|
|
72
|
+
argsIgnorePattern: "^_",
|
|
73
|
+
varsIgnorePattern: "^_",
|
|
74
|
+
caughtErrorsIgnorePattern: "^_",
|
|
75
|
+
},
|
|
76
|
+
],
|
|
77
|
+
"@typescript-eslint/no-explicit-any": "warn",
|
|
78
|
+
"@typescript-eslint/prefer-const": "error",
|
|
79
|
+
"@typescript-eslint/no-var-requires": "error",
|
|
80
|
+
"@typescript-eslint/consistent-type-definitions": ["error", "interface"],
|
|
81
|
+
"@typescript-eslint/consistent-type-imports": [
|
|
82
|
+
"error",
|
|
83
|
+
{ prefer: "type-imports" },
|
|
84
|
+
],
|
|
85
|
+
"@typescript-eslint/no-import-type-side-effects": "error",
|
|
86
|
+
"@typescript-eslint/prefer-nullish-coalescing": "error",
|
|
87
|
+
"@typescript-eslint/prefer-optional-chain": "error",
|
|
88
|
+
"@typescript-eslint/no-unnecessary-type-assertion": "error",
|
|
89
|
+
"@typescript-eslint/no-non-null-assertion": "warn",
|
|
90
|
+
"@typescript-eslint/prefer-as-const": "error",
|
|
91
|
+
"@typescript-eslint/no-inferrable-types": "error",
|
|
92
|
+
"@typescript-eslint/consistent-type-exports": "error",
|
|
93
|
+
...(importPlugin.flatConfigs?.recommended
|
|
94
|
+
? {
|
|
95
|
+
"import/no-unresolved": "error",
|
|
96
|
+
"import/named": "error",
|
|
97
|
+
"import/default": "error",
|
|
98
|
+
"import/namespace": "error",
|
|
99
|
+
"import/no-absolute-path": "error",
|
|
100
|
+
"import/no-dynamic-require": "warn",
|
|
101
|
+
"import/no-webpack-loader-syntax": "error",
|
|
102
|
+
"import/order": [
|
|
103
|
+
"error",
|
|
104
|
+
{
|
|
105
|
+
groups: [
|
|
106
|
+
"builtin",
|
|
107
|
+
"external",
|
|
108
|
+
"internal",
|
|
109
|
+
"parent",
|
|
110
|
+
"sibling",
|
|
111
|
+
"index",
|
|
112
|
+
],
|
|
113
|
+
"newlines-between": "always",
|
|
114
|
+
alphabetize: { order: "asc", caseInsensitive: true },
|
|
115
|
+
},
|
|
116
|
+
],
|
|
117
|
+
}
|
|
118
|
+
: {}),
|
|
119
|
+
...(security.configs?.recommended
|
|
120
|
+
? {
|
|
121
|
+
"security/detect-object-injection": "warn",
|
|
122
|
+
"security/detect-non-literal-regexp": "warn",
|
|
123
|
+
"security/detect-unsafe-regex": "error",
|
|
124
|
+
}
|
|
125
|
+
: {}),
|
|
126
|
+
...(jsdoc.configs?.["flat/recommended"]
|
|
127
|
+
? {
|
|
128
|
+
"jsdoc/require-description": "warn",
|
|
129
|
+
"jsdoc/check-values": "warn",
|
|
130
|
+
"jsdoc/check-param-names": "error",
|
|
131
|
+
"jsdoc/check-tag-names": "error",
|
|
132
|
+
"jsdoc/require-param": "warn",
|
|
133
|
+
"jsdoc/require-returns": "warn",
|
|
134
|
+
}
|
|
135
|
+
: {}),
|
|
136
|
+
"no-unused-vars": "off",
|
|
137
|
+
"prefer-const": "error",
|
|
138
|
+
"no-var": "error",
|
|
139
|
+
"object-shorthand": "error",
|
|
140
|
+
"prefer-arrow-callback": "error",
|
|
141
|
+
"prefer-template": "error",
|
|
142
|
+
eqeqeq: ["error", "always"],
|
|
143
|
+
curly: ["error", "all"],
|
|
144
|
+
"no-duplicate-imports": "error",
|
|
145
|
+
},
|
|
146
|
+
settings: {
|
|
147
|
+
...(importPlugin.flatConfigs?.recommended
|
|
148
|
+
? {
|
|
149
|
+
"import/resolver": {
|
|
150
|
+
typescript: true,
|
|
151
|
+
node: true,
|
|
152
|
+
},
|
|
153
|
+
}
|
|
154
|
+
: {}),
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
files: ["**/*.js", "**/*.mjs", "**/*.cjs"],
|
|
159
|
+
rules: {
|
|
160
|
+
"@typescript-eslint/no-var-requires": "off",
|
|
161
|
+
"@typescript-eslint/no-require-imports": "off",
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
files: ["**/*.d.ts"],
|
|
166
|
+
rules: {
|
|
167
|
+
"@typescript-eslint/no-unused-vars": "off",
|
|
168
|
+
"no-unused-vars": "off",
|
|
169
|
+
},
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
files: ["**/*.test.{ts,tsx,js,jsx}", "**/*.spec.{ts,tsx,js,jsx}"],
|
|
173
|
+
languageOptions: {
|
|
174
|
+
globals: {
|
|
175
|
+
...globals.jest,
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
rules: {
|
|
179
|
+
"@typescript-eslint/no-explicit-any": "off",
|
|
180
|
+
"@typescript-eslint/no-non-null-assertion": "off",
|
|
181
|
+
"jsdoc/require-description": "off",
|
|
182
|
+
"jsdoc/require-param": "off",
|
|
183
|
+
"jsdoc/require-returns": "off",
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
files: [
|
|
188
|
+
"**/*.config.{ts,js}",
|
|
189
|
+
"**/vite.config.{ts,js}",
|
|
190
|
+
"**/vitest.config.{ts,js}",
|
|
191
|
+
],
|
|
192
|
+
rules: {
|
|
193
|
+
"no-console": "off",
|
|
194
|
+
"@typescript-eslint/no-var-requires": "off",
|
|
195
|
+
},
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
ignores: [
|
|
199
|
+
"dist/**",
|
|
200
|
+
"build/**",
|
|
201
|
+
"node_modules/**",
|
|
202
|
+
"*.min.js",
|
|
203
|
+
"*.bundle.js",
|
|
204
|
+
"coverage/**",
|
|
205
|
+
".next/**",
|
|
206
|
+
".nuxt/**",
|
|
207
|
+
".output/**",
|
|
208
|
+
".vercel/**",
|
|
209
|
+
".netlify/**",
|
|
210
|
+
"public/**",
|
|
211
|
+
"**/*.d.ts",
|
|
212
|
+
],
|
|
213
|
+
},
|
|
214
|
+
prettierRecommended,
|
|
215
|
+
];
|
|
216
|
+
export default baseConfig;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../configs/node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,QAAQ,CAAC;AAInC,QAAA,MAAM,UAAU,EAAE,MAAM,CAAC,MAAM,EAiB9B,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import globals from "globals";
|
|
2
|
+
import baseConfig from "./base.js";
|
|
3
|
+
const nodeConfig = [
|
|
4
|
+
...baseConfig,
|
|
5
|
+
{
|
|
6
|
+
languageOptions: {
|
|
7
|
+
globals: {
|
|
8
|
+
...globals.node,
|
|
9
|
+
...globals.es2021,
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
rules: {
|
|
13
|
+
"no-console": "off",
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
];
|
|
17
|
+
export default nodeConfig;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../../configs/react.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,QAAQ,CAAC;AAanC,QAAA,MAAM,WAAW,EAAE,MAAM,CAAC,MAAM,EAqC/B,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import react from "eslint-plugin-react";
|
|
2
|
+
import baseConfig from "./base.js";
|
|
3
|
+
let jsxA11y = { flatConfigs: { recommended: {} } };
|
|
4
|
+
try {
|
|
5
|
+
jsxA11y = require("eslint-plugin-jsx-a11y");
|
|
6
|
+
}
|
|
7
|
+
catch {
|
|
8
|
+
}
|
|
9
|
+
const reactConfig = [
|
|
10
|
+
...baseConfig,
|
|
11
|
+
...(react.configs.flat?.recommended ? [react.configs.flat.recommended] : []),
|
|
12
|
+
...(react.configs.flat?.["jsx-runtime"]
|
|
13
|
+
? [react.configs.flat["jsx-runtime"]]
|
|
14
|
+
: []),
|
|
15
|
+
...(jsxA11y.flatConfigs?.recommended
|
|
16
|
+
? [jsxA11y.flatConfigs.recommended]
|
|
17
|
+
: []),
|
|
18
|
+
{
|
|
19
|
+
plugins: {
|
|
20
|
+
...(jsxA11y.flatConfigs?.recommended ? { "jsx-a11y": jsxA11y } : {}),
|
|
21
|
+
react,
|
|
22
|
+
},
|
|
23
|
+
rules: {
|
|
24
|
+
"react/prop-types": "off",
|
|
25
|
+
"react/react-in-jsx-scope": "off",
|
|
26
|
+
"react/jsx-uses-react": "off",
|
|
27
|
+
"react/jsx-uses-vars": "error",
|
|
28
|
+
"react/jsx-key": ["error", { checkFragmentShorthand: true }],
|
|
29
|
+
"react/jsx-no-useless-fragment": "error",
|
|
30
|
+
"react/self-closing-comp": "error",
|
|
31
|
+
},
|
|
32
|
+
settings: {
|
|
33
|
+
react: {
|
|
34
|
+
version: "detect",
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
];
|
|
39
|
+
export default reactConfig;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strict.d.ts","sourceRoot":"","sources":["../../configs/strict.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,QAAQ,CAAC;AAGnC,QAAA,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EA0BhC,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import baseConfig from "./base.js";
|
|
2
|
+
const strictConfig = [
|
|
3
|
+
...baseConfig,
|
|
4
|
+
{
|
|
5
|
+
rules: {
|
|
6
|
+
"@typescript-eslint/no-explicit-any": "error",
|
|
7
|
+
"@typescript-eslint/explicit-function-return-type": "warn",
|
|
8
|
+
"jsdoc/require-description": "error",
|
|
9
|
+
"jsdoc/require-param": "error",
|
|
10
|
+
"jsdoc/require-returns": "error",
|
|
11
|
+
"no-console": "error",
|
|
12
|
+
"security/detect-object-injection": "error",
|
|
13
|
+
complexity: ["error", 10],
|
|
14
|
+
"max-depth": ["error", 4],
|
|
15
|
+
"max-lines-per-function": ["error", 50],
|
|
16
|
+
"max-params": ["error", 4],
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
];
|
|
20
|
+
export default strictConfig;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Linter } from "eslint";
|
|
2
|
+
import type { ConfigOptions, ESLintConfig, Preset, TestEnvironment } from "./types/index.js";
|
|
3
|
+
export type { Preset, TestEnvironment, ConfigOptions, ESLintConfig };
|
|
4
|
+
export declare function createConfig(options?: ConfigOptions): Linter.Config[];
|
|
5
|
+
export declare const minimal: Linter.Config[];
|
|
6
|
+
export declare const base: Linter.Config[];
|
|
7
|
+
export declare const react: Linter.Config[];
|
|
8
|
+
export declare const node: Linter.Config[];
|
|
9
|
+
export declare const strict: Linter.Config[];
|
|
10
|
+
declare const defaultConfig: Linter.Config[];
|
|
11
|
+
export default defaultConfig;
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,QAAQ,CAAC;AACnC,OAAO,KAAK,EACV,aAAa,EACb,YAAY,EACZ,MAAM,EACN,eAAe,EAChB,MAAM,kBAAkB,CAAC;AAW1B,YAAY,EAAC,MAAM,EAAE,eAAe,EAAE,aAAa,EAAE,YAAY,EAAC,CAAC;AAyBnE,wBAAgB,YAAY,CAAC,OAAO,GAAE,aAAkB,GAAG,MAAM,CAAC,MAAM,EAAE,CA4DzE;AAKD,eAAO,MAAM,OAAO,EAAE,MAAM,CAAC,MAAM,EAAkB,CAAC;AAKtD,eAAO,MAAM,IAAI,EAAE,MAAM,CAAC,MAAM,EAAe,CAAC;AAKhD,eAAO,MAAM,KAAK,EAAE,MAAM,CAAC,MAAM,EAAgB,CAAC;AAKlD,eAAO,MAAM,IAAI,EAAE,MAAM,CAAC,MAAM,EAAe,CAAC;AAKhD,eAAO,MAAM,MAAM,EAAE,MAAM,CAAC,MAAM,EAAiB,CAAC;AAKpD,QAAA,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAgB,CAAC;AAEnD,eAAe,aAAa,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import baseConfig from "./configs/base.js";
|
|
2
|
+
import reactConfig from "./configs/react.js";
|
|
3
|
+
import nodeConfig from "./configs/node.js";
|
|
4
|
+
import strictConfig from "./configs/strict.js";
|
|
5
|
+
import minimalConfig from "./presets/minimal.js";
|
|
6
|
+
export function createConfig(options = {}) {
|
|
7
|
+
const { preset = "react", overrides = [], environments = [], } = options;
|
|
8
|
+
let config;
|
|
9
|
+
switch (preset) {
|
|
10
|
+
case "minimal":
|
|
11
|
+
config = [...minimalConfig];
|
|
12
|
+
break;
|
|
13
|
+
case "base":
|
|
14
|
+
config = [...baseConfig];
|
|
15
|
+
break;
|
|
16
|
+
case "react":
|
|
17
|
+
config = [...reactConfig];
|
|
18
|
+
break;
|
|
19
|
+
case "node":
|
|
20
|
+
config = [...nodeConfig];
|
|
21
|
+
break;
|
|
22
|
+
case "strict":
|
|
23
|
+
config = [...strictConfig];
|
|
24
|
+
break;
|
|
25
|
+
default:
|
|
26
|
+
throw new Error(`Unknown preset: ${preset}. Available presets: minimal, base, react, node, strict`);
|
|
27
|
+
}
|
|
28
|
+
if (environments.includes("jest")) {
|
|
29
|
+
config.push({
|
|
30
|
+
files: ["**/*.test.{ts,tsx,js,jsx}", "**/*.spec.{ts,tsx,js,jsx}"],
|
|
31
|
+
languageOptions: {
|
|
32
|
+
globals: {
|
|
33
|
+
...require("globals").jest,
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
if (environments.includes("vitest")) {
|
|
39
|
+
config.push({
|
|
40
|
+
files: ["**/*.test.{ts,tsx,js,jsx}", "**/*.spec.{ts,tsx,js,jsx}"],
|
|
41
|
+
languageOptions: {
|
|
42
|
+
globals: {
|
|
43
|
+
...require("globals").vitest,
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
if (overrides.length > 0) {
|
|
49
|
+
config.push(...overrides);
|
|
50
|
+
}
|
|
51
|
+
return config;
|
|
52
|
+
}
|
|
53
|
+
export const minimal = minimalConfig;
|
|
54
|
+
export const base = baseConfig;
|
|
55
|
+
export const react = reactConfig;
|
|
56
|
+
export const node = nodeConfig;
|
|
57
|
+
export const strict = strictConfig;
|
|
58
|
+
const defaultConfig = reactConfig;
|
|
59
|
+
export default defaultConfig;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"minimal.d.ts","sourceRoot":"","sources":["../../presets/minimal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,QAAQ,CAAC;AAKnC,QAAA,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAiEjC,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import js from "@eslint/js";
|
|
2
|
+
import ts from "typescript-eslint";
|
|
3
|
+
import globals from "globals";
|
|
4
|
+
const minimalConfig = [
|
|
5
|
+
js.configs.recommended,
|
|
6
|
+
...ts.configs.recommended,
|
|
7
|
+
{
|
|
8
|
+
languageOptions: {
|
|
9
|
+
globals: {
|
|
10
|
+
...globals.node,
|
|
11
|
+
...globals.browser,
|
|
12
|
+
...globals.es2021,
|
|
13
|
+
},
|
|
14
|
+
parser: ts.parser,
|
|
15
|
+
parserOptions: {
|
|
16
|
+
ecmaVersion: "latest",
|
|
17
|
+
sourceType: "module",
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
files: ["**/*.ts", "**/*.tsx", "**/*.mts", "**/*.cts"],
|
|
21
|
+
rules: {
|
|
22
|
+
"no-console": "warn",
|
|
23
|
+
"no-debugger": "error",
|
|
24
|
+
"@typescript-eslint/explicit-function-return-type": "off",
|
|
25
|
+
"@typescript-eslint/no-unused-vars": [
|
|
26
|
+
"error",
|
|
27
|
+
{
|
|
28
|
+
argsIgnorePattern: "^_",
|
|
29
|
+
varsIgnorePattern: "^_",
|
|
30
|
+
caughtErrorsIgnorePattern: "^_",
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
"@typescript-eslint/no-explicit-any": "warn",
|
|
34
|
+
"prefer-const": "error",
|
|
35
|
+
"no-var": "error",
|
|
36
|
+
eqeqeq: ["error", "always"],
|
|
37
|
+
curly: ["error", "all"],
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
ignores: [
|
|
42
|
+
"dist/**",
|
|
43
|
+
"build/**",
|
|
44
|
+
"node_modules/**",
|
|
45
|
+
"*.min.js",
|
|
46
|
+
"*.bundle.js",
|
|
47
|
+
"coverage/**",
|
|
48
|
+
".next/**",
|
|
49
|
+
".nuxt/**",
|
|
50
|
+
".output/**",
|
|
51
|
+
".vercel/**",
|
|
52
|
+
".netlify/**",
|
|
53
|
+
"public/**",
|
|
54
|
+
"**/*.d.ts",
|
|
55
|
+
],
|
|
56
|
+
},
|
|
57
|
+
];
|
|
58
|
+
export default minimalConfig;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Linter } from "eslint";
|
|
2
|
+
export type Preset = "minimal" | "base" | "react" | "node" | "strict";
|
|
3
|
+
export type TestEnvironment = "jest" | "vitest";
|
|
4
|
+
export interface ConfigOptions {
|
|
5
|
+
preset?: Preset;
|
|
6
|
+
environments?: TestEnvironment[];
|
|
7
|
+
overrides?: Linter.Config[];
|
|
8
|
+
}
|
|
9
|
+
export type ESLintConfig = Linter.Config[];
|
|
10
|
+
export declare function createConfig(options?: ConfigOptions): ESLintConfig;
|
|
11
|
+
export declare const minimal: ESLintConfig;
|
|
12
|
+
export declare const base: ESLintConfig;
|
|
13
|
+
export declare const react: ESLintConfig;
|
|
14
|
+
export declare const node: ESLintConfig;
|
|
15
|
+
export declare const strict: ESLintConfig;
|
|
16
|
+
declare const _default: ESLintConfig;
|
|
17
|
+
export default _default;
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../types/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,QAAQ,CAAC;AAKnC,MAAM,MAAM,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAC;AAKtE,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,QAAQ,CAAC;AAKhD,MAAM,WAAW,aAAa;IAE5B,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,YAAY,CAAC,EAAE,eAAe,EAAE,CAAC;IAEjC,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC;CAC7B;AAKD,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC;AAK3C,wBAAgB,YAAY,CAAC,OAAO,CAAC,EAAE,aAAa,GAAG,YAAY,CAElE;AAKD,MAAM,CAAC,OAAO,CAAC,MAAM,OAAO,EAAE,YAAY,CAAC;AAC3C,MAAM,CAAC,OAAO,CAAC,MAAM,IAAI,EAAE,YAAY,CAAC;AACxC,MAAM,CAAC,OAAO,CAAC,MAAM,KAAK,EAAE,YAAY,CAAC;AACzC,MAAM,CAAC,OAAO,CAAC,MAAM,IAAI,EAAE,YAAY,CAAC;AACxC,MAAM,CAAC,OAAO,CAAC,MAAM,MAAM,EAAE,YAAY,CAAC;wBAMjB,YAAY;AAArC,wBAAsC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kiid_brian/eslint-config",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
4
4
|
"description": "ESLint config for @kiid_brian",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint",
|
|
@@ -17,22 +17,44 @@
|
|
|
17
17
|
"license": "MIT",
|
|
18
18
|
"author": "Brian Paintsil",
|
|
19
19
|
"type": "module",
|
|
20
|
+
"main": "dist/index.js",
|
|
21
|
+
"types": "dist/index.d.ts",
|
|
20
22
|
"exports": {
|
|
21
|
-
".":
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
"./
|
|
23
|
+
".": {
|
|
24
|
+
"types": "./dist/index.d.ts",
|
|
25
|
+
"import": "./dist/index.js"
|
|
26
|
+
},
|
|
27
|
+
"./minimal": {
|
|
28
|
+
"types": "./dist/presets/minimal.d.ts",
|
|
29
|
+
"import": "./dist/presets/minimal.js"
|
|
30
|
+
},
|
|
31
|
+
"./base": {
|
|
32
|
+
"types": "./dist/configs/base.d.ts",
|
|
33
|
+
"import": "./dist/configs/base.js"
|
|
34
|
+
},
|
|
35
|
+
"./react": {
|
|
36
|
+
"types": "./dist/configs/react.d.ts",
|
|
37
|
+
"import": "./dist/configs/react.js"
|
|
38
|
+
},
|
|
39
|
+
"./node": {
|
|
40
|
+
"types": "./dist/configs/node.d.ts",
|
|
41
|
+
"import": "./dist/configs/node.js"
|
|
42
|
+
},
|
|
43
|
+
"./strict": {
|
|
44
|
+
"types": "./dist/configs/strict.d.ts",
|
|
45
|
+
"import": "./dist/configs/strict.js"
|
|
46
|
+
}
|
|
26
47
|
},
|
|
27
|
-
"main": "index.js",
|
|
28
48
|
"files": [
|
|
29
|
-
"
|
|
30
|
-
"configs/"
|
|
49
|
+
"dist/"
|
|
31
50
|
],
|
|
32
51
|
"scripts": {
|
|
52
|
+
"build": "tsc",
|
|
53
|
+
"clean": "rm -rf dist",
|
|
54
|
+
"prepublishOnly": "npm run clean && npm run build",
|
|
33
55
|
"lint": "eslint . --ext .js,.ts",
|
|
34
56
|
"lint:fix": "eslint . --ext .js,.ts --fix",
|
|
35
|
-
"test": "node -e \"const fs = require('fs'); const path = require('path'); ['index.
|
|
57
|
+
"test": "node -e \"const fs = require('fs'); const path = require('path'); ['index.ts', 'configs/base.ts', 'configs/react.ts', 'configs/node.ts', 'configs/strict.ts', 'presets/minimal.ts', 'types/index.ts', 'tsconfig.json'].forEach(f => { if (fs.existsSync(f)) console.log('✅', f); else console.log('❌ Missing:', f); });\""
|
|
36
58
|
},
|
|
37
59
|
"dependencies": {
|
|
38
60
|
"acorn": "^8.15.0",
|
|
@@ -254,32 +276,47 @@
|
|
|
254
276
|
},
|
|
255
277
|
"devDependencies": {
|
|
256
278
|
"@eslint/js": "^9.39.2",
|
|
279
|
+
"@types/node": "^22.5.4",
|
|
257
280
|
"eslint": "^9.39.2",
|
|
281
|
+
"globals": "^17.0.0",
|
|
282
|
+
"typescript": "^5.6.2",
|
|
283
|
+
"typescript-eslint": "^8.51.0",
|
|
258
284
|
"eslint-config-prettier": "^10.1.8",
|
|
259
|
-
"eslint-plugin-import": "^2.32.0",
|
|
260
|
-
"eslint-plugin-jsx-a11y": "^6.10.0",
|
|
261
|
-
"eslint-plugin-jsdoc": "^50.2.2",
|
|
262
285
|
"eslint-plugin-prettier": "^5.5.4",
|
|
263
|
-
"
|
|
264
|
-
"eslint-plugin-security": "^3.0.1",
|
|
265
|
-
"globals": "^17.0.0",
|
|
266
|
-
"prettier": "^3.7.4",
|
|
267
|
-
"typescript-eslint": "^8.51.0"
|
|
286
|
+
"prettier": "^3.7.4"
|
|
268
287
|
},
|
|
269
288
|
"peerDependencies": {
|
|
270
289
|
"@eslint/js": "^9.22.0",
|
|
271
290
|
"eslint": "^9.22.0",
|
|
272
|
-
"eslint-config-prettier": "^10.1.8",
|
|
273
|
-
"eslint-plugin-import": "^2.32.0",
|
|
274
|
-
"eslint-plugin-jsx-a11y": "^6.10.0",
|
|
275
|
-
"eslint-plugin-jsdoc": "^50.2.2",
|
|
276
|
-
"eslint-plugin-prettier": "^5.5.4",
|
|
277
|
-
"eslint-plugin-react": "^7.37.5",
|
|
278
|
-
"eslint-plugin-security": "^3.0.1",
|
|
279
291
|
"globals": "^17.0.0",
|
|
280
|
-
"prettier": "^3.7.4",
|
|
281
292
|
"typescript-eslint": "^8.28.0"
|
|
282
293
|
},
|
|
294
|
+
"peerDependenciesMeta": {
|
|
295
|
+
"eslint-config-prettier": {
|
|
296
|
+
"optional": true
|
|
297
|
+
},
|
|
298
|
+
"eslint-plugin-import": {
|
|
299
|
+
"optional": true
|
|
300
|
+
},
|
|
301
|
+
"eslint-plugin-jsdoc": {
|
|
302
|
+
"optional": true
|
|
303
|
+
},
|
|
304
|
+
"eslint-plugin-jsx-a11y": {
|
|
305
|
+
"optional": true
|
|
306
|
+
},
|
|
307
|
+
"eslint-plugin-prettier": {
|
|
308
|
+
"optional": true
|
|
309
|
+
},
|
|
310
|
+
"eslint-plugin-react": {
|
|
311
|
+
"optional": true
|
|
312
|
+
},
|
|
313
|
+
"eslint-plugin-security": {
|
|
314
|
+
"optional": true
|
|
315
|
+
},
|
|
316
|
+
"prettier": {
|
|
317
|
+
"optional": true
|
|
318
|
+
}
|
|
319
|
+
},
|
|
283
320
|
"engines": {
|
|
284
321
|
"node": ">=18.0.0"
|
|
285
322
|
},
|
package/configs/base.js
DELETED
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
import js from "@eslint/js";
|
|
2
|
-
import ts from "typescript-eslint";
|
|
3
|
-
import globals from "globals";
|
|
4
|
-
import prettierRecommended from "eslint-plugin-prettier/recommended";
|
|
5
|
-
import importPlugin from "eslint-plugin-import";
|
|
6
|
-
import jsdoc from "eslint-plugin-jsdoc";
|
|
7
|
-
import security from "eslint-plugin-security";
|
|
8
|
-
|
|
9
|
-
export default [
|
|
10
|
-
// Base ESLint recommended rules
|
|
11
|
-
js.configs.recommended,
|
|
12
|
-
|
|
13
|
-
// TypeScript recommended rules
|
|
14
|
-
...ts.configs.recommended,
|
|
15
|
-
...ts.configs.recommendedTypeChecked,
|
|
16
|
-
|
|
17
|
-
// Import rules
|
|
18
|
-
importPlugin.flatConfigs.recommended,
|
|
19
|
-
importPlugin.flatConfigs.typescript,
|
|
20
|
-
|
|
21
|
-
// Security rules
|
|
22
|
-
security.configs.recommended,
|
|
23
|
-
|
|
24
|
-
// JSDoc rules
|
|
25
|
-
jsdoc.configs["flat/recommended"],
|
|
26
|
-
|
|
27
|
-
// Custom configuration
|
|
28
|
-
{
|
|
29
|
-
languageOptions: {
|
|
30
|
-
globals: {
|
|
31
|
-
...globals.node,
|
|
32
|
-
...globals.browser,
|
|
33
|
-
...globals.es2021,
|
|
34
|
-
},
|
|
35
|
-
parser: ts.parser,
|
|
36
|
-
parserOptions: {
|
|
37
|
-
ecmaVersion: "latest",
|
|
38
|
-
sourceType: "module",
|
|
39
|
-
project: true, // Enable type-aware rules
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
plugins: {
|
|
43
|
-
import: importPlugin,
|
|
44
|
-
jsdoc,
|
|
45
|
-
security,
|
|
46
|
-
},
|
|
47
|
-
rules: {
|
|
48
|
-
// Console and debugging
|
|
49
|
-
"no-console": "warn",
|
|
50
|
-
"no-debugger": "error",
|
|
51
|
-
|
|
52
|
-
// TypeScript specific rules
|
|
53
|
-
"@typescript-eslint/explicit-function-return-type": "off",
|
|
54
|
-
"@typescript-eslint/no-unused-vars": [
|
|
55
|
-
"error",
|
|
56
|
-
{
|
|
57
|
-
argsIgnorePattern: "^_",
|
|
58
|
-
varsIgnorePattern: "^_",
|
|
59
|
-
caughtErrorsIgnorePattern: "^_",
|
|
60
|
-
},
|
|
61
|
-
],
|
|
62
|
-
"@typescript-eslint/no-explicit-any": "warn",
|
|
63
|
-
"@typescript-eslint/prefer-const": "error",
|
|
64
|
-
"@typescript-eslint/no-var-requires": "error",
|
|
65
|
-
|
|
66
|
-
// Import rules
|
|
67
|
-
"import/no-unresolved": "error",
|
|
68
|
-
"import/named": "error",
|
|
69
|
-
"import/default": "error",
|
|
70
|
-
"import/namespace": "error",
|
|
71
|
-
"import/no-absolute-path": "error",
|
|
72
|
-
"import/no-dynamic-require": "warn",
|
|
73
|
-
"import/no-webpack-loader-syntax": "error",
|
|
74
|
-
"import/order": [
|
|
75
|
-
"error",
|
|
76
|
-
{
|
|
77
|
-
groups: [
|
|
78
|
-
"builtin",
|
|
79
|
-
"external",
|
|
80
|
-
"internal",
|
|
81
|
-
"parent",
|
|
82
|
-
"sibling",
|
|
83
|
-
"index",
|
|
84
|
-
],
|
|
85
|
-
"newlines-between": "always",
|
|
86
|
-
alphabetize: {order: "asc", caseInsensitive: true},
|
|
87
|
-
},
|
|
88
|
-
],
|
|
89
|
-
|
|
90
|
-
// Security rules
|
|
91
|
-
"security/detect-object-injection": "warn",
|
|
92
|
-
"security/detect-non-literal-regexp": "warn",
|
|
93
|
-
"security/detect-unsafe-regex": "error",
|
|
94
|
-
|
|
95
|
-
// JSDoc rules
|
|
96
|
-
"jsdoc/require-description": "warn",
|
|
97
|
-
"jsdoc/check-values": "warn",
|
|
98
|
-
"jsdoc/check-param-names": "error",
|
|
99
|
-
"jsdoc/check-tag-names": "error",
|
|
100
|
-
"jsdoc/require-param": "warn",
|
|
101
|
-
"jsdoc/require-returns": "warn",
|
|
102
|
-
|
|
103
|
-
// General code quality
|
|
104
|
-
"no-unused-vars": "off", // Use @typescript-eslint/no-unused-vars instead
|
|
105
|
-
"prefer-const": "error",
|
|
106
|
-
"no-var": "error",
|
|
107
|
-
"object-shorthand": "error",
|
|
108
|
-
"prefer-arrow-callback": "error",
|
|
109
|
-
"prefer-template": "error",
|
|
110
|
-
eqeqeq: ["error", "always"],
|
|
111
|
-
curly: ["error", "all"],
|
|
112
|
-
"no-duplicate-imports": "error",
|
|
113
|
-
},
|
|
114
|
-
settings: {
|
|
115
|
-
"import/resolver": {
|
|
116
|
-
typescript: true,
|
|
117
|
-
node: true,
|
|
118
|
-
},
|
|
119
|
-
},
|
|
120
|
-
},
|
|
121
|
-
|
|
122
|
-
// Environment-specific configurations
|
|
123
|
-
{
|
|
124
|
-
files: ["**/*.test.{ts,tsx,js,jsx}", "**/*.spec.{ts,tsx,js,jsx}"],
|
|
125
|
-
languageOptions: {
|
|
126
|
-
globals: {
|
|
127
|
-
...globals.jest,
|
|
128
|
-
},
|
|
129
|
-
},
|
|
130
|
-
rules: {
|
|
131
|
-
"@typescript-eslint/no-explicit-any": "off", // Allow any in tests
|
|
132
|
-
"jsdoc/require-description": "off", // Less strict JSDoc in tests
|
|
133
|
-
"jsdoc/require-param": "off",
|
|
134
|
-
"jsdoc/require-returns": "off",
|
|
135
|
-
},
|
|
136
|
-
},
|
|
137
|
-
|
|
138
|
-
{
|
|
139
|
-
files: [
|
|
140
|
-
"**/*.config.{ts,js}",
|
|
141
|
-
"**/vite.config.{ts,js}",
|
|
142
|
-
"**/vitest.config.{ts,js}",
|
|
143
|
-
],
|
|
144
|
-
rules: {
|
|
145
|
-
"no-console": "off", // Allow console in config files
|
|
146
|
-
"@typescript-eslint/no-var-requires": "off", // Allow require in configs
|
|
147
|
-
},
|
|
148
|
-
},
|
|
149
|
-
|
|
150
|
-
// Ignore patterns
|
|
151
|
-
{
|
|
152
|
-
ignores: [
|
|
153
|
-
"dist/**",
|
|
154
|
-
"build/**",
|
|
155
|
-
"node_modules/**",
|
|
156
|
-
"*.min.js",
|
|
157
|
-
"*.bundle.js",
|
|
158
|
-
"coverage/**",
|
|
159
|
-
".next/**",
|
|
160
|
-
".nuxt/**",
|
|
161
|
-
".output/**",
|
|
162
|
-
".vercel/**",
|
|
163
|
-
".netlify/**",
|
|
164
|
-
"public/**",
|
|
165
|
-
"**/*.d.ts",
|
|
166
|
-
],
|
|
167
|
-
},
|
|
168
|
-
|
|
169
|
-
// Prettier must be last to override conflicting rules
|
|
170
|
-
prettierRecommended,
|
|
171
|
-
];
|
package/configs/node.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import globals from "globals";
|
|
2
|
-
import baseConfig from "./base.js";
|
|
3
|
-
|
|
4
|
-
export default [
|
|
5
|
-
...baseConfig,
|
|
6
|
-
|
|
7
|
-
// Node.js-specific configuration
|
|
8
|
-
{
|
|
9
|
-
languageOptions: {
|
|
10
|
-
globals: {
|
|
11
|
-
...globals.node,
|
|
12
|
-
...globals.es2021,
|
|
13
|
-
},
|
|
14
|
-
},
|
|
15
|
-
rules: {
|
|
16
|
-
"no-console": "off",
|
|
17
|
-
|
|
18
|
-
// Node.js specific rules can be added here
|
|
19
|
-
// For example, you might want to enforce certain patterns
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
];
|
package/configs/react.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import jsxA11y from "eslint-plugin-jsx-a11y";
|
|
2
|
-
import react from "eslint-plugin-react";
|
|
3
|
-
import baseConfig from "./base.js";
|
|
4
|
-
|
|
5
|
-
export default [
|
|
6
|
-
...baseConfig,
|
|
7
|
-
|
|
8
|
-
// React recommended rules
|
|
9
|
-
react.configs.flat.recommended,
|
|
10
|
-
react.configs.flat["jsx-runtime"],
|
|
11
|
-
|
|
12
|
-
// Accessibility rules
|
|
13
|
-
jsxA11y.flatConfigs.recommended,
|
|
14
|
-
|
|
15
|
-
// React-specific configuration
|
|
16
|
-
{
|
|
17
|
-
plugins: {
|
|
18
|
-
"jsx-a11y": jsxA11y,
|
|
19
|
-
react,
|
|
20
|
-
},
|
|
21
|
-
rules: {
|
|
22
|
-
// React specific rules
|
|
23
|
-
"react/prop-types": "off", // TypeScript handles prop validation
|
|
24
|
-
"react/react-in-jsx-scope": "off", // Not needed in React 17+
|
|
25
|
-
"react/jsx-uses-react": "off", // Not needed in React 17+
|
|
26
|
-
"react/jsx-uses-vars": "error",
|
|
27
|
-
"react/jsx-key": ["error", {checkFragmentShorthand: true}],
|
|
28
|
-
"react/jsx-no-useless-fragment": "error",
|
|
29
|
-
"react/self-closing-comp": "error",
|
|
30
|
-
},
|
|
31
|
-
settings: {
|
|
32
|
-
react: {
|
|
33
|
-
version: "detect",
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
];
|
package/configs/strict.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import baseConfig from "./base.js";
|
|
2
|
-
|
|
3
|
-
export default [
|
|
4
|
-
...baseConfig,
|
|
5
|
-
|
|
6
|
-
// Strict configuration overrides
|
|
7
|
-
{
|
|
8
|
-
rules: {
|
|
9
|
-
// Stricter TypeScript rules
|
|
10
|
-
"@typescript-eslint/no-explicit-any": "error", // Upgrade to error
|
|
11
|
-
"@typescript-eslint/explicit-function-return-type": "warn", // Enable return type requirements
|
|
12
|
-
|
|
13
|
-
// Stricter JSDoc requirements
|
|
14
|
-
"jsdoc/require-description": "error", // Upgrade to error
|
|
15
|
-
"jsdoc/require-param": "error", // Upgrade to error
|
|
16
|
-
"jsdoc/require-returns": "error", // Upgrade to error
|
|
17
|
-
|
|
18
|
-
// Stricter general rules
|
|
19
|
-
"no-console": "error", // Upgrade to error
|
|
20
|
-
"security/detect-object-injection": "error", // Upgrade to error
|
|
21
|
-
|
|
22
|
-
// Additional strict rules
|
|
23
|
-
complexity: ["error", 10], // Limit cyclomatic complexity
|
|
24
|
-
"max-depth": ["error", 4], // Limit nesting depth
|
|
25
|
-
"max-lines-per-function": ["error", 50], // Limit function length
|
|
26
|
-
"max-params": ["error", 4], // Limit parameter count
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
];
|
package/index.js
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import baseConfig from "./configs/base.js";
|
|
2
|
-
import reactConfig from "./configs/react.js";
|
|
3
|
-
import nodeConfig from "./configs/node.js";
|
|
4
|
-
import strictConfig from "./configs/strict.js";
|
|
5
|
-
|
|
6
|
-
// Default export (backwards compatibility with original eslint.config.js)
|
|
7
|
-
export default reactConfig;
|
|
8
|
-
|
|
9
|
-
// Named exports for different presets
|
|
10
|
-
export const base = baseConfig;
|
|
11
|
-
export const react = reactConfig;
|
|
12
|
-
export const node = nodeConfig;
|
|
13
|
-
export const strict = strictConfig;
|
|
14
|
-
|
|
15
|
-
// Function to create custom config with overrides
|
|
16
|
-
export function createConfig(options = {}) {
|
|
17
|
-
const {
|
|
18
|
-
preset = "react", // default preset
|
|
19
|
-
overrides = [],
|
|
20
|
-
environments = [],
|
|
21
|
-
typescript = true,
|
|
22
|
-
react: enableReact = true,
|
|
23
|
-
accessibility = true,
|
|
24
|
-
security = true,
|
|
25
|
-
jsdoc = true,
|
|
26
|
-
prettier = true,
|
|
27
|
-
} = options;
|
|
28
|
-
|
|
29
|
-
// Start with the chosen preset
|
|
30
|
-
let config;
|
|
31
|
-
switch (preset) {
|
|
32
|
-
case "base":
|
|
33
|
-
config = [...baseConfig];
|
|
34
|
-
break;
|
|
35
|
-
case "react":
|
|
36
|
-
config = [...reactConfig];
|
|
37
|
-
break;
|
|
38
|
-
case "node":
|
|
39
|
-
config = [...nodeConfig];
|
|
40
|
-
break;
|
|
41
|
-
case "strict":
|
|
42
|
-
config = [...strictConfig];
|
|
43
|
-
break;
|
|
44
|
-
default:
|
|
45
|
-
throw new Error(
|
|
46
|
-
`Unknown preset: ${preset}. Available presets: base, react, node, strict`
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// Add environment-specific configurations
|
|
51
|
-
if (environments.includes("jest")) {
|
|
52
|
-
config.push({
|
|
53
|
-
files: ["**/*.test.{ts,tsx,js,jsx}", "**/*.spec.{ts,tsx,js,jsx}"],
|
|
54
|
-
languageOptions: {
|
|
55
|
-
globals: {
|
|
56
|
-
...require("globals").jest,
|
|
57
|
-
},
|
|
58
|
-
},
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
if (environments.includes("vitest")) {
|
|
63
|
-
config.push({
|
|
64
|
-
files: ["**/*.test.{ts,tsx,js,jsx}", "**/*.spec.{ts,tsx,js,jsx}"],
|
|
65
|
-
languageOptions: {
|
|
66
|
-
globals: {
|
|
67
|
-
...require("globals").vitest,
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// Apply custom overrides
|
|
74
|
-
if (overrides.length > 0) {
|
|
75
|
-
config.push(...overrides);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
return config;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// Re-export individual configs for advanced usage
|
|
82
|
-
export {baseConfig, reactConfig, nodeConfig, strictConfig};
|