@santi020k/eslint-config-santi020k 1.2.1 → 2.0.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 +86 -111
- package/dist/configs/astro/index.config.d.ts +9 -0
- package/dist/configs/astro/rules.d.ts +6 -0
- package/dist/configs/expo/index.config.d.ts +9 -0
- package/dist/configs/expo/rules.d.ts +6 -0
- package/dist/configs/index.d.ts +6 -0
- package/dist/configs/js/index.config.d.ts +3 -0
- package/dist/configs/js/rules.d.ts +4 -0
- package/dist/configs/next/index.config.d.ts +9 -0
- package/dist/configs/next/rules.d.ts +6 -0
- package/dist/configs/react/index.config.d.ts +11 -0
- package/dist/configs/react/rules.d.ts +3 -0
- package/dist/configs/ts/index.config.d.ts +3 -0
- package/dist/configs/ts/rules.d.ts +25 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +453 -0
- package/dist/index.mjs +453 -0
- package/dist/optionals/cspell.d.ts +15 -0
- package/dist/optionals/i18next.d.ts +2 -0
- package/dist/optionals/index.d.ts +5 -0
- package/dist/optionals/mdx.d.ts +21 -0
- package/dist/optionals/tailwind.d.ts +2 -0
- package/dist/optionals/vitest.d.ts +16 -0
- package/dist/package.json +104 -0
- package/dist/utils/flatCompat.d.ts +6 -0
- package/package.json +40 -30
- package/dist/cjs/index.cjs +0 -441
- package/dist/esm/index.mjs +0 -432
package/README.md
CHANGED
|
@@ -1,24 +1,13 @@
|
|
|
1
1
|
# @santi020k/eslint-config-santi020k
|
|
2
2
|
|
|
3
|
-
Welcome to @santi020k/eslint-config-santi020k, a comprehensive and opinionated ESLint configuration package for JavaScript, TypeScript, and
|
|
3
|
+
Welcome to @santi020k/eslint-config-santi020k, a comprehensive and opinionated ESLint configuration package for JavaScript, TypeScript, React, and various other frameworks. This repository was born out of my frustration with projects that suffer from bad practices and poor code quality. By automating code quality and reducing cognitive load during code reviews, this package aims to enforce a consistent coding style across your projects.
|
|
4
4
|
|
|
5
5
|
## Why Use This Configuration?
|
|
6
6
|
|
|
7
|
-
- Consistency
|
|
8
|
-
- Quality
|
|
9
|
-
- Automation
|
|
10
|
-
- Customization
|
|
11
|
-
|
|
12
|
-
## Links to Configurations
|
|
13
|
-
|
|
14
|
-
- [jsEslint](./src/js/README.md): For JavaScript projects.
|
|
15
|
-
- [tsEslint](./src/ts/README.md): For TypeScript projects.
|
|
16
|
-
- [reactEslint](./src/react/README.md): For JavaScript and React projects.
|
|
17
|
-
- [reactTsEslint](./src/react-ts/README.md): For TypeScript and React projects.
|
|
18
|
-
- [nextEslint](./src/next/README.md): For JavaScript and Next projects.
|
|
19
|
-
- [nextTsEslint](./src/next-ts/README.md): For TypeScript and Next projects.
|
|
20
|
-
- [astroEslint](./src/astro/README.md): For JavaScript and Astro projects. (Beta)
|
|
21
|
-
- [astroTsEslint](./src/astro-ts/README.md): For TypeScript and Astro projects. (Beta)
|
|
7
|
+
- **Consistency**: Enforces a uniform coding style, minimizing code differences and easing collaboration.
|
|
8
|
+
- **Quality**: Promotes best practices and helps avoid common pitfalls in JavaScript, TypeScript, and React development.
|
|
9
|
+
- **Automation**: Reduces the need for manual code reviews by catching issues early in the development process.
|
|
10
|
+
- **Customization**: While opinionated, it can be tailored to fit your project's specific needs.
|
|
22
11
|
|
|
23
12
|
## Installation
|
|
24
13
|
|
|
@@ -36,128 +25,108 @@ Then, install the configuration package:
|
|
|
36
25
|
|
|
37
26
|
## Usage
|
|
38
27
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
Create an `eslint.config.js` file (or use your existing one) and extend `@santi020k/eslint-config-santi020k`:
|
|
42
|
-
|
|
43
|
-
```js
|
|
44
|
-
import { jsEslint } from '@santi020k/eslint-config-santi020k'
|
|
45
|
-
|
|
46
|
-
export default [
|
|
47
|
-
...jsEslint,
|
|
48
|
-
{
|
|
49
|
-
// Other rules or overrides
|
|
50
|
-
}
|
|
51
|
-
]
|
|
52
|
-
```
|
|
28
|
+
Create an eslint.config.js file (or use your existing one) and extend @santi020k/eslint-config-santi020k based on your project type:
|
|
53
29
|
|
|
54
|
-
###
|
|
30
|
+
### Basic Usage
|
|
55
31
|
|
|
56
|
-
|
|
32
|
+
For a basic JavaScript project:
|
|
57
33
|
|
|
58
34
|
```js
|
|
59
|
-
import {
|
|
35
|
+
import { eslintConfig } from './dist/index.mjs'
|
|
60
36
|
|
|
61
37
|
export default [
|
|
62
|
-
...
|
|
63
|
-
|
|
64
|
-
// Other rules or overrides
|
|
65
|
-
}
|
|
38
|
+
...eslintConfig(),
|
|
39
|
+
// Your custom config
|
|
66
40
|
]
|
|
67
41
|
```
|
|
68
42
|
|
|
69
|
-
###
|
|
43
|
+
### Advanced Usage
|
|
70
44
|
|
|
71
|
-
|
|
45
|
+
For projects with specific configurations (TypeScript, React, Next.js, etc.), use the appropriate options:
|
|
72
46
|
|
|
73
47
|
```js
|
|
74
|
-
import {
|
|
48
|
+
import { ConfigOptions, eslintConfig } from '@santi020k/eslint-config-santi020k';
|
|
75
49
|
|
|
76
|
-
|
|
77
|
-
...reactEslint,
|
|
78
|
-
{
|
|
79
|
-
// Other rules or overrides
|
|
80
|
-
}
|
|
81
|
-
]
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
### For TypeScript and React Projects
|
|
85
|
-
|
|
86
|
-
Create an `eslint.config.js` file (or use your existing one) and extend `@santi020k/eslint-config-santi020k` with TypeScript support:
|
|
87
|
-
|
|
88
|
-
```js
|
|
89
|
-
import { reactTsEslint } from '@santi020k/eslint-config-santi020k'
|
|
50
|
+
// Examples of different configurations
|
|
90
51
|
|
|
52
|
+
// TypeScript project
|
|
91
53
|
export default [
|
|
92
|
-
...
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
96
|
-
]
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
### For JavaScript and Next Projects
|
|
100
|
-
|
|
101
|
-
Create an `eslint.config.js` file (or use your existing one) and extend `@santi020k/eslint-config-santi020k`:
|
|
102
|
-
|
|
103
|
-
```js
|
|
104
|
-
import { nextEslint } from '@santi020k/eslint-config-santi020k'
|
|
54
|
+
...eslintConfig({ config: [ConfigOptions.Ts] }),
|
|
55
|
+
// Your custom config
|
|
56
|
+
];
|
|
105
57
|
|
|
58
|
+
// React project
|
|
106
59
|
export default [
|
|
107
|
-
...
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}
|
|
111
|
-
]
|
|
112
|
-
```
|
|
60
|
+
...eslintConfig({ config: [ConfigOptions.React] }),
|
|
61
|
+
// Your custom config
|
|
62
|
+
];
|
|
113
63
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
import { nextTsEslint } from '@santi020k/eslint-config-santi020k'
|
|
64
|
+
// TypeScript and React project
|
|
65
|
+
export default [
|
|
66
|
+
...eslintConfig({ config: [ConfigOptions.React, ConfigOptions.Ts] }),
|
|
67
|
+
// Your custom config
|
|
68
|
+
];
|
|
120
69
|
|
|
70
|
+
// Next.js project
|
|
121
71
|
export default [
|
|
122
|
-
...
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
126
|
-
]
|
|
127
|
-
```
|
|
72
|
+
...eslintConfig({ config: [ConfigOptions.Next] }),
|
|
73
|
+
// Your custom config
|
|
74
|
+
];
|
|
128
75
|
|
|
129
|
-
|
|
76
|
+
// TypeScript and Next.js project
|
|
77
|
+
export default [
|
|
78
|
+
...eslintConfig({ config: [ConfigOptions.Next, ConfigOptions.Ts] }),
|
|
79
|
+
// Your custom config
|
|
80
|
+
];
|
|
130
81
|
|
|
131
|
-
|
|
82
|
+
// Expo project (Beta)
|
|
83
|
+
export default [
|
|
84
|
+
...eslintConfig({ config: [ConfigOptions.Expo] }),
|
|
85
|
+
// Your custom config
|
|
86
|
+
];
|
|
132
87
|
|
|
133
|
-
|
|
88
|
+
// TypeScript and Expo project (Beta)
|
|
89
|
+
export default [
|
|
90
|
+
...eslintConfig({ config: [ConfigOptions.Expo, ConfigOptions.Ts] }),
|
|
91
|
+
// Your custom config
|
|
92
|
+
];
|
|
134
93
|
|
|
135
|
-
|
|
136
|
-
|
|
94
|
+
// Astro project (beta, supports Astro with React)
|
|
95
|
+
export default [
|
|
96
|
+
...eslintConfig({ config: [ConfigOptions.Astro] }),
|
|
97
|
+
// Your custom config
|
|
98
|
+
];
|
|
137
99
|
|
|
100
|
+
// TypeScript and Astro project (beta, supports Astro with React)
|
|
138
101
|
export default [
|
|
139
|
-
...
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
}
|
|
143
|
-
]
|
|
102
|
+
...eslintConfig({ config: [ConfigOptions.Astro, ConfigOptions.Ts] }),
|
|
103
|
+
// Your custom config
|
|
104
|
+
];
|
|
144
105
|
```
|
|
145
106
|
|
|
146
|
-
###
|
|
107
|
+
### Optionals Usage
|
|
147
108
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
Create an `eslint.config.js` file (or use your existing one) and extend `@santi020k/eslint-config-santi020k` with TypeScript support:
|
|
109
|
+
Additionally, there are some optional parameters that add support to other technologies that could be needed in a front-end project. The idea is to add support for more options in the future. Here is an example of how to use these optionals:
|
|
151
110
|
|
|
152
111
|
```js
|
|
153
|
-
import {
|
|
112
|
+
import { ConfigOptions, eslintConfig, OptionalOptions } from '@santi020k/eslint-config-santi020k';
|
|
154
113
|
|
|
155
114
|
export default [
|
|
156
|
-
...
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
115
|
+
...eslintConfig({
|
|
116
|
+
config: [ConfigOptions.Next, ConfigOptions.Ts],
|
|
117
|
+
optionals: [
|
|
118
|
+
// Spell checker
|
|
119
|
+
OptionalOptions.Cspell,
|
|
120
|
+
// TailwindCss
|
|
121
|
+
OptionalOptions.Tailwind,
|
|
122
|
+
// Vitest and testing-library
|
|
123
|
+
OptionalOptions.Vitest,
|
|
124
|
+
// I18next
|
|
125
|
+
OptionalOptions.I18next
|
|
126
|
+
]
|
|
127
|
+
}),
|
|
128
|
+
// Your custom config
|
|
129
|
+
];
|
|
161
130
|
```
|
|
162
131
|
|
|
163
132
|
## Opinionated but Flexible
|
|
@@ -190,12 +159,15 @@ Here are some useful scripts you can add to your `package.json`:
|
|
|
190
159
|
|
|
191
160
|
4. Adjust as Necessary: Review the linting rules and adjust them based on your project's needs. Since this configuration is opinionated, some rules might be too strict or not applicable to your project. Feel free to disable or modify them.
|
|
192
161
|
|
|
193
|
-
## Future
|
|
162
|
+
## Future Features
|
|
194
163
|
|
|
195
|
-
[ ] Unit testing
|
|
196
|
-
[ ] Better documentation
|
|
197
|
-
[ ] Additional Frameworks support
|
|
198
|
-
[ ]
|
|
164
|
+
- [ ] Unit testing
|
|
165
|
+
- [ ] Better documentation
|
|
166
|
+
- [ ] Additional Frameworks support
|
|
167
|
+
- [ ] Vue
|
|
168
|
+
- [ ] Angular
|
|
169
|
+
- [ ] Astro (Process)
|
|
170
|
+
- [X] Refactor rules structure (eslint configurations are currently duplicated)
|
|
199
171
|
|
|
200
172
|
## Contributing
|
|
201
173
|
|
|
@@ -217,7 +189,10 @@ I would like to express my gratitude to the developers and maintainers of the fo
|
|
|
217
189
|
- `eslint-plugin-unused-imports`
|
|
218
190
|
- `@stylistic/eslint-plugin`
|
|
219
191
|
- `@typescript-eslint`
|
|
220
|
-
-
|
|
192
|
+
- `@cspell/eslint-plugin`
|
|
193
|
+
- `eslint-plugin-tailwindcss`
|
|
194
|
+
- `eslint-plugin-vitest`
|
|
195
|
+
- `etc...`
|
|
221
196
|
|
|
222
197
|
These tools have significantly contributed to the JavaScript and TypeScript ecosystem, and their continued development helps maintain the high standards of code quality that we all strive for.
|
|
223
198
|
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { astroConfig } from './astro/index.config';
|
|
2
|
+
export { jsConfig } from './js/index.config';
|
|
3
|
+
export { nextConfig } from './next/index.config';
|
|
4
|
+
export { reactConfig } from './react/index.config';
|
|
5
|
+
export { tsConfig } from './ts/index.config';
|
|
6
|
+
export { expoConfig } from './expo/index.config';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { FlatConfig } from '@typescript-eslint/utils/ts-eslint';
|
|
2
|
+
declare const reactConfig: (FlatConfig.Config | {
|
|
3
|
+
name: string;
|
|
4
|
+
plugins: {
|
|
5
|
+
'react-hooks': any;
|
|
6
|
+
};
|
|
7
|
+
languageOptions: any;
|
|
8
|
+
files: string[];
|
|
9
|
+
rules: any;
|
|
10
|
+
})[];
|
|
11
|
+
export { reactConfig };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
declare const rules: {
|
|
2
|
+
semi: string;
|
|
3
|
+
'no-unused-vars': string;
|
|
4
|
+
'@typescript-eslint/indent': string;
|
|
5
|
+
'@typescript-eslint/no-unused-vars': (string | {
|
|
6
|
+
vars: string;
|
|
7
|
+
varsIgnorePattern: string;
|
|
8
|
+
args: string;
|
|
9
|
+
argsIgnorePattern: string;
|
|
10
|
+
destructuredArrayIgnorePattern: string;
|
|
11
|
+
ignoreRestSiblings: boolean;
|
|
12
|
+
})[];
|
|
13
|
+
'@typescript-eslint/no-explicit-any': string;
|
|
14
|
+
'@typescript-eslint/no-empty-function': string;
|
|
15
|
+
'@typescript-eslint/ban-types': string;
|
|
16
|
+
'@typescript-eslint/no-var-requires': string;
|
|
17
|
+
'@typescript-eslint/ban-ts-comment': string;
|
|
18
|
+
'@typescript-eslint/no-non-null-assertion': string;
|
|
19
|
+
'@typescript-eslint/no-invalid-void-type': string;
|
|
20
|
+
'@typescript-eslint/no-dynamic-delete': string;
|
|
21
|
+
'@typescript-eslint/no-useless-constructor': string;
|
|
22
|
+
'@typescript-eslint/prefer-for-of': string;
|
|
23
|
+
'@typescript-eslint/no-duplicate-enum-values': string;
|
|
24
|
+
};
|
|
25
|
+
export { rules };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { FlatConfig } from '@typescript-eslint/utils/ts-eslint';
|
|
2
|
+
declare enum ConfigOptions {
|
|
3
|
+
Ts = "ts",
|
|
4
|
+
React = "react",
|
|
5
|
+
Next = "next",
|
|
6
|
+
Expo = "expo",
|
|
7
|
+
Astro = "astro"
|
|
8
|
+
}
|
|
9
|
+
declare enum OptionalOptions {
|
|
10
|
+
Cspell = "cspell",
|
|
11
|
+
Tailwind = "tailwind",
|
|
12
|
+
Vitest = "vitest",
|
|
13
|
+
I18next = "i18next"
|
|
14
|
+
}
|
|
15
|
+
interface EslintConfig {
|
|
16
|
+
config?: ConfigOptions[];
|
|
17
|
+
optionals?: OptionalOptions[];
|
|
18
|
+
}
|
|
19
|
+
declare const eslintConfig: ({ config, optionals }?: EslintConfig) => FlatConfig.ConfigArray;
|
|
20
|
+
export { ConfigOptions, eslintConfig, OptionalOptions };
|