# @agds/eslint-config-js

> agds的js eslint配置，支持js、json、markdown的js代码

Latest version **1.0.8** (published 2022-06-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install @agds/eslint-config-js
pnpm add @agds/eslint-config-js
yarn add @agds/eslint-config-js
bun add @agds/eslint-config-js
```

## 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.8 |
| Published | 2022-06-14 |
| First published | 2021-06-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 9 |
| Unpacked size | 8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | junyang |
| Maintainers | chujunyang |
| Keywords | eslint, agds, config, js |

## Links

- npm: https://www.npmjs.com/package/@agds/eslint-config-js
- Repository: https://gitee.com/agile-development-system/eslint-config-js
- npm.io page: https://npm.io/package/@agds/eslint-config-js

## Dependencies (9)

- [eslint](https://npm.io/package/eslint.md) ^7.27.0
- [@agds/node-utils](https://npm.io/package/@agds/node-utils.md) ^1.0.0
- [eslint-plugin-node](https://npm.io/package/eslint-plugin-node.md) ^11.1.0
- [@babel/eslint-parser](https://npm.io/package/@babel/eslint-parser.md) ^7.14.3
- [eslint-plugin-import](https://npm.io/package/eslint-plugin-import.md) ^2.23.3
- [eslint-plugin-promise](https://npm.io/package/eslint-plugin-promise.md) ^4.3.1
- [eslint-config-standard](https://npm.io/package/eslint-config-standard.md) ^16.0.2
- [eslint-plugin-markdown](https://npm.io/package/eslint-plugin-markdown.md) ^2.0.0-rc.2
- [eslint-plugin-json-format](https://npm.io/package/eslint-plugin-json-format.md) ^2.0.1

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.0.8 (latest) — 2022-06-14
- 1.0.7 — 2021-07-07
- 1.0.6 — 2021-06-16
- 1.0.0 — 2021-06-15

## README

<p align="center">
    <img src="https://gitee.com/agile-development-system/agds-doc-preset/raw/master/lib/docs/logos/light/1.png" alt="logo">
</p>

# @agds/eslint-config-js

**版本** ：1.0.8

agds的js eslint配置，支持js、json、markdown的js代码

## 快速开始

### 安装

```bash
npm i -D @agds/eslint-config-js
```

### 引入

```js
// .eslintrc.js
module.exports = {
    extends: [
        '@agds/js',
    ],
};
```


### 添加lint脚本

在`package.json`的`scripts`下添加lint命令；

```json
{
  "scripts": {
    "lint": "eslint --ext .js,.json,.md src",
    "lint:fix": "eslint --ext .js,.json,.md src --fix"
  }
}
```

### 基于`lint-staged`提供增量lint脚本

- 安装`lint-staged`包
    ```
    npm i -D lint-staged
    ```
- 在`package.json`中添加`pkg['lint-staged']`脚本
    ```json
    {
      "lint-staged": {
        "src/**/*.{js,json,md}": [
          "eslint --fix"
        ]
      }
    }
    ```

### 使用`yorkie`在git声明周期内检测代码格式

- 安装`yorkie`包
    ```
    npm i -D yorkie
    ```
- 在`package.json`中添加`pkg.gitHooks`脚本
    ```json
    {
      "gitHooks": {
        "pre-commit": "lint-staged"
      }
    }
    ```


<a name="source"></a>

## 配置源码

```js
const { FastPath, FastFs } = require('@agds/node-utils');
const cwdBabelConfigPath = FastPath.getCwdPath('./babel.config.js');
const hasCwdBabelConfg = FastFs.getPathStatSync(cwdBabelConfigPath);
module.exports = {
    env: {
        commonjs: true,
        es2021: true,
        node: true,
    },
    extends: [
        'standard',
        'plugin:markdown/recommended',
    ],
    plugins: [
        'json-format',
    ],
    settings: {
        'json/sort-package-json': false,
        'json/json-with-comments-files': [],
        'json/ignore-files': [],
    },
    parser: hasCwdBabelConfg ? '@babel/eslint-parser' : undefined,
    parserOptions: {
        ecmaVersion: 12,
        babelOptions: {
            configFile: hasCwdBabelConfg ? cwdBabelConfigPath : undefined,
        },
    },
    rules: {
        indent: ['error', 4, { SwitchCase: 1 }],
        semi: ['error', 'always'],
        'comma-dangle': ['error', 'always-multiline'],
        'space-before-function-paren': [
            'error',
            { anonymous: 'always', named: 'never', asyncArrow: 'always' },
        ],
    },
    overrides: [
        {
            files: ['**/*.md/*.{js,json}', 'docs/**', 'test/**'],
            rules: {
                'no-console': 'off',
                'import/no-unresolved': 'off',
                'no-undef': 'off',
                'no-unused-expressions': 'off',
                'no-unused-vars': 'off',
                'padded-blocks': 'off',
                'eol-last': 'off',
            },
        },
    ],
};
```


<a name="license"></a>

## 许可证

[MIT License](https://gitee.com/agile-development-system/eslint-config-js/blob/master/LICENSE)
Copyright (c) 2021 锦阳

<a name="donate"></a>

## 请维护者喝杯咖啡

<div style="display:flex;">
<img src="https://gitee.com/agile-development-system/agds-doc-preset/raw/master/lib/docs/qrcode/alipay.jpeg" width="209px" >
<img src="https://gitee.com/agile-development-system/agds-doc-preset/raw/master/lib/docs/qrcode/wechatpay.jpeg" width="237px" >
</div>

<a name="dingtalk"></a>

## 加入钉钉群讨论或加入开发

<img src="https://gitee.com/agile-development-system/agds-doc-preset/raw/master/lib/docs/qrcode/dingtalk.jpeg" width="188px" >

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