Skip to content

Commit

Permalink
optimize: 优化js、ts lint配置
Browse files Browse the repository at this point in the history
  • Loading branch information
GONGONGONG authored and zhangzhw8 committed Dec 16, 2021
1 parent 889bb53 commit 5f0d57f
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -179,3 +179,6 @@ tests/postman/bkman

.helm
!env/

# frontend
vetur.config.js
6 changes: 6 additions & 0 deletions frontend/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
module.exports = {
root: true,
// 前端项目不在根目录时, 配合 vetur.config.js 来保证eslint正确解析ts的配置
parserOptions: {
project: 'tsconfig.json',
tsconfigRootDir: __dirname,
sourceType: 'module',
},
extends: ['plugin:vue/recommended', '@bkui/eslint-config-bk/tsvue'],
globals: {
// value 为 true 允许被重写,为 false 不允许被重写
Expand Down
19 changes: 19 additions & 0 deletions frontend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,23 @@ npm install
npm run dll
// 4. 启动服务
npm run dev
```

### eslint
前端文件不处于根目录时, eslint不生效。 根目录新建 `vetur.config.js` 文件。引导正确js、ts检查配置文件路径, 同下:
```javascript
module.exports = {
projects: [
'./frontend',
{
root: './frontend',
package: './package.json',
tsconfig: './tsconfig.json',
snippetFolder: './.vscode/vetur/snippets',
globalComponents: [
'./src/components/**/*.vue'
]
}
]
}
```
1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"build": "better-npm-run build",
"build:analyzer": "better-npm-run build:analyzer",
"dll": "better-npm-run dll",
"lint": "eslint --ext .ts,.js,.vue src/",
"fix": "eslint --fix --ext .ts,.js,.vue src/",
"check-dll": "ts-node --project build/tsconfig.json build/check-dll.ts"
},
Expand Down

0 comments on commit 5f0d57f

Please sign in to comment.