Giter Club home page Giter Club logo

eslint-plugin-san's Introduction

eslint-plugin-san

Official ESLint plugin for San. Inspired by eslint-plugin-vue

Installation

You'll first need to install ESLint:

$ npm i eslint --save-dev

Next, install eslint-plugin-san:

$ npm install eslint-plugin-san --save-dev

Usage

Add san to the plugins section of your .eslintrc configuration file.

{
    "extends": ["plugin:san/essential"],
    "parserOptions": {
        "parser": "babel-eslint"
    }
}

Then configure the rules you want to use under the rules section.

{
    "rules": {
        "san/rule-name": 2
    }
}

Supported on VS Code

On VS Code using ESlint extension to support. By default, Eslint extension is NOT support San, you shoud config eslint.validate option like this in settings.json:

{
    "eslint.validate": [
        "san"
    ]
}

Supported Rules

  • Fill in provided rules here

eslint-plugin-san's People

Contributors

buptlhuanyu avatar jinzhan avatar kidnes avatar ksky521 avatar merlin-liu avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

eslint-plugin-san's Issues

Feature Request: 提议升级 @typescript-eslint/parser 依赖版本 v5+

在 eslint-plugin-san 工程尝试升级 @typescript-eslint/parser 到 5.8.1 版本后,测试用例不通过

bfe3200b9325af799022a819e4a8880d

对比 eslint-plugin-vue 已经将升级了对应依赖的版本。
实际项目中,也期望升级对应依赖的版本,结果是升级该依赖项之后 eslint-plugin-san 就失效了,与预期不符。

Feature Request: 提议san/order-in-components规则对自定义成员方法进行排序检测

在该 san/order-in-components 规则下,san 组件中自定义的成员方法在 checkOrder 的排序检测方法中没有相应的处理。
在默认配置下,如有下列属性,排序检测是符合预期的:
['template', 'initData', 'attached']
image

但是,当为 san 组件自定义了成员方法,由于 getOrderPosition 方法在 orderMap 中没有记录或配置,那么就不会被正确检测。比如['template', 'customMethod1', 'customMethod2', 'initData', 'attached'],示例:
image

主要代码逻辑:
https://github.com/ecomfe/eslint-plugin-san/blob/main/lib/rules/order-in-components.js#L51
https://github.com/ecomfe/eslint-plugin-san/blob/main/lib/rules/order-in-components.js#L221

期望的结果是,开发者自定义的成员方法,应该独立形成一个 group,在定义的 order 指定位置处参与排序检测,group 内部可以支持 alpabeta 排序,类似san/attributes-order规则。

提议配置规则添加 CUSTOM_METHODS,指代自定义的成员方法,示例:

{
  "san/order-in-components": ["error", {
    "order": [
      // 视图
      "template",
      "components",
      "trimWhitespace",

      // 事件
      "messages",

      // 数据
      "dataTypes",
      "computed",
      "filters",
      "initData",

      // 生命周期
      "LIFECYCLE_HOOKS",

      // 自定义的成员方法
      "CUSTOM_METHODS"
    ]
  }]
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.