@viclafouch/eslint-config-viclafouch 4.22.1-beta.3 → 4.22.1-beta.5
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 +4 -1
- package/CLAUDE.md +39 -45
- package/README.md +113 -185
- package/bin/init.js +77 -0
- package/eslint.config.mjs +2 -2
- package/index.d.ts +0 -1
- package/index.mjs +0 -1
- package/package.json +4 -1
- package/rules/react.mjs +1 -1
- package/rules/typescript.mjs +927 -100
- package/templates/nextjs.js +19 -0
- package/templates/react.js +26 -0
- package/templates/typescript.js +15 -0
- package/base.mjs +0 -36
- package/rules/best-practices.mjs +0 -517
- package/rules/errors.mjs +0 -46
- package/rules/es6.mjs +0 -218
- package/rules/node.mjs +0 -24
- package/rules/style.mjs +0 -43
- package/rules/variables.mjs +0 -84
|
@@ -10,7 +10,10 @@
|
|
|
10
10
|
"Bash(npm view:*)",
|
|
11
11
|
"Bash(node -e:*)",
|
|
12
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\\)\")"
|
|
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
|
+
"WebSearch",
|
|
15
|
+
"Bash(npx eslint:*)",
|
|
16
|
+
"Bash(git -C /Users/victordelafouchardiere/Desktop/eslint-config-viclafouch status)"
|
|
14
17
|
]
|
|
15
18
|
}
|
|
16
19
|
}
|
package/CLAUDE.md
CHANGED
|
@@ -4,14 +4,15 @@ This file documents the **@viclafouch/eslint-config-viclafouch** project to faci
|
|
|
4
4
|
|
|
5
5
|
## What is this project?
|
|
6
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
|
|
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 TypeScript projects. The goal is to share consistent code quality standards across all of Victor de la Fouchardiere's projects.
|
|
8
8
|
|
|
9
9
|
**Key features:**
|
|
10
|
-
-
|
|
10
|
+
- TypeScript-first configuration (all projects are TypeScript by default)
|
|
11
|
+
- ES6+, JSX/TSX support
|
|
11
12
|
- React.js and Next.js frameworks
|
|
12
13
|
- Tailwind CSS v4 linting
|
|
13
|
-
- Testing libraries support
|
|
14
14
|
- Promise handling and best practices
|
|
15
|
+
- Unicorn plugin for modern JavaScript
|
|
15
16
|
|
|
16
17
|
## File Structure
|
|
17
18
|
|
|
@@ -21,14 +22,13 @@ This is a reusable ESLint and Prettier configuration package published on npm. I
|
|
|
21
22
|
|------|-------------|
|
|
22
23
|
| `index.mjs` | Main entry point, exports all configuration modules |
|
|
23
24
|
| `index.d.ts` | TypeScript type definitions for the package |
|
|
24
|
-
| `eslint.config.mjs` | ESLint configuration for this package itself
|
|
25
|
+
| `eslint.config.mjs` | ESLint configuration for this package itself |
|
|
25
26
|
|
|
26
27
|
### Configuration Modules (root)
|
|
27
28
|
|
|
28
29
|
| File | Description |
|
|
29
30
|
|------|-------------|
|
|
30
|
-
| `
|
|
31
|
-
| `typescript.mjs` | TypeScript-specific rules with parser and project service |
|
|
31
|
+
| `typescript.mjs` | Wrapper that exports `rules/typescript.mjs` |
|
|
32
32
|
| `react.mjs` | React library rules and JSX accessibility (jsx-a11y) |
|
|
33
33
|
| `next.mjs` | Next.js-specific rules (extends react + hooks + Next.js plugin) |
|
|
34
34
|
| `hooks.mjs` | React Hooks rules (rules-of-hooks, exhaustive-deps, useState naming) |
|
|
@@ -36,6 +36,15 @@ This is a reusable ESLint and Prettier configuration package published on npm. I
|
|
|
36
36
|
| `prettier.mjs` | Prettier integration via eslint-plugin-prettier |
|
|
37
37
|
| `better-tailwindcss.mjs` | Tailwind CSS v4 linting (function accepting `{ entryPoint }`) |
|
|
38
38
|
|
|
39
|
+
### Rules Directory
|
|
40
|
+
|
|
41
|
+
| File | Description |
|
|
42
|
+
|------|-------------|
|
|
43
|
+
| `rules/typescript.mjs` | **Main configuration file.** Contains all base rules (best practices, ES6+, variables, errors, style, node) + TypeScript rules + Unicorn + Promise plugins |
|
|
44
|
+
| `rules/imports.mjs` | Import sorting rules with alias detection from tsconfig/jsconfig |
|
|
45
|
+
| `rules/react.mjs` | React-specific rules |
|
|
46
|
+
| `rules/react-hooks.mjs` | React Hooks rules |
|
|
47
|
+
|
|
39
48
|
### Utility Files for Other Projects
|
|
40
49
|
|
|
41
50
|
| File | Description |
|
|
@@ -61,51 +70,34 @@ npm run publish:beta # Publish beta version
|
|
|
61
70
|
Each module exports an array of configurations that can be spread:
|
|
62
71
|
|
|
63
72
|
```javascript
|
|
64
|
-
//
|
|
65
|
-
import {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
73
|
+
// Typical Next.js setup
|
|
74
|
+
import {
|
|
75
|
+
typescriptConfig,
|
|
76
|
+
nextConfig,
|
|
77
|
+
importsConfig,
|
|
78
|
+
prettierConfig
|
|
79
|
+
} from '@viclafouch/eslint-config-viclafouch'
|
|
80
|
+
|
|
81
|
+
export default [
|
|
82
|
+
{ ignores: ['**/node_modules/**', '**/.next/**'] },
|
|
83
|
+
...typescriptConfig,
|
|
84
|
+
...nextConfig,
|
|
85
|
+
...importsConfig,
|
|
86
|
+
...prettierConfig
|
|
87
|
+
]
|
|
71
88
|
```
|
|
72
89
|
|
|
73
90
|
### Loading Hierarchy
|
|
74
91
|
|
|
75
|
-
1. **
|
|
76
|
-
2. **
|
|
77
|
-
3. **reactConfig** →
|
|
78
|
-
4. **
|
|
79
|
-
5. **
|
|
80
|
-
6. **prettierConfig** →
|
|
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.
|
|
92
|
+
1. **typescriptConfig** → Base configuration with all rules (ES6+, best practices, TypeScript, Unicorn, Promise)
|
|
93
|
+
2. **nextConfig** → Next.js rules (includes React + Hooks + a11y)
|
|
94
|
+
3. **reactConfig** + **hooksConfig** → For React without Next.js
|
|
95
|
+
4. **importsConfig** → Import sorting
|
|
96
|
+
5. **betterTailwindcssConfig({ entryPoint })** → Tailwind CSS v4
|
|
97
|
+
6. **prettierConfig** → Formatting (must be last)
|
|
105
98
|
|
|
106
99
|
## Integrated Plugins
|
|
107
100
|
|
|
108
|
-
- `@eslint/js` - Core ESLint rules
|
|
109
101
|
- `typescript-eslint` - TypeScript linting
|
|
110
102
|
- `eslint-plugin-react` - React rules
|
|
111
103
|
- `eslint-plugin-react-hooks` - Hooks enforcement
|
|
@@ -132,6 +124,8 @@ To use it, reference it in your project's tsconfig.json or include it in your ty
|
|
|
132
124
|
- Use `'off'` for rules that should be disabled
|
|
133
125
|
- **NEVER use `'warn'`** - warnings are not acceptable in this configuration
|
|
134
126
|
|
|
127
|
+
**Exception**: `no-console` uses `'warn'` to allow console statements during development.
|
|
128
|
+
|
|
135
129
|
This ensures that linting is either passing or failing, with no ambiguous middle ground.
|
|
136
130
|
|
|
137
131
|
### Rule Comment Format
|
|
@@ -162,4 +156,4 @@ For TypeScript rules, use the appropriate documentation URL:
|
|
|
162
156
|
- TypeScript ESLint: `https://typescript-eslint.io/rules/rule-name`
|
|
163
157
|
- React: `https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/rule-name.md`
|
|
164
158
|
- React Hooks: `https://react.dev/reference/rules/rules-of-hooks`
|
|
165
|
-
|
|
159
|
+
- Unicorn: `https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/rule-name.md`
|
package/README.md
CHANGED
|
@@ -1,258 +1,177 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @viclafouch/eslint-config-viclafouch
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
ESLint and Prettier configuration for modern TypeScript projects.
|
|
4
4
|
|
|
5
|
+
## Installation
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
- [Eslint / Prettier Setup of @viclafouch 📦](#eslint--prettier-setup-of-viclafouch-)
|
|
9
|
-
- [Table of Contents](#table-of-contents)
|
|
10
|
-
- [What it does](#what-it-does)
|
|
11
|
-
- [Local / Per Project Install](#local--per-project-install)
|
|
12
|
-
- [Scripts](#scripts)
|
|
13
|
-
- [If you use TypeScript](#if-you-use-typescript)
|
|
14
|
-
- [Extend your tsconfig](#extend-your-tsconfig)
|
|
15
|
-
- [Add the typescript eslint config](#add-the-typescript-eslint-config)
|
|
16
|
-
- [Better typing](#better-typing)
|
|
17
|
-
- [Scripts](#scripts-1)
|
|
18
|
-
- [If you want to enable imports sorting](#if-you-want-to-enable-imports-sorting)
|
|
19
|
-
- [If you use Next.js](#if-you-use-nextjs)
|
|
20
|
-
- [If you use React.js](#if-you-use-reactjs)
|
|
21
|
-
- [If you use Tailwind CSS v4](#if-you-use-tailwind-css-v4)
|
|
22
|
-
- [If you want to use Prettier](#if-you-want-to-use-prettier)
|
|
23
|
-
- [If you use VS Code](#if-you-use-vs-code)
|
|
24
|
-
|
|
25
|
-
## What it does
|
|
26
|
-
|
|
27
|
-
* Lints JavaScript / TypeScript based on the latest standards
|
|
28
|
-
* Multiple configs `react` `hooks` `next` `tailwindcss`..
|
|
29
|
-
* Shared `tsconfig.json`
|
|
30
|
-
* Fixes issues and formatting errors with Prettier
|
|
31
|
-
* Check for accessibility rules on JSX elements.
|
|
32
|
-
|
|
33
|
-
## Local / Per Project Install
|
|
34
|
-
|
|
35
|
-
1. If you don't already have a `package.json` file, create one with `npm init`.
|
|
36
|
-
|
|
37
|
-
2. Then we need to install the config:
|
|
38
|
-
|
|
39
|
-
```
|
|
7
|
+
```bash
|
|
40
8
|
npm i -D @viclafouch/eslint-config-viclafouch
|
|
41
9
|
```
|
|
42
10
|
|
|
43
|
-
|
|
11
|
+
## Quick Init (recommended)
|
|
44
12
|
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
"name": "your-project",
|
|
48
|
-
"type": "module",
|
|
49
|
-
...
|
|
50
|
-
}
|
|
13
|
+
```bash
|
|
14
|
+
npx @viclafouch/eslint-config-viclafouch
|
|
51
15
|
```
|
|
52
16
|
|
|
53
|
-
|
|
17
|
+
This will prompt you to select your stack and create the `eslint.config.js` file automatically.
|
|
54
18
|
|
|
55
|
-
|
|
19
|
+
## Manual Setup (React + Tailwind)
|
|
56
20
|
|
|
57
21
|
```js
|
|
58
|
-
|
|
22
|
+
// eslint.config.js
|
|
23
|
+
import {
|
|
24
|
+
betterTailwindcssConfig,
|
|
25
|
+
importsConfig,
|
|
26
|
+
prettierConfig,
|
|
27
|
+
reactConfig,
|
|
28
|
+
typescriptConfig
|
|
29
|
+
} from '@viclafouch/eslint-config-viclafouch'
|
|
59
30
|
|
|
60
31
|
/**
|
|
61
32
|
* @type {import("eslint").Linter.Config}
|
|
62
33
|
*/
|
|
63
34
|
export default [
|
|
64
|
-
...baseConfig,
|
|
65
35
|
{
|
|
66
|
-
ignores: [
|
|
67
|
-
|
|
36
|
+
ignores: [
|
|
37
|
+
'**/node_modules/**',
|
|
38
|
+
'**/.output/**',
|
|
39
|
+
'**/.tanstack/**'
|
|
40
|
+
]
|
|
41
|
+
},
|
|
42
|
+
...typescriptConfig,
|
|
43
|
+
...reactConfig,
|
|
44
|
+
...importsConfig,
|
|
45
|
+
...betterTailwindcssConfig({ entryPoint: 'src/styles.css' }),
|
|
46
|
+
...prettierConfig
|
|
68
47
|
]
|
|
69
48
|
```
|
|
70
49
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
You can add two scripts to your package.json to lint and/or fix your code:
|
|
74
|
-
|
|
75
|
-
```json
|
|
76
|
-
{
|
|
77
|
-
"scripts": {
|
|
78
|
-
"lint": "eslint",
|
|
79
|
-
"lint:fix": "npm run lint -- --fix",
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
```
|
|
83
|
-
## If you use TypeScript
|
|
84
|
-
|
|
85
|
-
### Extend your tsconfig
|
|
50
|
+
## Stack Examples
|
|
86
51
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
```json
|
|
90
|
-
{
|
|
91
|
-
"extends": "@viclafouch/eslint-config-viclafouch/tsconfig.json",
|
|
92
|
-
...
|
|
93
|
-
}
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
### Add the typescript eslint config
|
|
97
|
-
|
|
98
|
-
Then, add the TypeScript Eslint rules to your `.eslintrc` file:
|
|
52
|
+
### React + Vite (without Tailwind)
|
|
99
53
|
|
|
100
54
|
```js
|
|
101
|
-
|
|
55
|
+
// eslint.config.js
|
|
56
|
+
import {
|
|
57
|
+
hooksConfig,
|
|
58
|
+
importsConfig,
|
|
59
|
+
prettierConfig,
|
|
60
|
+
reactConfig,
|
|
61
|
+
typescriptConfig
|
|
62
|
+
} from '@viclafouch/eslint-config-viclafouch'
|
|
102
63
|
|
|
103
64
|
/**
|
|
104
65
|
* @type {import("eslint").Linter.Config}
|
|
105
66
|
*/
|
|
106
67
|
export default [
|
|
107
|
-
|
|
68
|
+
{ ignores: ['**/node_modules/**', '**/dist/**'] },
|
|
108
69
|
...typescriptConfig,
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
70
|
+
...reactConfig,
|
|
71
|
+
...hooksConfig,
|
|
72
|
+
...importsConfig,
|
|
73
|
+
...prettierConfig
|
|
112
74
|
]
|
|
113
75
|
```
|
|
114
76
|
|
|
115
|
-
###
|
|
116
|
-
|
|
117
|
-
TypeScript's built-in typings are not perfect. viclafouch-reset makes them better.
|
|
118
|
-
|
|
119
|
-
1. Create a `reset.d.ts` file in your project with these contents:
|
|
120
|
-
|
|
121
|
-
```ts
|
|
122
|
-
// Do not add any other lines of code to this file!
|
|
123
|
-
import '@viclafouch/eslint-config-viclafouch/reset.d'
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
2. Enjoy improved typings across your entire project.
|
|
127
|
-
|
|
128
|
-
### Scripts
|
|
129
|
-
|
|
130
|
-
You can add two scripts to your package.json to lint and/or fix your code:
|
|
131
|
-
|
|
132
|
-
```json
|
|
133
|
-
{
|
|
134
|
-
"scripts": {
|
|
135
|
-
"lint": "tsc --noEmit && eslint",
|
|
136
|
-
"lint:fix": "npm run lint -- --fix",
|
|
137
|
-
},
|
|
138
|
-
}
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
## If you want to enable imports sorting
|
|
142
|
-
|
|
143
|
-
If you want to sort your imports using your alias at the same time from your `jsonfig.json` or `tsconfig.json` file.
|
|
77
|
+
### Pure TypeScript (Node.js, lib)
|
|
144
78
|
|
|
145
79
|
```js
|
|
146
|
-
|
|
80
|
+
// eslint.config.js
|
|
81
|
+
import {
|
|
82
|
+
importsConfig,
|
|
83
|
+
prettierConfig,
|
|
84
|
+
typescriptConfig
|
|
85
|
+
} from '@viclafouch/eslint-config-viclafouch'
|
|
147
86
|
|
|
148
87
|
/**
|
|
149
88
|
* @type {import("eslint").Linter.Config}
|
|
150
89
|
*/
|
|
151
90
|
export default [
|
|
152
|
-
|
|
91
|
+
{ ignores: ['**/node_modules/**', '**/dist/**'] },
|
|
92
|
+
...typescriptConfig,
|
|
153
93
|
...importsConfig,
|
|
154
|
-
|
|
155
|
-
ignores: ['**/node_modules/**']
|
|
156
|
-
}
|
|
94
|
+
...prettierConfig
|
|
157
95
|
]
|
|
158
96
|
```
|
|
159
97
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
You can also add additional rules for Next.js. It includes the following configurations : `reactConfig`, `hooksConfig` and Next.js specific rules.
|
|
98
|
+
### Next.js
|
|
163
99
|
|
|
164
100
|
```js
|
|
165
|
-
|
|
101
|
+
// eslint.config.js
|
|
102
|
+
import {
|
|
103
|
+
betterTailwindcssConfig,
|
|
104
|
+
importsConfig,
|
|
105
|
+
nextConfig,
|
|
106
|
+
prettierConfig,
|
|
107
|
+
typescriptConfig
|
|
108
|
+
} from '@viclafouch/eslint-config-viclafouch'
|
|
166
109
|
|
|
167
110
|
/**
|
|
168
111
|
* @type {import("eslint").Linter.Config}
|
|
169
112
|
*/
|
|
170
113
|
export default [
|
|
171
|
-
|
|
114
|
+
{ ignores: ['**/node_modules/**', '**/.next/**'] },
|
|
115
|
+
...typescriptConfig,
|
|
172
116
|
...nextConfig,
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
117
|
+
...importsConfig,
|
|
118
|
+
...betterTailwindcssConfig({ entryPoint: 'src/app/globals.css' }),
|
|
119
|
+
...prettierConfig
|
|
176
120
|
]
|
|
177
121
|
```
|
|
178
122
|
|
|
179
|
-
##
|
|
123
|
+
## Available Configurations
|
|
180
124
|
|
|
181
|
-
|
|
125
|
+
| Config | Description |
|
|
126
|
+
|--------|-------------|
|
|
127
|
+
| `typescriptConfig` | **Required base.** TypeScript, ES6+, best practices, unicorn, promise |
|
|
128
|
+
| `reactConfig` | React and JSX a11y |
|
|
129
|
+
| `hooksConfig` | React Hooks |
|
|
130
|
+
| `nextConfig` | Next.js (includes React + Hooks + a11y) |
|
|
131
|
+
| `importsConfig` | Automatic import sorting |
|
|
132
|
+
| `betterTailwindcssConfig({ entryPoint })` | Tailwind CSS v4 |
|
|
133
|
+
| `prettierConfig` | Prettier (always last) |
|
|
182
134
|
|
|
183
|
-
|
|
184
|
-
import { baseConfig, hooksConfig, reactConfig } from '@viclafouch/eslint-config-viclafouch'
|
|
135
|
+
## TypeScript
|
|
185
136
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
137
|
+
### Extend tsconfig.json
|
|
138
|
+
|
|
139
|
+
```json
|
|
140
|
+
{
|
|
141
|
+
"extends": "@viclafouch/eslint-config-viclafouch/tsconfig.json",
|
|
142
|
+
"compilerOptions": {
|
|
143
|
+
"baseUrl": ".",
|
|
144
|
+
"paths": {
|
|
145
|
+
"@/*": ["./src/*"]
|
|
146
|
+
}
|
|
195
147
|
}
|
|
196
|
-
|
|
148
|
+
}
|
|
197
149
|
```
|
|
198
150
|
|
|
199
|
-
|
|
151
|
+
### Better Typing with reset.d.ts
|
|
200
152
|
|
|
201
|
-
|
|
153
|
+
Improves native types (`.filter(Boolean)`, `JSON.parse`, `Array.includes()`, etc.):
|
|
202
154
|
|
|
203
|
-
```
|
|
204
|
-
import
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
* @type {import("eslint").Linter.Config}
|
|
208
|
-
*/
|
|
209
|
-
export default [
|
|
210
|
-
...baseConfig,
|
|
211
|
-
...betterTailwindcssConfig({
|
|
212
|
-
entryPoint: 'src/global.css'
|
|
213
|
-
}),
|
|
214
|
-
{
|
|
215
|
-
ignores: ['**/node_modules/**']
|
|
216
|
-
}
|
|
217
|
-
]
|
|
155
|
+
```ts
|
|
156
|
+
import '@viclafouch/eslint-config-viclafouch/reset.d'
|
|
218
157
|
```
|
|
219
158
|
|
|
220
|
-
##
|
|
221
|
-
|
|
222
|
-
Be sure for the prettier config to be the last one.
|
|
223
|
-
|
|
224
|
-
```js
|
|
225
|
-
import {
|
|
226
|
-
baseConfig,
|
|
227
|
-
hooksConfig,
|
|
228
|
-
importsConfig,
|
|
229
|
-
prettierConfig,
|
|
230
|
-
reactConfig,
|
|
231
|
-
typescriptConfig
|
|
232
|
-
} from '@viclafouch/eslint-config-viclafouch'
|
|
159
|
+
## Scripts
|
|
233
160
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
...hooksConfig,
|
|
241
|
-
...importsConfig,
|
|
242
|
-
...typescriptConfig,
|
|
243
|
-
...prettierConfig,
|
|
244
|
-
{
|
|
245
|
-
ignores: ['**/node_modules/**', '**/dist/**']
|
|
161
|
+
```json
|
|
162
|
+
{
|
|
163
|
+
"type": "module",
|
|
164
|
+
"scripts": {
|
|
165
|
+
"lint": "tsc --noEmit && eslint .",
|
|
166
|
+
"lint:fix": "npm run lint -- --fix"
|
|
246
167
|
}
|
|
247
|
-
|
|
168
|
+
}
|
|
248
169
|
```
|
|
249
170
|
|
|
250
|
-
##
|
|
251
|
-
|
|
252
|
-
Once you have done. You probably want your editor to lint and fix for you.
|
|
171
|
+
## VS Code
|
|
253
172
|
|
|
254
|
-
1. Install the [ESLint
|
|
255
|
-
2.
|
|
173
|
+
1. Install the [ESLint extension](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)
|
|
174
|
+
2. Create a `.vscode` folder at your root project, and create a `settings.json` file:
|
|
256
175
|
|
|
257
176
|
```json
|
|
258
177
|
{
|
|
@@ -261,3 +180,12 @@ Once you have done. You probably want your editor to lint and fix for you.
|
|
|
261
180
|
}
|
|
262
181
|
}
|
|
263
182
|
```
|
|
183
|
+
|
|
184
|
+
## Configuration Order
|
|
185
|
+
|
|
186
|
+
1. `ignores` (always first)
|
|
187
|
+
2. `typescriptConfig` (base)
|
|
188
|
+
3. `reactConfig` / `nextConfig` / `hooksConfig`
|
|
189
|
+
4. `importsConfig`
|
|
190
|
+
5. `betterTailwindcssConfig`
|
|
191
|
+
6. `prettierConfig` (always last)
|
package/bin/init.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/* eslint-disable no-console */
|
|
3
|
+
|
|
4
|
+
import { existsSync, readFileSync, writeFileSync } from 'node:fs'
|
|
5
|
+
import { dirname, join } from 'node:path'
|
|
6
|
+
import { createInterface } from 'node:readline'
|
|
7
|
+
import { fileURLToPath } from 'node:url'
|
|
8
|
+
|
|
9
|
+
const filename = fileURLToPath(import.meta.url)
|
|
10
|
+
const directory = dirname(filename)
|
|
11
|
+
|
|
12
|
+
const TEMPLATES = {
|
|
13
|
+
1: { name: 'React + Tailwind', file: 'react.js' },
|
|
14
|
+
2: { name: 'Next.js + Tailwind', file: 'nextjs.js' },
|
|
15
|
+
3: { name: 'Pure TypeScript', file: 'typescript.js' }
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const rl = createInterface({
|
|
19
|
+
input: process.stdin,
|
|
20
|
+
output: process.stdout
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
function question(query) {
|
|
24
|
+
return new Promise((resolve) => {
|
|
25
|
+
rl.question(query, resolve)
|
|
26
|
+
})
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async function main() {
|
|
30
|
+
console.log('\n@viclafouch/eslint-config-viclafouch\n')
|
|
31
|
+
console.log('Select your stack:\n')
|
|
32
|
+
|
|
33
|
+
for (const [key, value] of Object.entries(TEMPLATES)) {
|
|
34
|
+
console.log(` ${key}. ${value.name}`)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
console.log('')
|
|
38
|
+
|
|
39
|
+
const answer = await question('Your choice (1-3): ')
|
|
40
|
+
const choice = TEMPLATES[answer]
|
|
41
|
+
|
|
42
|
+
if (!choice) {
|
|
43
|
+
console.log('\nInvalid choice. Exiting.\n')
|
|
44
|
+
rl.close()
|
|
45
|
+
process.exit(1)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const templatePath = join(directory, '..', 'templates', choice.file)
|
|
49
|
+
const targetPath = join(process.cwd(), 'eslint.config.js')
|
|
50
|
+
|
|
51
|
+
if (existsSync(targetPath)) {
|
|
52
|
+
const overwrite = await question(
|
|
53
|
+
'\neslint.config.js already exists. Overwrite? (y/N): '
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
if (overwrite.toLowerCase() !== 'y') {
|
|
57
|
+
console.log('\nAborted.\n')
|
|
58
|
+
rl.close()
|
|
59
|
+
process.exit(0)
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const template = readFileSync(templatePath, 'utf-8')
|
|
64
|
+
writeFileSync(targetPath, template)
|
|
65
|
+
|
|
66
|
+
console.log(`\neslint.config.js created with ${choice.name} configuration.\n`)
|
|
67
|
+
console.log('Next steps:')
|
|
68
|
+
console.log(' 1. Run: npm i -D @viclafouch/eslint-config-viclafouch')
|
|
69
|
+
console.log(' 2. Run: npm run lint\n')
|
|
70
|
+
|
|
71
|
+
rl.close()
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
main().catch((error) => {
|
|
75
|
+
console.error(error)
|
|
76
|
+
process.exit(1)
|
|
77
|
+
})
|
package/eslint.config.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { prettierConfig, typescriptConfig } from './index.mjs'
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @type {import("eslint").Linter.Config}
|
|
@@ -7,7 +7,7 @@ export default [
|
|
|
7
7
|
{
|
|
8
8
|
ignores: ['**/*.d.ts']
|
|
9
9
|
},
|
|
10
|
-
...
|
|
10
|
+
...typescriptConfig,
|
|
11
11
|
...prettierConfig,
|
|
12
12
|
{
|
|
13
13
|
rules: {
|
package/index.d.ts
CHANGED
package/index.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@viclafouch/eslint-config-viclafouch",
|
|
3
|
-
"version": "4.22.1-beta.
|
|
3
|
+
"version": "4.22.1-beta.5",
|
|
4
4
|
"description": "ESLint and Prettier Config from Victor de la Fouchardiere",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.mjs",
|
|
7
7
|
"types": "./index.d.ts",
|
|
8
|
+
"bin": {
|
|
9
|
+
"eslint-config-viclafouch": "./bin/init.js"
|
|
10
|
+
},
|
|
8
11
|
"exports": {
|
|
9
12
|
".": {
|
|
10
13
|
"types": "./index.d.ts",
|
package/rules/react.mjs
CHANGED
|
@@ -365,7 +365,7 @@ export default [
|
|
|
365
365
|
|
|
366
366
|
// Enforce sandbox attribute on iframe elements
|
|
367
367
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/c8833f301314dab3e79ef7ac4cf863e4d5fa0019/docs/rules/iframe-missing-sandbox.md
|
|
368
|
-
'react/iframe-missing-sandbox': '
|
|
368
|
+
'react/iframe-missing-sandbox': 'off',
|
|
369
369
|
|
|
370
370
|
// Prevent problematic leaked values from being rendered
|
|
371
371
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/c42b624d0fb9ad647583a775ab9751091eec066f/docs/rules/jsx-no-leaked-render.md
|