Skip to content
This repository was archived by the owner on May 13, 2024. It is now read-only.

Commit 6aabec6

Browse files
committed
build: setup linter
1 parent a4aa0d5 commit 6aabec6

File tree

4 files changed

+1252
-46
lines changed

4 files changed

+1252
-46
lines changed

.eslintrc.js

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
module.exports = {
2+
root: true,
3+
4+
env: {
5+
"browser": true,
6+
"commonjs": true,
7+
"es6": true,
8+
"node": true
9+
},
10+
11+
globals: {
12+
COMMENT_SERVICE: true
13+
},
14+
15+
extends: [
16+
'plugin:vue/recommended',
17+
'plugin:prettier/recommended',
18+
'prettier/@typescript-eslint',
19+
"prettier/vue",
20+
],
21+
22+
parserOptions: {
23+
parser: 'babel-eslint' // Support dynamic import
24+
},
25+
26+
rules: {
27+
'no-undef': ['error'],
28+
29+
'vue/match-component-file-name': [
30+
'error',
31+
{
32+
extensions: ['js', 'vue'],
33+
shouldMatchCase: false
34+
}
35+
],
36+
37+
'vue/prop-name-casing': 0,
38+
39+
'vue/require-default-prop': 0
40+
},
41+
42+
overrides: [
43+
{
44+
files: ['*.ts'],
45+
extends: [
46+
'plugin:@typescript-eslint/recommended'
47+
],
48+
parser: 'vue-eslint-parser',
49+
parserOptions: {
50+
parser: '@typescript-eslint/parser'
51+
},
52+
rules: {
53+
'@typescript-eslint/ban-ts-ignore': 0,
54+
55+
'@typescript-eslint/explicit-function-return-type': 0,
56+
57+
'@typescript-eslint/no-explicit-any': 0,
58+
59+
'@typescript-eslint/no-use-before-define': ['error', { functions: false }]
60+
}
61+
},
62+
]
63+
}

.prettierrc.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
singleQuote: true,
3+
tabWidth: 2,
4+
trailingComma: 'es5',
5+
}

package.json

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "1.5.2",
44
"description": "Offical blog plugin for VuePress",
55
"scripts": {
6-
"lint": "xo",
6+
"lint": "eslint src --ext .ts,.vue",
77
"dev": "concurrently \"rimraf lib\" \"npm:dev:client\" \"npm:dev:node\" \"nodemon\"",
88
"build": "concurrently \"rimraf lib\" \"npm:build:client\" \"npm:build:node\" \"npm:build:components\"",
99
"dev:client": "tsc -p tsconfig.client.json --watch",
@@ -28,6 +28,17 @@
2828
},
2929
"author": "ULIVZ <chl814@foxmail.com>",
3030
"license": "MIT",
31+
"husky": {
32+
"hooks": {
33+
"pre-commit": "lint-staged"
34+
}
35+
},
36+
"lint-staged": {
37+
"*.{js,ts,vue}": [
38+
"eslint --fix",
39+
"git add"
40+
]
41+
},
3142
"dependencies": {
3243
"@vssue/api-github-v3": "^1.1.2",
3344
"@vssue/vuepress-plugin-vssue": "^1.2.0",
@@ -36,11 +47,21 @@
3647
"vuepress-plugin-sitemap": "^2.3.0"
3748
},
3849
"devDependencies": {
50+
"@typescript-eslint/eslint-plugin": "^2.11.0",
51+
"@typescript-eslint/parser": "^2.11.0",
52+
"babel-eslint": "^10.0.3",
3953
"concurrently": "^4.1.0",
4054
"conventional-changelog-cli": "^2.0.1",
4155
"cpx": "^1.5.0",
56+
"eslint": "^6.7.2",
57+
"eslint-config-prettier": "^6.7.0",
58+
"eslint-plugin-prettier": "^3.1.1",
59+
"eslint-plugin-vue": "^6.0.1",
60+
"husky": "^3.1.0",
4261
"inquirer": "^6.3.1",
62+
"lint-staged": "^9.5.0",
4363
"nodemon": "^1.18.7",
64+
"prettier": "^1.19.1",
4465
"rimraf": "^3.0.0",
4566
"ts-node": "^7.0.1",
4667
"typescript": "3.1.4",
@@ -53,30 +74,6 @@
5374
"src/client/components/"
5475
]
5576
},
56-
"xo": {
57-
"extends": [
58-
"rem",
59-
"plugin:prettier/recommended",
60-
"xo-typescript"
61-
],
62-
"extensions": [
63-
"ts"
64-
],
65-
"rules": {
66-
"unicorn/filename-case": "off",
67-
"new-cap": "off",
68-
"typescript/no-inferrable-types": "off",
69-
"import/no-unassigned-import": "off",
70-
"typescript/explicit-function-return-type": "off",
71-
"no-throw-literal": "off",
72-
"typescript/no-var-requires": "off",
73-
"no-implicit-globals": "off",
74-
"import/no-unresolved": "off",
75-
"import/no-extraneous-dependencies": "off",
76-
"typescript/no-use-before-define": "off",
77-
"typescript/no-type-alias": "off"
78-
}
79-
},
8077
"publishConfig": {
8178
"registry": "https://registry.npmjs.org/"
8279
}

0 commit comments

Comments
 (0)