IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> 开发工具 -> husky(7.0.0+)+pretty-quick+eslint+commitlint -> 正文阅读

[开发工具]husky(7.0.0+)+pretty-quick+eslint+commitlint

payarn add @commitlint/config-conventional

yarn add @commitlint/cli

yarn add husky

注意:最新版husky配置跟旧版本有差别~~~~~~~~~~~~~

https://www.npmjs.com/package/husky

yarn prepare
npx husky add .husky/pre-commit "yarn pretty"  //每次提交前执行pretty命令
git add .husky/pre-commit
npx husky add .husky/commit-msg "yarn commitlint"  //提交信息拦截
git add .husky/commit-msg
"scripts":{

 "lintfix": "eslint --config .eslintrc.js --fix --ext .js,.vue ./../pchome --ignore-path .gitignore",
    "prepare": "husky install",
    "pretty": "pretty-quick --staged",
    "commitlint": "commitlint --config .commitlint.config.js -e -V"
}

https://www.npmjs.com/package/pretty-quick

.commitlint.config.js

module.exports = {
  extends: ['@commitlint/config-conventional'],
  rules: {
    'type-enum': [
      2,
      'always',
      [
        'build',
        'ci',
        'chore',
        'docs',
        'feat',
        'fix',
        'perf',
        'refactor',
        'revert',
        'style',
        'test'
      ]
    ]
    // 'subject-full-stop': [0, 'never'],
    // 'subject-case': [0, 'never']
  }
}
//   build:主要目的是修改项目构建系统(例如 glup,webpack,rollup 的配置等)的提交
//   ci:主要目的是修改项目继续集成流程(例如 Travis,Jenkins,GitLab CI,Circle等)的提交
//   docs:文档更新
//   feat:新增功能
//   fix:bug 修复
//   perf:性能优化
//   refactor:重构代码(既没有新增功能,也没有修复 bug)
//   style:不影响程序逻辑的代码修改(修改空白字符,补全缺失的分号等)
//   test:新增测试用例或是更新现有测试
//   revert:回滚某个更早之前的提交
//   chore:不属于以上类型的其他类型
/**
 * demo
 * feat: 新增功能
 * */

.editorconfig

# https://editorconfig.org
#此文件的作用是为了防止团队协作时大家所用ide不同导致代码规范不同
# 每次合并代码时带来大量的并没有变化的代码合并和不必要的冲突。
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
insert_final_newline = false
trim_trailing_whitespace = false

.eslintignore

coverage
debug.log
error.log
static
.DS_Store
node_modules/
dist/
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.nuxt

# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln

.eslintrc.js

