@coderwyd/eslint-config 1.0.10 → 1.1.0-beta.1
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 +132 -0
- package/dist/index.cjs +1441 -0
- package/dist/index.d.cts +178 -0
- package/dist/index.d.ts +178 -0
- package/dist/index.js +1360 -0
- package/package.json +67 -10
- package/index.js +0 -3
package/README.md
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# @coderwyd/eslint-config
|
|
2
|
+
|
|
3
|
+
[](https://github.com/coderwyd/eslint-config/actions/workflows/release.yml)
|
|
4
|
+
[](https://npmjs.org/package/@coderwyd/eslint-config)
|
|
5
|
+
[](https://npmjs.org/package/@coderwyd/eslint-config)
|
|
6
|
+
|
|
7
|
+
## Feature
|
|
8
|
+
|
|
9
|
+
- Single quotes, no semi
|
|
10
|
+
- Auto fix for formatting (aimed to be used standalone **without** Prettier)
|
|
11
|
+
- Designed to work with TypeScript, Vue out-of-box
|
|
12
|
+
- Lint also for json, yaml, markdown
|
|
13
|
+
- Sorted imports, dangling commas
|
|
14
|
+
- Reasonable defaults, best practices, only one-line of config
|
|
15
|
+
|
|
16
|
+
## Usage
|
|
17
|
+
|
|
18
|
+
### Install
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
pnpm add -D eslint @coderwyd/eslint-config # JavaScript, TypeScript and Vue 3
|
|
22
|
+
# Or yarn add eslint @coderwyd/eslint-config -D / npm install eslint @coderwyd/eslint-config -D
|
|
23
|
+
pnpm add -D @coderwyd/eslint-config-basic # JavaScript only
|
|
24
|
+
pnpm add -D @coderwyd/eslint-config-ts # JavaScript and TypeScript
|
|
25
|
+
pnpm add -D @coderwyd/eslint-config-react # JavaScript, TypeScript and React
|
|
26
|
+
pnpm add -D @coderwyd/eslint-config-vue # JavaScript, TypeScript and Vue 3
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Config `.eslintrc`
|
|
30
|
+
|
|
31
|
+
```json
|
|
32
|
+
{
|
|
33
|
+
"extends": "@coderwyd"
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
> You don't need `.eslintignore` normally as it has been provided by the preset.
|
|
38
|
+
|
|
39
|
+
### Add script for package.json
|
|
40
|
+
|
|
41
|
+
For example:
|
|
42
|
+
|
|
43
|
+
```json
|
|
44
|
+
{
|
|
45
|
+
"scripts": {
|
|
46
|
+
"lint": "eslint .",
|
|
47
|
+
"lint:fix": "eslint . --fix"
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### VS Code support (auto fix)
|
|
53
|
+
|
|
54
|
+
Add the following settings to your `settings.json`:
|
|
55
|
+
|
|
56
|
+
```jsonc
|
|
57
|
+
{
|
|
58
|
+
"prettier.enable": false,
|
|
59
|
+
"editor.formatOnSave": false,
|
|
60
|
+
"editor.codeActionsOnSave": {
|
|
61
|
+
"source.fixAll.eslint": true,
|
|
62
|
+
"source.organizeImports": false
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
// The following is optional.
|
|
66
|
+
// It's better to put under project setting `.vscode/settings.json`
|
|
67
|
+
// to avoid conflicts with working with different eslint configs
|
|
68
|
+
// that does not support all formats.
|
|
69
|
+
"eslint.validate": ["javascript", "javascriptreact", "typescript", "typescriptreact", "vue", "html", "markdown", "json", "jsonc", "yaml"]
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### TypeScript Aware Rules
|
|
74
|
+
|
|
75
|
+
Type aware rules are enabled when a `tsconfig.eslint.json` is found in the project root, which will introduce some stricter rules into your project. If you want to enable it while have no `tsconfig.eslint.json` in the project root, you can change tsconfig name by modifying `ESLINT_TSCONFIG` env.
|
|
76
|
+
|
|
77
|
+
```js
|
|
78
|
+
// .eslintrc.js
|
|
79
|
+
const process = require('node:process')
|
|
80
|
+
|
|
81
|
+
process.env.ESLINT_TSCONFIG = 'tsconfig.json'
|
|
82
|
+
|
|
83
|
+
module.exports = {
|
|
84
|
+
extends: '@coderwyd',
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Lint Staged
|
|
89
|
+
|
|
90
|
+
If you want to apply lint and auto-fix before every commit, you can add the following to your `package.json`:
|
|
91
|
+
|
|
92
|
+
```json
|
|
93
|
+
{
|
|
94
|
+
"simple-git-hooks": {
|
|
95
|
+
"pre-commit": "pnpm lint-staged"
|
|
96
|
+
},
|
|
97
|
+
"lint-staged": {
|
|
98
|
+
"*": "eslint --fix"
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
and then
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
npm i -D lint-staged simple-git-hooks
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## FAQ
|
|
110
|
+
|
|
111
|
+
### Customization rules
|
|
112
|
+
|
|
113
|
+
add you like rules to your .eslintrc file.
|
|
114
|
+
|
|
115
|
+
<!-- eslint-skip -->
|
|
116
|
+
|
|
117
|
+
```jsonc
|
|
118
|
+
{
|
|
119
|
+
"extends": "@coderwyd",
|
|
120
|
+
"rules": {
|
|
121
|
+
// your rules...
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## Thanks
|
|
127
|
+
|
|
128
|
+
This project is based on [@antfu/eslint-config](https://github.com/antfu/eslint-config)
|
|
129
|
+
|
|
130
|
+
## License
|
|
131
|
+
|
|
132
|
+
[MIT](./LICENSE) License © 2019-PRESENT [Donny Wang](https://github.com/coderwyd)
|