@cany748/eslint-config 2.0.0 → 3.0.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 +85 -0
- package/dist/index.cjs +1330 -0
- package/dist/index.d.cts +10544 -0
- package/dist/index.d.ts +10544 -0
- package/dist/index.js +1244 -0
- package/package.json +70 -16
- package/index.js +0 -366
package/README.md
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# @cany748/eslint-config
|
|
2
|
+
|
|
3
|
+
ESLint config for JavaScript, TypeScript, Vue 2/3.
|
|
4
|
+
|
|
5
|
+
Based on [Anthony Fu](https://github.com/antfu/eslint-config) configs.
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
### Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pnpm add -D @cany748/eslint-config
|
|
13
|
+
# Or yarn add -D / npm install -D / bun add -D
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
### Config
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
// eslint.config.ts
|
|
20
|
+
{
|
|
21
|
+
import { factoryConfig } from "@cany748/eslint-config";
|
|
22
|
+
|
|
23
|
+
export default factoryConfig({
|
|
24
|
+
// Type of the project. 'lib' for libraries, the default is 'app'
|
|
25
|
+
type: "lib",
|
|
26
|
+
|
|
27
|
+
// TypeScript, Vue and UnoCSS are autodetected, you can also explicitly enable them:
|
|
28
|
+
typescript: true,
|
|
29
|
+
vue: true,
|
|
30
|
+
unocss: true,
|
|
31
|
+
|
|
32
|
+
// to enable type-aware rules use
|
|
33
|
+
typescript: { tsconfigPath: "./tsconfig.json", filesTypeAware: ["**/*.{ts,tsx,vue}"] },
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
```jsonc
|
|
39
|
+
// `.prettierrc` or `prettier` on `package.json`
|
|
40
|
+
{
|
|
41
|
+
"printWidth": 140
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Add script for package.json
|
|
46
|
+
|
|
47
|
+
For example:
|
|
48
|
+
|
|
49
|
+
```json
|
|
50
|
+
{
|
|
51
|
+
"scripts": {
|
|
52
|
+
"lint": "eslint .",
|
|
53
|
+
"lint:fix": "eslint . --fix"
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Lint Staged
|
|
59
|
+
|
|
60
|
+
If you want to apply lint and auto-fix before every commit, you can add the following to your `package.json`:
|
|
61
|
+
|
|
62
|
+
```json
|
|
63
|
+
{
|
|
64
|
+
"simple-git-hooks": {
|
|
65
|
+
"pre-commit": "pnpm lint-staged"
|
|
66
|
+
},
|
|
67
|
+
"lint-staged": {
|
|
68
|
+
"*": "eslint --fix"
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
and then
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
pnpm add -D lint-staged simple-git-hooks
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### View what rules are enabled
|
|
80
|
+
|
|
81
|
+
Go to your project root that contains `eslint.config.*` and run:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
npx @eslint/config-inspector
|
|
85
|
+
```
|