@tuia/base-config-common

1.0.2 • Public • Published

下列基础配置

  • stylelint
  • commit-lint
  • lint-staged

接入指南

安装

yarn add @tuia/base-config-common -D

// 安装对应的依赖
# stylelint
yarn add stylelint stylelint-config-standard -D

#commmit-lint
yarn add @commitlint/cli @commitlint/config-conventional husky@4.3.8 -D

#lintstaged
yarn add lint-staged husky@4.3.8 -D

根目录下添加对应配置文件

  • .stylelintrc.js
module.exports = {
  extends: ['@tuia/base-config-common/stylelintrc'],
  rules: {
    // 其他自定义规则
  },
}
  • .lintstagedrc.js
module.exports = {
  // 允许eslint报警告
  // ...require('@tuia/base-config-common/lintstaged'),
  // 不允许eslint报警告
  ...require('@tuia/base-config-common/lintstaged-strict'),

  // 其他自定义操作 eg:
  //  "*.{css,md,html,json}": [
  //   "prettier --write",
  //   "git add"
  // ]
}
  • commitlint.config.js
module.exports = {
  ...require('@tuia/base-config-common/commitlint.config'),
  // 其他属性需要全量覆盖
}

注意事项

  • 如果有遇到 git hooks 不生效或者报错 “husky run“ not found
rm -rf .git/hooks
yarn install

如果仍然不生效,请查看项目中 husky 的版本,推荐使用husky@4.3.8

  • 配置对应的 githooks(根据项目情况修改 pre-commit)
{
  "husky": {
    "hooks": {
      "commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
      "pre-commit": "lint-staged"
    }
  }
}
  • 添加.lintstagedrc.js后,需要在 package.json 中移除对应操作,配置文件的优先级是package.json最高的。 eg package.json
{
  // ...
-   "lint-staged": {
-    "*.{js,jsx,vue,ts}": [
-      "eslint",
-      "git add"
-    ],
-    // ...
 }
}
  • stylelint建议搭配vscode插件使用
 "editor.codeActionsOnSave": {
    // ...
    /* 是否需要自动保存修复stylelint格式 */
    "source.fixAll.stylelint": true
  },
  "stylelint.validate": [
    "css",
    "less",
    "postcss",
    "scss",
    "vue",
    "sass"
],

Readme

Keywords

none

Package Sidebar

Install

npm i @tuia/base-config-common

Weekly Downloads

0

Version

1.0.2

License

ISC

Unpacked Size

5.52 kB

Total Files

7

Last publish

Collaborators

  • any-u
  • dinglh
  • candy_dd
  • wintersun97
  • tump
  • inuanfeng
  • zhoucheng
  • zhangmin173
  • aiduck
  • chao.zhou
  • babalk
  • leitingting
  • nbseven
  • linhao-vue
  • liusandy