eslint-config-plus-prettier 4.1.8 → 4.1.9
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 +87 -30
- package/eslint.config.js +1 -9
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -1,26 +1,24 @@
|
|
|
1
1
|
# eslint-config-plus-prettier
|
|
2
2
|
|
|
3
|
-
Standard config for ESLint, Prettier and Package Lint. Also includes an optional TSConfig.
|
|
3
|
+
> Standard config for ESLint, Prettier and Package Lint. Also includes an optional TSConfig.
|
|
4
4
|
|
|
5
|
-
##
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
npm install --save-dev eslint-config-plus-prettier
|
|
9
|
-
```
|
|
5
|
+
## Quick Setup
|
|
10
6
|
|
|
11
7
|
Add the following scripts to your `package.json`:
|
|
12
8
|
|
|
13
9
|
```json
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
10
|
+
{
|
|
11
|
+
"scripts": {
|
|
12
|
+
"format": "prettier --write .",
|
|
13
|
+
"format:check": "prettier --check .",
|
|
14
|
+
"lint": "eslint --fix",
|
|
15
|
+
"lint:check": "eslint",
|
|
16
|
+
"package:lint": "npx npm-package-json-lint ."
|
|
17
|
+
}
|
|
18
|
+
}
|
|
21
19
|
```
|
|
22
20
|
|
|
23
|
-
|
|
21
|
+
## Configuration
|
|
24
22
|
|
|
25
23
|
Add a `eslint.config.js` file with the following:
|
|
26
24
|
|
|
@@ -36,26 +34,29 @@ Consider adding a `.eslintignore` file to avoid trying to lint compiled code in
|
|
|
36
34
|
dist
|
|
37
35
|
```
|
|
38
36
|
|
|
39
|
-
###
|
|
37
|
+
### Prettier
|
|
40
38
|
|
|
41
|
-
Add prettier
|
|
39
|
+
Add prettier configuration to your `package.json`:
|
|
42
40
|
|
|
43
41
|
```json
|
|
44
|
-
|
|
42
|
+
{
|
|
43
|
+
"prettier": "eslint-config-plus-prettier/prettier"
|
|
44
|
+
}
|
|
45
45
|
```
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
**Optional**: Create a `.prettierignore` file to exclude generated files:
|
|
48
48
|
|
|
49
49
|
```text
|
|
50
50
|
package-lock.json
|
|
51
51
|
CHANGELOG.md
|
|
52
|
+
dist
|
|
52
53
|
```
|
|
53
54
|
|
|
54
|
-
###
|
|
55
|
+
### Package Lint
|
|
55
56
|
|
|
56
|
-
|
|
57
|
+
Create a `.npmpackagejsonlintrc.json` file in your project root:
|
|
57
58
|
|
|
58
|
-
|
|
59
|
+
**For npm modules/libraries:**
|
|
59
60
|
|
|
60
61
|
```json
|
|
61
62
|
{
|
|
@@ -63,7 +64,7 @@ If you are working on a module:
|
|
|
63
64
|
}
|
|
64
65
|
```
|
|
65
66
|
|
|
66
|
-
|
|
67
|
+
**For applications/servers (with fixed dependencies):**
|
|
67
68
|
|
|
68
69
|
```json
|
|
69
70
|
{
|
|
@@ -71,28 +72,84 @@ If you are working on a server, that needs fixed dependencies:
|
|
|
71
72
|
}
|
|
72
73
|
```
|
|
73
74
|
|
|
74
|
-
###
|
|
75
|
+
### TypeScript (Optional)
|
|
75
76
|
|
|
76
|
-
|
|
77
|
+
Create a `tsconfig.json` file for TypeScript projects:
|
|
77
78
|
|
|
78
79
|
```json
|
|
79
80
|
{
|
|
80
81
|
"extends": "eslint-config-plus-prettier/tsconfig",
|
|
81
|
-
"include": ["src"],
|
|
82
|
+
"include": ["src/**/*"],
|
|
82
83
|
"compilerOptions": {
|
|
83
|
-
"outDir": "dist"
|
|
84
|
+
"outDir": "dist"
|
|
84
85
|
}
|
|
85
86
|
}
|
|
86
87
|
```
|
|
87
88
|
|
|
88
|
-
##
|
|
89
|
+
## Usage
|
|
90
|
+
|
|
91
|
+
Run the following commands to lint and format your code:
|
|
89
92
|
|
|
90
93
|
```bash
|
|
94
|
+
# Lint and auto-fix JavaScript/TypeScript files
|
|
91
95
|
npm run lint
|
|
96
|
+
|
|
97
|
+
# Format all files with Prettier
|
|
92
98
|
npm run format
|
|
99
|
+
|
|
100
|
+
# Validate package.json structure
|
|
93
101
|
npm run package:lint
|
|
102
|
+
|
|
103
|
+
# Check formatting without making changes
|
|
104
|
+
npm run format:check
|
|
105
|
+
|
|
106
|
+
# Check linting without auto-fixing
|
|
107
|
+
npm run lint:check
|
|
94
108
|
```
|
|
95
109
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
110
|
+
## What's Included
|
|
111
|
+
|
|
112
|
+
### ESLint Rules
|
|
113
|
+
|
|
114
|
+
- **TypeScript support** with `@typescript-eslint` parser and plugin
|
|
115
|
+
- **Import sorting** with `simple-import-sort` plugin
|
|
116
|
+
- **Unused import removal** with `unused-imports` plugin
|
|
117
|
+
- **Consistent quotes** (double quotes)
|
|
118
|
+
- **Prefer const** for immutable variables
|
|
119
|
+
- **Unused variable warnings** (with underscore prefix exception)
|
|
120
|
+
|
|
121
|
+
### Prettier Configuration
|
|
122
|
+
|
|
123
|
+
- **Double quotes** for strings
|
|
124
|
+
- **Semicolons** enabled
|
|
125
|
+
- **Trailing commas** in ES5-compatible locations
|
|
126
|
+
- **120 character** line width
|
|
127
|
+
- **2 spaces** for indentation
|
|
128
|
+
|
|
129
|
+
### Package Lint Rules
|
|
130
|
+
|
|
131
|
+
- Validates `package.json` structure and dependencies
|
|
132
|
+
- Different rulesets for modules vs. applications
|
|
133
|
+
- Ensures consistent package metadata
|
|
134
|
+
|
|
135
|
+
## Troubleshooting
|
|
136
|
+
|
|
137
|
+
### ESLint Issues
|
|
138
|
+
|
|
139
|
+
- Make sure you're using ESLint v9+ for flat config support
|
|
140
|
+
- Check that your `eslint.config.js` is in the project root
|
|
141
|
+
- Verify all files you want to lint match the file patterns
|
|
142
|
+
|
|
143
|
+
### Prettier Conflicts
|
|
144
|
+
|
|
145
|
+
- This config uses `eslint-config-prettier` to disable conflicting ESLint rules
|
|
146
|
+
- If you see formatting conflicts, check your `.prettierignore` file
|
|
147
|
+
|
|
148
|
+
### Import Errors
|
|
149
|
+
|
|
150
|
+
- Ensure you're using ES modules (`"type": "module"` in package.json)
|
|
151
|
+
- For CommonJS projects, use `.cjs` extension for config files
|
|
152
|
+
|
|
153
|
+
## Contributing
|
|
154
|
+
|
|
155
|
+
Found an issue or have a suggestion? Please [open an issue](https://github.com/aimeerivers/eslint-config-plus-prettier/issues) or submit a pull request.
|
package/eslint.config.js
CHANGED
|
@@ -16,15 +16,6 @@ export default {
|
|
|
16
16
|
files: ["**/*.ts", "**/*.js"],
|
|
17
17
|
rules: {
|
|
18
18
|
"@typescript-eslint/no-floating-promises": ["off"],
|
|
19
|
-
"@typescript-eslint/no-unused-vars": [
|
|
20
|
-
"warn",
|
|
21
|
-
{
|
|
22
|
-
vars: "all",
|
|
23
|
-
varsIgnorePattern: "^_",
|
|
24
|
-
args: "after-used",
|
|
25
|
-
argsIgnorePattern: "^_",
|
|
26
|
-
},
|
|
27
|
-
],
|
|
28
19
|
"prefer-const": [
|
|
29
20
|
"error",
|
|
30
21
|
{
|
|
@@ -36,5 +27,6 @@ export default {
|
|
|
36
27
|
"simple-import-sort/exports": "error",
|
|
37
28
|
quotes: ["error", "double"],
|
|
38
29
|
"unused-imports/no-unused-imports": "warn",
|
|
30
|
+
"no-unused-vars": "warn",
|
|
39
31
|
},
|
|
40
32
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-config-plus-prettier",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.9",
|
|
4
4
|
"description": "Standard config for ESLint, Prettier and Package Lint. Also includes an optional TSConfig.",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "aimee rivers",
|
|
@@ -31,12 +31,12 @@
|
|
|
31
31
|
"package:lint": "npx npm-package-json-lint ."
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
35
|
-
"@typescript-eslint/parser": "^8.
|
|
36
|
-
"eslint": "^9.
|
|
37
|
-
"eslint-config-prettier": "^
|
|
34
|
+
"@typescript-eslint/eslint-plugin": "^8.33.1",
|
|
35
|
+
"@typescript-eslint/parser": "^8.33.1",
|
|
36
|
+
"eslint": "^9.28.0",
|
|
37
|
+
"eslint-config-prettier": "^10.1.5",
|
|
38
38
|
"eslint-plugin-import": "^2.31.0",
|
|
39
|
-
"eslint-plugin-prettier": "^5.
|
|
39
|
+
"eslint-plugin-prettier": "^5.4.1",
|
|
40
40
|
"eslint-plugin-promise": "^7.2.1",
|
|
41
41
|
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
42
42
|
"eslint-plugin-unused-imports": "^4.1.4",
|