Skip to content

Commit fd4e106

Browse files
committed
build: refine eslint and set up commitlint
1 parent ef96a54 commit fd4e106

File tree

8 files changed

+599
-382
lines changed

8 files changed

+599
-382
lines changed

.commitlintrc.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
const fs = require('fs')
2+
const path = require('path')
3+
4+
const VuepressPackages = fs.readdirSync(path.resolve(__dirname, 'packages/@vuepress'))
5+
6+
module.exports = {
7+
extends: [
8+
'@commitlint/config-conventional'
9+
],
10+
rules: {
11+
'scope-enum': [
12+
'cli',
13+
...VuepressPackages
14+
].map(name => `$${name}`)
15+
}
16+
}

.eslintignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
**/node_modules
2+
!.eslintrc.js
3+
!.commitlintrc.js
4+
!.vuepress
25
packages/@vuepress/shared-utils/lib
6+
packages/@vuepress/shared-utils/types

.eslintrc.js

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,27 @@
11
module.exports = {
22
root: true,
33
extends: [
4-
'plugin:vue-libs/recommended',
5-
'plugin:jest/recommended'
4+
'plugin:vue-libs/recommended'
65
],
76
rules: {
87
indent: ['error', 2, { MemberExpression: 'off' }],
9-
"no-undef": ["error"],
10-
'operator-linebreak': ["error", "before"]
11-
}
8+
'no-undef': ['error'],
9+
'operator-linebreak': ['error', 'before']
10+
},
11+
overrides: [
12+
{
13+
files: ['**/__tests__/**/*.spec.js'],
14+
extends: ['plugin:jest/recommended']
15+
},
16+
{
17+
files: ['*.ts'],
18+
extends: [
19+
'plugin:@typescript-eslint/recommended'
20+
],
21+
parser: 'vue-eslint-parser',
22+
parserOptions: {
23+
parser: '@typescript-eslint/parser'
24+
}
25+
}
26+
]
1227
}

.lintstagedrc

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

package.json

Lines changed: 38 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,73 @@
11
{
22
"private": true,
3+
"description": "Minimalistic doc generator with Vue component based layout system",
34
"workspaces": [
45
"packages/@vuepress/*",
56
"packages/vuepress",
67
"packages/docs"
78
],
8-
"description": "Minimalistic doc generator with Vue component based layout system",
99
"scripts": {
10+
"boot": "node scripts/bootstrap.js",
1011
"bootstrap": "yarn && yarn tsc",
11-
"lerna:bootstrap": "lerna bootstrap",
12+
"build": "yarn tsc && yarn build:docs",
13+
"build:docs": "yarn workspace docs build",
14+
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 2",
1215
"clean": "lerna clean && rm -rf node_modules",
13-
"packages:list": "lerna ls -l",
14-
"packages:diff": "lerna diff",
15-
"packages:changed": "lerna changed",
16-
"boot": "node scripts/bootstrap.js",
17-
"remote-version": "node scripts/remote-version.js",
1816
"dev": "yarn tsc && yarn dev:docs",
1917
"dev:docs": "yarn workspace docs dev",
20-
"build": "yarn tsc && yarn build:docs",
21-
"build:docs": "yarn workspace docs build",
22-
"view-info": "yarn tsc && yarn workspace docs view-info",
23-
"show-help": "yarn workspace docs show-help",
24-
"register-vuepress": "lerna exec --scope vuepress -- yarn link",
18+
"lerna:bootstrap": "lerna bootstrap",
2519
"lint": "yarn lint:check --fix",
2620
"lint:check": "eslint packages --ext .js,.vue",
21+
"packages:changed": "lerna changed",
22+
"packages:diff": "lerna diff",
23+
"packages:list": "lerna ls -l",
24+
"register-vuepress": "lerna exec --scope vuepress -- yarn link",
2725
"release": "yarn --pure-lockfile && yarn tsc && node scripts/release.js",
28-
"unregister-vuepress": "lerna exec --scope vuepress -- yarn unlink",
29-
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 2",
26+
"remote-version": "node scripts/remote-version.js",
27+
"show-help": "yarn workspace docs show-help",
3028
"test": "node scripts/test.js",
31-
"tsc": "yarn workspace @vuepress/shared-utils tsc"
29+
"tsc": "yarn workspace @vuepress/shared-utils tsc",
30+
"unregister-vuepress": "lerna exec --scope vuepress -- yarn unlink",
31+
"view-info": "yarn tsc && yarn workspace docs view-info"
32+
},
33+
"husky": {
34+
"hooks": {
35+
"pre-commit": "lint-staged"
36+
}
37+
},
38+
"lint-staged": {
39+
"*.{js,vue}": [
40+
"eslint --fix",
41+
"git add"
42+
],
43+
"package.json": [
44+
"sort-package-json",
45+
"git add"
46+
]
3247
},
3348
"devDependencies": {
49+
"@commitlint/cli": "^8.2.0",
50+
"@commitlint/config-conventional": "^8.2.0",
3451
"@types/escape-html": "^0.0.20",
3552
"@types/fs-extra": "^5.0.4",
3653
"@types/globby": "^9.1.0",
3754
"@types/hash-sum": "^1.0.0",
3855
"@types/lru-cache": "^5.1.0",
3956
"@types/node": "^12.7.5",
4057
"@types/semver": "^6.0.0",
41-
"conventional-changelog-cli": "^2.0.23",
58+
"@typescript-eslint/eslint-plugin": "^2.9.0",
59+
"@typescript-eslint/parser": "^2.9.0",
4260
"all-contributors-cli": "^6.9.1",
43-
"eslint": "5.11.1",
44-
"eslint-plugin-jest": "^22.17.0",
61+
"conventional-changelog-cli": "^2.0.23",
62+
"eslint": "^6.7.1",
63+
"eslint-plugin-jest": "^23.0.5",
4564
"eslint-plugin-vue-libs": "^4.0.0",
4665
"husky": "^3.0.5",
4766
"inquirer": "^7.0.0",
4867
"lerna": "3.16.4",
4968
"lint-staged": "^9.3.0",
5069
"minimist": "^1.2.0",
70+
"sort-package-json": "^1.24.0",
5171
"typescript": "^3.6.3"
52-
},
53-
"husky": {
54-
"hooks": {
55-
"pre-commit": "lint-staged"
56-
}
5772
}
5873
}

