From 6754da4d83976a02eced801220320d8c9aa1da85 Mon Sep 17 00:00:00 2001 From: Soybean <2570172956@qq.com> Date: Fri, 28 May 2021 00:32:34 +0800 Subject: [PATCH] =?UTF-8?q?feat(projects):=20=E9=A1=B9=E7=9B=AE=E5=88=9D?= =?UTF-8?q?=E5=A7=8B=E5=8C=96=E6=90=AD=E5=BB=BA=EF=BC=8C=E9=9B=86=E6=88=90?= =?UTF-8?q?eslint=E8=A7=84=E8=8C=83=EF=BC=8C=E9=9B=86=E6=88=90=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E6=8F=90=E4=BA=A4=E8=A7=84=E8=8C=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .cz-config.js | 83 + .editorconfig | 12 + .eslintignore | 14 + .eslintrc.js | 20 + .gitignore | 5 + .husky/.gitignore | 1 + .husky/commit-msg | 4 + .husky/pre-commit | 4 + .prettierrc.js | 22 + README.md | 1 + commitlint.config.js | 1 + doc/提交规范.md | 140 + index.html | 13 + package.json | 45 + public/favicon.ico | Bin 0 -> 4286 bytes src/App.vue | 19 + src/assets/logo.png | Bin 0 -> 6849 bytes src/components/HelloWorld.vue | 71 + src/main.ts | 4 + src/shims-vue.d.ts | 6 + src/vite-env.d.ts | 1 + tsconfig.json | 14 + vite.config.ts | 6 + yarn.lock | 5041 +++++++++++++++++++++++++++++++++ 24 files changed, 5527 insertions(+) create mode 100644 .cz-config.js create mode 100644 .editorconfig create mode 100644 .eslintignore create mode 100644 .eslintrc.js create mode 100644 .gitignore create mode 100644 .husky/.gitignore create mode 100755 .husky/commit-msg create mode 100755 .husky/pre-commit create mode 100644 .prettierrc.js create mode 100644 README.md create mode 100644 commitlint.config.js create mode 100644 doc/提交规范.md create mode 100644 index.html create mode 100644 package.json create mode 100644 public/favicon.ico create mode 100644 src/App.vue create mode 100644 src/assets/logo.png create mode 100644 src/components/HelloWorld.vue create mode 100644 src/main.ts create mode 100644 src/shims-vue.d.ts create mode 100644 src/vite-env.d.ts create mode 100644 tsconfig.json create mode 100644 vite.config.ts create mode 100644 yarn.lock diff --git a/.cz-config.js b/.cz-config.js new file mode 100644 index 00000000..67dd4078 --- /dev/null +++ b/.cz-config.js @@ -0,0 +1,83 @@ +module.exports = { + // type 类型(定义之后,可通过上下键选择) + types: [ + { value: 'feat', name: 'feat: 新增功能' }, + { value: 'fix', name: 'fix: 修复 bug' }, + { value: 'docs', name: 'docs: 文档变更' }, + { value: 'style', name: 'style: 代码格式(不影响功能,例如空格、分号等格式修正)' }, + { value: 'refactor', name: 'refactor: 代码重构(不包括 bug 修复、功能新增)' }, + { value: 'perf', name: 'perf: 性能优化' }, + { value: 'test', name: 'test: 添加、修改测试用例' }, + { value: 'build', name: 'build: 构建流程、外部依赖变更(如升级 npm 包、修改 脚手架 配置等)' }, + { value: 'ci', name: 'ci: 修改 CI 配置、脚本' }, + { value: 'chore', name: 'chore: 对构建过程或辅助工具和库的更改(不影响源文件、测试用例)' }, + { value: 'revert', name: 'revert: 回滚 commit' } + ], + + // scope 类型(定义之后,可通过上下键选择) + scopes: [ + ['projects', '项目搭建'], + ['components', '组件相关'], + ['hooks', 'hook 相关'], + ['utils', 'utils 相关'], + ['element-ui', '对 element-ui 的调整'], + ['styles', '样式相关'], + ['deps', '项目依赖'], + ['auth', '对 auth 修改'], + ['other', '其他修改'], + // 如果选择 custom,后面会让你再输入一个自定义的 scope。也可以不设置此项,把后面的 allowCustomScopes 设置为 true + ['custom', '以上都不是?我要自定义'] + ].map(([value, description]) => { + return { + value, + name: `${value.padEnd(30)} (${description})` + } + }), + + // 是否允许自定义填写 scope,在 scope 选择的时候,会有 empty 和 custom 可以选择。 + // allowCustomScopes: true, + + // allowTicketNumber: false, + // isTicketNumberRequired: false, + // ticketNumberPrefix: 'TICKET-', + // ticketNumberRegExp: '\\d{1,5}', + + + // 针对每一个 type 去定义对应的 scopes,例如 fix + /* + scopeOverrides: { + fix: [ + { name: 'merge' }, + { name: 'style' }, + { name: 'e2eTest' }, + { name: 'unitTest' } + ] + }, + */ + + // 交互提示信息 + messages: { + type: '确保本次提交遵循 Angular 规范!\n选择你要提交的类型:', + scope: '\n选择一个 scope(可选):', + // 选择 scope: custom 时会出下面的提示 + customScope: '请输入自定义的 scope:', + subject: '填写简短精炼的变更描述:\n', + body: + '填写更加详细的变更描述(可选)。使用 "|" 换行:\n', + breaking: '列举非兼容性重大的变更(可选):\n', + footer: '列举出所有变更的 ISSUES CLOSED(可选)。 例如: #31, #34:\n', + confirmCommit: '确认提交?' + }, + + // 设置只有 type 选择了 feat 或 fix,才询问 breaking message + allowBreakingChanges: ['feat', 'fix'], + + // 跳过要询问的步骤 + // skipQuestions: ['body', 'footer'], + + // subject 限制长度 + subjectLimit: 100, + breaklineChar: '|', // 支持 body 和 footer + // footerPrefix : 'ISSUES CLOSED:' + // askForBreakingChangeFirst : true, +} diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..acf8428b --- /dev/null +++ b/.editorconfig @@ -0,0 +1,12 @@ +# Editor configuration, see http://editorconfig.org + +# 表示是最顶层的 EditorConfig 配置文件 +root = true + +[*] # 表示所有文件适用 +charset = utf-8 # 设置文件字符集为 utf-8 +indent_style = tab # 缩进风格(tab | space) +indent_size = 2 # 缩进大小 +end_of_line = lf # 控制换行类型(lf | cr | crlf) +trim_trailing_whitespace = true # 去除行首的任意空白字符 +insert_final_newline = true # 始终在文件末尾插入一个新行 diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 00000000..e25b5e5b --- /dev/null +++ b/.eslintignore @@ -0,0 +1,14 @@ +*.sh +node_modules +lib +*.md +*.woff +*.ttf +.vscode +.idea +/dist/ +/mock/ +/public +/docs +.vscode +.local diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 00000000..08dac4aa --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,20 @@ +module.exports = { + env: { + browser: true, + es2021: true + }, + extends: [ + 'plugin:vue/vue3-essential', + 'airbnb-base', + 'plugin:prettier/recommended' + ], + parserOptions: { + ecmaVersion: 12, + parser: '@typescript-eslint/parser', + sourceType: 'module' + }, + plugins: ['vue', '@typescript-eslint'], + rules: { + 'no-unused-vars': 0 + } +}; diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..d451ff16 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +node_modules +.DS_Store +dist +dist-ssr +*.local diff --git a/.husky/.gitignore b/.husky/.gitignore new file mode 100644 index 00000000..31354ec1 --- /dev/null +++ b/.husky/.gitignore @@ -0,0 +1 @@ +_ diff --git a/.husky/commit-msg b/.husky/commit-msg new file mode 100755 index 00000000..7cd8dd9a --- /dev/null +++ b/.husky/commit-msg @@ -0,0 +1,4 @@ +#!/bin/sh +. "$(dirname "$0")/_/husky.sh" + +npx --no-install commitlint --edit diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100755 index 00000000..f2f851f7 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,4 @@ +#!/bin/sh +. "$(dirname "$0")/_/husky.sh" + +yarn lint:fix diff --git a/.prettierrc.js b/.prettierrc.js new file mode 100644 index 00000000..1a889e95 --- /dev/null +++ b/.prettierrc.js @@ -0,0 +1,22 @@ +module.exports = { + printWidth: 180, // 超过最大值换行 + tabWidth: 2, // 缩进字节数 + useTabs: false, // 缩进使用tab,不使用空格 + semi: true, // 句尾添加分号 + singleQuote: true, // 使用单引号代替双引号 + proseWrap: 'preserve', // 默认值。因为使用了一些折行敏感型的渲染器(如GitHub comment)而按照markdown文本样式进行折行 + arrowParens: 'avoid', // (x) => {} 箭头函数参数只有一个时是否要有小括号。avoid:省略括号 + bracketSpacing: true, // 在对象,数组括号与文字之间加空格 "{ foo: bar }" + // disableLanguages: ['vue'], // 不格式化vue文件,vue文件的格式化单独设置 + endOfLine: 'auto', // 结尾是 \n \r \n\r auto + eslintIntegration: false, //不让prettier使用eslint的代码格式进行校验 + htmlWhitespaceSensitivity: 'ignore', // 指定HTML文件的全局空白区域敏感度 有效选项:"css"- 遵守CSS display属性的默认值。"strict" - 空格被认为是敏感的。"ignore" - 空格被认为是不敏感的。html 中空格也会占位,影响布局,prettier 格式化的时候可能会将文本换行,造成布局错乱 + ignorePath: '.prettierignore', // 不使用prettier格式化的文件填写在项目的.prettierignore文件中 + jsxBracketSameLine: false, // 在jsx中把'>' 是否单独放一行 + jsxSingleQuote: false, // 在jsx中使用单引号代替双引号 + // parser: 'babylon', // 格式化的解析器,默认是babylon + requireConfig: false, // Require a 'prettierconfig' to format prettier + stylelintIntegration: false, //不让prettier使用stylelint的代码格式进行校验 + trailingComma: 'none', // 在对象或数组最后一个元素后面是否加逗号(在ES5中加尾逗号) + tslintIntegration: false // 不让prettier使用tslint的代码格式进行校验 +} diff --git a/README.md b/README.md new file mode 100644 index 00000000..aa8be1f0 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +web-cli 前端开发项目的脚手架 \ No newline at end of file diff --git a/commitlint.config.js b/commitlint.config.js new file mode 100644 index 00000000..422b1944 --- /dev/null +++ b/commitlint.config.js @@ -0,0 +1 @@ +module.exports = { extends: ['@commitlint/config-conventional'] }; diff --git a/doc/提交规范.md b/doc/提交规范.md new file mode 100644 index 00000000..964fe28c --- /dev/null +++ b/doc/提交规范.md @@ -0,0 +1,140 @@ +提交规范 +前面我们已经统一代码规范,并且在提交代码时进行强约束来保证仓库代码质量。多人协作的项目中,在提交代码这个环节,也存在一种情况:不能保证每个人对提交信息的准确描述,因此会出现提交信息紊乱、风格不一致的情况。 +如果 git commit 的描述信息精准,在后期维护和 Bug 处理时会变得有据可查,项目开发周期内还可以根据规范的提交信息快速生成开发日志,从而方便我们追踪项目和把控进度。 +这里,我们使用社区最流行、最知名、最受认可的 Angular 团队提交规范。 + +commit message 格式规范 +commit message 由 Header、Body、Footer 组成。 +
+ + + +