@codfish/eslint-config 12.0.1 → 12.1.1
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 +31 -7
- package/dist/vitest.config.d.ts +3 -0
- package/dist/vitest.config.d.ts.map +1 -0
- package/index.js +48 -3
- package/package.json +9 -4
- package/rules/react.js +2 -2
package/README.md
CHANGED
|
@@ -48,8 +48,32 @@ Install the package and required peer dependencies:
|
|
|
48
48
|
|
|
49
49
|
```sh
|
|
50
50
|
npm i -D eslint@9 @codfish/eslint-config
|
|
51
|
+
|
|
52
|
+
# Optionally, you can uninstall plugins or presets you don't need to manage anymore,
|
|
53
|
+
# @codfish/eslint-config includes them all.
|
|
54
|
+
npm uninstall typescript-eslint \
|
|
55
|
+
eslint-config-prettier \
|
|
56
|
+
eslint-plugin-jest \
|
|
57
|
+
eslint-plugin-jsx-a11y \
|
|
58
|
+
eslint-plugin-prettier \
|
|
59
|
+
eslint-plugin-react \
|
|
60
|
+
eslint-plugin-react-hooks \
|
|
61
|
+
eslint-plugin-simple-import-sort \
|
|
62
|
+
eslint-plugin-testing-library \
|
|
63
|
+
eslint-plugin-yml \
|
|
64
|
+
@next/eslint-plugin-next \
|
|
65
|
+
eslint-plugin-next \
|
|
66
|
+
commitlint \
|
|
67
|
+
@commitlint/cli \
|
|
68
|
+
@commitlint/config-conventional
|
|
51
69
|
```
|
|
52
70
|
|
|
71
|
+
> [!NOTE]
|
|
72
|
+
>
|
|
73
|
+
> Optionally, you can uninstall prettier as well. If you don't have prettier installed already but you want to format
|
|
74
|
+
> other file types (like Markdown, JSON, CSS, etc.), you can install it as a dev dependency: `npm i -D prettier`. Then
|
|
75
|
+
> you can use Prettier to format your non-JS files directly. Eslint will still run Prettier as an ESLint rule.
|
|
76
|
+
|
|
53
77
|
## Usage
|
|
54
78
|
|
|
55
79
|
Create an `eslint.config.js` file in your project root:
|
|
@@ -145,6 +169,11 @@ import codfish from '@codfish/eslint-config';
|
|
|
145
169
|
export default defineConfig(
|
|
146
170
|
codfish,
|
|
147
171
|
|
|
172
|
+
// Custom ignores
|
|
173
|
+
{
|
|
174
|
+
ignores: ['some-directory'],
|
|
175
|
+
},
|
|
176
|
+
|
|
148
177
|
{
|
|
149
178
|
files: ['**/*.spec.{js,ts,jsx,tsx}'],
|
|
150
179
|
rules: {
|
|
@@ -306,11 +335,6 @@ export default {
|
|
|
306
335
|
};
|
|
307
336
|
```
|
|
308
337
|
|
|
309
|
-
> [!TIP]
|
|
310
|
-
>
|
|
311
|
-
> If you want to format other file types (like Markdown, JSON, CSS, or YAML) or run Prettier directly, you can install
|
|
312
|
-
> it as a dev dependency: `npm i -D prettier`.
|
|
313
|
-
|
|
314
338
|
### Use in combination with prettier-plugin-tailwindcss
|
|
315
339
|
|
|
316
340
|
```sh
|
|
@@ -320,11 +344,11 @@ npm i -D eslint@9 @codfish/eslint-config prettier-plugin-tailwindcss
|
|
|
320
344
|
```js
|
|
321
345
|
// prettier.config.js
|
|
322
346
|
|
|
323
|
-
import
|
|
347
|
+
import codfish from '@codfish/eslint-config/prettier';
|
|
324
348
|
|
|
325
349
|
/** @type {import('prettier').Config & import('prettier-plugin-tailwindcss').PluginOptions} */
|
|
326
350
|
export default {
|
|
327
|
-
...
|
|
351
|
+
...codfish,
|
|
328
352
|
plugins: ['prettier-plugin-tailwindcss'],
|
|
329
353
|
tailwindStylesheet: './src/styles/app.css',
|
|
330
354
|
tailwindFunctions: ['clsx'], // optional
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vitest.config.d.ts","sourceRoot":"","sources":["../vitest.config.js"],"names":[],"mappings":""}
|
package/index.js
CHANGED
|
@@ -20,12 +20,11 @@ const useBuiltinPrettierConfig = !hasLocalConfig('prettier');
|
|
|
20
20
|
* Supports TypeScript, React, Jest, Vitest, Prettier, YAML, and Next.js
|
|
21
21
|
*/
|
|
22
22
|
export default defineConfig([
|
|
23
|
-
// Base JavaScript configuration
|
|
24
23
|
js.configs.recommended,
|
|
25
24
|
|
|
26
25
|
tseslint.configs.recommended,
|
|
27
26
|
|
|
28
|
-
// Base
|
|
27
|
+
// Base opinionated rules
|
|
29
28
|
{
|
|
30
29
|
name: 'codfish/base',
|
|
31
30
|
|
|
@@ -44,6 +43,20 @@ export default defineConfig([
|
|
|
44
43
|
},
|
|
45
44
|
|
|
46
45
|
rules: {
|
|
46
|
+
// Error handling rules to enforce using the Error object
|
|
47
|
+
'no-throw-literal': 'error',
|
|
48
|
+
'prefer-promise-reject-errors': 'error',
|
|
49
|
+
|
|
50
|
+
// Asynchronous functions that don’t use await might not need to be asynchronous functions
|
|
51
|
+
// Usually result of refactoring, leads to misunderstanding/misusage
|
|
52
|
+
'require-await': 'error',
|
|
53
|
+
|
|
54
|
+
// Disallow console statements in regular code (only allowed in test files)
|
|
55
|
+
'no-console': 'error',
|
|
56
|
+
|
|
57
|
+
// Consolidate your imports
|
|
58
|
+
'no-duplicate-imports': ['error', { includeExports: false }],
|
|
59
|
+
|
|
47
60
|
// Custom Grouping: https://github.com/lydell/eslint-plugin-simple-import-sort#custom-grouping
|
|
48
61
|
// Examples: https://github.com/lydell/eslint-plugin-simple-import-sort/blob/main/examples/.eslintrc.js
|
|
49
62
|
'simple-import-sort/imports': [
|
|
@@ -91,6 +104,36 @@ export default defineConfig([
|
|
|
91
104
|
},
|
|
92
105
|
},
|
|
93
106
|
|
|
107
|
+
{
|
|
108
|
+
name: 'codfish/ts-overrides',
|
|
109
|
+
|
|
110
|
+
files: ['**/*.ts', '**/*.tsx'],
|
|
111
|
+
|
|
112
|
+
rules: {
|
|
113
|
+
'@typescript-eslint/no-empty-function': 'off',
|
|
114
|
+
'@typescript-eslint/naming-convention': [
|
|
115
|
+
'error',
|
|
116
|
+
{
|
|
117
|
+
selector: ['interface', 'typeAlias'],
|
|
118
|
+
format: ['PascalCase'],
|
|
119
|
+
custom: {
|
|
120
|
+
regex: '^I[A-Z]', // prevent prefixing interfaces and type alias declarations with "I"
|
|
121
|
+
match: false,
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
],
|
|
125
|
+
'@typescript-eslint/ban-ts-comment': [
|
|
126
|
+
'error',
|
|
127
|
+
{
|
|
128
|
+
// If you need to use a ts comment, make sure you have a description.
|
|
129
|
+
'ts-ignore': 'allow-with-description',
|
|
130
|
+
'ts-expect-error': 'allow-with-description',
|
|
131
|
+
'ts-nocheck': 'allow-with-description',
|
|
132
|
+
},
|
|
133
|
+
],
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
|
|
94
137
|
// Custom ignores
|
|
95
138
|
{
|
|
96
139
|
name: 'codfish/ignores',
|
|
@@ -102,7 +145,6 @@ export default defineConfig([
|
|
|
102
145
|
'coverage',
|
|
103
146
|
'.vercel',
|
|
104
147
|
'**/logs/',
|
|
105
|
-
'bin/*',
|
|
106
148
|
'**/dist/',
|
|
107
149
|
'**/dist-ssr/',
|
|
108
150
|
'**/cache/',
|
|
@@ -136,6 +178,9 @@ export default defineConfig([
|
|
|
136
178
|
'.tmp',
|
|
137
179
|
'.eslintcache',
|
|
138
180
|
'*.tsbuildinfo',
|
|
181
|
+
'node_modules',
|
|
182
|
+
'pnpm-lock.yaml',
|
|
183
|
+
'pnpm-lock.*.yaml',
|
|
139
184
|
],
|
|
140
185
|
},
|
|
141
186
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codfish/eslint-config",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.1.1",
|
|
4
4
|
"description": "Modern ESLint configuration with TypeScript, React, and testing framework support.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -48,6 +48,9 @@
|
|
|
48
48
|
"type-check": "tsc --noEmit",
|
|
49
49
|
"lint": "eslint .",
|
|
50
50
|
"fix": "prettier --write \"**/*.{json,css,scss,md}\" --config ./prettier.js && npm run lint -- --fix",
|
|
51
|
+
"test": "vitest",
|
|
52
|
+
"test:watch": "vitest --watch",
|
|
53
|
+
"test:coverage": "vitest --coverage",
|
|
51
54
|
"prepublishOnly": "npm run build",
|
|
52
55
|
"prepare": "husky"
|
|
53
56
|
},
|
|
@@ -78,7 +81,8 @@
|
|
|
78
81
|
"eslint": "^9.35.0",
|
|
79
82
|
"husky": "^9.1.7",
|
|
80
83
|
"lint-staged": "^16.1.6",
|
|
81
|
-
"typescript": "^5.9.2"
|
|
84
|
+
"typescript": "^5.9.2",
|
|
85
|
+
"vitest": "^1.0.0"
|
|
82
86
|
},
|
|
83
87
|
"engines": {
|
|
84
88
|
"node": ">=20.0.0"
|
|
@@ -94,10 +98,11 @@
|
|
|
94
98
|
"commitlint.js"
|
|
95
99
|
],
|
|
96
100
|
"peerDependencies": {
|
|
97
|
-
"eslint": ">= 9"
|
|
101
|
+
"eslint": ">= 9",
|
|
102
|
+
"prettier": ">= 3"
|
|
98
103
|
},
|
|
99
104
|
"peerDependenciesMeta": {
|
|
100
|
-
"
|
|
105
|
+
"prettier": {
|
|
101
106
|
"optional": true
|
|
102
107
|
}
|
|
103
108
|
},
|
package/rules/react.js
CHANGED
|
@@ -38,8 +38,8 @@ export default defineConfig([
|
|
|
38
38
|
ifAnyDep(
|
|
39
39
|
'next',
|
|
40
40
|
{
|
|
41
|
-
...nextPlugin
|
|
42
|
-
...nextPlugin
|
|
41
|
+
...(nextPlugin?.flatConfig?.recommended || {}),
|
|
42
|
+
...(nextPlugin?.flatConfig?.coreWebVitals || {}),
|
|
43
43
|
|
|
44
44
|
name: 'codfish/next',
|
|
45
45
|
},
|