# @zhaiun/eslint-plugin-miniprogram

> 微信小程序自定义eslint

Latest version **0.0.1** (published 2022-04-19) · ISC license · 0 weekly downloads

## Install

```sh
npm install @zhaiun/eslint-plugin-miniprogram
pnpm add @zhaiun/eslint-plugin-miniprogram
yarn add @zhaiun/eslint-plugin-miniprogram
bun add @zhaiun/eslint-plugin-miniprogram
```

## 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.1 |
| Published | 2022-04-19 |
| First published | 2022-04-19 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 14.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | 504988670@qq.com |
| Maintainers | zhaiun |
| Keywords | eslint, eslint-plugin, weapp, wxml, wechat, miniprogram |

## Links

- npm: https://www.npmjs.com/package/@zhaiun/eslint-plugin-miniprogram
- npm.io page: https://npm.io/package/@zhaiun/eslint-plugin-miniprogram

## Dependencies (1)

- [@wxml/parser](https://npm.io/package/@wxml/parser.md) ^0.2.0

## 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.1 (latest) — 2022-04-19

## README

# 小程序 eslint

## 开发方式

* 安装全局依赖(如已安装，可直接跳过)

```bash
npm install -g yo generator-eslint
```

* 安装开发依赖

```bash
npm i
```

* 生成 eslint rule

```bash
yarn create:rule
```

会出现创建规则命令行交互

```bash
? What is your name?  // 开发者名称
? Where will this rule be published? (Use arrow keys) // 这个规则将在哪里发布？
❯ ESLint Core    // 官方核心规则
  ESLint Plugin  // 选择ESLint插件，我们选择这个
? What is the rule ID?   // 规则的ID，推荐使用kebab-case命名规则，例如attribute-kebab-case
? Type a short description of this rule:  // 输入该规则的描述
? Type a short example of the code that will fail:  // 后续可在tests中进行测试用
   create docs/rules/attribute-kebab-case.md         // 文档
   create lib/rules/attribute-kebab-case.js          // 规则文件
   create tests/lib/rules/attribute-kebab-case.js    // 测试文件
```

## 使用方式

* 安装依赖(需要安装 eslint)

```sh
yarn add @zhaiun/eslint-plugin-miniprogram --dev
```

* 添加至项目中

    1. 在 vscode 配置中开启 eslint 校验语言列表(eslint.validate)

        ```js
        "eslint.validate": [
          ......
          "wxml"
        ],
        ```

    2. 在 eslintrc 添加 > .eslintrc, .eslintrc.js, .eslintrc.json

       ```diff
        module.exports = {
          root: true,
          parser: 'babel-eslint',
       -  extends: [...],
       +  extends: [..., 'plugin:@zhaiun/miniprogram/all'],
          rules: {
         	...
         },
       +  // 为特定类型的文件指定处理器
       +  overrides: [
       +    {
       +      // 定义需要解析文件的扩展名
       +      files: ["*.wxml"],
       +      // 定义eslint的插件
       +      plugins: ["@zhaiun/miniprogram"],
       +      // 定义解析器
       +      parser: "@wxml/parser"
       +    }
       +  ]
        };

       ```

## 参考文档

[手摸手教你定制 ESLint rule 以及了解 ESLint 的运行原理](https://segmentfault.com/a/1190000021228113)

[微信wxml解析器](https://npm.runkit.com/%40wxml%2Fparser)

## TODO

* [ ] 事件命名不符合`handle`开头

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