0.0.0 • Published 4 years ago

@hagan/eslint-plugin-link-slash-end v0.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
4 years ago

@hagan/eslint-plugin-link-slash-end

业务需要,所有页面链接必须以 / 结尾进行跳转,但开发人员较多,有时会有的同学忘掉这个规则,导致线上报错,因此做了这个 @hagan/eslint-plugin-link-slash-end 校验规则

使用方法

yarn add -D eslint
yarn add -D @hagan/eslint-plugin-link-slash-end

规则说明

此规则主要做如下几个校验

  1. 校验所有 a 标签的 href 属性是否以 / 结尾
<!-- 正确 -->
<a href="/admin/login/"></a>

<!-- 报错 -->
<a href="/admin/login"></a>
  1. 校验所有 window.open() 的参数是否以 / 结尾
window.open('/admin/login/') // 正确
window.open('/admin/login') // 报错

Usage

Add link-slash-end to the plugins section of your .eslintrc configuration file. You can omit the eslint-plugin- prefix:

{
    "plugins": [
        "link-slash-end"
    ]
}

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

{
    "rules": {
        "link-slash-end/rule-name": 2
    }
}

Supported Rules

  • Fill in provided rules here
0.0.0

4 years ago

0.0.1

4 years ago