# @buibis/code-config

> code config guide

Latest version **0.1.0** (published 2021-08-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install @buibis/code-config
pnpm add @buibis/code-config
yarn add @buibis/code-config
bun add @buibis/code-config
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2021-08-09 |
| First published | 2021-01-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | ^10.12.0 \|\| >=12.0.0 |
| Dependencies | 7 |
| Unpacked size | 25.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | reahink |
| Maintainers | markzhang |
| Keywords | code, config, guide, commitlint, prettier, stylelint |

## Links

- npm: https://www.npmjs.com/package/@buibis/code-config
- Repository: https://github.com/zqinmiao/buibis-code-standard-fe
- Homepage: https://github.com/zqinmiao/buibis-code-standard-fe/tree/master/packages/code-config
- Issues: https://github.com/zqinmiao/buibis-code-standard-fe/issues
- npm.io page: https://npm.io/package/@buibis/code-config

## Dependencies (7)

- [prettier](https://npm.io/package/prettier.md) ^2.2.1
- [stylelint](https://npm.io/package/stylelint.md) ^13.8.0
- [@commitlint/cli](https://npm.io/package/@commitlint/cli.md) ^11.0.0
- [stylelint-find-new-rules](https://npm.io/package/stylelint-find-new-rules.md) ^3.0.1
- [stylelint-config-standard](https://npm.io/package/stylelint-config-standard.md) ^20.0.0
- [stylelint-config-recommended](https://npm.io/package/stylelint-config-recommended.md) ^3.0.0
- [@commitlint/config-conventional](https://npm.io/package/@commitlint/config-conventional.md) ^11.0.0

## Alternatives

- [flatbuffers](https://npm.io/package/flatbuffers.md) — 6.0M weekly downloads
- [jwt-simple](https://npm.io/package/jwt-simple.md) — 259.5K weekly downloads
- [@exodus/patch-broken-hermes-typed-arrays](https://npm.io/package/@exodus/patch-broken-hermes-typed-arrays.md) — 28.5K weekly downloads
- [@native-to-anchor/buffer-layout](https://npm.io/package/@native-to-anchor/buffer-layout.md) — 12.2K weekly downloads
- [binary-parser-encoder](https://npm.io/package/binary-parser-encoder.md) — 5.3K weekly downloads

## Recent versions

- 0.1.0 (latest) — 2021-08-09
- 0.0.16 — 2021-06-07
- 0.0.15 — 2021-05-08
- 0.0.14 — 2021-05-08
- 0.0.13 — 2021-05-02
- 0.0.12 — 2021-02-04
- 0.0.11 — 2021-01-15
- 0.0.10 — 2021-01-15
- 0.0.9 — 2021-01-14
- 0.0.8 — 2021-01-14
- 0.0.7 — 2021-01-14
- 0.0.5 — 2021-01-12
- 0.0.4 — 2021-01-12
- 0.0.3 — 2021-01-12
- 0.0.2 — 2021-01-12
- … 1 more at https://npm.io/package/@buibis/code-config/versions

## README

# code-config

[![npm package](https://img.shields.io/npm/v/@buibis/code-config?color=brightgreen)](https://www.npmjs.com/package/@buibis/code-config)

# 安装

```sh
$ npm install --save-dev @buibis/code-config
```

# 使用

> 修改了相关规则后，有可能出现不会生效的情况，这时首先尝试重启编辑器

- 编辑器配合[EditorConfig](https://editorconfig.org/)一起使用，[参考](https://github.com/zqinmiao/buibis-code-standard-fe/blob/master/docs/editor.md)

## 版本控制

- 忽略文件[.gitignore](https://help.github.com/articles/ignoring-files/)

在项目根目录创建`commitlint.config.js`文件，内容如下:

```javascript
module.exports = {
  extends: ["@buibis/code-config/commitlint.config.js"],
};
```

`package.json`中增加如下配置：

```javascript
// husky 版本4.x
{
  "husky": {
    "hooks": {
      // npm run codecheck 为scripts中的命令
      "pre-commit": "npm run codecheck",
      "commit-msg": "cross-env-shell \"commitlint -e $HUSKY_GIT_PARAMS\""
    }
  }
}
```

## 使用[lint-staged](https://github.com/okonet/lint-staged)来配合linter检查

使用lint-staged 的好处是，它只会对本次加到git暂存区的文件进行检查，而不是全量检查。这样就提高了lint的速度。

```bash
$ npm install lint-staged -D
```

.lintstagedrc.js

```js
module.exports = {
  'packages/**/*.{js,jsx,ts,tsx}': ["eslint -c .eslintrc.js --rule \"'no-console':'error'\""],
  'packages/**/*.ts?(x)': () => 'tsc --noEmit',
};
```

package.json

```json
{
  "husky": {
    "hooks": {
      "pre-commit": "lint-staged",
      "commit-msg": "cross-env-shell \"commitlint -e $HUSKY_GIT_PARAMS\""
    }
  },
}
```

## stylelint

- [编辑器集成](https://stylelint.io/user-guide/integrations/editor)
- 忽略文件[.stylelintignore](https://stylelint.io/user-guide/ignore-code#files-entirely)

在项目根目录创建`.stylelintrc.js`文件，内容如下:

```javascript
module.exports = {
  extends: ["@buibis/code-config/stylelint.js"],
  rules: {},
};
```

## Prettier

- [编辑器集成](https://prettier.io/docs/en/editors.html)
- 忽略文件[.prettierignore](https://prettier.io/docs/en/ignore.html#ignoring-files-prettierignore)

在项目根目录创建`.prettierrc.js`文件，内容如下:

```javascript
module.exports = {
  ...require("@buibis/code-config/prettier.js"),
};
```

## VScode 下 prettier 自动格式化

`.vscode/settings.json` 配置如下：

```javascript
{
  // 保存时自动格式化
  "editor.formatOnSave": true,
  // 采取prettier作为默认的格式化工具
  "editor.defaultFormatter": "esbenp.prettier-vscode",
  // 为包括ESLint在内的所有插件打开“自动修复”
  "editor.codeActionsOnSave": {
    "source.fixAll": true
  }
}
```

## TypeScript 使用 tsconfig.json

在项目根目录创建`tsconfig.json`文件，内容如下:

```javascript
{
  "extends": "@buibis/code-config/tsconfig.json"
}
```

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