1.2.1 • Published 1 year ago

eslint-plugin-wxs v1.2.1

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

简介

该 eslint 插件目标是为了在微信小程序环境下开发 WXS 进行语法的错误提示和修复

使用方法

安装

npm install --save-dev eslint eslint-plugin-wxs

::: 版本要求

  • Node.js 8.10.0 或更高.
  • ESLint 4.19.1 或更高. :::

eslint 配置文件示例

module.exports = {
    {
      "files": ["**/*.wxs"], //针对wxs文件
      "extends": ["plugin:wxs/recommended"], //使用推荐配置
      "parserOptions": {
        "ecmaVersion": 2020 //默认js版本
      },
      "env": {
        "es6": true
      },
      "settings": {
        "es": { "aggressive": true } //是否打开类型推断在any情况下依然检测对应方法是否符合对应规则
      },
      "rules": {
        "wxs/no-array-prototype-keys": ["error", { "aggressive": false }],//其中object是自定义类  //如果出现同名自定义方法是否报错 比如object.keys()
        "no-restricted-syntax": [ //屏蔽eslint基础报错
          "off",
          {
            "selector": "*",
            "message": "Do not use built-in ESLint rules on .wxs files."
          }
        ],
        "wxs/restrict-string-wxs": [ // 特殊规则,配置禁止的字符串
          "error",
          {
            "strings": ["所需要禁止的字符串"]
          }
        ]
      }
    },
};

json 格式修改为 js 格式即可

package 说明

所有除 es6+语法之外的特殊配置都在 restrict-to-wxs 中 wxs 特殊语法相关 rule 均在 no-wxs(禁止),restrict(限制)文件夹中

特别说明

项目中参考了大量 eslint-plugin-es 的代码

1.2.0

1 year ago

1.2.1

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago