Skip to content

Commit 3cce249

Browse files
authored
🔥 Eslint Commitlint upgrade (#262)
* chore: commitlint upgrade * chore: eslint commitlint upgrade * style: opt dir & files * docs: opt
1 parent 75f6c1f commit 3cce249

File tree

18 files changed

+253
-373
lines changed

18 files changed

+253
-373
lines changed

.eslintignore

Lines changed: 0 additions & 12 deletions
This file was deleted.

.eslintrc.js

Lines changed: 0 additions & 4 deletions
This file was deleted.

.husky/commit-msg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/usr/bin/env sh
22
. "$(dirname -- "$0")/_/husky.sh"
33

4-
# npx --no-install commitlint --edit "$1"
4+
npx --no-install commitlint --edit "$1"

CONTRIBUTING.md

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ To develop and test the core `VueHooks Plus` package:
2222

2323
1. `packages/hooks/src` folder adds a folder starting with an `useXxx`.
2424

25-
2. Add `en-US.md` and `zh-CN.md` as a document.
25+
2. Add `*.md` as a document at `docs/en` or `docs/zh`.
2626

27-
3. Add `demo` folder as a document example.
27+
3. Add `demo` folder as a document example as `docs/demo`.
2828

2929
4. Add `__tests__` folder as Unit Tests.
3030

@@ -40,19 +40,7 @@ Start documentation via [Dev Document Guide](./DEV_DOCUMENT.md).
4040

4141
1. Run `pnpm docs:dev` in VueHooks Plus's root folder or Run `pnpm initial` and `pnpm docs:dev` `packages/hooks` folder.
4242

43-
2. `.md` must add a mapping path.
44-
45-
```
46-
47-
---
48-
map:
49-
# Path mapped to docs
50-
path: /useBoolean
51-
---
52-
53-
```
54-
55-
3. `packages/hooks/docs/.vitepress/router.ts` add hooks router info.
43+
2. `docs/.vitepress/config` add hooks router info.
5644

5745
## Pull Request Guidelines
5846

DEV_DOCUMENT.md

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,8 @@
11
# Dev the Document
22

3-
## Working principle
4-
5-
I modified the [ruabick](https://github.com/dewfall123/ruabick) plugin o read the .md file and map the generated path。
6-
7-
### plugins:
8-
9-
- `@vue-hooks-plus/vite-plugin-gen-temp` dynamically generate md files.
10-
- `@vue-hooks-plus/vitepress-demo-block` demo block at the md files.
11-
- `@vue-hooks-plus/vitepress` transformation based on vitepress to support internationalization.
12-
- `@vue-hooks-plus/md-demo-plugins` apply demo block.
13-
14-
[Source](https://github.com/InhiblabCore/plugins)
15-
163
## Start
174

18-
need run initial at `packages/hooks` folder.
19-
20-
```bash
21-
22-
pnpm initial
23-
24-
```
25-
26-
Check if a .docs folder is generated in your directory。If it fails, it cannot be started and needs to be re-run `initial` 👆 .
27-
28-
next, vitepress run .docs
29-
305
```bash
31-
32-
pnpm docs:dev
33-
34-
```
35-
36-
or
37-
38-
at `root` dir run
39-
40-
```bash
41-
6+
pnpm install
427
pnpm docs:dev
43-
448
```
45-
46-
will implement script to finished `scripts/docs.ts`
47-
48-
If the page startup is blank, you need to refresh the page.
Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,12 @@
1111
// revert:回滚某个更早之前的提交 | Roll back some earlier previous submission
1212
// version: 改变package.json 版本 | Change the package.json version
1313

14-
module.exports = {
14+
import { RuleConfigSeverity, type UserConfig } from "@commitlint/types";
15+
16+
const Configuration: UserConfig = {
17+
extends: ["@commitlint/config-conventional"],
18+
formatter: "@commitlint/format",
1519
ignores: [commit => commit.includes('init')],
16-
extends: ['@commitlint/config-conventional'],
1720
rules: {
1821
'body-leading-blank': [2, 'always'],
1922
'footer-leading-blank': [1, 'always'],
@@ -22,8 +25,7 @@ module.exports = {
2225
'type-empty': [2, 'never'],
2326
'subject-case': [0],
2427
'type-enum': [
25-
2,
26-
'always',
28+
RuleConfigSeverity.Error, "always",
2729
[
2830
'feat',
2931
'fix',
@@ -42,4 +44,7 @@ module.exports = {
4244
],
4345
],
4446
},
45-
}
47+
};
48+
49+
export default Configuration;
50+

eslint.config.js

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import pluginVue from 'eslint-plugin-vue'
2+
import globals from 'globals'
3+
import { defineConfig, globalIgnores } from 'eslint/config'
4+
5+
export default defineConfig([
6+
...pluginVue.configs['flat/recommended'],
7+
globalIgnores(['dist/*', 'node_modules/*', 'patches/*', 'types/*']),
8+
{
9+
rules: {
10+
'vue/multi-word-component-names': 'off',
11+
'vue/html-self-closing': 'off',
12+
'react/no-string-refs': 'off',
13+
'react/no-unknown-property': 'off',
14+
'react/display-name': 'off',
15+
'no-sparse-arrays': 0,
16+
'no-inner-declarations': 0,
17+
'no-constant-condition': 0,
18+
'no-restricted-imports': [
19+
'error',
20+
{
21+
paths: ['vue-hooks-plus', '..', '../..', 'packages/hooks/src/index.ts'],
22+
},
23+
],
24+
'no-unused-vars': [
25+
2,
26+
{
27+
vars: 'local',
28+
args: 'none',
29+
},
30+
],
31+
'node/no-callback-literal': 'off',
32+
'import/namespace': 'off',
33+
'import/default': 'off',
34+
'import/no-named-as-default': 'off',
35+
'import/no-named-as-default-member': 'off',
36+
37+
'vue/attributes-order': 'off',
38+
'vue/one-component-per-file': 'off',
39+
'vue/html-closing-bracket-newline': 'off',
40+
'vue/max-attributes-per-line': 'off',
41+
'vue/multiline-html-element-content-newline': 'off',
42+
'vue/singleline-html-element-content-newline': 'off',
43+
'vue/attribute-hyphenation': 'off',
44+
'vue/require-default-prop': 'off',
45+
},
46+
languageOptions: {
47+
sourceType: 'module',
48+
globals: {
49+
...globals.browser,
50+
},
51+
},
52+
},
53+
])

package.json

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
"docs:build": "pnpm build && vitepress build docs",
1515
"docs:build-github": "pnpm build:vitepress-demo-block && tsx scripts/gitPage.ts github",
1616
"docs:build-gitee": "pnpm build:vitepress-demo-block && tsx scripts/gitPage.ts gitee",
17-
"clean": " rimraf dist lib es",
1817
"build": "pnpm recursive exec pnpm run build",
1918
"test": "vitest",
2019
"test:ui": "vitest --ui",
@@ -23,8 +22,8 @@
2322
"docs:preview": "vitepress preview docs"
2423
},
2524
"devDependencies": {
26-
"@commitlint/cli": "^17.1.2",
27-
"@commitlint/config-conventional": "^17.1.0",
25+
"@commitlint/cli": "^17.8.1",
26+
"@commitlint/config-conventional": "^17.8.1",
2827
"@types/fs-extra": "^9.0.13",
2928
"@types/jest": "^29.0.0",
3029
"@types/lodash": "^4.14.178",
@@ -34,18 +33,18 @@
3433
"@types/prettier": "^2.6.3",
3534
"@types/qs": "^6.9.7",
3635
"@types/react-dom": "^18.0.6",
36+
"@typescript-eslint/eslint-plugin": "^5.33.0",
3737
"@vite-pwa/vitepress": "^1.0.0",
3838
"@vitejs/plugin-vue": "^2.3.1",
3939
"@vitest/coverage-c8": "^0.25.7",
4040
"@vitest/ui": "^0.25.3",
41-
"@vue-hooks-plus/eslint-config": "workspace:^1.0.0",
4241
"@vue-hooks-plus/md-demo-plugins": "^1.0.0",
4342
"@vue-hooks-plus/types": "workspace:^2.0.0",
4443
"@vue-hooks-plus/use-immer": "workspace:^1.0.0",
4544
"@vue-hooks-plus/use-request": "workspace:^2.0.0",
4645
"@vue-hooks-plus/use-request-plugins": "workspace:^2.0.0",
47-
"@vue-hooks-plus/use-worker": "workspace:^1.0.0",
4846
"@vue-hooks-plus/use-url-state": "workspace:^1.0.0",
47+
"@vue-hooks-plus/use-worker": "workspace:^1.0.0",
4948
"@vue-hooks-plus/vite-plugin-gen-temp": "^2.6.6",
5049
"@vue-hooks-plus/vitepress": "^1.2.4",
5150
"@vue-hooks-plus/vitepress-demo-block": "workspace:^1.0.0",
@@ -54,6 +53,8 @@
5453
"axios": "^1.4.0",
5554
"broadcast-channel": "^5.1.0",
5655
"cross-env": "^7.0.3",
56+
"eslint": "^9.24.0",
57+
"eslint-plugin-vue": "^9.6.0",
5758
"execa": "^6.1.0",
5859
"fast-glob": "^3.2.12",
5960
"fs-extra": "^11.3.0",
@@ -84,9 +85,12 @@
8485
"vue-tsc": "1.0.9",
8586
"vue-typical": "^2.1.0"
8687
},
88+
"simple-git-hooks": {
89+
"pre-commit": "npx lint-staged"
90+
},
8791
"lint-staged": {
88-
"*.{js,ts,tsx,vue}": [
89-
"echo Linting..."
92+
"*.{js,ts,tsx,vue,md,json}": [
93+
"eslint --cache --fix"
9094
]
9195
},
9296
"repository": "https://github.com/InhiblabCore/vue-hooks-plus",

packages/eslint-config/index.js

Lines changed: 0 additions & 100 deletions
This file was deleted.

0 commit comments

Comments
 (0)