@codfish/eslint-config 0.0.0-PR-128--b274922 → 12.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 +12 -33
- package/index.js +3 -58
- package/package.json +4 -9
- package/rules/react.js +2 -2
- package/dist/vitest.config.d.ts +0 -3
- package/dist/vitest.config.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# @codfish/eslint-config
|
|
2
2
|
|
|
3
3
|
> Modern ESLint configuration with TypeScript, React/Next.js, YAML, Testing Library, and testing framework support using
|
|
4
|
-
> ESLint v9+ flat config format.
|
|
4
|
+
> ESLint v9+ flat config format.
|
|
5
5
|
|
|
6
6
|
[](http://npm.im/@codfish/eslint-config)
|
|
7
7
|
[](http://npm-stat.com/charts.html?package=@codfish/eslint-config&from=2015-08-01)
|
|
@@ -48,32 +48,8 @@ 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
|
|
69
51
|
```
|
|
70
52
|
|
|
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
|
-
|
|
77
53
|
## Usage
|
|
78
54
|
|
|
79
55
|
Create an `eslint.config.js` file in your project root:
|
|
@@ -169,11 +145,6 @@ import codfish from '@codfish/eslint-config';
|
|
|
169
145
|
export default defineConfig(
|
|
170
146
|
codfish,
|
|
171
147
|
|
|
172
|
-
// Custom ignores
|
|
173
|
-
{
|
|
174
|
-
ignores: ['some-directory'],
|
|
175
|
-
},
|
|
176
|
-
|
|
177
148
|
{
|
|
178
149
|
files: ['**/*.spec.{js,ts,jsx,tsx}'],
|
|
179
150
|
rules: {
|
|
@@ -284,7 +255,14 @@ preferences.
|
|
|
284
255
|
**Prettier is included and runs automatically** through ESLint for JavaScript, TypeScript, JSX, and TSX files using the
|
|
285
256
|
[built-in configuration](./prettier.js). **You don't need to install or configure Prettier separately** for basic usage.
|
|
286
257
|
|
|
287
|
-
|
|
258
|
+
However, if you want to format other file types (like Markdown, JSON, CSS, or YAML) or run Prettier directly, you can
|
|
259
|
+
install it as a dev dependency:
|
|
260
|
+
|
|
261
|
+
```sh
|
|
262
|
+
npm i -D prettier
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
You can then override the defaults by creating your own Prettier config file, or extend the built-in config:
|
|
288
266
|
|
|
289
267
|
**Option 1: Extend the built-in config (Recommended)**
|
|
290
268
|
|
|
@@ -344,11 +322,12 @@ npm i -D eslint@9 @codfish/eslint-config prettier-plugin-tailwindcss
|
|
|
344
322
|
```js
|
|
345
323
|
// prettier.config.js
|
|
346
324
|
|
|
347
|
-
import
|
|
325
|
+
import codfishPrettier from '@codfish/eslint-config/prettier';
|
|
326
|
+
import tailwindcss from 'prettier-plugin-tailwindcss';
|
|
348
327
|
|
|
349
328
|
/** @type {import('prettier').Config & import('prettier-plugin-tailwindcss').PluginOptions} */
|
|
350
329
|
export default {
|
|
351
|
-
...
|
|
330
|
+
...codfishPrettier,
|
|
352
331
|
plugins: ['prettier-plugin-tailwindcss'],
|
|
353
332
|
tailwindStylesheet: './src/styles/app.css',
|
|
354
333
|
tailwindFunctions: ['clsx'], // optional
|
package/index.js
CHANGED
|
@@ -20,11 +20,12 @@ 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
|
|
23
24
|
js.configs.recommended,
|
|
24
25
|
|
|
25
26
|
tseslint.configs.recommended,
|
|
26
27
|
|
|
27
|
-
// Base
|
|
28
|
+
// Base configuration for all files
|
|
28
29
|
{
|
|
29
30
|
name: 'codfish/base',
|
|
30
31
|
|
|
@@ -43,20 +44,6 @@ export default defineConfig([
|
|
|
43
44
|
},
|
|
44
45
|
|
|
45
46
|
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
|
-
|
|
60
47
|
// Custom Grouping: https://github.com/lydell/eslint-plugin-simple-import-sort#custom-grouping
|
|
61
48
|
// Examples: https://github.com/lydell/eslint-plugin-simple-import-sort/blob/main/examples/.eslintrc.js
|
|
62
49
|
'simple-import-sort/imports': [
|
|
@@ -104,36 +91,6 @@ export default defineConfig([
|
|
|
104
91
|
},
|
|
105
92
|
},
|
|
106
93
|
|
|
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
|
-
|
|
137
94
|
// Custom ignores
|
|
138
95
|
{
|
|
139
96
|
name: 'codfish/ignores',
|
|
@@ -145,6 +102,7 @@ export default defineConfig([
|
|
|
145
102
|
'coverage',
|
|
146
103
|
'.vercel',
|
|
147
104
|
'**/logs/',
|
|
105
|
+
'bin/*',
|
|
148
106
|
'**/dist/',
|
|
149
107
|
'**/dist-ssr/',
|
|
150
108
|
'**/cache/',
|
|
@@ -178,9 +136,6 @@ export default defineConfig([
|
|
|
178
136
|
'.tmp',
|
|
179
137
|
'.eslintcache',
|
|
180
138
|
'*.tsbuildinfo',
|
|
181
|
-
'node_modules',
|
|
182
|
-
'pnpm-lock.yaml',
|
|
183
|
-
'pnpm-lock.*.yaml',
|
|
184
139
|
],
|
|
185
140
|
},
|
|
186
141
|
|
|
@@ -191,16 +146,6 @@ export default defineConfig([
|
|
|
191
146
|
ymlPlugin.configs['flat/standard'],
|
|
192
147
|
ymlPlugin.configs['flat/prettier'], // handles conflicting rules with the yml plugin
|
|
193
148
|
|
|
194
|
-
{
|
|
195
|
-
name: 'codfish/github-yml-overrides',
|
|
196
|
-
|
|
197
|
-
files: ['.github/**/*.yml', '.github/**/*.yaml'],
|
|
198
|
-
|
|
199
|
-
rules: {
|
|
200
|
-
'yml/no-empty-mapping-value': 'off', // somewhat common in github workflows
|
|
201
|
-
},
|
|
202
|
-
},
|
|
203
|
-
|
|
204
149
|
// React configuration (dynamic)
|
|
205
150
|
ifAnyDep('react', reactConfig, []),
|
|
206
151
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codfish/eslint-config",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "12.0.0",
|
|
4
4
|
"description": "Modern ESLint configuration with TypeScript, React, and testing framework support.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -48,9 +48,6 @@
|
|
|
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",
|
|
54
51
|
"prepublishOnly": "npm run build",
|
|
55
52
|
"prepare": "husky"
|
|
56
53
|
},
|
|
@@ -81,8 +78,7 @@
|
|
|
81
78
|
"eslint": "^9.35.0",
|
|
82
79
|
"husky": "^9.1.7",
|
|
83
80
|
"lint-staged": "^16.1.6",
|
|
84
|
-
"typescript": "^5.9.2"
|
|
85
|
-
"vitest": "^1.0.0"
|
|
81
|
+
"typescript": "^5.9.2"
|
|
86
82
|
},
|
|
87
83
|
"engines": {
|
|
88
84
|
"node": ">=20.0.0"
|
|
@@ -98,11 +94,10 @@
|
|
|
98
94
|
"commitlint.js"
|
|
99
95
|
],
|
|
100
96
|
"peerDependencies": {
|
|
101
|
-
"eslint": ">= 9"
|
|
102
|
-
"prettier": ">= 3"
|
|
97
|
+
"eslint": ">= 9"
|
|
103
98
|
},
|
|
104
99
|
"peerDependenciesMeta": {
|
|
105
|
-
"
|
|
100
|
+
"typescript": {
|
|
106
101
|
"optional": true
|
|
107
102
|
}
|
|
108
103
|
},
|
package/rules/react.js
CHANGED
|
@@ -38,8 +38,8 @@ export default defineConfig([
|
|
|
38
38
|
ifAnyDep(
|
|
39
39
|
'next',
|
|
40
40
|
{
|
|
41
|
-
...
|
|
42
|
-
...
|
|
41
|
+
...nextPlugin.flatConfig.recommended,
|
|
42
|
+
...nextPlugin.flatConfig.coreWebVitals,
|
|
43
43
|
|
|
44
44
|
name: 'codfish/next',
|
|
45
45
|
},
|
package/dist/vitest.config.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"vitest.config.d.ts","sourceRoot":"","sources":["../vitest.config.js"],"names":[],"mappings":""}
|