@codfish/eslint-config 0.0.0-PR-124--4943524 → 0.0.0-PR-124--8ec70e4
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 +282 -49
- package/index.js +40 -2
- package/package.json +46 -42
- package/rules/jest.js +12 -1
- package/rules/react.js +15 -0
- package/rules/vitest.js +8 -2
package/README.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# @codfish/eslint-config
|
|
2
2
|
|
|
3
|
-
> Modern ESLint configuration with TypeScript, React,
|
|
3
|
+
> Modern ESLint configuration with TypeScript, React/Next.js, Tailwind CSS, YAML, Testing Library, and testing framework
|
|
4
|
+
> support using ESLint v9+ flat config format.
|
|
4
5
|
|
|
5
6
|
[](http://npm.im/@codfish/eslint-config)
|
|
6
7
|
[](http://npm-stat.com/charts.html?package=@codfish/eslint-config&from=2015-08-01)
|
|
@@ -14,12 +15,14 @@
|
|
|
14
15
|
|
|
15
16
|
- [Features](#features)
|
|
16
17
|
- [Automatic Configuration](#automatic-configuration)
|
|
18
|
+
- [Opinionated Highlights](#opinionated-highlights)
|
|
17
19
|
- [Installation](#installation)
|
|
18
20
|
- [Usage](#usage)
|
|
19
|
-
- [Prettier](#prettier)
|
|
20
|
-
- [With dApps](#with-dapps)
|
|
21
21
|
- [Docker Configuration](#docker-configuration)
|
|
22
|
-
- [
|
|
22
|
+
- [dApps Configuration](#dapps-configuration)
|
|
23
|
+
- [Prettier Configuration](#prettier-configuration)
|
|
24
|
+
- [Example scripts](#example-scripts)
|
|
25
|
+
- [Commitlint Configuration](#commitlint-configuration)
|
|
23
26
|
- [Known issues](#known-issues)
|
|
24
27
|
- [Migration from Legacy Config](#migration-from-legacy-config)
|
|
25
28
|
|
|
@@ -31,7 +34,11 @@
|
|
|
31
34
|
- **Dynamic feature detection**: Automatically configures based on your project's dependencies
|
|
32
35
|
- **TypeScript support**: Full TypeScript linting with modern typescript-eslint parser and rules
|
|
33
36
|
- **React ecosystem**: React, React Hooks, and JSX accessibility rules when React is detected
|
|
37
|
+
- **Next.js support**: Automatically configures Next.js official plugin linting rules when detected
|
|
34
38
|
- **Test framework agnostic**: Supports Jest and Vitest with automatic detection
|
|
39
|
+
- **Testing Library integration**: Automatically includes Testing Library rules for test files
|
|
40
|
+
- **Tailwind CSS support**: Automatically configures Tailwind CSS linting when detected
|
|
41
|
+
- **YAML/YML support**: Built-in linting for YAML configuration files
|
|
35
42
|
- **Prettier integration**: Built-in Prettier configuration with conflict resolution via eslint-config-prettier
|
|
36
43
|
- **ESM architecture**: Built with ECMAScript modules and full TypeScript typing
|
|
37
44
|
- **Docker support**: Optional configuration for dockerized applications
|
|
@@ -42,16 +49,52 @@
|
|
|
42
49
|
The config automatically detects and configures:
|
|
43
50
|
|
|
44
51
|
- **React**: Includes React, React Hooks, and JSX a11y rules when `react` is installed
|
|
52
|
+
- **Next.js**: Includes Next.js recommended and Core Web Vitals rules when `next` is detected
|
|
45
53
|
- **Jest**: Configures Jest-specific rules when `jest` is found in dependencies
|
|
46
54
|
- **Vitest**: Configures Vitest-specific rules when `vitest` is detected
|
|
47
|
-
- **
|
|
55
|
+
- **Testing Library**: Automatically adds Testing Library rules for test files in Jest/Vitest projects
|
|
56
|
+
- **Tailwind CSS**: Includes Tailwind CSS linting rules when `tailwindcss` is detected
|
|
57
|
+
- **YAML files**: Always includes YAML/YML file linting support
|
|
58
|
+
- **Prettier**: Loads your project's Prettier config or falls back to [my defaults](./prettier.js)
|
|
59
|
+
|
|
60
|
+
### Opinionated Highlights
|
|
61
|
+
|
|
62
|
+
This configuration includes some opinionated settings that you might want to customize for your project:
|
|
63
|
+
|
|
64
|
+
**Prettier/Formatting:**
|
|
65
|
+
|
|
66
|
+
- **Semicolons**: Enforces semicolons (`;`)
|
|
67
|
+
- **120 character line width**: Wider than the common 80/100 - you might prefer shorter lines
|
|
68
|
+
- **2-space indentation**: Uses 2 spaces for tabs
|
|
69
|
+
- **Single quotes**: Prefers `'single'` over `"double"` quotes
|
|
70
|
+
- **Trailing commas**: Adds trailing commas everywhere
|
|
71
|
+
- **Arrow parentheses**: Avoids parens around single args (`x => x` not `(x) => x`)
|
|
72
|
+
|
|
73
|
+
**ESLint Rules:**
|
|
74
|
+
|
|
75
|
+
- **Import sorting**: Enforces automatic import organization with specific grouping rules
|
|
76
|
+
- **Lodash restrictions**: Requires direct imports (`import get from 'lodash-es/get'`) instead of full lodash
|
|
77
|
+
- **React hooks deps**: Disables `exhaustive-deps` rule - you might want this stricter
|
|
78
|
+
- **Console statements**: Disallows `console.log` in regular code (only allowed in test files) - some teams prefer
|
|
79
|
+
warnings instead of errors
|
|
80
|
+
- **Next.js rules**: Enforces Next.js best practices and Core Web Vitals optimization
|
|
81
|
+
- **Tailwind class sorting**: Automatically sorts Tailwind classes (can break dynamic class builds - see Known Issues)
|
|
82
|
+
- **Testing Library rules**: Enforces Testing Library best practices in test files
|
|
83
|
+
|
|
84
|
+
**File Ignores:**
|
|
85
|
+
|
|
86
|
+
- Ignores common build directories (`.next`, `coverage`, `.vercel`, etc.)
|
|
87
|
+
- Includes `.github` and `.vitepress` folders (not ignored like most configs)
|
|
88
|
+
|
|
89
|
+
See the [configuration examples below](#usage) for instructions on overriding these settings to match your team's
|
|
90
|
+
preferences.
|
|
48
91
|
|
|
49
92
|
## Installation
|
|
50
93
|
|
|
51
94
|
Install the package and required peer dependencies:
|
|
52
95
|
|
|
53
96
|
```sh
|
|
54
|
-
npm i -D @codfish/eslint-config
|
|
97
|
+
npm i -D eslint@9 @codfish/eslint-config
|
|
55
98
|
```
|
|
56
99
|
|
|
57
100
|
## Usage
|
|
@@ -62,54 +105,89 @@ Create an `eslint.config.js` file in your project root:
|
|
|
62
105
|
import { defineConfig } from 'eslint/config';
|
|
63
106
|
import codfish from '@codfish/eslint-config';
|
|
64
107
|
|
|
65
|
-
export default defineConfig(
|
|
108
|
+
export default defineConfig(
|
|
109
|
+
codfish,
|
|
110
|
+
|
|
66
111
|
{
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
112
|
+
rules: {
|
|
113
|
+
// Relax some rules for your project
|
|
114
|
+
'react/prop-types': 'off',
|
|
115
|
+
'import/prefer-default-export': 'off',
|
|
116
|
+
'@typescript-eslint/explicit-function-return-type': 'warn',
|
|
117
|
+
},
|
|
70
118
|
},
|
|
71
|
-
|
|
119
|
+
);
|
|
72
120
|
```
|
|
73
121
|
|
|
74
122
|
> [!IMPORTANT] If you get ES module errors, you may need to set the `type` field in your `package.json` to `module` or
|
|
75
123
|
> rename your config file to `eslint.config.mjs`.
|
|
76
124
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
Prettier is automatically run through eslint with the [default configuration](./prettier.js). You can optionally add a
|
|
80
|
-
prettier configuration file in the root of your project and it will take precedence over the
|
|
81
|
-
[built-in config](./prettier.js). You can also choose to extend the Prettier config:
|
|
82
|
-
|
|
83
|
-
**prettier.config.js**
|
|
125
|
+
Not using the `defineConfig` function, just spread the config object:
|
|
84
126
|
|
|
85
127
|
```js
|
|
86
|
-
import
|
|
128
|
+
import codfish from '@codfish/eslint-config';
|
|
87
129
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
* @type {import("prettier").Config}
|
|
91
|
-
*/
|
|
92
|
-
const config = {
|
|
93
|
-
...codfishConfig,
|
|
94
|
-
// your overrides here
|
|
95
|
-
};
|
|
130
|
+
export default [
|
|
131
|
+
...codfish,
|
|
96
132
|
|
|
97
|
-
|
|
133
|
+
{
|
|
134
|
+
// Your project-specific overrides
|
|
135
|
+
rules: {
|
|
136
|
+
// Override or add specific rules
|
|
137
|
+
'no-console': 'warn',
|
|
138
|
+
'@typescript-eslint/no-unused-vars': 'error',
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
];
|
|
98
142
|
```
|
|
99
143
|
|
|
100
|
-
|
|
144
|
+
**Use the config without any overrides:**
|
|
101
145
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
want to run the linter in a ci/cd environment and build artifacts might not be present.
|
|
146
|
+
```js
|
|
147
|
+
import codfish from '@codfish/eslint-config';
|
|
105
148
|
|
|
106
|
-
|
|
149
|
+
export default codfish;
|
|
150
|
+
```
|
|
107
151
|
|
|
108
|
-
|
|
152
|
+
**Framework-specific customizations:**
|
|
109
153
|
|
|
110
154
|
```js
|
|
111
|
-
import
|
|
112
|
-
|
|
155
|
+
import { defineConfig } from 'eslint/config';
|
|
156
|
+
import codfish from '@codfish/eslint-config';
|
|
157
|
+
|
|
158
|
+
export default defineConfig(
|
|
159
|
+
codfish,
|
|
160
|
+
|
|
161
|
+
{
|
|
162
|
+
files: ['**/*.spec.{js,ts,jsx,tsx}'],
|
|
163
|
+
rules: {
|
|
164
|
+
// Allow any in test files
|
|
165
|
+
'@typescript-eslint/no-explicit-any': 'off',
|
|
166
|
+
// Relax Testing Library rules if needed
|
|
167
|
+
'testing-library/prefer-screen-queries': 'warn',
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
|
|
171
|
+
{
|
|
172
|
+
files: ['**/*.config.{js,ts}'],
|
|
173
|
+
rules: {
|
|
174
|
+
// Allow require in config files
|
|
175
|
+
'@typescript-eslint/no-require-imports': 'off',
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
|
|
179
|
+
{
|
|
180
|
+
files: ['**/*.{js,jsx,ts,tsx}'],
|
|
181
|
+
rules: {
|
|
182
|
+
// Customize Tailwind CSS rules
|
|
183
|
+
'tailwindcss/classnames-order': 'warn',
|
|
184
|
+
'tailwindcss/no-custom-classname': 'off',
|
|
185
|
+
// Customize Next.js rules
|
|
186
|
+
'@next/next/no-img-element': 'warn',
|
|
187
|
+
'@next/next/no-html-link-for-pages': 'off',
|
|
188
|
+
},
|
|
189
|
+
},
|
|
190
|
+
);
|
|
113
191
|
```
|
|
114
192
|
|
|
115
193
|
### Docker Configuration
|
|
@@ -131,22 +209,17 @@ export default defineConfig(
|
|
|
131
209
|
);
|
|
132
210
|
```
|
|
133
211
|
|
|
134
|
-
###
|
|
135
|
-
|
|
136
|
-
For decentralized applications that use build artifacts and blockchain globals, use the specialized dApp config:
|
|
212
|
+
### dApps Configuration
|
|
137
213
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
214
|
+
For decentralized applications that use build artifacts and blockchain globals, use the specialized dApp config. This
|
|
215
|
+
config will set some globals as well as ignore missing build artifact imports. While you obviously need those to run
|
|
216
|
+
your app, sometimes you might want to run the linter in a ci/cd environment and build artifacts might not be present.
|
|
141
217
|
|
|
142
|
-
|
|
143
|
-
codfish,
|
|
144
|
-
dapp,
|
|
218
|
+
You can also directly import the Prettier config:
|
|
145
219
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
);
|
|
220
|
+
```js
|
|
221
|
+
import prettierConfig from '@codfish/eslint-config/prettier';
|
|
222
|
+
export default prettierConfig;
|
|
150
223
|
```
|
|
151
224
|
|
|
152
225
|
The dApp configuration provides:
|
|
@@ -155,6 +228,166 @@ The dApp configuration provides:
|
|
|
155
228
|
- Import resolution handling for smart contract build artifacts
|
|
156
229
|
- Relaxed rules for generated contract files
|
|
157
230
|
|
|
231
|
+
## Prettier Configuration
|
|
232
|
+
|
|
233
|
+
**Prettier is included and runs automatically** through ESLint for JavaScript, TypeScript, JSX, and TSX files using the
|
|
234
|
+
[built-in configuration](./prettier.js). **You don't need to install or configure Prettier separately** for basic usage.
|
|
235
|
+
|
|
236
|
+
However, if you want to format other file types (like Markdown, JSON, CSS, or YAML) or run Prettier directly, you can
|
|
237
|
+
install it as a dev dependency:
|
|
238
|
+
|
|
239
|
+
```sh
|
|
240
|
+
npm i -D prettier
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
You can then override the defaults by creating your own Prettier config file, or extend the built-in config:
|
|
244
|
+
|
|
245
|
+
**Option 1: Extend the built-in config (Recommended)**
|
|
246
|
+
|
|
247
|
+
Create a `prettier.config.js` file in your project root:
|
|
248
|
+
|
|
249
|
+
```js
|
|
250
|
+
// prettier.config.js
|
|
251
|
+
|
|
252
|
+
import codfishConfig from '@codfish/eslint-config/prettier';
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* @see https://prettier.io/docs/en/configuration.html
|
|
256
|
+
* @type {import("prettier").Config}
|
|
257
|
+
*/
|
|
258
|
+
export default {
|
|
259
|
+
...codfishConfig,
|
|
260
|
+
|
|
261
|
+
// Override specific settings
|
|
262
|
+
printWidth: 80,
|
|
263
|
+
singleQuote: false,
|
|
264
|
+
tabWidth: 4,
|
|
265
|
+
trailingComma: 'none',
|
|
266
|
+
};
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
**Option 2: Completely custom config**
|
|
270
|
+
|
|
271
|
+
This config will completely override the built-in config.
|
|
272
|
+
|
|
273
|
+
```js
|
|
274
|
+
// prettier.config.js
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* @see https://prettier.io/docs/en/configuration.html
|
|
278
|
+
* @type {import("prettier").Config}
|
|
279
|
+
*/
|
|
280
|
+
export default {
|
|
281
|
+
printWidth: 100,
|
|
282
|
+
tabWidth: 2,
|
|
283
|
+
useTabs: false,
|
|
284
|
+
semi: true,
|
|
285
|
+
singleQuote: true,
|
|
286
|
+
trailingComma: 'all',
|
|
287
|
+
bracketSpacing: true,
|
|
288
|
+
bracketSameLine: false,
|
|
289
|
+
arrowParens: 'avoid',
|
|
290
|
+
proseWrap: 'always',
|
|
291
|
+
};
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
## Example scripts
|
|
295
|
+
|
|
296
|
+
Optionally, you can add these scripts to your `package.json` for common linting workflows:
|
|
297
|
+
|
|
298
|
+
**Basic scripts (no separate Prettier installation needed):**
|
|
299
|
+
|
|
300
|
+
```json
|
|
301
|
+
{
|
|
302
|
+
"scripts": {
|
|
303
|
+
"lint": "eslint .",
|
|
304
|
+
"fix": "eslint . --fix"
|
|
305
|
+
},
|
|
306
|
+
"lint-staged": {
|
|
307
|
+
"*.{js,jsx,ts,tsx}": ["eslint --fix"]
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
**With Prettier installed separately (for formatting non-JS files):**
|
|
313
|
+
|
|
314
|
+
```json
|
|
315
|
+
{
|
|
316
|
+
"scripts": {
|
|
317
|
+
"lint": "eslint .",
|
|
318
|
+
"fix": "eslint . --fix",
|
|
319
|
+
"format": "prettier --config ./node_modules/@codfish/eslint-config/prettier.js --write \"**/*.{json,css,md}\"",
|
|
320
|
+
"check": "npm run lint && npm run format -- --check --no-write"
|
|
321
|
+
},
|
|
322
|
+
"lint-staged": {
|
|
323
|
+
"*.{js,jsx,ts,tsx}": ["eslint --fix"],
|
|
324
|
+
"*.{json,css,md}": ["prettier --write --config ./node_modules/@codfish/eslint-config/prettier.js"]
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
## Commitlint Configuration
|
|
330
|
+
|
|
331
|
+
Extend from the shared codfish commitlint config.
|
|
332
|
+
|
|
333
|
+
```js
|
|
334
|
+
import codfishConfig from '@codfish/eslint-config/commitlint.js';
|
|
335
|
+
|
|
336
|
+
export default Object.assign(codfishConfig, {
|
|
337
|
+
// your overrides here
|
|
338
|
+
rules: {
|
|
339
|
+
'scope-case': [1],
|
|
340
|
+
},
|
|
341
|
+
});
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
**Or just reference it in your package.json:**
|
|
345
|
+
|
|
346
|
+
```json
|
|
347
|
+
{
|
|
348
|
+
"commitlint": {
|
|
349
|
+
"extends": ["./node_modules/@codfish/eslint-config/commitlint.js"]
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
Run commitlint in your CI to validate your commits:
|
|
355
|
+
|
|
356
|
+
> [!NOTE]
|
|
357
|
+
>
|
|
358
|
+
> If you have @codfish/eslint-config as a dev dependency, and a commitlint config in your project, you can just call
|
|
359
|
+
> `npx commitlint` in your CI and it will use the shared config.
|
|
360
|
+
>
|
|
361
|
+
> - You just need to setup node & install your dependencies before running commitlint.
|
|
362
|
+
> - Don't forget to set the `fetch-depth` to `0` to ensure commitlint can work properly.
|
|
363
|
+
|
|
364
|
+
```yaml
|
|
365
|
+
# .github/workflows/validate.yml
|
|
366
|
+
|
|
367
|
+
on: pull_request_target
|
|
368
|
+
|
|
369
|
+
jobs:
|
|
370
|
+
validate:
|
|
371
|
+
runs-on: ubuntu-latest
|
|
372
|
+
|
|
373
|
+
steps:
|
|
374
|
+
- uses: actions/checkout@v5
|
|
375
|
+
with:
|
|
376
|
+
ref: ${{ github.event.pull_request.head.sha || github.ref }}
|
|
377
|
+
fetch-depth: 0 # Important for commitlint to work
|
|
378
|
+
|
|
379
|
+
- uses: actions/setup-node@v5
|
|
380
|
+
with:
|
|
381
|
+
node-version: lts/*
|
|
382
|
+
registry-url: https://registry.npmjs.org
|
|
383
|
+
|
|
384
|
+
- run: npm ci # or npm install
|
|
385
|
+
|
|
386
|
+
- run:
|
|
387
|
+
npx commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }}
|
|
388
|
+
--verbose
|
|
389
|
+
```
|
|
390
|
+
|
|
158
391
|
## Known issues
|
|
159
392
|
|
|
160
393
|
> https://github.com/francoismassart/eslint-plugin-tailwindcss/issues/149
|
package/index.js
CHANGED
|
@@ -2,6 +2,8 @@ import js from '@eslint/js';
|
|
|
2
2
|
import { defineConfig } from 'eslint/config';
|
|
3
3
|
import prettier from 'eslint-plugin-prettier/recommended';
|
|
4
4
|
import simpleImportSortPlugin from 'eslint-plugin-simple-import-sort';
|
|
5
|
+
import tailwindPlugin from 'eslint-plugin-tailwindcss';
|
|
6
|
+
import ymlPlugin from 'eslint-plugin-yml';
|
|
5
7
|
import globals from 'globals';
|
|
6
8
|
import tseslint from 'typescript-eslint';
|
|
7
9
|
|
|
@@ -16,7 +18,7 @@ const useBuiltinPrettierConfig = !hasLocalConfig('prettier');
|
|
|
16
18
|
|
|
17
19
|
/**
|
|
18
20
|
* Modern ESLint configuration with dynamic feature detection
|
|
19
|
-
* Supports TypeScript, React, Jest, Vitest, and
|
|
21
|
+
* Supports TypeScript, React, Jest, Vitest, Prettier, YAML, Tailwind CSS, and Next.js
|
|
20
22
|
*/
|
|
21
23
|
export default defineConfig([
|
|
22
24
|
// Base JavaScript configuration
|
|
@@ -97,6 +99,9 @@ export default defineConfig([
|
|
|
97
99
|
ignores: [
|
|
98
100
|
'!.github',
|
|
99
101
|
'!.vitepress',
|
|
102
|
+
'.next',
|
|
103
|
+
'coverage',
|
|
104
|
+
'.vercel',
|
|
100
105
|
'**/logs/',
|
|
101
106
|
'bin/*',
|
|
102
107
|
'**/dist/',
|
|
@@ -105,16 +110,49 @@ export default defineConfig([
|
|
|
105
110
|
'**/coverage/',
|
|
106
111
|
'cypress/screenshots/',
|
|
107
112
|
'cypress/videos/',
|
|
108
|
-
'storybook-static
|
|
113
|
+
'storybook-static',
|
|
114
|
+
'.nuxt',
|
|
115
|
+
'.svelte-kit',
|
|
116
|
+
'.docusaurus',
|
|
117
|
+
'.astro',
|
|
118
|
+
'.output',
|
|
119
|
+
'**/out/',
|
|
120
|
+
'.vite',
|
|
121
|
+
'.parcel-cache',
|
|
122
|
+
'.webpack',
|
|
123
|
+
'.turbo',
|
|
124
|
+
'.nyc_output',
|
|
125
|
+
'playwright-report',
|
|
126
|
+
'cypress/downloads/',
|
|
127
|
+
'cypress/reports/',
|
|
128
|
+
'.serverless',
|
|
129
|
+
'.netlify',
|
|
130
|
+
'.wrangler',
|
|
131
|
+
'.firebase',
|
|
132
|
+
'android',
|
|
133
|
+
'ios',
|
|
134
|
+
'.expo',
|
|
135
|
+
'**/tmp/',
|
|
136
|
+
'**/temp/',
|
|
137
|
+
'.tmp',
|
|
138
|
+
'.eslintcache',
|
|
139
|
+
'*.tsbuildinfo',
|
|
109
140
|
],
|
|
110
141
|
},
|
|
111
142
|
|
|
112
143
|
// Configuration files (eslint, prettier, etc.)
|
|
113
144
|
configFilesConfig,
|
|
114
145
|
|
|
146
|
+
// YML files
|
|
147
|
+
ymlPlugin.configs['flat/standard'],
|
|
148
|
+
ymlPlugin.configs['flat/prettier'], // handles conflicting rules with the yml plugin
|
|
149
|
+
|
|
115
150
|
// React configuration (dynamic)
|
|
116
151
|
ifAnyDep('react', reactConfig, []),
|
|
117
152
|
|
|
153
|
+
// Tailwind CSS configuration (dynamic)
|
|
154
|
+
ifAnyDep('tailwindcss', tailwindPlugin.configs['flat/recommended'], []),
|
|
155
|
+
|
|
118
156
|
// Jest OR Vitest configuration (dynamic)
|
|
119
157
|
ifAnyDep('jest', jestConfig, []),
|
|
120
158
|
|
package/package.json
CHANGED
|
@@ -1,8 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codfish/eslint-config",
|
|
3
|
-
"version": "0.0.0-PR-124--
|
|
3
|
+
"version": "0.0.0-PR-124--8ec70e4",
|
|
4
4
|
"description": "Modern ESLint configuration with TypeScript, React, and testing framework support.",
|
|
5
5
|
"type": "module",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/codfish/eslint-config.git"
|
|
9
|
+
},
|
|
10
|
+
"keywords": [
|
|
11
|
+
"eslint",
|
|
12
|
+
"eslintconfig",
|
|
13
|
+
"config",
|
|
14
|
+
"codfish",
|
|
15
|
+
"prettier",
|
|
16
|
+
"javascript",
|
|
17
|
+
"styleguide"
|
|
18
|
+
],
|
|
19
|
+
"author": "Chris O'Donnell <chris@codfish.dev> (https://www.codfish.dev)",
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"bugs": {
|
|
22
|
+
"url": "https://github.com/codfish/eslint-config/issues"
|
|
23
|
+
},
|
|
24
|
+
"homepage": "https://github.com/codfish/eslint-config#readme",
|
|
6
25
|
"main": "index.js",
|
|
7
26
|
"types": "dist/index.d.ts",
|
|
8
27
|
"exports": {
|
|
@@ -32,46 +51,6 @@
|
|
|
32
51
|
"prepublishOnly": "npm run build",
|
|
33
52
|
"prepare": "husky"
|
|
34
53
|
},
|
|
35
|
-
"repository": {
|
|
36
|
-
"type": "git",
|
|
37
|
-
"url": "git+https://github.com/codfish/eslint-config.git"
|
|
38
|
-
},
|
|
39
|
-
"keywords": [
|
|
40
|
-
"eslint",
|
|
41
|
-
"eslintconfig",
|
|
42
|
-
"config",
|
|
43
|
-
"codfish",
|
|
44
|
-
"prettier",
|
|
45
|
-
"javascript",
|
|
46
|
-
"styleguide"
|
|
47
|
-
],
|
|
48
|
-
"author": "Chris O'Donnell <chris@codfish.dev> (https://www.codfish.dev)",
|
|
49
|
-
"license": "MIT",
|
|
50
|
-
"bugs": {
|
|
51
|
-
"url": "https://github.com/codfish/eslint-config-codfish/issues"
|
|
52
|
-
},
|
|
53
|
-
"homepage": "https://github.com/codfish/eslint-config-codfish#readme",
|
|
54
|
-
"peerDependencies": {
|
|
55
|
-
"eslint": ">= 9"
|
|
56
|
-
},
|
|
57
|
-
"peerDependenciesMeta": {
|
|
58
|
-
"typescript": {
|
|
59
|
-
"optional": true
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
"engines": {
|
|
63
|
-
"node": ">=20.0.0"
|
|
64
|
-
},
|
|
65
|
-
"files": [
|
|
66
|
-
"dist",
|
|
67
|
-
"rules",
|
|
68
|
-
"index.js",
|
|
69
|
-
"prettier.js",
|
|
70
|
-
"dapp.js",
|
|
71
|
-
"docker.js",
|
|
72
|
-
"utils.js",
|
|
73
|
-
"commitlint.js"
|
|
74
|
-
],
|
|
75
54
|
"dependencies": {
|
|
76
55
|
"@commitlint/cli": "^19.8.1",
|
|
77
56
|
"@commitlint/config-conventional": "^19.8.1",
|
|
@@ -85,6 +64,10 @@
|
|
|
85
64
|
"eslint-plugin-react": "^7.37.5",
|
|
86
65
|
"eslint-plugin-react-hooks": "^5.2.0",
|
|
87
66
|
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
67
|
+
"eslint-plugin-tailwindcss": "^3.18.2",
|
|
68
|
+
"eslint-plugin-testing-library": "^7.1.0",
|
|
69
|
+
"eslint-plugin-yml": "^1.16.0",
|
|
70
|
+
"@next/eslint-plugin-next": "^15.1.6",
|
|
88
71
|
"globals": "^16.4.0",
|
|
89
72
|
"lodash.has": "^4.5.2",
|
|
90
73
|
"prettier": "^3.6.2",
|
|
@@ -98,13 +81,34 @@
|
|
|
98
81
|
"lint-staged": "^16.1.6",
|
|
99
82
|
"typescript": "^5.9.2"
|
|
100
83
|
},
|
|
84
|
+
"engines": {
|
|
85
|
+
"node": ">=20.0.0"
|
|
86
|
+
},
|
|
87
|
+
"files": [
|
|
88
|
+
"dist",
|
|
89
|
+
"rules",
|
|
90
|
+
"index.js",
|
|
91
|
+
"prettier.js",
|
|
92
|
+
"dapp.js",
|
|
93
|
+
"docker.js",
|
|
94
|
+
"utils.js",
|
|
95
|
+
"commitlint.js"
|
|
96
|
+
],
|
|
97
|
+
"peerDependencies": {
|
|
98
|
+
"eslint": ">= 9"
|
|
99
|
+
},
|
|
100
|
+
"peerDependenciesMeta": {
|
|
101
|
+
"typescript": {
|
|
102
|
+
"optional": true
|
|
103
|
+
}
|
|
104
|
+
},
|
|
101
105
|
"commitlint": {
|
|
102
106
|
"extends": [
|
|
103
107
|
"./commitlint"
|
|
104
108
|
]
|
|
105
109
|
},
|
|
106
110
|
"lint-staged": {
|
|
107
|
-
"*.{json,yml}": [
|
|
111
|
+
"*.{json,css,md,yml}": [
|
|
108
112
|
"prettier --write --config ./prettier.js"
|
|
109
113
|
],
|
|
110
114
|
"*.md": [
|
package/rules/jest.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { defineConfig } from 'eslint/config';
|
|
2
2
|
import jest from 'eslint-plugin-jest';
|
|
3
|
+
import testingLibrary from 'eslint-plugin-testing-library';
|
|
4
|
+
|
|
5
|
+
import { ifAnyDep } from '../utils.js';
|
|
3
6
|
|
|
4
7
|
/**
|
|
5
8
|
* Jest ESLint configuration for flat config format
|
|
6
|
-
* Includes Jest-specific rules and
|
|
9
|
+
* Includes Jest-specific rules, globals, and Testing Library rules for test files
|
|
7
10
|
*/
|
|
8
11
|
export default defineConfig([
|
|
9
12
|
{
|
|
@@ -20,5 +23,13 @@ export default defineConfig([
|
|
|
20
23
|
],
|
|
21
24
|
|
|
22
25
|
...jest.configs['flat/recommended'],
|
|
26
|
+
|
|
27
|
+
...ifAnyDep('react-testing-library', testingLibrary.configs['flat/react'], {}),
|
|
28
|
+
...ifAnyDep('vue-testing-library', testingLibrary.configs['flat/vue'], {}),
|
|
29
|
+
|
|
30
|
+
rules: {
|
|
31
|
+
'no-console': 'off',
|
|
32
|
+
...ifAnyDep('tailwindcss', { 'tailwindcss/no-custom-classname': 'off' }, {}),
|
|
33
|
+
},
|
|
23
34
|
},
|
|
24
35
|
]);
|
package/rules/react.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import nextPlugin from '@next/eslint-plugin-next';
|
|
1
2
|
import { defineConfig } from 'eslint/config';
|
|
2
3
|
import jsxA11y from 'eslint-plugin-jsx-a11y';
|
|
3
4
|
import react from 'eslint-plugin-react';
|
|
4
5
|
import reactHooks from 'eslint-plugin-react-hooks';
|
|
5
6
|
import globals from 'globals';
|
|
6
7
|
|
|
8
|
+
import { ifAnyDep } from '../utils.js';
|
|
9
|
+
|
|
7
10
|
/**
|
|
8
11
|
* React ESLint configuration. Includes React, React Hooks, and JSX accessibility rules.
|
|
9
12
|
*
|
|
@@ -31,6 +34,18 @@ export default defineConfig([
|
|
|
31
34
|
// React Hooks configuration
|
|
32
35
|
reactHooks.configs['recommended-latest'],
|
|
33
36
|
|
|
37
|
+
// Next.js configuration (dynamic)
|
|
38
|
+
ifAnyDep(
|
|
39
|
+
'next',
|
|
40
|
+
{
|
|
41
|
+
...nextPlugin.flatConfig.recommended,
|
|
42
|
+
...nextPlugin.flatConfig.coreWebVitals,
|
|
43
|
+
|
|
44
|
+
name: 'codfish/next',
|
|
45
|
+
},
|
|
46
|
+
{},
|
|
47
|
+
),
|
|
48
|
+
|
|
34
49
|
{
|
|
35
50
|
rules: {
|
|
36
51
|
'react-hooks/exhaustive-deps': 'off',
|
package/rules/vitest.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import vitest from '@vitest/eslint-plugin';
|
|
2
2
|
import { defineConfig } from 'eslint/config';
|
|
3
|
+
import testingLibrary from 'eslint-plugin-testing-library';
|
|
3
4
|
import globals from 'globals';
|
|
4
5
|
|
|
6
|
+
import { ifAnyDep } from '../utils.js';
|
|
7
|
+
|
|
5
8
|
/**
|
|
6
9
|
* Vitest ESLint configuration for flat config format
|
|
7
|
-
* Includes Vitest-specific rules and
|
|
10
|
+
* Includes Vitest-specific rules, globals, and Testing Library rules for test files
|
|
8
11
|
*/
|
|
9
12
|
export default defineConfig([
|
|
10
13
|
{
|
|
@@ -17,6 +20,9 @@ export default defineConfig([
|
|
|
17
20
|
|
|
18
21
|
...vitest.configs.recommended,
|
|
19
22
|
|
|
23
|
+
...ifAnyDep('react-testing-library', testingLibrary.configs['flat/react'], {}),
|
|
24
|
+
...ifAnyDep('vue-testing-library', testingLibrary.configs['flat/vue'], {}),
|
|
25
|
+
|
|
20
26
|
name: 'codfish/vitest',
|
|
21
27
|
|
|
22
28
|
languageOptions: {
|
|
@@ -28,7 +34,7 @@ export default defineConfig([
|
|
|
28
34
|
|
|
29
35
|
rules: {
|
|
30
36
|
'no-console': 'off',
|
|
31
|
-
'tailwindcss/no-custom-classname': 'off',
|
|
37
|
+
...ifAnyDep('tailwindcss', { 'tailwindcss/no-custom-classname': 'off' }, {}),
|
|
32
38
|
},
|
|
33
39
|
},
|
|
34
40
|
]);
|