packages/docs/.lintstagedrc

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

packages/docs/package.json

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,39 @@
11
{
2-
"private": true,
3-
"version": "1.2.0",
42
"name": "docs",
3+
"version": "1.2.0",
4+
"private": true,
55
"description": "docs of VuePress",
6-
"scripts": {
7-
"precommit": "lint-staged",
8-
"dev": "vuepress dev docs --temp .temp",
9-
"build": "vuepress build docs --temp .temp",
10-
"view-info": "vuepress view-info docs --temp .temp",
11-
"show-help": "vuepress --help",
12-
"lint-md:wording": "textlint ./docs/**/*.md",
13-
"lint-md:style": "remark --quiet --frail .",
14-
"lint-md": "yarn lint-md:style && yarn lint-md:wording"
6+
"keywords": [
7+
"documentation",
8+
"generator",
9+
"vue"
10+
],
11+
"homepage": "https://github.com/vuejs/vuepress#readme",
12+
"bugs": {
13+
"url": "https://github.com/vuejs/vuepress/issues"
1514
},
1615
"repository": {
1716
"type": "git",
1817
"url": "git+https://github.com/vuejs/vuepress.git"
1918
},
20-
"keywords": [
21-
"documentation",
22-
"vue",
23-
"generator"
24-
],
25-
"author": "Evan You",
2619
"license": "MIT",
27-
"bugs": {
28-
"url": "https://github.com/vuejs/vuepress/issues"
20+
"author": "Evan You",
21+
"scripts": {
22+
"build": "vuepress build docs --temp .temp",
23+
"dev": "vuepress dev docs --temp .temp",
24+
"lint-md": "yarn lint-md:style && yarn lint-md:wording",
25+
"lint-md:style": "remark --quiet --frail .",
26+
"lint-md:wording": "textlint ./docs/**/*.md",
27+
"show-help": "vuepress --help",
28+
"view-info": "vuepress view-info docs --temp .temp"
2929
},
30-
"homepage": "https://github.com/vuejs/vuepress#readme",
3130
"devDependencies": {
3231
"@textlint-rule/textlint-rule-no-unmatched-pair": "^1.0.7",
3332
"@vuepress/plugin-back-to-top": "^1.2.0",
3433
"@vuepress/plugin-google-analytics": "^1.2.0",
3534
"@vuepress/plugin-medium-zoom": "^1.2.0",
3635
"@vuepress/plugin-pwa": "^1.2.0",
3736
"@vuepress/theme-vue": "^1.2.0",
38-
"lint-staged": "^8.1.5",
3937
"remark-cli": "^7.0.0",
4038
"remark-lint": "^6.0.5",
4139
"remark-preset-lint-consistent": "^2.0.3",

0 commit comments

Comments
 (0)