1.7.3 • Published 3 years ago

eslint-plugin-weiyi v1.7.3

Weekly downloads
1
License
ISC
Repository
github
Last release
3 years ago

eslint-plugin-weiyi

微易 eslint 插件

使用

通过 mrm 更新项目配置

⚠️ 注意,该方式会完全覆盖原项目中的 .eslintrc.js 文件内容。

# 全局安装 mrm
npm i -g mrm
# 应用配置到工程项目
cd <project-root-dir>
mrm lintformat-bxs

手动 npm 安装

  1. npm 5+ 安装插件及其 peerDependencies。
npx install-peerdeps --dev eslint-plugin-weiyi
  1. 如示例配置 .eslintrc.js,请根据使用场景选择 config。
module.exports = {
  root: true,
  extends: ['plugin:weiyi/vue-admin'],
}

config

plugin:weiyi/recommended:

plugin:weiyi/vue-recommended:

  • 继承 'eslint:recommended', 'plugin:vue/recommended', '@vue/airbnb', 'prettier', 'prettier/vue'
  • 开启自定义规则和 override

plugin:weiyi/vue-admin:

  • plugin:weiyi/vue-recommended
  • 面向现代浏览器,babel-parser 使用 ecmaVersion:2019。适用于管理后台等桌面端项目。

rules

no-dead-protocol: 禁止在字符串中使用 'http://'。请使用 'https://' 或 '//'。
vue-no-dead-protocol: 同上,包括检查 vue template 中的使用。
no-third-party-res: 禁止引用第三方 CDN 资源。请使用 'assets.winbaoxian.com' 镜像(howto)。
vue-no-third-party-res: 同上,包括检查 vue template 中的使用。

override

rules: {
  // 生产环境不使用 console 和 debugger 调试语句
  'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
  'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
  // 允许使用 hoist,支持任意安排 function 定义顺序
  'no-use-before-define': 'off',
  // 允许使用自增、自减运算
  'no-plusplus': 'off',
  // parseInt 十进制数字时不指定 radix 参数
  radix: ['error', 'as-needed'],
  // 不使用结尾分号,自动处理特殊情形
  semi: ['error', 'never', { beforeStatementContinuationChars: 'always' }],
  // 不允许未使用的表达式,但允许逻辑运算符和三元运算符的短路逻辑控制
  'no-unused-expressions': [
    'error',
    {
      allowShortCircuit: true,
      allowTernary: true,
      allowTaggedTemplates: true,
    },
  ],
  // 不允许隐式数据类型转换,始终使用 Number(foo), String(bar) 等
  'no-implicit-coercion': 'error',
  // 不允许在类、对象上下文之外使用不知所指的 this
  'no-invalid-this': 'error',
},
1.7.3

3 years ago

1.7.2

4 years ago

1.7.1

5 years ago

1.7.0

5 years ago

1.6.0

5 years ago

1.5.5

5 years ago

1.5.4

5 years ago

1.4.6

6 years ago

1.4.5

6 years ago

1.4.4

7 years ago

1.4.3

7 years ago

1.4.2

7 years ago

1.4.1

7 years ago

1.4.0

7 years ago

1.3.1

7 years ago

1.3.0

7 years ago

1.2.2

7 years ago

1.2.1

7 years ago

1.2.0

7 years ago

1.1.6

7 years ago

1.1.5

7 years ago

1.1.0

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago