# eslint-config-lei

> my own eslint config

Latest version **0.0.16** (published 2016-11-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install eslint-config-lei
pnpm add eslint-config-lei
yarn add eslint-config-lei
bun add eslint-config-lei
```

## 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.0.16 |
| Published | 2016-11-23 |
| First published | 2016-07-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 12 |
| Author | Zongmin Lei |
| Maintainers | leizongmin |
| Keywords | eslint, lei |

## Links

- npm: https://www.npmjs.com/package/eslint-config-lei
- Repository: https://github.com/leizongmin/eslint-config-lei
- Homepage: https://github.com/leizongmin/eslint-config-lei#readme
- Issues: https://github.com/leizongmin/eslint-config-lei/issues
- npm.io page: https://npm.io/package/eslint-config-lei

## Alternatives

- [eslint-plugin-sonarjs](https://npm.io/package/eslint-plugin-sonarjs.md) — 2.9M weekly downloads
- [eslint-config-expo](https://npm.io/package/eslint-config-expo.md) — 1.5M weekly downloads
- [@matter/protocol](https://npm.io/package/@matter/protocol.md) — 63.5K weekly downloads
- [@eventcatalog/linter](https://npm.io/package/@eventcatalog/linter.md) — 24.8K weekly downloads
- [@inrupt/eslint-config-base](https://npm.io/package/@inrupt/eslint-config-base.md) — 4.5K weekly downloads

## Recent versions

- 0.0.16 (latest) — 2016-11-23
- 0.0.15 — 2016-11-10
- 0.0.14 — 2016-10-24
- 0.0.13 — 2016-10-24
- 0.0.12 — 2016-10-22
- 0.0.11 — 2016-10-22
- 0.0.10 — 2016-10-11
- 0.0.9 — 2016-10-09
- 0.0.8 — 2016-09-23
- 0.0.7 — 2016-08-24
- 0.0.6 — 2016-07-31
- 0.0.5 — 2016-07-31
- 0.0.4 — 2016-07-31
- 0.0.3 — 2016-07-30
- 0.0.2 — 2016-07-30
- … 1 more at https://npm.io/package/eslint-config-lei/versions

## README

# eslint-config 配置

## 安装

```bash
$ npm install eslint-config-lei eslint-plugin-promise --save-dev
```

说明：由于本配置使用了`promise`插件，因此需要同时安装`eslint-plugin-promise`模块。


## 使用方法

### 配置文件

在项目根目录下新建文件`.eslintrc.js`：

仅包含 ES6 语法时：

```javascript
module.exports = {
  extends: 'lei',
};
```

包含 ES7 语法时：

```javascript
module.exports = {
  parser: 'babel-eslint',
  parserOptions: {
    sourceType: 'module',
    allowImportExportEverywhere: false,
  },
  extends: 'lei',
};
```

在基于`mocha`框架的单元测试中使用，在`test`目录下新建文件`.eslintrc.js`：

```javascript
module.exports = {
  extends: 'lei/mocha',
};
```

### 使用

执行以下命令即可：

```bash
$ eslint dir/**.js
```

如果需要自动格式化代码，在执行时添加`--fix`选项：

```bash
$ eslint dir/**.js --fix
```

## 配置文件

+ `lei` - 默认的配置，基于Node.js/ES6
+ `lei/mocha` - mocha测试环境
+ `lei/wechat` - 微信小程序环境


## 常见问题

1、如果在使用`babel-eslint`时报错，可能是该模块的 Bug，目前可以通过以下方法解决：

```javascript
module.exports = {
  parser: 'babel-eslint',
  parserOptions: {
    sourceType: 'module',
    allowImportExportEverywhere: false,
  },
  extends: 'lei',
  rules: {
    // 关闭以下规则
    'generator-star-spacing': 'off',
    'require-yield': 'off',
  },
};
```

2、在使用过程中，可能会遇到一些例外情况，比如需要更改参数对象的属性，可以通过`eslint-disable-next`来临时关闭对下一行的检查：

```javascript
// eslint-disable-next-line no-param-reassign
param.xxx = 'ok';
```

**注意：任何时候请勿使用`eslint-disable`来关闭`eslint`的检查，如果该备注不能与`eslint-enable`成对出现将会导致余下的程序不能正常获得检查**

3、检查 HTML 文件内的 script 标签：

需要执行以下命令安装`eslint-plugin-html`插件：

```bash
$ npm install eslint-plugin-html --save-dev
```

并修改文件`.eslintrc.js`，载入`eslint-plugin-html`插件：

```
{
  plugins: [ 'html' ],
}
```

在 HTML 文件中，`<script>`标签需要包含`type="text/javascript"`，比如：

```html
<script type="text/javascript">
  var a = 10;
</script>
```

由于`eslint`命令默认只会检查`.js`后缀的文件，所以需要在执行命令时指定`.html`后缀，比如：

```bash
$ eslint --ext .js,.html . --fix
```


## 相关链接

+ [开始使用 JSDoc](http://usejsdoc.org/about-getting-started.html)


## License

```
The MIT License (MIT)

Copyright (c) 2016 Zongmin Lei <leizongmin@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
```

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