0.1.2 • Published 2 years ago

@dushenyan/eslint-config v0.1.2

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

eslint-config

NPM   npm (scoped)

Antzy ESLint config presets

  • Supports vue ts js

Install

pnpm add eslint -D
pnpm add @dushenyan/eslint-config -D

Config eslintrc.js

{
  "extends":"@dushenyan"
}

Used Rules

The following configuration has been used and will be fixed automatically

Base Config

used rulesexplain
arrow-parens箭头函数去掉不必要的括号
sort-importsimport 单行从大到小排序
no-useless-return关闭不允许多余的return
no-multiple-empty-lines不允许多个空行
array-bracket-newline数组括号前后 >= 3个换行
array-element-newline数组括号内的元素 >= 3个换行
function-paren-newline函数括号内参数有一个换行就换行
newline-per-chained-call方法链 >= 3个换行
object-curly-newlineimport 解构 超过6个换行
object-property-newline花括号属性强制换行,默认一个参数不换行
no-extra-label禁用不必要的标签
object-property-newline花括号属性强制换行,默认一个参数不换行
decimal禁止浮点小数
switch-colon-spacingswitch 的冒号左右有空格
implicit-arrow-linebreak箭头函数体后面不能换行
multiline-comment-style对多行注释格式化
operator-assignment简化赋值操作
template-tag-spacing函数调用模板字符串后面不能有空格
object-shorthand对象字面量中方法和属性使用简写语法
prefer-arrow-callback回调使用箭头函数
prefer-template使用字符串模板连接
yield-star-spacingyield* 周围空格

Typescript Config

used rulesexplain
no-non-null-assertion去掉禁止使用!后缀运算符
array-type使用数组 T[]
sort-type-union-intersection-members(| or &) 排序
space-infix-ops中缀运算符周围需要间距
semi禁止不必要的分号
comma-dangle要求或不允许尾随逗号
type-annotation-spacing类型注释间距
consistent-generic-constructors如果使用构造函数 泛型就要这样写 new Map<string,number>()
consistent-indexed-object-style强制使用 Record
member-delimiter-styleinterface type 不要分号和逗号
method-signature-style函数声明 func: (arg: string) => number
space-before-blocksinterface 后面加空格
consistent-type-imports使用引用类型时自动加上 type
consistent-type-definitions对象类型使用interface

Vue Config

used rulesexplain
require-default-prop(off) 关闭强制props有默认值
no-setup-props-destructure(off)setup可以解构
multi-word-component-names(off) 组价名可以简短
html-indenttemplate 缩进两列
script-indentscript 缩进两列
max-attributes-per-line属性超过3个自动换行,换行后 同一行不能超过1个
html-closing-bracket-newline标签右箭头换行
html-closing-bracket-spacing禁止右箭头有空格
html-self-closing自闭合标签
mustache-interpolation-spacing{{ 这里有空格 }}
no-multi-spaces不允许多个空格
no-spaces-around-equal-signs-in-attribute属性周围不允许等号有空格
component-tags-ordervue格式'script','template'
define-macros-order强制 defineProps defineEmits的顺序
static-class-names-orderclass名排序