-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(eslint): 配置 Eslint、Prettierrc、Husky等项目提交规范
- Loading branch information
Showing
9 changed files
with
1,611 additions
and
208 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
module.exports = { | ||
root: true, | ||
env: { | ||
browser: true, // 支持浏览器环境的检测 | ||
es2021: true, // 支持es2021语法的检测 | ||
node: true // 支持node环境的检测 | ||
}, | ||
extends: [ | ||
'eslint:recommended', // 使用eslint推荐的配置进行检测 | ||
'plugin:vue/vue3-essential' // 支持vue3相关语法的检测 | ||
], | ||
overrides: [], | ||
parserOptions: { | ||
ecmaVersion: 'latest', // 解析文件的时候使用最新的ecmaVersion | ||
sourceType: 'module' // 文件是ES6模块规范 | ||
}, | ||
plugins: ['vue'], | ||
rules: { | ||
camelcase: 2, // 驼峰 | ||
indent: [2, 2], // 缩进2个空格 | ||
semi: [2, 'never'], // 要求或禁止使用分号代替 ASI,即禁用行尾使用分号 | ||
quotes: ['error', 'single'], // 强制使用一致的反勾号、双引号或单引号 | ||
'no-debugger': 2, // 不能debugg | ||
'no-empty': 2, // 块语句中的内容不能为空 | ||
'no-extra-parens': 2, // 禁止非必要的括号 | ||
'no-extra-semi': 2, // 禁止多余的冒号 | ||
'comma-dangle': [2, 'never'], // 键值对最后一个不能有, | ||
'spaced-comment': ['error', 'always'] // 注释必须空格 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
.nitro | ||
.cache | ||
dist | ||
pnpm-lock.yaml | ||
|
||
# Node dependencies | ||
node_modules | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
npm run commitlint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
npm run pre-commit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"src/**/*.{ts,vue}": [ | ||
"prettier --write", | ||
"eslint --fix" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"semi": false, | ||
"singleQuote": true, | ||
"trailingComma": "none", | ||
"printWidth": 100, | ||
"tabWidth": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
module.exports = { | ||
extends: ['@commitlint/config-conventional'], | ||
rules: { | ||
'type-enum': [ | ||
// type枚举 | ||
2, | ||
'always', | ||
[ | ||
'build', // 编译相关的修改,例如发布版本、对项目构建或者依赖的改动 | ||
'feat', // 新功能 | ||
'fix', // 修补bug | ||
'docs', // 文档修改 | ||
'style', // 代码格式修改, 注意不是 css 修改 | ||
'refactor', // 重构 | ||
'perf', // 优化相关,比如提升性能、体验 | ||
'test', // 测试用例修改 | ||
'revert', // 代码回滚 | ||
'ci', // 持续集成修改 | ||
'config', // 配置修改 | ||
'chore' // 其他改动 | ||
] | ||
], | ||
'type-empty': [2, 'never'], // never: type不能为空; always: type必须为空 | ||
'type-case': [0, 'always', 'lower-case'], // type必须小写,upper-case大写,camel-case小驼峰,kebab-case短横线,pascal-case大驼峰,等等 | ||
'scope-empty': [0], | ||
'scope-case': [0], | ||
'subject-empty': [2, 'never'], // subject不能为空 | ||
'subject-case': [0], | ||
'subject-full-stop': [0, 'never', '.'], // subject以.为结束标记 | ||
'header-max-length': [2, 'always', 72], // header最长72 | ||
'body-leading-blank': [0], // body换行 | ||
'footer-leading-blank': [0, 'always'] // footer以空行开头 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.