@wildpastry/eslint-config 1.7.9 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc +230 -228
- package/.prettierrc +19 -0
- package/README.md +121 -29
- package/index.js +294 -305
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,55 +1,147 @@
|
|
|
1
|
-
# ESLintConfig
|
|
2
|
-
|
|
1
|
+
# ESLintConfig React
|
|
2
|
+
|
|
3
|
+
Shareable ESLint React configuration settings linked with Prettier. ESLint formatting rules are disabled, then re-enabled through the eslint-prettier plugin. This way the formatting rules still get applied and Prettier formatting won't conflict with ESLint linting.
|
|
3
4
|
|
|
4
5
|
No errors, only warnings.
|
|
5
6
|
|
|
6
7
|
## Prerequisites
|
|
8
|
+
|
|
7
9
|
- NodeJS and NPM installed
|
|
8
10
|
- Project set up with NodeJS and a package.json
|
|
9
11
|
- Official ESLint and Prettier extensions installed
|
|
10
12
|
- Navigate to the root directory of your project
|
|
11
13
|
|
|
12
|
-
## Installation and
|
|
14
|
+
## Installation and Usage
|
|
13
15
|
|
|
14
|
-
### Install
|
|
15
|
-
```
|
|
16
|
-
npm i eslint@latest prettier@latest
|
|
17
|
-
```
|
|
16
|
+
### 1. Install ESLint and Prettier core packages
|
|
18
17
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
npm i @typescript-eslint/eslint-plugin@latest eslint-plugin-react@latest eslint-plugin-prettier@latest
|
|
18
|
+
```bash
|
|
19
|
+
npm i eslint prettier
|
|
22
20
|
```
|
|
23
21
|
|
|
24
|
-
### Install
|
|
22
|
+
### 2. Install ESLint plugins
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npm i @typescript-eslint/eslint-plugin @typescript-eslint/parser eslint-plugin-react eslint-plugin-prettier
|
|
25
26
|
```
|
|
26
|
-
|
|
27
|
+
|
|
28
|
+
### 3. Install @wildpastry custom ESLint config
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npm i @wildpastry/eslint-config
|
|
27
32
|
```
|
|
28
33
|
|
|
29
|
-
###
|
|
34
|
+
### 4. Create .prettierrc file
|
|
35
|
+
|
|
36
|
+
Create a `.prettierrc` file in your project root:
|
|
37
|
+
|
|
38
|
+
```json
|
|
39
|
+
{
|
|
40
|
+
"arrowParens": "always",
|
|
41
|
+
"bracketSameLine": true,
|
|
42
|
+
"bracketSpacing": true,
|
|
43
|
+
"embeddedLanguageFormatting": "auto",
|
|
44
|
+
"endOfLine": "auto",
|
|
45
|
+
"htmlWhitespaceSensitivity": "strict",
|
|
46
|
+
"insertPragma": false,
|
|
47
|
+
"jsxSingleQuote": true,
|
|
48
|
+
"printWidth": 80,
|
|
49
|
+
"proseWrap": "preserve",
|
|
50
|
+
"quoteProps": "consistent",
|
|
51
|
+
"requirePragma": false,
|
|
52
|
+
"semi": true,
|
|
53
|
+
"singleQuote": true,
|
|
54
|
+
"tabWidth": 2,
|
|
55
|
+
"trailingComma": "none",
|
|
56
|
+
"useTabs": false
|
|
57
|
+
}
|
|
30
58
|
```
|
|
59
|
+
|
|
60
|
+
### 5. Add config to eslint.config.js
|
|
61
|
+
|
|
62
|
+
Create an `eslint.config.js` file in your project root:
|
|
63
|
+
|
|
64
|
+
```javascript
|
|
65
|
+
import { defineConfig, globalIgnores } from 'eslint/config';
|
|
31
66
|
import wildpastryConfig from '@wildpastry/eslint-config';
|
|
32
67
|
|
|
33
68
|
export default defineConfig([
|
|
69
|
+
globalIgnores(['dist']),
|
|
70
|
+
...wildpastryConfig,
|
|
34
71
|
{
|
|
35
|
-
files: ['**/*.{
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
72
|
+
files: ['**/*.{ts,tsx}'],
|
|
73
|
+
extends: [
|
|
74
|
+
// All other recommended here
|
|
75
|
+
],
|
|
76
|
+
languageOptions: {
|
|
77
|
+
ecmaVersion: 2020,
|
|
78
|
+
globals: globals.browser
|
|
79
|
+
}
|
|
80
|
+
}
|
|
44
81
|
]);
|
|
45
82
|
```
|
|
46
83
|
|
|
47
|
-
###
|
|
48
|
-
|
|
84
|
+
### 6. Add TypeScript declaration (if needed)
|
|
85
|
+
|
|
86
|
+
If using TypeScript, create a `types/wildpastry-eslint-config.d.ts` file:
|
|
87
|
+
|
|
88
|
+
```typescript
|
|
89
|
+
declare module '@wildpastry/eslint-config';
|
|
49
90
|
```
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
91
|
+
|
|
92
|
+
### 7. Add optional scripts to package.json
|
|
93
|
+
|
|
94
|
+
Add these scripts inside `"scripts": { ... }` in your package.json:
|
|
95
|
+
|
|
96
|
+
```json
|
|
97
|
+
{
|
|
98
|
+
"scripts": {
|
|
99
|
+
"lint": "eslint \"**/*.{js,jsx,ts,tsx}\"",
|
|
100
|
+
"lint:fix": "eslint --fix \"**/*.{js,jsx,ts,tsx}\"",
|
|
101
|
+
"format": "npx prettier --check \"**/*.{js,jsx,ts,tsx}\"",
|
|
102
|
+
"format:fix": "npx prettier --write \"**/*.{js,jsx,ts,tsx}\"",
|
|
103
|
+
"clean": "npx prettier --write \"**/*.{js,jsx,ts,tsx}\" && npm run lint:fix"
|
|
104
|
+
}
|
|
105
|
+
}
|
|
55
106
|
```
|
|
107
|
+
|
|
108
|
+
## Usage Commands
|
|
109
|
+
|
|
110
|
+
### Check linting issues:
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
npm run lint
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Fix linting issues automatically (may not fix all):
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
npm run lint:fix
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Check formatting issues:
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
npm run format
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Fix formatting issues automatically (may not fix all):
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
npm run format:fix
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Clean and fix both formatting and linting (may not fix all):
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
npm run clean
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## Features
|
|
141
|
+
|
|
142
|
+
- Modern ESLint flat config format
|
|
143
|
+
- TypeScript support with modern rules
|
|
144
|
+
- React 17+ support (no React import required)
|
|
145
|
+
- Prettier integration for consistent formatting
|
|
146
|
+
- Warnings only (no errors) for better development experience
|
|
147
|
+
- Optimized for modern JavaScript/TypeScript practices
|