# @ebullience/web-project-config

> 前端项目代码配置文件

Latest version **0.2.3** (published 2022-04-29) · Apache license · 0 weekly downloads

## Install

```sh
npm install @ebullience/web-project-config
pnpm add @ebullience/web-project-config
yarn add @ebullience/web-project-config
bun add @ebullience/web-project-config
```

## Health

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

Positive: has types; no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.3 |
| Published | 2022-04-29 |
| First published | 2022-03-01 |
| Weekly downloads | 0 |
| License | Apache |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=16.0.0 |
| Dependencies | 17 |
| Unpacked size | 12.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | qinshixixing |
| Maintainers | qinshixixing |

## Links

- npm: https://www.npmjs.com/package/@ebullience/web-project-config
- Repository: https://github.com/qinshixixing/ebullience
- Homepage: https://github.com/qinshixixing/ebullience#readme
- Issues: https://github.com/qinshixixing/ebullience/issues
- npm.io page: https://npm.io/package/@ebullience/web-project-config

## Dependencies (17)

- [eslint](https://npm.io/package/eslint.md) ^8.14.0
- [prettier](https://npm.io/package/prettier.md) ^2.6.2
- [stylelint](https://npm.io/package/stylelint.md) ^14.8.0
- [typescript](https://npm.io/package/typescript.md) ^4.6.3
- [postcss-less](https://npm.io/package/postcss-less.md) ^6.0.0
- [eslint-plugin-react](https://npm.io/package/eslint-plugin-react.md) ^7.29.4
- [@tsconfig/recommended](https://npm.io/package/@tsconfig/recommended.md) ^1.0.1
- [stylelint-css-modules](https://npm.io/package/stylelint-css-modules.md) ^1.2.2
- [eslint-config-prettier](https://npm.io/package/eslint-config-prettier.md) ^8.5.0
- [eslint-plugin-prettier](https://npm.io/package/eslint-plugin-prettier.md) ^4.0.0
- [@typescript-eslint/parser](https://npm.io/package/@typescript-eslint/parser.md) ^5.21.0
- [eslint-plugin-react-hooks](https://npm.io/package/eslint-plugin-react-hooks.md) ^4.5.0
- [stylelint-config-prettier](https://npm.io/package/stylelint-config-prettier.md) ^9.0.3
- [stylelint-config-standard](https://npm.io/package/stylelint-config-standard.md) ^25.0.0
- [stylelint-config-css-modules](https://npm.io/package/stylelint-config-css-modules.md) ^3.0.0
- [stylelint-config-standard-scss](https://npm.io/package/stylelint-config-standard-scss.md) ^3.0.0
- [@typescript-eslint/eslint-plugin](https://npm.io/package/@typescript-eslint/eslint-plugin.md) ^5.21.0

## Recent versions

- 0.2.3 (latest) — 2022-04-29
- 0.2.2 — 2022-04-29
- 0.2.1 — 2022-04-29
- 0.2.0 — 2022-04-28
- 0.1.0 — 2022-03-01

## README

# @ebullience/web-project-config

前端项目代码配置文件

```shell script
npm i -D @ebullience/web-project-config
```

请使用node16及其以上版本

所有配置只支持原生或react项目

#### 配置eslint
项目根目录下新建配置文件.eslintrc.js：
```js
const config = require('@ebullience/web-project-config').eslint;

module.exports = {
  ...config,
  rules: {
    ...config.rules,
    // 自己的规则
  }
}
```
重启ide或编辑器可完成识别

规则限制了any和require的使用，如果项目中用到了大量any和require，可以设置以下规则忽略：
```js
const rules = {
  // 关闭any检测
  '@typescript-eslint/no-explicit-any': 'off',
  // 关闭require检测
  '@typescript-eslint/no-var-requires': 'off'
}
```

#### 配置stylelint
项目根目录下新建配置文件.stylelintrc.js：
```js
const config = require('@ebullience/web-project-config').stylelint;

module.exports = {
  ...config,
  rules: {
    ...config.rules,
    // 自己的规则
  }
}
```
重启ide或编辑器可完成识别

#### 配置prettier
项目根目录下新建配置文件.prettierrc.js：
```js
const config = require('@ebullience/web-project-config').prettier;

module.exports = {
  ...config,
  // 自己的规则
}
```
重启ide或编辑器可完成识别

规则强制使用单引号和句尾分号，如果项目中有大量双引号或者不带句尾分号，可以设置以下规则忽略：
```js
const rules = {
  // 使用双引号
  singleQuote: false,
  // jsx中使用双引号
  jsxSingleQuote: false,
  // 不使用句尾分号
  semi: false
}
```


#### 配置typescript
目前一共有两个ts配置文件：

##### 1. typescript-web/tsconfig.json
用于编写直接在浏览器中执行的代码，编译后只会去掉类型说明，保留最新es特性。该配置不兼容node特性比如node_modules。

项目根目录下新建配置文件tsconfig.json：
```json
{
  "extends": "@ebullience/web-project-config/typescript-web/tsconfig.json"
}
```

##### 2. typescript-node/tsconfig.json
用于编写前端库，编译后会去掉类型说明，并去除最新es特性。编译后的代码会在node中交给前端打包器进一步处理。

项目根目录下新建配置文件tsconfig.json：
```json
{
  "extends": "@ebullience/web-project-config/typescript-node/tsconfig.json"
}
```
如果项目没有浏览器兼容性要求web环境可以使用最新es特性，可以配置target选项在ts编译时不转化es特性只去掉类型说明
```json
{
  "extends": "@ebullience/web-project-config/typescript-node/tsconfig.json",
  "compilerOptions": {
    "target": "esnext"
  }
}
```
如果项目库中包含js，需要编译js文件，可以配置允许编译js文件选项
```json
{
  "extends": "@ebullience/web-project-config/typescript-node/tsconfig.json",
  "compilerOptions": {
    "allowJs": true
  }
}
```

重启ide或编辑器可完成识别

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