@codfish/eslint-config 0.0.0-PR-155--2a9a213 → 0.0.0-PR-124--4943524
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 +57 -456
- package/dist/dapp.d.ts +1 -1
- package/dist/docker.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/rules/config-files.d.ts +1 -1
- package/dist/rules/jest.d.ts +3 -0
- package/dist/rules/jest.d.ts.map +1 -0
- package/dist/rules/react.d.ts +1 -1
- package/dist/rules/vitest.d.ts +3 -0
- package/dist/rules/vitest.d.ts.map +1 -0
- package/dist/utils.d.ts +0 -5
- package/dist/utils.d.ts.map +1 -1
- package/index.js +27 -183
- package/package.json +56 -71
- package/rules/jest.js +24 -0
- package/rules/react.js +7 -54
- package/rules/vitest.js +34 -0
- package/utils.js +5 -13
- package/dist/rules/tests.d.ts +0 -3
- package/dist/rules/tests.d.ts.map +0 -1
- package/dist/rules/typescript.d.ts +0 -38
- package/dist/rules/typescript.d.ts.map +0 -1
- package/dist/tests/integration/eslint-execution.spec.d.ts +0 -2
- package/dist/tests/integration/eslint-execution.spec.d.ts.map +0 -1
- package/dist/tests/integration/react-integration.spec.d.ts +0 -2
- package/dist/tests/integration/react-integration.spec.d.ts.map +0 -1
- package/dist/tests/integration/rule-application.spec.d.ts +0 -2
- package/dist/tests/integration/rule-application.spec.d.ts.map +0 -1
- package/dist/tests/scenarios/edge-cases.spec.d.ts +0 -2
- package/dist/tests/scenarios/edge-cases.spec.d.ts.map +0 -1
- package/dist/tests/unit/config-loading.spec.d.ts +0 -2
- package/dist/tests/unit/config-loading.spec.d.ts.map +0 -1
- package/dist/tests/unit/dynamic-detection.spec.d.ts +0 -2
- package/dist/tests/unit/dynamic-detection.spec.d.ts.map +0 -1
- package/dist/tests/unit/utils.spec.d.ts +0 -2
- package/dist/tests/unit/utils.spec.d.ts.map +0 -1
- package/dist/vitest.config.d.ts +0 -3
- package/dist/vitest.config.d.ts.map +0 -1
- package/rules/tests.js +0 -52
- package/rules/typescript.js +0 -56
package/README.md
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
# @codfish/eslint-config
|
|
2
2
|
|
|
3
|
-
> Modern ESLint configuration with TypeScript, React
|
|
4
|
-
> ESLint v10+ flat config format.
|
|
3
|
+
> Modern ESLint configuration with TypeScript, React, and testing framework support using ESLint v9+ flat config format.
|
|
5
4
|
|
|
6
5
|
[](http://npm.im/@codfish/eslint-config)
|
|
7
6
|
[](http://npm-stat.com/charts.html?package=@codfish/eslint-config&from=2015-08-01)
|
|
@@ -9,79 +8,52 @@
|
|
|
9
8
|
[](https://github.com/semantic-release/semantic-release)
|
|
10
9
|
[](http://commitizen.github.io/cz-cli/)
|
|
11
10
|
|
|
12
|
-
<!-- prettier-ignore-start -->
|
|
13
11
|
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
|
|
14
12
|
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
|
15
13
|
## Table of Contents
|
|
16
14
|
|
|
17
15
|
- [Features](#features)
|
|
16
|
+
- [Automatic Configuration](#automatic-configuration)
|
|
18
17
|
- [Installation](#installation)
|
|
19
18
|
- [Usage](#usage)
|
|
20
|
-
- [
|
|
21
|
-
- [
|
|
22
|
-
- [
|
|
23
|
-
- [
|
|
24
|
-
|
|
25
|
-
- [Example scripts](#example-scripts)
|
|
26
|
-
- [Commitlint Configuration](#commitlint-configuration)
|
|
27
|
-
- [Upgrading to ESLint 10](#upgrading-to-eslint-10)
|
|
28
|
-
- [Breaking Changes in ESLint 10](#breaking-changes-in-eslint-10)
|
|
29
|
-
- [Migration Steps](#migration-steps)
|
|
30
|
-
- [What Changed](#what-changed)
|
|
19
|
+
- [Prettier](#prettier)
|
|
20
|
+
- [With dApps](#with-dapps)
|
|
21
|
+
- [Docker Configuration](#docker-configuration)
|
|
22
|
+
- [Blockchain/dApp Configuration](#blockchaindapp-configuration)
|
|
23
|
+
- [Known issues](#known-issues)
|
|
31
24
|
- [Migration from Legacy Config](#migration-from-legacy-config)
|
|
32
25
|
|
|
33
26
|
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
|
34
|
-
<!-- prettier-ignore-end -->
|
|
35
27
|
|
|
36
28
|
## Features
|
|
37
29
|
|
|
38
|
-
- **Modern ESLint
|
|
30
|
+
- **Modern ESLint v9+ flat config**: Uses the new flat configuration format
|
|
39
31
|
- **Dynamic feature detection**: Automatically configures based on your project's dependencies
|
|
40
32
|
- **TypeScript support**: Full TypeScript linting with modern typescript-eslint parser and rules
|
|
41
33
|
- **React ecosystem**: React, React Hooks, and JSX accessibility rules when React is detected
|
|
42
|
-
- **Next.js support**: Automatically configures Next.js official plugin linting rules when detected
|
|
43
34
|
- **Test framework agnostic**: Supports Jest and Vitest with automatic detection
|
|
44
|
-
- **Testing Library integration**: Automatically includes Testing Library rules for test files
|
|
45
|
-
- **Multi-format support**: Built-in linting and formatting for Markdown, HTML, JSON, YAML/YML files
|
|
46
35
|
- **Prettier integration**: Built-in Prettier configuration with conflict resolution via eslint-config-prettier
|
|
47
36
|
- **ESM architecture**: Built with ECMAScript modules and full TypeScript typing
|
|
48
37
|
- **Docker support**: Optional configuration for dockerized applications
|
|
49
38
|
- **Blockchain/dApp support**: Optional configuration for decentralized applications
|
|
50
39
|
|
|
40
|
+
### Automatic Configuration
|
|
41
|
+
|
|
42
|
+
The config automatically detects and configures:
|
|
43
|
+
|
|
44
|
+
- **React**: Includes React, React Hooks, and JSX a11y rules when `react` is installed
|
|
45
|
+
- **Jest**: Configures Jest-specific rules when `jest` is found in dependencies
|
|
46
|
+
- **Vitest**: Configures Vitest-specific rules when `vitest` is detected
|
|
47
|
+
- **Prettier**: Loads your project's Prettier config or falls back to built-in defaults
|
|
48
|
+
|
|
51
49
|
## Installation
|
|
52
50
|
|
|
53
51
|
Install the package and required peer dependencies:
|
|
54
52
|
|
|
55
53
|
```sh
|
|
56
|
-
npm i -D
|
|
57
|
-
|
|
58
|
-
# Optionally, you can uninstall plugins or presets you don't need to manage anymore,
|
|
59
|
-
# @codfish/eslint-config includes them all.
|
|
60
|
-
npm uninstall typescript-eslint \
|
|
61
|
-
eslint-config-prettier \
|
|
62
|
-
eslint-plugin-jest \
|
|
63
|
-
eslint-plugin-jsx-a11y \
|
|
64
|
-
eslint-plugin-prettier \
|
|
65
|
-
eslint-plugin-react \
|
|
66
|
-
eslint-plugin-react-hooks \
|
|
67
|
-
@tanstack/eslint-plugin-query \
|
|
68
|
-
eslint-plugin-simple-import-sort \
|
|
69
|
-
eslint-plugin-testing-library \
|
|
70
|
-
eslint-plugin-yml \
|
|
71
|
-
@next/eslint-plugin-next \
|
|
72
|
-
eslint-plugin-next \
|
|
73
|
-
commitlint \
|
|
74
|
-
@commitlint/cli \
|
|
75
|
-
@commitlint/config-conventional \
|
|
76
|
-
prettier # optional, see note
|
|
54
|
+
npm i -D @codfish/eslint-config eslint@9
|
|
77
55
|
```
|
|
78
56
|
|
|
79
|
-
> [!NOTE]
|
|
80
|
-
>
|
|
81
|
-
> ESLint now handles linting and formatting for JavaScript, TypeScript, Markdown, HTML, JSON, and YAML files
|
|
82
|
-
> automatically. If you want to format additional file types (like CSS, SCSS, etc.), you can leave Prettier installed as
|
|
83
|
-
> a dev dependency in your project.
|
|
84
|
-
|
|
85
57
|
## Usage
|
|
86
58
|
|
|
87
59
|
Create an `eslint.config.js` file in your project root:
|
|
@@ -90,128 +62,57 @@ Create an `eslint.config.js` file in your project root:
|
|
|
90
62
|
import { defineConfig } from 'eslint/config';
|
|
91
63
|
import codfish from '@codfish/eslint-config';
|
|
92
64
|
|
|
93
|
-
export default defineConfig(
|
|
94
|
-
codfish,
|
|
95
|
-
|
|
65
|
+
export default defineConfig([
|
|
96
66
|
{
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
'import/prefer-default-export': 'off',
|
|
101
|
-
'@typescript-eslint/explicit-function-return-type': 'warn',
|
|
102
|
-
},
|
|
67
|
+
files: ['**/*.{js,jsx,ts,tsx}'],
|
|
68
|
+
extends: [codfish],
|
|
69
|
+
// Your overrides here
|
|
103
70
|
},
|
|
104
|
-
);
|
|
71
|
+
]);
|
|
105
72
|
```
|
|
106
73
|
|
|
107
74
|
> [!IMPORTANT] If you get ES module errors, you may need to set the `type` field in your `package.json` to `module` or
|
|
108
75
|
> rename your config file to `eslint.config.mjs`.
|
|
109
76
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
```js
|
|
113
|
-
import codfish from '@codfish/eslint-config';
|
|
114
|
-
|
|
115
|
-
export default defineConfig({
|
|
116
|
-
extends: [codfish],
|
|
117
|
-
rules: {
|
|
118
|
-
// temporary
|
|
119
|
-
'@typescript-eslint/no-explicit-any': 'off',
|
|
120
|
-
},
|
|
121
|
-
});
|
|
122
|
-
```
|
|
77
|
+
### Prettier
|
|
123
78
|
|
|
124
|
-
|
|
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:
|
|
125
82
|
|
|
126
|
-
|
|
127
|
-
>
|
|
128
|
-
> **Not recommended.** This will prevent it from using the `files` specified in the main config, so rules around test
|
|
129
|
-
> files, yml files, etc. will not be applied.
|
|
83
|
+
**prettier.config.js**
|
|
130
84
|
|
|
131
85
|
```js
|
|
132
|
-
import
|
|
133
|
-
|
|
134
|
-
export default defineConfig({
|
|
135
|
-
files: ['**/*.{js,jsx,ts,tsx}'],
|
|
136
|
-
extends: [codfish],
|
|
137
|
-
rules: {
|
|
138
|
-
// temporary
|
|
139
|
-
'@typescript-eslint/no-explicit-any': 'off',
|
|
140
|
-
},
|
|
141
|
-
});
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
**Not using the `defineConfig` function, just spread the config object:**
|
|
86
|
+
import codfishConfig from '@codfish/eslint-config/prettier.js';
|
|
145
87
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
88
|
+
/**
|
|
89
|
+
* @see https://prettier.io/docs/en/configuration.html
|
|
90
|
+
* @type {import("prettier").Config}
|
|
91
|
+
*/
|
|
92
|
+
const config = {
|
|
93
|
+
...codfishConfig,
|
|
94
|
+
// your overrides here
|
|
95
|
+
};
|
|
151
96
|
|
|
152
|
-
|
|
153
|
-
// Your project-specific overrides
|
|
154
|
-
rules: {
|
|
155
|
-
// Override or add specific rules
|
|
156
|
-
'no-console': 'warn',
|
|
157
|
-
'@typescript-eslint/no-unused-vars': 'error',
|
|
158
|
-
},
|
|
159
|
-
},
|
|
160
|
-
];
|
|
97
|
+
export default config;
|
|
161
98
|
```
|
|
162
99
|
|
|
163
|
-
|
|
100
|
+
### With dApps
|
|
164
101
|
|
|
165
|
-
|
|
166
|
-
|
|
102
|
+
Similar to the issues with docker, there may be rules you want to adjust for dApp's. This config will set some globals
|
|
103
|
+
as well as ignore missing build artifact imports. While you obviously need those to run your app, sometimes you might
|
|
104
|
+
want to run the linter in a ci/cd environment and build artifacts might not be present.
|
|
167
105
|
|
|
168
|
-
|
|
169
|
-
```
|
|
106
|
+
**Note**: The dApp config also includes the `import/no-unresolved` rule found in the docker config.
|
|
170
107
|
|
|
171
|
-
|
|
108
|
+
You can also directly import the Prettier config:
|
|
172
109
|
|
|
173
110
|
```js
|
|
174
|
-
import
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
export default defineConfig(
|
|
178
|
-
codfish,
|
|
179
|
-
|
|
180
|
-
// Custom ignores
|
|
181
|
-
{
|
|
182
|
-
ignores: ['some-directory'],
|
|
183
|
-
},
|
|
184
|
-
|
|
185
|
-
{
|
|
186
|
-
files: ['**/*.spec.{js,ts,jsx,tsx}'],
|
|
187
|
-
rules: {
|
|
188
|
-
// Allow any in test files
|
|
189
|
-
'@typescript-eslint/no-explicit-any': 'off',
|
|
190
|
-
// Relax Testing Library rules if needed
|
|
191
|
-
'testing-library/prefer-screen-queries': 'warn',
|
|
192
|
-
},
|
|
193
|
-
},
|
|
194
|
-
|
|
195
|
-
{
|
|
196
|
-
files: ['**/*.config.{js,ts}'],
|
|
197
|
-
rules: {
|
|
198
|
-
// Allow require in config files
|
|
199
|
-
'@typescript-eslint/no-require-imports': 'off',
|
|
200
|
-
},
|
|
201
|
-
},
|
|
202
|
-
|
|
203
|
-
{
|
|
204
|
-
files: ['**/*.{js,jsx,ts,tsx}'],
|
|
205
|
-
rules: {
|
|
206
|
-
// Customize Next.js rules
|
|
207
|
-
'@next/next/no-img-element': 'warn',
|
|
208
|
-
'@next/next/no-html-link-for-pages': 'off',
|
|
209
|
-
},
|
|
210
|
-
},
|
|
211
|
-
);
|
|
111
|
+
import prettierConfig from '@codfish/eslint-config/prettier';
|
|
112
|
+
export default prettierConfig;
|
|
212
113
|
```
|
|
213
114
|
|
|
214
|
-
|
|
115
|
+
### Docker Configuration
|
|
215
116
|
|
|
216
117
|
For projects leveraging Docker containers, you may want to disable import resolution errors for `node_modules` if
|
|
217
118
|
packages are only available in the container but you're running the linter locally.
|
|
@@ -230,15 +131,13 @@ export default defineConfig(
|
|
|
230
131
|
);
|
|
231
132
|
```
|
|
232
133
|
|
|
233
|
-
|
|
134
|
+
### Blockchain/dApp Configuration
|
|
234
135
|
|
|
235
|
-
For decentralized applications that use build artifacts and blockchain globals, use the specialized dApp config
|
|
236
|
-
config will set some globals as well as ignore missing build artifact imports. While you obviously need those to run
|
|
237
|
-
your app, sometimes you might want to run the linter in a ci/cd environment and build artifacts might not be present.
|
|
136
|
+
For decentralized applications that use build artifacts and blockchain globals, use the specialized dApp config:
|
|
238
137
|
|
|
239
138
|
```js
|
|
240
139
|
import codfish from '@codfish/eslint-config';
|
|
241
|
-
import
|
|
140
|
+
import dappConfig from '@codfish/eslint-config/dapp';
|
|
242
141
|
|
|
243
142
|
export default defineConfig(
|
|
244
143
|
codfish,
|
|
@@ -256,321 +155,23 @@ The dApp configuration provides:
|
|
|
256
155
|
- Import resolution handling for smart contract build artifacts
|
|
257
156
|
- Relaxed rules for generated contract files
|
|
258
157
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
This configuration includes some opinionated settings that you might want to customize for your project:
|
|
262
|
-
|
|
263
|
-
**Prettier/Formatting:**
|
|
264
|
-
|
|
265
|
-
- **Semicolons**: Enforces semicolons (`;`)
|
|
266
|
-
- **120 character line width**: Wider than the common 80/100 - you might prefer shorter lines
|
|
267
|
-
- **2-space indentation**: Uses 2 spaces for tabs
|
|
268
|
-
- **Single quotes**: Prefers `'single'` over `"double"` quotes
|
|
269
|
-
- **Trailing commas**: Adds trailing commas everywhere
|
|
270
|
-
- **Arrow parentheses**: Avoids parens around single args (`x => x` not `(x) => x`)
|
|
271
|
-
|
|
272
|
-
**ESLint Rules:**
|
|
273
|
-
|
|
274
|
-
- **Import sorting**: Enforces automatic import organization with specific grouping rules
|
|
275
|
-
- **Lodash restrictions**: Requires direct imports (`import get from 'lodash-es/get'`) instead of full lodash
|
|
276
|
-
- **React hooks deps**: Disables `exhaustive-deps` rule - you might want this stricter
|
|
277
|
-
- **Console statements**: Disallows `console.log` in regular code (only allowed in test files) - some teams prefer
|
|
278
|
-
warnings instead of errors
|
|
279
|
-
- **Next.js rules**: Enforces Next.js best practices and Core Web Vitals optimization
|
|
280
|
-
- **Testing Library rules**: Enforces Testing Library best practices in test files
|
|
281
|
-
|
|
282
|
-
**File Ignores:**
|
|
283
|
-
|
|
284
|
-
- Ignores common build directories (`.next`, `coverage`, `.vercel`, etc.)
|
|
285
|
-
- Includes `.github` and `.vitepress` folders (not ignored like most configs)
|
|
286
|
-
|
|
287
|
-
See the [configuration examples below](#usage) for instructions on overriding these settings to match your team's
|
|
288
|
-
preferences.
|
|
289
|
-
|
|
290
|
-
## IDE Setup
|
|
291
|
-
|
|
292
|
-
### VS Code / Cursor
|
|
293
|
-
|
|
294
|
-
For the best development experience with VS Code or Cursor (or any VS Code-based IDE), install the
|
|
295
|
-
[ESLint extension](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) and configure it to
|
|
296
|
-
auto-fix on save:
|
|
297
|
-
|
|
298
|
-
Add these settings to your `.vscode/settings.json` or user settings:
|
|
299
|
-
|
|
300
|
-
```json
|
|
301
|
-
{
|
|
302
|
-
"editor.codeActionsOnSave": {
|
|
303
|
-
"source.fixAll": "explicit"
|
|
304
|
-
},
|
|
305
|
-
"eslint.validate": [
|
|
306
|
-
"javascript",
|
|
307
|
-
"javascriptreact",
|
|
308
|
-
"typescript",
|
|
309
|
-
"typescriptreact",
|
|
310
|
-
"markdown",
|
|
311
|
-
"json",
|
|
312
|
-
"jsonc",
|
|
313
|
-
"html",
|
|
314
|
-
"yml",
|
|
315
|
-
"yaml"
|
|
316
|
-
]
|
|
317
|
-
}
|
|
318
|
-
```
|
|
319
|
-
|
|
320
|
-
This configuration enables:
|
|
321
|
-
|
|
322
|
-
- Automatic linting and formatting on save for all supported file types
|
|
323
|
-
- ESLint validation for Markdown, JSON, YAML, and HTML files
|
|
324
|
-
- A unified development experience across your entire codebase
|
|
325
|
-
|
|
326
|
-
## Prettier Configuration
|
|
327
|
-
|
|
328
|
-
**Prettier is included and runs automatically** through ESLint for JavaScript, TypeScript, JSX, TSX, Markdown, HTML,
|
|
329
|
-
JSON, and YAML files using the [built-in configuration](./prettier.js). **You don't need to install or configure
|
|
330
|
-
Prettier separately** for these file types.
|
|
331
|
-
|
|
332
|
-
You can then override the default config by creating your own Prettier config file, or extend the built-in config:
|
|
333
|
-
|
|
334
|
-
**Option 1: Extend the built-in config (Recommended)**
|
|
335
|
-
|
|
336
|
-
Create a `prettier.config.js` file in your project root:
|
|
337
|
-
|
|
338
|
-
```js
|
|
339
|
-
// prettier.config.js
|
|
340
|
-
|
|
341
|
-
import codfishConfig from '@codfish/eslint-config/prettier';
|
|
342
|
-
|
|
343
|
-
/**
|
|
344
|
-
* @see https://prettier.io/docs/en/configuration.html
|
|
345
|
-
* @type {import("prettier").Config}
|
|
346
|
-
*/
|
|
347
|
-
export default {
|
|
348
|
-
...codfishConfig,
|
|
349
|
-
|
|
350
|
-
// Override specific settings
|
|
351
|
-
printWidth: 80,
|
|
352
|
-
singleQuote: false,
|
|
353
|
-
tabWidth: 4,
|
|
354
|
-
trailingComma: 'none',
|
|
355
|
-
};
|
|
356
|
-
```
|
|
357
|
-
|
|
358
|
-
**Option 2: Completely custom config**
|
|
359
|
-
|
|
360
|
-
This config will completely override the built-in config.
|
|
361
|
-
|
|
362
|
-
```js
|
|
363
|
-
// prettier.config.js
|
|
364
|
-
|
|
365
|
-
/**
|
|
366
|
-
* @see https://prettier.io/docs/en/configuration.html
|
|
367
|
-
* @type {import("prettier").Config}
|
|
368
|
-
*/
|
|
369
|
-
export default {
|
|
370
|
-
printWidth: 100,
|
|
371
|
-
tabWidth: 2,
|
|
372
|
-
useTabs: false,
|
|
373
|
-
semi: true,
|
|
374
|
-
singleQuote: true,
|
|
375
|
-
trailingComma: 'all',
|
|
376
|
-
bracketSpacing: true,
|
|
377
|
-
bracketSameLine: false,
|
|
378
|
-
arrowParens: 'avoid',
|
|
379
|
-
proseWrap: 'always',
|
|
380
|
-
};
|
|
381
|
-
```
|
|
382
|
-
|
|
383
|
-
### Use in combination with prettier-plugin-tailwindcss
|
|
384
|
-
|
|
385
|
-
```sh
|
|
386
|
-
npm i -D eslint@10 @codfish/eslint-config prettier-plugin-tailwindcss
|
|
387
|
-
```
|
|
388
|
-
|
|
389
|
-
```js
|
|
390
|
-
// prettier.config.js
|
|
391
|
-
|
|
392
|
-
import codfish from '@codfish/eslint-config/prettier';
|
|
393
|
-
|
|
394
|
-
/** @type {import('prettier').Config & import('prettier-plugin-tailwindcss').PluginOptions} */
|
|
395
|
-
export default {
|
|
396
|
-
...codfish,
|
|
397
|
-
plugins: ['prettier-plugin-tailwindcss'],
|
|
398
|
-
tailwindStylesheet: './src/styles/app.css',
|
|
399
|
-
tailwindFunctions: ['clsx'], // optional
|
|
400
|
-
};
|
|
401
|
-
```
|
|
402
|
-
|
|
403
|
-
## Example scripts
|
|
404
|
-
|
|
405
|
-
Optionally, you can add these scripts to your `package.json` for common linting workflows:
|
|
406
|
-
|
|
407
|
-
**Recommended scripts:**
|
|
408
|
-
|
|
409
|
-
```json
|
|
410
|
-
{
|
|
411
|
-
"scripts": {
|
|
412
|
-
"lint": "eslint .",
|
|
413
|
-
"fix": "eslint . --fix"
|
|
414
|
-
},
|
|
415
|
-
"lint-staged": {
|
|
416
|
-
"*.{js,jsx,ts,tsx,md,json,yml,yaml,html}": ["eslint --fix"]
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
```
|
|
420
|
-
|
|
421
|
-
> [!NOTE]
|
|
422
|
-
>
|
|
423
|
-
> ESLint now handles linting and formatting for JavaScript, TypeScript, Markdown, HTML, JSON, and YAML files. You don't
|
|
424
|
-
> need to run Prettier separately for these file types.
|
|
425
|
-
|
|
426
|
-
**With Prettier for other file types (CSS, SCSS, etc.):**
|
|
158
|
+
## Known issues
|
|
427
159
|
|
|
428
|
-
|
|
429
|
-
these scripts:
|
|
160
|
+
> https://github.com/francoismassart/eslint-plugin-tailwindcss/issues/149
|
|
430
161
|
|
|
431
|
-
|
|
432
|
-
{
|
|
433
|
-
"scripts": {
|
|
434
|
-
"lint": "eslint .",
|
|
435
|
-
"fix": "eslint . --fix",
|
|
436
|
-
"format": "prettier --write \"**/*.{css,scss}\"",
|
|
437
|
-
"check": "npm run lint && npm run format -- --check --no-write"
|
|
438
|
-
},
|
|
439
|
-
"lint-staged": {
|
|
440
|
-
"*.{js,jsx,ts,tsx,md,json,yml,yaml,html}": ["eslint --fix"],
|
|
441
|
-
"*.{css,scss}": ["prettier --write"]
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
```
|
|
445
|
-
|
|
446
|
-
## Commitlint Configuration
|
|
447
|
-
|
|
448
|
-
Extend from the shared codfish commitlint config.
|
|
449
|
-
|
|
450
|
-
```js
|
|
451
|
-
import codfishConfig from '@codfish/eslint-config/commitlint.js';
|
|
452
|
-
|
|
453
|
-
export default Object.assign(codfishConfig, {
|
|
454
|
-
// your overrides here
|
|
455
|
-
rules: {
|
|
456
|
-
'scope-case': [1],
|
|
457
|
-
},
|
|
458
|
-
});
|
|
459
|
-
```
|
|
460
|
-
|
|
461
|
-
**Or just reference it in your package.json:**
|
|
462
|
-
|
|
463
|
-
```json
|
|
464
|
-
{
|
|
465
|
-
"commitlint": {
|
|
466
|
-
"extends": ["./node_modules/@codfish/eslint-config/commitlint.js"]
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
```
|
|
470
|
-
|
|
471
|
-
Run commitlint in your CI to validate your commits:
|
|
472
|
-
|
|
473
|
-
> [!NOTE]
|
|
474
|
-
>
|
|
475
|
-
> If you have @codfish/eslint-config as a dev dependency, and a commitlint config in your project, you can just call
|
|
476
|
-
> `npx commitlint` in your CI and it will use the shared config.
|
|
477
|
-
>
|
|
478
|
-
> - You just need to setup node & install your dependencies before running commitlint.
|
|
479
|
-
> - Don't forget to set the `fetch-depth` to `0` to ensure commitlint can work properly.
|
|
480
|
-
|
|
481
|
-
```yaml
|
|
482
|
-
# .github/workflows/validate.yml
|
|
483
|
-
|
|
484
|
-
on: pull_request_target
|
|
485
|
-
|
|
486
|
-
jobs:
|
|
487
|
-
validate:
|
|
488
|
-
runs-on: ubuntu-latest
|
|
489
|
-
|
|
490
|
-
steps:
|
|
491
|
-
- uses: actions/checkout@v5
|
|
492
|
-
with:
|
|
493
|
-
ref: ${{ github.event.pull_request.head.sha || github.ref }}
|
|
494
|
-
fetch-depth: 0 # Important for commitlint to work
|
|
495
|
-
|
|
496
|
-
- uses: actions/setup-node@v5
|
|
497
|
-
with:
|
|
498
|
-
node-version: lts/*
|
|
499
|
-
registry-url: https://registry.npmjs.org
|
|
162
|
+
When building dynamic classes, the auto sorting of tailwind classes can break things so beware.
|
|
500
163
|
|
|
501
|
-
|
|
164
|
+
To avoid this happening you can re-wrap the dynamic class expression like so:
|
|
502
165
|
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
--verbose
|
|
166
|
+
```vue-html
|
|
167
|
+
class="`p-0 ${`tw-border-${accentColor}`}`"
|
|
506
168
|
```
|
|
507
169
|
|
|
508
|
-
## Upgrading to ESLint 10
|
|
509
|
-
|
|
510
|
-
This package now requires **ESLint 10.0.0 or higher** and **Node.js v20.19.0 or higher**.
|
|
511
|
-
|
|
512
|
-
### Breaking Changes in ESLint 10
|
|
513
|
-
|
|
514
|
-
- **ESLint 10 Required**: Minimum ESLint version is now 10.0.0
|
|
515
|
-
- **Node.js v20.19.0+**: Minimum Node.js version increased from v20.0.0 to v20.19.0
|
|
516
|
-
- **Legacy eslintrc removed**: ESLint 10 completely removes the deprecated eslintrc config system (this package already
|
|
517
|
-
uses flat config)
|
|
518
|
-
- **Improved JSX tracking**: ESLint 10 properly tracks JSX references in scope analysis, which may surface previously
|
|
519
|
-
hidden unused import warnings in React files
|
|
520
|
-
- **New recommended rules**: Three new rules enabled in `eslint:recommended`:
|
|
521
|
-
- `no-unassigned-vars` - Disallow variables that are assigned but never used
|
|
522
|
-
- `no-useless-assignment` - Disallow assignments that don't change the value
|
|
523
|
-
- `preserve-caught-error` - Enforce that caught errors are not reassigned
|
|
524
|
-
|
|
525
|
-
### Migration Steps
|
|
526
|
-
|
|
527
|
-
1. **Update Node.js** (if needed):
|
|
528
|
-
|
|
529
|
-
```sh
|
|
530
|
-
node --version # Ensure you're on v20.19.0+ or v22.13.0+
|
|
531
|
-
```
|
|
532
|
-
|
|
533
|
-
2. **Update ESLint and this config**:
|
|
534
|
-
|
|
535
|
-
```sh
|
|
536
|
-
npm install --save-dev eslint@10 @codfish/eslint-config@latest
|
|
537
|
-
```
|
|
538
|
-
|
|
539
|
-
3. **Install dependencies with legacy peer deps** (required until all plugins update):
|
|
540
|
-
|
|
541
|
-
```sh
|
|
542
|
-
npm install --legacy-peer-deps
|
|
543
|
-
```
|
|
544
|
-
|
|
545
|
-
This is necessary because some ESLint plugins haven't updated their `peerDependencies` to include ESLint 10 yet. The
|
|
546
|
-
plugins still work correctly with ESLint 10.
|
|
547
|
-
|
|
548
|
-
4. **Run linting** and check for new violations:
|
|
549
|
-
|
|
550
|
-
```sh
|
|
551
|
-
npm run lint
|
|
552
|
-
```
|
|
553
|
-
|
|
554
|
-
5. **Review React files** for newly reported unused imports. ESLint 10's improved JSX tracking may flag imports that
|
|
555
|
-
were previously ignored but are actually used in JSX.
|
|
556
|
-
|
|
557
|
-
### What Changed
|
|
558
|
-
|
|
559
|
-
Since this package already uses ESLint's flat config format (the biggest change in ESLint 9), the upgrade to ESLint 10
|
|
560
|
-
is relatively smooth. The main changes are:
|
|
561
|
-
|
|
562
|
-
- ✅ Flat config format (already implemented)
|
|
563
|
-
- ✅ Plugin configurations updated to ESLint 10-compatible versions
|
|
564
|
-
- ✅ All tests passing with ESLint 10
|
|
565
|
-
- ⚠️ Some plugins show peer dependency warnings but work correctly (ecosystem is catching up)
|
|
566
|
-
|
|
567
|
-
For more details, see the [ESLint 10 Migration Guide](https://eslint.org/docs/latest/use/migrate-to-10.0.0).
|
|
568
|
-
|
|
569
170
|
## Migration from Legacy Config
|
|
570
171
|
|
|
571
172
|
If you're upgrading from an older version that used Airbnb presets:
|
|
572
173
|
|
|
573
|
-
1. **Update to ESLint
|
|
174
|
+
1. **Update to ESLint v9+**: `npm install --save-dev eslint@9`
|
|
574
175
|
2. **Switch to flat config**: Replace `.eslintrc.js` with `eslint.config.js`
|
|
575
176
|
3. **Use import syntax**: Change from `require()` to `import` statements
|
|
576
177
|
4. **Remove explicit React config**: React support is now automatically detected
|
package/dist/dapp.d.ts
CHANGED
package/dist/docker.d.ts
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jest.d.ts","sourceRoot":"","sources":["../../rules/jest.js"],"names":[],"mappings":""}
|
package/dist/rules/react.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vitest.d.ts","sourceRoot":"","sources":["../../rules/vitest.js"],"names":[],"mappings":""}
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Get the version of a dependency from the consumer's package.json.
|
|
3
|
-
* Returns the major version as a string (e.g. '18', '19'), or null if not found.
|
|
4
|
-
*/
|
|
5
|
-
export function getDepVersion(dep: any): string | null;
|
|
6
1
|
export function hasLocalConfig(moduleName: any, searchOptions?: {}): boolean;
|
|
7
2
|
export function hasDep(props: any): boolean;
|
|
8
3
|
export function hasDevDep(props: any): boolean;
|
package/dist/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../utils.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../utils.js"],"names":[],"mappings":"AA4BA,6EAKC;AAfgC,4CAA+D;AAA/D,+CAA+D;AAA/D,gDAA+D;AAMzF,8CAA8E;AAE9E,yDAAmE"}
|