module.exports = {
  root: true,
  plugins: ['vue'],
  env: {
    browser: true,
    node: true,
    commonjs: true,
    jquery: true,
    es6: true
  },
  globals: {
    EASY_ENV_IS_PROD: true,
    EASY_ENV_IS_NODE: true,
    EASY_ENV_IS_BROWSER: true,
    EASY_ENV_IS_DEV: true,
    wx: true,
    uni: true,
    _: true
  },
  parserOptions: {
    ecmaVersion: 6,
    sourceType: 'module',
    parser: 'babel-eslint'
  },
  extends: [
    'eslint:recommended',
    // https://github.com/vuejs/eslint-plugin-vue#priority-a-essential-error-prevention
    // consider switching to `plugin:vue/strongly-recommended` or `plugin:vue/recommended` for stricter rules.
    'plugin:vue/recommended',
    'plugin:prettier/recommended'
  ],
  rules: {
    'default-case': 2, //switch语句最后必须有default
    'no-var': 0, //禁用var,用let和const代替
    'no-undef': 1, //不能有未定义的变量
    'no-spaced-func': 2, //函数调用时 函数名与()之间不能有空格
    'no-return-assign': 1, //return 语句中不能有赋值表达式
    'no-script-url': 0, //禁止使用javascript:void(0)
    'no-self-compare': 2, //不能比较自身
    'no-redeclare': 2, //禁止重复声明变量
    'no-multiple-empty-lines': [1, { max: 2 }], //空行最多不能超过2行
    'no-multi-spaces': 1, //不能用多余的空格
    'no-lone-blocks': 2, //禁止不必要的嵌套块
    'no-func-assign': 2, //禁止重复的函数声明
    'no-fallthrough': 1, //禁止switch穿透
    'no-eval': 1, //禁止使用eval
    'no-else-return': 2, //如果if语句里面有return,后面不能跟else语句
    'no-duplicate-case': 2, //switch中的case标签不能重复
    'no-dupe-args': 2, //函数参数不能重复
    eqeqeq: 2, //必须使用全等
    'no-const-assign': 2, //禁止修改const声明的变量
    'max-params': [0, 3], //函数最多只能有3个参数
    'max-statements': [0, 10], //函数内最多有几个声明
    'max-depth': [0, 4], //嵌套块深度
    'new-cap': 2, //函数名首行大写必须使用new方式调用,首行小写必须用不带new方式调用
    'prefer-const': 0, //首选const
    'no-prototype-builtins': 'off',
    'no-debugger': 'off',
    'no-console': 'off',
    // 允许 !! 运算,原本不允许
    'no-extra-boolean-cast': 'off',
    'prettier/prettier': 'off',
    // // 2空格缩进
    indent: ['warn', 2],
    // v-for当中要是用v-if,只能使用for的元素作为条件
    'vue/no-use-v-if-with-v-for': [
      'error',
      {
        allowUsingIterationVar: true // default: false
      }
    ],
    // 忽略 template 中的三元运算符使用小于号(<)时报错
    'vue/no-parsing-error': [
      2,
      {
        'x-invalid-end-tag': false,
        'invalid-first-character-of-tag-name': false
      }
    ],
    // 下面2个都要求是error的,但是暂时没办法改,所以先妥协
    'vue/no-side-effects-in-computed-properties': 'warn',
    'vue/no-async-in-computed-properties': 'warn'
  }
  // "parser": "babel-eslint"
}

.prettierignore

logs/
npm-debug.log
yarn-error.log
node_modules/
package-lock.json
yarn.lock
coverage/
.idea/
.vscode/
run/
.DS_Store
*.sw*
*.un~
config.json


.prettierrc.js

module.exports = {
  printWidth: 80,
  endOfLine: 'lf',
  // tab缩进大小,默认为2
  tabWidth: 2,
  // 使用tab缩进,默认false
  useTabs: false,
  // 使用分号, 默认true
  semi: false,
  // 使用单引号, 默认false(在jsx中配置无效, 默认都是双引号)
  singleQuote: true,
  // 行尾逗号,默认none,可选 none|es5|all
  // es5 包括es5中的数组、对象
  // all 包括函数对象等所有可选
  trailingComma: 'none',
  // 对象中的空格 默认true
  // true: { foo: bar }
  // false: {foo: bar}
  bracketSpacing: true,
  // JSX标签闭合位置 默认false
  // false: <div
  //          className=""
  //          style={{}}
  //       >
  // true: <div
  //          className=""
  //          style={{}} >
  // 箭头函数参数括号 默认avoid 可选 avoid| always
  // avoid 能省略括号的时候就省略 例如x => x
  // always 总是有括号
  arrowParens: 'avoid'
}

  开发工具 最新文章
Postman接口测试之Mock快速入门
ASCII码空格替换查表_最全ASCII码对照表0-2
如何使用 ssh 建立 socks 代理
Typora配合PicGo阿里云图床配置
SoapUI、Jmeter、Postman三种接口测试工具的
github用相对路径显示图片_GitHub 中 readm
Windows编译g2o及其g2o viewer
解决jupyter notebook无法连接/ jupyter连接
Git恢复到之前版本
VScode常用快捷键
上一篇文章      下一篇文章      查看所有文章
加:2021-07-09 17:38:00  更:2021-07-09 17:39:10 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年5日历 -2024/5/8 18:05:08-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码