chore(project): modify some lint rules

allow vue default props; disallow arrow parens when only one parameter; use rule words rather than
number; modify the sequences of rules; delete a duplicate field in tsconfig
This commit is contained in:
hanx316 2020-08-19 21:35:40 +08:00 committed by jeremywu
parent 2606158c38
commit 07d2beccfc
19 changed files with 51 additions and 61 deletions

@ -26,7 +26,24 @@ module.exports = {
semi: ['error', 'never'],
indent: ['error', 2, { SwitchCase: 1 }],
'object-curly-spacing': ['error', 'always'],
'arrow-parens': ['error', 'as-needed'],
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/member-delimiter-style': [
'error',
{
multiline: {
delimiter: 'none',
requireLast: false,
},
singleline: {
delimiter: 'semi',
requireLast: true,
},
},
],
// vue
'vue/no-v-html': 'off',
'vue/singleline-html-element-content-newline': 'off',
'vue/html-self-closing': ['error', {
html: {
@ -39,21 +56,7 @@ module.exports = {
singleline: 3,
multiline: 1,
}],
'@typescript-eslint/member-delimiter-style': [
2,
{
multiline: {
delimiter: 'none',
requireLast: false,
},
singleline: {
delimiter: 'semi',
requireLast: true,
},
},
],
'@typescript-eslint/explicit-module-boundary-types': 'off',
'vue/require-default-prop': 'off',
'vue/html-closing-bracket-spacing': 'error',
'@typescript-eslint/no-explicit-any': 0,
},
}

@ -10,8 +10,8 @@ function getPackages (context) {
const project = new Project(cwd)
return project.getPackages()
})
.then((packages) => {
return packages.map((pkg) => pkg.name).map((name) => (name.charAt(0) === '@' ? name.split('/')[1] : name))
.then(packages => {
return packages.map(pkg => pkg.name).map(name => (name.charAt(0) === '@' ? name.split('/')[1] : name))
})
}
@ -29,7 +29,7 @@ const scopes = [
module.exports = {
rules: {
'scope-enum': (ctx) => getPackages(ctx).then((packages) => [2, 'always', [...packages, ...scopes]]),
'scope-enum': ctx => getPackages(ctx).then(packages => [2, 'always', [...packages, ...scopes]]),
'body-leading-blank': [1, 'always'],
'footer-leading-blank': [1, 'always'],
'header-max-length': [2, 'always', 72],

@ -80,7 +80,7 @@ export default defineComponent({
const isBoldTitle = computed(() => props.description || ctx.slots.default ? 'is-bold' : '')
// methods
const close = (evt) => {
const close = evt => {
visible.value = false
ctx.emit('click', evt)
}

@ -37,22 +37,10 @@ export default defineComponent({
return ['circle', 'square'].includes(val)
},
},
icon: {
type: String,
default: undefined,
},
src: {
type: String,
default: undefined,
},
alt: {
type: String,
default: undefined,
},
srcSet: {
type: String,
default: undefined,
},
icon: String,
src: String,
alt: String,
srcSet: String,
fit: {
type: String,
default: 'cover',

@ -75,7 +75,7 @@ export default defineComponent({
const onScroll = () => {
visible.value = el.value.scrollTop >= props.visibilityHeight
}
const handleClick = (event) => {
const handleClick = event => {
scrollToTop()
ctx.emit('click', event)
}

@ -105,7 +105,7 @@ export default defineComponent({
})
//methods
const handleClick = (evt) => {
const handleClick = evt => {
ctx.emit('click', evt)
}

@ -23,7 +23,7 @@ const _mount = <T={data: any; checkList: [];}>(template: string, data, otherObj?
})
describe('Checkbox', () => {
test('create', async (done) => {
test('create', async done => {
const wrapper = _mount('<el-checkbox v-model="checkbox" label="a"/>', () => ({ checkbox: false }))
const vm = wrapper.vm
expect(wrapper.classes()).toContain('el-checkbox')
@ -36,7 +36,7 @@ describe('Checkbox', () => {
})
})
test('disabled', async (done) => {
test('disabled', async done => {
const wrapper = _mount('<el-checkbox v-model="checkbox" disabled label="a"/>', () => ({ checkbox: false }))
const vm = wrapper.vm
expect(wrapper.classes()).toContain('is-disabled')
@ -47,7 +47,7 @@ describe('Checkbox', () => {
})
})
test('change event', async (done) => {
test('change event', async done => {
const wrapper = _mount(
`
<el-checkbox v-model="checked" @change="onChange" />
@ -74,7 +74,7 @@ describe('Checkbox', () => {
})
})
test('checkbox group', async (done) => {
test('checkbox group', async done => {
const wrapper = _mount(
`
<el-checkbox-group v-model="checkList">
@ -187,7 +187,7 @@ describe('Checkbox', () => {
})
describe('check-button', () => {
test('create', async (done) => {
test('create', async done => {
const wrapper = _mount('<el-checkbox-button v-model="checkbox" label="a"/>', () => ({ checkbox: false }))
const vm = wrapper.vm
expect(wrapper.classes()).toContain('el-checkbox-button')
@ -200,7 +200,7 @@ describe('check-button', () => {
})
})
test('disabled', async (done) => {
test('disabled', async done => {
const wrapper = _mount('<el-checkbox-button v-model="checkbox" disabled label="a"/>', () => ({ checkbox: false }))
const vm = wrapper.vm
expect(wrapper.classes()).toContain('is-disabled')
@ -211,7 +211,7 @@ describe('check-button', () => {
})
})
test('change event', async (done) => {
test('change event', async done => {
const wrapper = _mount(
`
<el-checkbox-button v-model="checked" @change="onChange" />

@ -177,7 +177,7 @@ export default defineComponent({
// })
}
watch(() => props.modelValue, (val) => {
watch(() => props.modelValue, val => {
elFormItem.changeEvent?.(val)
})

@ -197,7 +197,7 @@ export default defineComponent({
// })
}
watch(() => props.modelValue, (val) => {
watch(() => props.modelValue, val => {
elFormItem.changeEvent?.(val)
})

@ -26,13 +26,13 @@ export default defineComponent({
const activeNames = ref([].concat(props.modelValue))
const collapseMitt: mitt.Emitter = mitt()
const setActiveNames = (_activeNames) => {
const setActiveNames = _activeNames => {
activeNames.value = [].concat(_activeNames)
const value = props.accordion ? activeNames.value[0] : activeNames.value
emit('update:modelValue', value)
}
const handleItemClick = (name) => {
const handleItemClick = name => {
if(props.accordion) {
setActiveNames(
(activeNames.value[0] || activeNames.value[0] === 0) &&

@ -23,7 +23,7 @@ export default defineComponent({
}
if (slots && slots.default) {
const vNodes: VNode[] = slots.default()
return vNodes.some((vNode) => {
return vNodes.some(vNode => {
const tag = vNode.type.name
return tag === 'ElHeader' || tag === 'ElFooter'
})

@ -81,7 +81,7 @@ describe('Popper.vue', () => {
test('append to body', () => {
const { appendChild } = document.body
document.body.appendChild = jest.fn((child) => {
document.body.appendChild = jest.fn(child => {
return appendChild.call(document.body, child)
})

@ -329,7 +329,7 @@ export default defineComponent({
},
)
watch(() => popperOptions.value, (val) => {
watch(() => popperOptions.value, val => {
popperInstance.value.setOptions({
placement: val.placement,
strategy: val.strategy,

@ -86,7 +86,7 @@ export default {
modelValue,
})
const handleKeydown = (e) => { // radio
const handleKeydown = e => { // radio
const target = e.target
const className = target.nodeName === 'INPUT' ? '[type=radio]' : '[role=radio]'
const radios = radioGroup.value.querySelectorAll(className)

@ -20,7 +20,7 @@ export default {
})
const barStore = ref({})
const cursorDown = ref(null)
const clickThumbHandler= (e) => {
const clickThumbHandler= e => {
// prevent click event of right button
if (e.ctrlKey || e.button === 2) {
return
@ -29,14 +29,14 @@ export default {
barStore.value[bar.value.axis] = (e.currentTarget[bar.value.offset] - (e[bar.value.client] - e.currentTarget.getBoundingClientRect()[bar.value.direction]))
}
const clickTrackHandler = (e) => {
const clickTrackHandler = e => {
const offset = Math.abs(e.target.getBoundingClientRect()[bar.value.direction] - e[bar.value.client])
const thumbHalf = (thumb.value[bar.value.offset] / 2)
const thumbPositionPercentage = ((offset - thumbHalf) * 100 / instance.vnode.el[bar.value.offset])
wrap.value[bar.value.scroll] = (thumbPositionPercentage * wrap.value[bar.value.scrollSize] / 100)
}
const startDrag = (e) =>{
const startDrag = e =>{
e.stopImmediatePropagation()
cursorDown.value = true
on(document, 'mousemove', mouseMoveDocumentHandler)
@ -44,7 +44,7 @@ export default {
document.onselectstart = () => false
}
const mouseMoveDocumentHandler = (e) => {
const mouseMoveDocumentHandler = e => {
if (cursorDown.value === false) return
const prevPage = barStore.value[bar.value.axis]

@ -88,12 +88,12 @@ export default defineComponent({
})
// methods
const handleClose = (event) => {
const handleClose = event => {
event.stopPropagation()
ctx.emit('close', event)
}
const handleClick = (event) => {
const handleClick = event => {
ctx.emit('close', event)
}

@ -12,7 +12,6 @@
"lib": [
"es2020", "dom"
],
"esModuleInterop": true,
"allowSyntheticDefaultImports": true
},
"exclude": [

@ -28,7 +28,7 @@ app.mixin({
computed: {
$isEle: {
get: () => (globalEle.data.$isEle),
set: (data) => {globalEle.data.$isEle = data},
set: data => {globalEle.data.$isEle = data},
},
},
})

@ -40,7 +40,7 @@ const loadDocs = function(lang, path) {
return LOAD_DOCS_MAP[lang](path)
}
const registerRoute = (navConfig) => {
const registerRoute = navConfig => {
let route = []
Object.keys(navConfig).forEach((lang, index) => {
let navs = navConfig[lang]