@viclafouch/eslint-config-viclafouch 4.22.1-beta.1 → 4.22.1-beta.2
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/.claude/settings.local.json +16 -0
- package/CLAUDE.md +165 -0
- package/eslint.config.mjs +3 -0
- package/index.mjs +5 -5
- package/next.mjs +4 -12
- package/package.json +17 -17
- package/rules/best-practices.mjs +125 -1
- package/rules/node.mjs +1 -0
- package/rules/react-hooks.mjs +2 -10
- package/rules/typescript.mjs +9 -1
- package/tsconfig.json +1 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"permissions": {
|
|
3
|
+
"allow": [
|
|
4
|
+
"Bash(npm run lint)",
|
|
5
|
+
"Bash(npm outdated:*)",
|
|
6
|
+
"WebFetch(domain:github.com)",
|
|
7
|
+
"WebFetch(domain:typescript-eslint.io)",
|
|
8
|
+
"WebFetch(domain:www.npmjs.com)",
|
|
9
|
+
"Bash(npm install:*)",
|
|
10
|
+
"Bash(npm view:*)",
|
|
11
|
+
"Bash(node -e:*)",
|
|
12
|
+
"Bash(git add:*)",
|
|
13
|
+
"Bash(git commit -m \"$\\(cat <<''EOF''\nfeat: update dependencies and refactor next config to flat config\n\n- Update all dependencies to latest versions\n- Refactor next.mjs to use nextPlugin.configs.recommended directly\n- Remove @eslint/eslintrc FlatCompat dependency\n- Reorganize exports alphabetically in index.mjs\n- Add ignores for *.d.ts files in eslint.config.mjs\n- Add coding conventions section to CLAUDE.md\n\nCo-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>\nEOF\n\\)\")"
|
|
14
|
+
]
|
|
15
|
+
}
|
|
16
|
+
}
|
package/CLAUDE.md
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
This file documents the **@viclafouch/eslint-config-viclafouch** project to facilitate working with Claude Code.
|
|
4
|
+
|
|
5
|
+
## What is this project?
|
|
6
|
+
|
|
7
|
+
This is a reusable ESLint and Prettier configuration package published on npm. It provides a comprehensive, modular set of linting and formatting rules designed for modern JavaScript/TypeScript projects. The goal is to share consistent code quality standards across all of Victor de la Fouchardiere's projects.
|
|
8
|
+
|
|
9
|
+
**Key features:**
|
|
10
|
+
- JavaScript ES6+, TypeScript, JSX/TSX support
|
|
11
|
+
- React.js and Next.js frameworks
|
|
12
|
+
- Tailwind CSS v4 linting
|
|
13
|
+
- Testing libraries support
|
|
14
|
+
- Promise handling and best practices
|
|
15
|
+
|
|
16
|
+
## File Structure
|
|
17
|
+
|
|
18
|
+
### Entry Files
|
|
19
|
+
|
|
20
|
+
| File | Description |
|
|
21
|
+
|------|-------------|
|
|
22
|
+
| `index.mjs` | Main entry point, exports all configuration modules |
|
|
23
|
+
| `index.d.ts` | TypeScript type definitions for the package |
|
|
24
|
+
| `eslint.config.mjs` | ESLint configuration for this package itself (uses baseConfig + prettierConfig) |
|
|
25
|
+
|
|
26
|
+
### Configuration Modules (root)
|
|
27
|
+
|
|
28
|
+
| File | Description |
|
|
29
|
+
|------|-------------|
|
|
30
|
+
| `base.mjs` | Core JavaScript/TypeScript linting rules (imports all `/rules/` files) |
|
|
31
|
+
| `typescript.mjs` | TypeScript-specific rules with parser and project service |
|
|
32
|
+
| `react.mjs` | React library rules and JSX accessibility (jsx-a11y) |
|
|
33
|
+
| `next.mjs` | Next.js-specific rules (extends react + hooks + Next.js plugin) |
|
|
34
|
+
| `hooks.mjs` | React Hooks rules (rules-of-hooks, exhaustive-deps, useState naming) |
|
|
35
|
+
| `imports.mjs` | Import sorting with simple-import-sort in priority groups |
|
|
36
|
+
| `prettier.mjs` | Prettier integration via eslint-plugin-prettier |
|
|
37
|
+
| `better-tailwindcss.mjs` | Tailwind CSS v4 linting (function accepting `{ entryPoint }`) |
|
|
38
|
+
|
|
39
|
+
### Utility Files for Other Projects
|
|
40
|
+
|
|
41
|
+
| File | Description |
|
|
42
|
+
|------|-------------|
|
|
43
|
+
| `tsconfig.json` | Shareable TypeScript configuration, can be extended in other projects |
|
|
44
|
+
| `reset.d.ts` | Re-exports improved typings from @total-typescript/ts-reset |
|
|
45
|
+
|
|
46
|
+
## NPM Scripts
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
npm run lint # Lint the entire project
|
|
50
|
+
npm run lint:fix # Lint and auto-fix issues
|
|
51
|
+
npm run bump # Increment minor version
|
|
52
|
+
npm run publish # Publish to npm
|
|
53
|
+
npm run bump:beta # Increment beta version
|
|
54
|
+
npm run publish:beta # Publish beta version
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Configuration Architecture
|
|
58
|
+
|
|
59
|
+
### Flat Config Pattern (ESLint 9+)
|
|
60
|
+
|
|
61
|
+
Each module exports an array of configurations that can be spread:
|
|
62
|
+
|
|
63
|
+
```javascript
|
|
64
|
+
// Minimal setup
|
|
65
|
+
import { baseConfig } from '@viclafouch/eslint-config-viclafouch'
|
|
66
|
+
export default [...baseConfig]
|
|
67
|
+
|
|
68
|
+
// Full Next.js setup
|
|
69
|
+
import { baseConfig, typescriptConfig, nextConfig, prettierConfig } from '@viclafouch/eslint-config-viclafouch'
|
|
70
|
+
export default [...baseConfig, ...typescriptConfig, ...nextConfig, ...prettierConfig]
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Loading Hierarchy
|
|
74
|
+
|
|
75
|
+
1. **baseConfig** → loads 7 rule modules + Unicorn plugin
|
|
76
|
+
2. **typescriptConfig** → replaces some rules with TypeScript versions
|
|
77
|
+
3. **reactConfig** → adds JSX/a11y rules
|
|
78
|
+
4. **nextConfig** → extends react + hooks + Next.js plugin
|
|
79
|
+
5. **importsConfig** → organizes import sorting
|
|
80
|
+
6. **prettierConfig** → formatting (must be last)
|
|
81
|
+
7. **betterTailwindcssConfig({ entryPoint })** → Tailwind CSS v4
|
|
82
|
+
|
|
83
|
+
## Usage in Other Projects
|
|
84
|
+
|
|
85
|
+
### Extending tsconfig.json
|
|
86
|
+
|
|
87
|
+
```json
|
|
88
|
+
{
|
|
89
|
+
"extends": "@viclafouch/eslint-config-viclafouch/tsconfig.json",
|
|
90
|
+
"compilerOptions": {
|
|
91
|
+
// Project-specific overrides
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Using reset.d.ts
|
|
97
|
+
|
|
98
|
+
The `reset.d.ts` file re-exports improved types from `@total-typescript/ts-reset`, providing:
|
|
99
|
+
|
|
100
|
+
- Better inference for `.filter(Boolean)`
|
|
101
|
+
- Stricter types for `JSON.parse`
|
|
102
|
+
- Improved `Array.includes()`
|
|
103
|
+
|
|
104
|
+
To use it, reference it in your project's tsconfig.json or include it in your types.
|
|
105
|
+
|
|
106
|
+
## Integrated Plugins
|
|
107
|
+
|
|
108
|
+
- `@eslint/js` - Core ESLint rules
|
|
109
|
+
- `typescript-eslint` - TypeScript linting
|
|
110
|
+
- `eslint-plugin-react` - React rules
|
|
111
|
+
- `eslint-plugin-react-hooks` - Hooks enforcement
|
|
112
|
+
- `eslint-plugin-jsx-a11y` - Accessibility
|
|
113
|
+
- `eslint-plugin-import` + `simple-import-sort` - Import ordering
|
|
114
|
+
- `eslint-plugin-promise` - Promise handling
|
|
115
|
+
- `eslint-plugin-unicorn` - Best practices
|
|
116
|
+
- `eslint-plugin-prettier` - Code formatting
|
|
117
|
+
- `eslint-plugin-better-tailwindcss` - Tailwind v4
|
|
118
|
+
- `@next/eslint-plugin-next` - Next.js specific
|
|
119
|
+
|
|
120
|
+
## Peer Dependencies
|
|
121
|
+
|
|
122
|
+
- ESLint >= 9
|
|
123
|
+
- Prettier >= 3
|
|
124
|
+
- TypeScript >= 5
|
|
125
|
+
|
|
126
|
+
## Coding Conventions
|
|
127
|
+
|
|
128
|
+
### Rule Severity
|
|
129
|
+
|
|
130
|
+
**IMPORTANT**: This project follows a strict binary approach for rule severity:
|
|
131
|
+
- Use `'error'` for rules that should be enforced
|
|
132
|
+
- Use `'off'` for rules that should be disabled
|
|
133
|
+
- **NEVER use `'warn'`** - warnings are not acceptable in this configuration
|
|
134
|
+
|
|
135
|
+
This ensures that linting is either passing or failing, with no ambiguous middle ground.
|
|
136
|
+
|
|
137
|
+
### Rule Comment Format
|
|
138
|
+
|
|
139
|
+
**IMPORTANT**: Every rule must be documented with a comment following this exact format:
|
|
140
|
+
|
|
141
|
+
```javascript
|
|
142
|
+
// Description of what the rule does
|
|
143
|
+
// https://eslint.org/docs/rules/rule-name
|
|
144
|
+
'rule-name': 'error',
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
For TypeScript rules, use the appropriate documentation URL:
|
|
148
|
+
|
|
149
|
+
```javascript
|
|
150
|
+
// Description of what the rule does
|
|
151
|
+
// https://typescript-eslint.io/rules/rule-name
|
|
152
|
+
'@typescript-eslint/rule-name': 'error',
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
**Format requirements:**
|
|
156
|
+
1. **Line 1**: A description of what the rule enforces/disallows (starts with a verb like "Enforce", "Disallow", "Require", etc.)
|
|
157
|
+
2. **Line 2**: The URL to the rule's official documentation
|
|
158
|
+
3. **Line 3+**: The rule configuration itself
|
|
159
|
+
|
|
160
|
+
**URL patterns by plugin:**
|
|
161
|
+
- ESLint core: `https://eslint.org/docs/rules/rule-name` or `https://eslint.org/docs/latest/rules/rule-name`
|
|
162
|
+
- TypeScript ESLint: `https://typescript-eslint.io/rules/rule-name`
|
|
163
|
+
- React: `https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/rule-name.md`
|
|
164
|
+
- React Hooks: `https://react.dev/reference/rules/rules-of-hooks`
|
|
165
|
+
|
package/eslint.config.mjs
CHANGED
package/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { default as baseConfig } from './base.mjs'
|
|
2
|
-
export { default as
|
|
3
|
-
export { default as reactConfig } from './react.mjs'
|
|
4
|
-
export { default as nextConfig } from './next.mjs'
|
|
5
|
-
export { default as prettierConfig } from './prettier.mjs'
|
|
2
|
+
export { default as betterTailwindcssConfig } from './better-tailwindcss.mjs'
|
|
6
3
|
export { default as hooksConfig } from './hooks.mjs'
|
|
7
4
|
export { default as importsConfig } from './imports.mjs'
|
|
8
|
-
export { default as
|
|
5
|
+
export { default as nextConfig } from './next.mjs'
|
|
6
|
+
export { default as prettierConfig } from './prettier.mjs'
|
|
7
|
+
export { default as reactConfig } from './react.mjs'
|
|
8
|
+
export { default as typescriptConfig } from './typescript.mjs'
|
package/next.mjs
CHANGED
|
@@ -1,26 +1,18 @@
|
|
|
1
|
-
import
|
|
1
|
+
import nextPlugin from '@next/eslint-plugin-next'
|
|
2
2
|
import hooksConfig from './hooks.mjs'
|
|
3
3
|
import reactConfig from './react.mjs'
|
|
4
4
|
|
|
5
|
-
const compat = new FlatCompat({
|
|
6
|
-
baseDirectory: import.meta.dirname
|
|
7
|
-
})
|
|
8
|
-
|
|
9
5
|
/**
|
|
10
6
|
* @type {import("eslint").Linter.Config}
|
|
11
7
|
*/
|
|
12
8
|
export default [
|
|
13
9
|
...reactConfig,
|
|
14
10
|
...hooksConfig,
|
|
15
|
-
|
|
16
|
-
extends: ['plugin:@next/next/recommended'],
|
|
17
|
-
rules: {
|
|
18
|
-
'react/no-unescaped-entities': 'off',
|
|
19
|
-
'@next/next/no-page-custom-font': 'off'
|
|
20
|
-
}
|
|
21
|
-
}),
|
|
11
|
+
nextPlugin.configs.recommended,
|
|
22
12
|
{
|
|
23
13
|
rules: {
|
|
14
|
+
'react/no-unescaped-entities': 'off',
|
|
15
|
+
'@next/next/no-page-custom-font': 'off',
|
|
24
16
|
// No error for anchor inside a Next Link
|
|
25
17
|
'jsx-a11y/anchor-is-valid': [
|
|
26
18
|
'error',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@viclafouch/eslint-config-viclafouch",
|
|
3
|
-
"version": "4.22.1-beta.
|
|
3
|
+
"version": "4.22.1-beta.2",
|
|
4
4
|
"description": "ESLint and Prettier Config from Victor de la Fouchardiere",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.mjs",
|
|
@@ -38,31 +38,31 @@
|
|
|
38
38
|
"typescript": ">= 5"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@babel/core": "^7.
|
|
42
|
-
"@babel/eslint-parser": "^7.
|
|
43
|
-
"@eslint/js": "^9.
|
|
44
|
-
"@next/eslint-plugin-next": "^
|
|
41
|
+
"@babel/core": "^7.28.6",
|
|
42
|
+
"@babel/eslint-parser": "^7.28.6",
|
|
43
|
+
"@eslint/js": "^9.39.2",
|
|
44
|
+
"@next/eslint-plugin-next": "^16.1.6",
|
|
45
45
|
"@total-typescript/ts-reset": "^0.6.1",
|
|
46
46
|
"app-root-path": "^3.1.0",
|
|
47
47
|
"babel-loader": "^10.0.0",
|
|
48
48
|
"eslint": ">= 9",
|
|
49
|
-
"eslint-config-prettier": "^10.1.
|
|
50
|
-
"eslint-plugin-better-tailwindcss": "^
|
|
51
|
-
"eslint-plugin-import": "^2.
|
|
49
|
+
"eslint-config-prettier": "^10.1.8",
|
|
50
|
+
"eslint-plugin-better-tailwindcss": "^4.0.2",
|
|
51
|
+
"eslint-plugin-import": "^2.32.0",
|
|
52
52
|
"eslint-plugin-jsx-a11y": "^6.10.2",
|
|
53
|
-
"eslint-plugin-prettier": "^5.
|
|
53
|
+
"eslint-plugin-prettier": "^5.5.5",
|
|
54
54
|
"eslint-plugin-promise": "^7.2.1",
|
|
55
|
-
"eslint-plugin-react": "^7.37.
|
|
56
|
-
"eslint-plugin-react-hooks": "^
|
|
55
|
+
"eslint-plugin-react": "^7.37.5",
|
|
56
|
+
"eslint-plugin-react-hooks": "^7.0.1",
|
|
57
57
|
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
58
|
-
"eslint-plugin-testing-library": "^7.
|
|
59
|
-
"eslint-plugin-unicorn": "^
|
|
60
|
-
"get-tsconfig": "^4.
|
|
61
|
-
"globals": "^
|
|
58
|
+
"eslint-plugin-testing-library": "^7.15.4",
|
|
59
|
+
"eslint-plugin-unicorn": "^62.0.0",
|
|
60
|
+
"get-tsconfig": "^4.13.0",
|
|
61
|
+
"globals": "^17.2.0",
|
|
62
62
|
"prettier": ">= 3",
|
|
63
|
-
"prettier-plugin-curly": "^0.
|
|
63
|
+
"prettier-plugin-curly": "^0.4.1",
|
|
64
64
|
"typescript": ">= 5",
|
|
65
|
-
"typescript-eslint": "^8.
|
|
65
|
+
"typescript-eslint": "^8.54.0"
|
|
66
66
|
},
|
|
67
67
|
"scripts": {
|
|
68
68
|
"lint": "eslint .",
|
package/rules/best-practices.mjs
CHANGED
|
@@ -388,6 +388,130 @@ export default {
|
|
|
388
388
|
|
|
389
389
|
// Enforce the use of u flag on RegExp
|
|
390
390
|
// https://eslint.org/docs/rules/require-unicode-regexp
|
|
391
|
-
'require-unicode-regexp': 'off'
|
|
391
|
+
'require-unicode-regexp': 'off',
|
|
392
|
+
|
|
393
|
+
// Disallow creating a variable and immediately mutating it
|
|
394
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-immediate-mutation.md
|
|
395
|
+
'unicorn/no-immediate-mutation': 'error',
|
|
396
|
+
|
|
397
|
+
// Disallow useless arguments when constructing Set, Map, WeakSet, WeakMap
|
|
398
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-useless-collection-argument.md
|
|
399
|
+
'unicorn/no-useless-collection-argument': 'error',
|
|
400
|
+
|
|
401
|
+
// Prefer class fields over constructor assignments
|
|
402
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-class-fields.md
|
|
403
|
+
'unicorn/prefer-class-fields': 'error',
|
|
404
|
+
|
|
405
|
+
// Prefer Array#toReversed() over Array#reverse() to avoid mutation
|
|
406
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-array-reverse.md
|
|
407
|
+
'unicorn/no-array-reverse': 'error',
|
|
408
|
+
|
|
409
|
+
// Require using new when throwing an error
|
|
410
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/throw-new-error.md
|
|
411
|
+
'unicorn/throw-new-error': 'error',
|
|
412
|
+
|
|
413
|
+
// Prefer includes() over indexOf() when checking for existence
|
|
414
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-includes.md
|
|
415
|
+
'unicorn/prefer-includes': 'error',
|
|
416
|
+
|
|
417
|
+
// Prefer find() over filter()[0] when searching for a single element
|
|
418
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-array-find.md
|
|
419
|
+
'unicorn/prefer-array-find': 'error',
|
|
420
|
+
|
|
421
|
+
// Prefer startsWith() and endsWith() over regex or slice comparisons
|
|
422
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-string-starts-ends-with.md
|
|
423
|
+
'unicorn/prefer-string-starts-ends-with': 'error',
|
|
424
|
+
|
|
425
|
+
// Prefer .at() for accessing elements by negative index
|
|
426
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-at.md
|
|
427
|
+
'unicorn/prefer-at': 'error',
|
|
428
|
+
|
|
429
|
+
// Prefer Number static properties over global ones
|
|
430
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-number-properties.md
|
|
431
|
+
'unicorn/prefer-number-properties': 'error',
|
|
432
|
+
|
|
433
|
+
// Prefer for...of over Array#forEach
|
|
434
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-array-for-each.md
|
|
435
|
+
'unicorn/no-array-for-each': 'error',
|
|
436
|
+
|
|
437
|
+
// Prefer Array#flat() over legacy techniques to flatten arrays
|
|
438
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-array-flat.md
|
|
439
|
+
'unicorn/prefer-array-flat': 'error',
|
|
440
|
+
|
|
441
|
+
// Prefer flatMap() over map().flat()
|
|
442
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-array-flat-map.md
|
|
443
|
+
'unicorn/prefer-array-flat-map': 'error',
|
|
444
|
+
|
|
445
|
+
// Disallow useless undefined
|
|
446
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-useless-undefined.md
|
|
447
|
+
'unicorn/no-useless-undefined': 'error',
|
|
448
|
+
|
|
449
|
+
// Prefer String#replaceAll() over regex with global flag
|
|
450
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-string-replace-all.md
|
|
451
|
+
'unicorn/prefer-string-replace-all': 'error',
|
|
452
|
+
|
|
453
|
+
// Prefer String#trimStart() / String#trimEnd() over trimLeft() / trimRight()
|
|
454
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-string-trim-start-end.md
|
|
455
|
+
'unicorn/prefer-string-trim-start-end': 'error',
|
|
456
|
+
|
|
457
|
+
// Disallow if statements as the only statement in else blocks
|
|
458
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-lonely-if.md
|
|
459
|
+
'unicorn/no-lonely-if': 'error',
|
|
460
|
+
|
|
461
|
+
// Prefer RegExp#test() over String#match() for boolean checks
|
|
462
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-regexp-test.md
|
|
463
|
+
'unicorn/prefer-regexp-test': 'error',
|
|
464
|
+
|
|
465
|
+
// Prefer modern DOM APIs
|
|
466
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-modern-dom-apis.md
|
|
467
|
+
'unicorn/prefer-modern-dom-apis': 'error',
|
|
468
|
+
|
|
469
|
+
// Prefer [...iterable] over Array.from(iterable)
|
|
470
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-spread.md
|
|
471
|
+
'unicorn/prefer-spread': 'off',
|
|
472
|
+
|
|
473
|
+
// Prefer omitting catch binding when unused
|
|
474
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-optional-catch-binding.md
|
|
475
|
+
'unicorn/prefer-optional-catch-binding': 'off',
|
|
476
|
+
|
|
477
|
+
// Disallow negated conditions when alternative exists
|
|
478
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-negated-condition.md
|
|
479
|
+
'unicorn/no-negated-condition': 'off',
|
|
480
|
+
|
|
481
|
+
// Prefer TypeError for type-related errors
|
|
482
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-type-error.md
|
|
483
|
+
'unicorn/prefer-type-error': 'off',
|
|
484
|
+
|
|
485
|
+
// Prefer Date.now() over new Date().getTime()
|
|
486
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-date-now.md
|
|
487
|
+
'unicorn/prefer-date-now': 'error',
|
|
488
|
+
|
|
489
|
+
// Prefer === undefined over typeof === 'undefined'
|
|
490
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-typeof-undefined.md
|
|
491
|
+
'unicorn/no-typeof-undefined': 'error',
|
|
492
|
+
|
|
493
|
+
// Prefer Object.fromEntries() over reduce to create objects
|
|
494
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-object-from-entries.md
|
|
495
|
+
'unicorn/prefer-object-from-entries': 'error',
|
|
496
|
+
|
|
497
|
+
// Prefer Set#has() over Array#includes() for frequent checks
|
|
498
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-set-has.md
|
|
499
|
+
'unicorn/prefer-set-has': 'off',
|
|
500
|
+
|
|
501
|
+
// Prefer some() over find() !== undefined for boolean checks
|
|
502
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-array-some.md
|
|
503
|
+
'unicorn/prefer-array-some': 'error',
|
|
504
|
+
|
|
505
|
+
// Disallow new Array() and prefer Array.from({length: n})
|
|
506
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-new-array.md
|
|
507
|
+
'unicorn/no-new-array': 'error',
|
|
508
|
+
|
|
509
|
+
// Prefer default parameters over reassignment
|
|
510
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-default-parameters.md
|
|
511
|
+
'unicorn/prefer-default-parameters': 'error',
|
|
512
|
+
|
|
513
|
+
// Prefer negative index over length minus index
|
|
514
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-negative-index.md
|
|
515
|
+
'unicorn/prefer-negative-index': 'error'
|
|
392
516
|
}
|
|
393
517
|
}
|
package/rules/node.mjs
CHANGED
|
@@ -18,6 +18,7 @@ export default {
|
|
|
18
18
|
'global-require': 'error',
|
|
19
19
|
|
|
20
20
|
// Enforce usage of the `node:` prefix for builtin imports
|
|
21
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-node-protocol.md
|
|
21
22
|
'unicorn/prefer-node-protocol': 'error'
|
|
22
23
|
}
|
|
23
24
|
}
|
package/rules/react-hooks.mjs
CHANGED
|
@@ -7,9 +7,7 @@ import globals from 'globals'
|
|
|
7
7
|
*/
|
|
8
8
|
export default {
|
|
9
9
|
name: 'react-hooks',
|
|
10
|
-
|
|
11
|
-
'react-hooks': pluginReactHooks
|
|
12
|
-
},
|
|
10
|
+
...pluginReactHooks.configs.flat.recommended,
|
|
13
11
|
languageOptions: {
|
|
14
12
|
...pluginReact.configs.flat.recommended.languageOptions,
|
|
15
13
|
globals: {
|
|
@@ -17,13 +15,7 @@ export default {
|
|
|
17
15
|
}
|
|
18
16
|
},
|
|
19
17
|
rules: {
|
|
20
|
-
|
|
21
|
-
// https://github.com/facebook/react/blob/c11015ff4f610ac2924d1fc6d569a17657a404fd/packages/eslint-plugin-react-hooks/src/RulesOfHooks.js
|
|
22
|
-
'react-hooks/rules-of-hooks': 'error',
|
|
23
|
-
|
|
24
|
-
// Verify the list of the dependencies for Hooks like useEffect and similar
|
|
25
|
-
// https://github.com/facebook/react/blob/1204c789776cb01fbaf3e9f032e7e2ba85a44137/packages/eslint-plugin-react-hooks/src/ExhaustiveDeps.js
|
|
26
|
-
'react-hooks/exhaustive-deps': 'error',
|
|
18
|
+
...pluginReactHooks.configs.flat.recommended.rules,
|
|
27
19
|
|
|
28
20
|
// Prefer to have a convention for naming states
|
|
29
21
|
// E.g: [thing, setThing]
|
package/rules/typescript.mjs
CHANGED
|
@@ -174,7 +174,15 @@ export default tseslint.config(
|
|
|
174
174
|
|
|
175
175
|
// Disallow non-null assertions after an optional chain expression
|
|
176
176
|
// https://typescript-eslint.io/rules/no-non-null-asserted-optional-chain
|
|
177
|
-
'@typescript-eslint/no-non-null-asserted-optional-chain': 'error'
|
|
177
|
+
'@typescript-eslint/no-non-null-asserted-optional-chain': 'error',
|
|
178
|
+
|
|
179
|
+
// Disallow default values that will never be used (type guarantees non-undefined)
|
|
180
|
+
// https://typescript-eslint.io/rules/no-useless-default-assignment
|
|
181
|
+
'@typescript-eslint/no-useless-default-assignment': 'error',
|
|
182
|
+
|
|
183
|
+
// Disallow passing a value-returning function where void is expected
|
|
184
|
+
// https://typescript-eslint.io/rules/strict-void-return
|
|
185
|
+
'@typescript-eslint/strict-void-return': 'error'
|
|
178
186
|
|
|
179
187
|
// Prefer using nullish coalescing (??) over logical (||) when possible.
|
|
180
188
|
// '@typescript-eslint/prefer-nullish-coalescing': 'error'
|
package/tsconfig.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
// Make indexing stricter, not accessing unknown properties
|
|
16
16
|
"noUncheckedIndexedAccess": true,
|
|
17
17
|
"noPropertyAccessFromIndexSignature": false,
|
|
18
|
-
"moduleResolution": "
|
|
18
|
+
"moduleResolution": "bundler",
|
|
19
19
|
// No accidental global script
|
|
20
20
|
"moduleDetection": "force",
|
|
21
21
|
"resolveJsonModule": true,
|