@fabdeh/eslint-config 0.0.4 → 0.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 +202 -7
- package/dist/index.cjs +1842 -767
- package/dist/index.d.cts +748 -34
- package/dist/index.d.mts +774 -0
- package/dist/index.d.ts +748 -34
- package/dist/index.mjs +1935 -0
- package/package.json +53 -64
- package/dist/index.js +0 -880
package/README.md
CHANGED
|
@@ -1,13 +1,208 @@
|
|
|
1
1
|
# @fabdeh/eslint-config
|
|
2
2
|
|
|
3
3
|
[](https://github.com/FabienDehopre/eslint-config/actions/workflows/ci.yml)
|
|
4
|
-
[](https://www.npmjs.com/package/@fabdeh/eslint-config)
|
|
5
5
|
[](https://app.netlify.com/sites/fabdeh-eslint-config/deploys)
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
- Auto fix for formatting (aimed to be used standalone **without** Prettier)
|
|
8
|
+
- Reasonable defaults, best practices, only one line of config
|
|
9
|
+
- Designed to work with TypeScript, JSX, etc. Out-of-box.
|
|
10
|
+
- Opinionated, but [very customizable](#customization)
|
|
11
|
+
- [ESLint Flat config](https://eslint.org/docs/latest/use/configure/configuration-files-new), compose easily!
|
|
12
|
+
- Automatic [Angular](#angular), [NGRX](#ngrx), [TailwindCSS](#tailwindcc), [Jest](#jest), [Vitest](#vitest) support when the corresponding dependency is detected.
|
|
13
|
+
<!--- - Optional [formatters](#formatters) support for formatting CSS, HTML, XML, etc. --->
|
|
14
|
+
- **Style principle**: Minimal for reading, stable for diff, consistent
|
|
15
|
+
- Sorted imports, dangling commas
|
|
16
|
+
- Single quotes, no semi
|
|
17
|
+
- Using [ESLint Stylistic](https://github.com/eslint-stylistic/eslint-stylistic)
|
|
18
|
+
- Respects `.gitignore` by default
|
|
19
|
+
- Requires ESLint v9.5.0+
|
|
8
20
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
21
|
+
> [!WARNING]
|
|
22
|
+
> Please keep in mind that this is **_a personal config_** with a lot opinions. Changes might not always be pleased by everyone and every use cases.
|
|
23
|
+
>
|
|
24
|
+
> If you are using this config directly, I'd suggest you **review the changes everytime you update**. Or if you want more control over the rules, always feel free to fork it. Thanks!
|
|
25
|
+
|
|
26
|
+
## Usage
|
|
27
|
+
|
|
28
|
+
### Install
|
|
29
|
+
|
|
30
|
+
Run the command in your terminal:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
pnpm add -D eslint @fabdeh/eslint-config
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
And create an `eslint.config.mjs` in you project root:
|
|
37
|
+
|
|
38
|
+
```js
|
|
39
|
+
// eslint.config.mjs
|
|
40
|
+
import { createConfig } from '@fabdeh/eslint-config';
|
|
41
|
+
|
|
42
|
+
export default createConfig();
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Add script for package.json
|
|
46
|
+
|
|
47
|
+
For example:
|
|
48
|
+
|
|
49
|
+
```json
|
|
50
|
+
{
|
|
51
|
+
"scripts": {
|
|
52
|
+
"lint": "eslint .",
|
|
53
|
+
"lint:fix": "eslint . --fix"
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## IDE Support (auto fix on save)
|
|
59
|
+
|
|
60
|
+
<details>
|
|
61
|
+
<summary>🟦 VS Code support</summary>
|
|
62
|
+
|
|
63
|
+
<br>
|
|
64
|
+
|
|
65
|
+
Install [VS Code ESLint extension](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)
|
|
66
|
+
|
|
67
|
+
Add the following settings to your `.vscode/settings.json`:
|
|
68
|
+
|
|
69
|
+
```jsonc
|
|
70
|
+
{
|
|
71
|
+
// Disable the default formatter, use eslint instead
|
|
72
|
+
"prettier.enable": false,
|
|
73
|
+
"editor.formatOnSave": false,
|
|
74
|
+
|
|
75
|
+
// Auto fix
|
|
76
|
+
"editor.codeActionsOnSave": {
|
|
77
|
+
"source.fixAll.eslint": "explicit",
|
|
78
|
+
"source.organizeImports": "never"
|
|
79
|
+
},
|
|
80
|
+
|
|
81
|
+
// Silent the stylistic rules in you IDE, but still auto fix them
|
|
82
|
+
"eslint.rules.customizations": [{ "rule": "@stylistic/*", "severity": "off", "fixable": true }],
|
|
83
|
+
|
|
84
|
+
// Enable eslint for all supported languages
|
|
85
|
+
"eslint.validate": ["javascript", "javascriptreact", "typescript", "typescriptreact", "html"]
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
</details>
|
|
90
|
+
|
|
91
|
+
## Customization
|
|
92
|
+
|
|
93
|
+
Since the beginning, we used [ESLint Flat config](https://eslint.org/docs/latest/use/configure/configuration-files-new). It provides much better organization and composition.
|
|
94
|
+
|
|
95
|
+
Normally you only need to import the `createConfig` function:
|
|
96
|
+
|
|
97
|
+
```js
|
|
98
|
+
// eslint.config.js
|
|
99
|
+
import { createConfig } from '@fabdeh/eslint-config';
|
|
100
|
+
|
|
101
|
+
export default createConfig();
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
And that's it! Or you can configure each integration individually, for example:
|
|
105
|
+
|
|
106
|
+
```js
|
|
107
|
+
// eslint.config.js
|
|
108
|
+
import { createConfig } from '@fabdeh/eslint-config';
|
|
109
|
+
|
|
110
|
+
export default createConfig({
|
|
111
|
+
// Enable stylistic formatting rules
|
|
112
|
+
// stylistic: true,
|
|
113
|
+
|
|
114
|
+
// Or customize the stylistic rules
|
|
115
|
+
stylistic: {
|
|
116
|
+
indent: 2, // 4, or 'tab'
|
|
117
|
+
quotes: 'single', // or 'double'
|
|
118
|
+
},
|
|
119
|
+
|
|
120
|
+
// Angular and NgRx are autodetected, you can also explicitly enable them:
|
|
121
|
+
angular: true,
|
|
122
|
+
ngrx: true,
|
|
123
|
+
|
|
124
|
+
// Disable jest and vitest
|
|
125
|
+
jest: false,
|
|
126
|
+
vitest: false,
|
|
127
|
+
|
|
128
|
+
// `.eslintignore` is no longer supported in Flat config, use `ignores` instead
|
|
129
|
+
ignores: [
|
|
130
|
+
'**/fixtures',
|
|
131
|
+
// ...globs
|
|
132
|
+
],
|
|
133
|
+
});
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
The `createConfig` factory function also accepts any number of arbitrary custom config overrides:
|
|
137
|
+
|
|
138
|
+
```js
|
|
139
|
+
// eslint.config.js
|
|
140
|
+
import { createConfig } from '@fabdeh/eslint-config';
|
|
141
|
+
|
|
142
|
+
export default createConfig(
|
|
143
|
+
{
|
|
144
|
+
// Configure the fabdeh's config
|
|
145
|
+
},
|
|
146
|
+
|
|
147
|
+
// From the second arguments they are ESLint Flat Configs
|
|
148
|
+
// you can have multiple configs
|
|
149
|
+
{
|
|
150
|
+
files: ['**/*.ts'],
|
|
151
|
+
rules: {},
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
rules: {},
|
|
155
|
+
}
|
|
156
|
+
);
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
Going more advanced, you can also import fine-grained configs and compose them as you wish:
|
|
160
|
+
|
|
161
|
+
<details>
|
|
162
|
+
<summary>Advanced Example</summary>
|
|
163
|
+
|
|
164
|
+
We wouldn't recommend using this style in general unless you know exactly what they are doing, as there are shared options between configs and might need extra care to make them consistent.
|
|
165
|
+
|
|
166
|
+
```js
|
|
167
|
+
// eslint.config.js
|
|
168
|
+
import {
|
|
169
|
+
angular,
|
|
170
|
+
comments,
|
|
171
|
+
ignores,
|
|
172
|
+
imports,
|
|
173
|
+
javascript,
|
|
174
|
+
jsdoc,
|
|
175
|
+
ngrx,
|
|
176
|
+
stylistic,
|
|
177
|
+
tailwindcss,
|
|
178
|
+
typescript,
|
|
179
|
+
unicorn,
|
|
180
|
+
vitest,
|
|
181
|
+
} from '@fabdeh/eslint-config';
|
|
182
|
+
import tseslint from 'typescript-eslint';
|
|
183
|
+
|
|
184
|
+
export default tseslint.config(
|
|
185
|
+
ignores(),
|
|
186
|
+
javascript(/* Options */),
|
|
187
|
+
comments(),
|
|
188
|
+
jsdoc(),
|
|
189
|
+
imports(),
|
|
190
|
+
unicorn(),
|
|
191
|
+
typescript(/* Options */),
|
|
192
|
+
stylistic(),
|
|
193
|
+
angular(),
|
|
194
|
+
ngrx(),
|
|
195
|
+
vitest(),
|
|
196
|
+
tailwindcss()
|
|
197
|
+
);
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
</details>
|
|
201
|
+
|
|
202
|
+
Check out the [configs](https://github.com/FabienDehopre/eslint-config/blob/main/src/configs) and [factory](https://github.com/FabienDehopre/eslint-config/blob/main/src/factory.ts) for more details.
|
|
203
|
+
|
|
204
|
+
> Thanks to [antfu/eslint-config](https://github.com/antfu/eslint-config) for the inspiration and reference.
|
|
205
|
+
|
|
206
|
+
## License
|
|
207
|
+
|
|
208
|
+
[MIT](./LICENSE) License © 2025-PRESENT [Fabien Dehopré](https://github.com/FabienDehopre)
|