# @tuia/base-config-common

> - stylelint - commit-lint - lint-staged

Latest version **1.0.2** (published 2022-01-19) · ISC license · 0 weekly downloads

## Install

```sh
npm install @tuia/base-config-common
pnpm add @tuia/base-config-common
yarn add @tuia/base-config-common
bun add @tuia/base-config-common
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2022-01-19 |
| First published | 2021-12-22 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | dinglh, candy_dd, wintersun97, tump, inuanfeng, zhoucheng, zhangmin173, aiduck, chao.zhou, babalk, leitingting, sillyy, nbseven, linhao-vue, liusandy |

## Links

- npm: https://www.npmjs.com/package/@tuia/base-config-common
- npm.io page: https://npm.io/package/@tuia/base-config-common

## Recent versions

- 1.0.2 (latest) — 2022-01-19
- 1.0.1 — 2021-12-22

## README

## 下列基础配置

- stylelint
- commit-lint
- lint-staged

## 接入指南

### 安装

```bash
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`

```js
module.exports = {
  extends: ['@tuia/base-config-common/stylelintrc'],
  rules: {
    // 其他自定义规则
  },
}
```

- `.lintstagedrc.js`

```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`

```js
module.exports = {
  ...require('@tuia/base-config-common/commitlint.config'),
  // 其他属性需要全量覆盖
}
```

### 注意事项

- 如果有遇到 git hooks 不生效或者报错` “husky run“ not found`

```bash
rm -rf .git/hooks
yarn install
```

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

- 配置对应的 githooks（根据项目情况修改 pre-commit）

```json
{
  "husky": {
    "hooks": {
      "commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
      "pre-commit": "lint-staged"
    }
  }
}
```

- 添加`.lintstagedrc.js`后，需要在 package.json 中移除对应操作，配置文件的优先级是`package.json`最高的。
  eg
  package.json

```json
{
  // ...
-   "lint-staged": {
-    "*.{js,jsx,vue,ts}": [
-      "eslint",
-      "git add"
-    ],
-    // ...
 }
}
```

- stylelint建议搭配vscode插件使用
```json
 "editor.codeActionsOnSave": {
    // ...
    /* 是否需要自动保存修复stylelint格式 */
    "source.fixAll.stylelint": true
  },
  "stylelint.validate": [
    "css",
    "less",
    "postcss",
    "scss",
    "vue",
    "sass"
],

````

---
_Source: https://npm.io/package/@tuia/base-config-common · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
