eslint fixes

This commit is contained in:
pikax 2021-04-06 17:21:58 +01:00
parent 6c86065307
commit 69a1bc909b
21 changed files with 32 additions and 21 deletions

View File

@ -22,6 +22,15 @@ module.exports = {
WXEnvironment: true,
},
rules: {
'no-unused-vars': [
'error',
// we are only using this rule to check for unused arguments since TS
// catches unused variables but not args.
{ varsIgnorePattern: '.*', args: 'none' }
],
'prefer-spread': 0,
'prefer-rest-params': 0,
'no-prototype-builtins': 0,
"no-console": process.env.NODE_ENV !== "production" ? 0 : 2,
"no-useless-escape": 0,
"no-empty": 0,

View File

@ -40,6 +40,7 @@ export function generateCodeFrame(
function repeat(str, n) {
let result = ''
if (n > 0) {
// eslint-disable-next-line no-constant-condition
while (true) {
// eslint-disable-line
if (n & 1) result += str

View File

@ -14,7 +14,7 @@ export function createCompilerCreator(baseCompile: Function): Function {
const tips: WarningMessage[] = []
let warn = (msg, range, tip) => {
;(tip ? tips : errors).push(msg)
(tip ? tips : errors).push(msg)
}
if (options) {
@ -35,7 +35,7 @@ export function createCompilerCreator(baseCompile: Function): Function {
data.end = range.end + leadingSpaceLength
}
}
;(tip ? tips : errors).push(data)
(tip ? tips : errors).push(data)
}
}
// merge custom modules

View File

@ -24,7 +24,7 @@ export function addProp(
range?: Range,
dynamic?: boolean
) {
;(el.props || (el.props = [])).push(
(el.props || (el.props = [])).push(
rangeSetItem({ name, value, dynamic }, range)
)
el.plain = false
@ -65,7 +65,7 @@ export function addDirective(
modifiers?: ASTModifiers,
range?: Range
) {
;(el.directives || (el.directives = [])).push(
(el.directives || (el.directives = [])).push(
rangeSetItem(
{
name,

View File

@ -91,7 +91,7 @@ export function parseFilters(exp: string): string {
}
function pushFilter() {
;(filters || (filters = [])).push(exp.slice(lastFilterIndex, i).trim())
(filters || (filters = [])).push(exp.slice(lastFilterIndex, i).trim())
lastFilterIndex = i + 1
}

View File

@ -773,7 +773,7 @@ function processAttrs(el) {
modifiers = parseModifiers(name.replace(dirRE, ''))
// support .foo shorthand syntax for the .prop modifier
if (process.env.VBIND_PROP_SHORTHAND && propBindRE.test(name)) {
;(modifiers || (modifiers = {})).prop = true
(modifiers || (modifiers = {})).prop = true
name = `.` + name.slice(1).replace(modifierRE, '')
} else if (modifiers) {
name = name.replace(modifierRE, '')

View File

@ -68,7 +68,7 @@ export function eventsMixin(Vue: Component) {
vm.$on(event[i], fn)
}
} else {
;(vm._events[event] || (vm._events[event] = [])).push(fn)
(vm._events[event] || (vm._events[event] = [])).push(fn)
// optimize hook:event cost by using a boolean flag marked at registration
// instead of a hash lookup
if (hookRE.test(event)) {

View File

@ -44,6 +44,6 @@ export function renderList(
if (!isDef(ret)) {
ret = []
}
;(ret as any)._isVList = true
(ret as any)._isVList = true
return ret
}

View File

@ -23,7 +23,7 @@ export function resolveScopedSlots(
}
}
if (contentHashKey) {
;(res as any).$key = contentHashKey
(res as any).$key = contentHashKey
}
return res as any
}

View File

@ -35,7 +35,7 @@ export function resolveSlots(
slot.push(child)
}
} else {
;(slots.default || (slots.default = [])).push(child)
(slots.default || (slots.default = [])).push(child)
}
}
// ignore slots that contains only whitespace

View File

@ -160,10 +160,10 @@ function cloneAndMarkFunctionalResult(
clone.fnContext = contextVm
clone.fnOptions = options
if (process.env.NODE_ENV !== 'production') {
;(clone.devtoolsMeta = clone.devtoolsMeta || {} as any).renderContext = renderContext
(clone.devtoolsMeta = clone.devtoolsMeta || {} as any).renderContext = renderContext
}
if (data.slot) {
;(clone.data || (clone.data = {})).slot = data.slot
(clone.data || (clone.data = {})).slot = data.slot
}
return clone
}

2
src/global.d.ts vendored
View File

@ -19,4 +19,4 @@ declare type WeexEnvironment = {
dpr?: number;
rem?: number;
};
declare var WXEnvironment: WeexEnvironment;
declare let WXEnvironment: WeexEnvironment;

View File

@ -97,7 +97,7 @@ function remove(
capture: boolean,
_target?: HTMLElement
) {
;(_target || target).removeEventListener(
(_target || target).removeEventListener(
name,
//@ts-expect-error
handler._wrapper || handler,

View File

@ -242,7 +242,7 @@ export function leave(vnode: VNodeWithData, rm: Function) {
}
// record leaving element
if (!vnode.data.show && el.parentNode) {
;(el.parentNode._pending || (el.parentNode._pending = {}))[
(el.parentNode._pending || (el.parentNode._pending = {}))[
vnode.key!
] = vnode
}

View File

@ -29,7 +29,7 @@ function add(
}
function remove(event: string, handler: any, capture: any, _target?: any) {
;(_target || target).removeEvent(event)
(_target || target).removeEvent(event)
}
function updateDOMListeners(oldVnode: VNodeWithData, vnode: VNodeWithData) {

View File

@ -224,7 +224,7 @@ function leave(vnode, rm) {
}
// record leaving element
if (!vnode.data.show) {
;(el.parentNode._pending || (el.parentNode._pending = {}))[
(el.parentNode._pending || (el.parentNode._pending = {}))[
vnode.key
] = vnode
}

View File

@ -1,4 +1,4 @@
declare var document: WeexDocument
declare let document: WeexDocument
import type { WeexDocument, WeexElement } from 'typescript/weex'
import TextNode from 'weex/runtime/text-node'

View File

@ -1,4 +1,4 @@
declare var document: WeexDocument
declare let document: WeexDocument
import { warn } from 'core/util/index'
import type { WeexDocument } from 'typescript/weex'

View File

@ -97,7 +97,7 @@ export function createBundleRendererCreator(
let promise
if (!cb) {
;({ promise, cb } = createPromiseCallback())
({ promise, cb } = createPromiseCallback())
}
run(context)

View File

@ -80,7 +80,7 @@ export function createRenderer({
// no callback, return Promise
let promise
if (!cb) {
;({ promise, cb } = createPromiseCallback())
({ promise, cb } = createPromiseCallback())
}
let result = ''

View File

@ -221,6 +221,7 @@ describe('Observer', () => {
get () { return this.val },
set (v) {
this.val = v
// eslint-disable-next-line no-setter-return
return this.val
}
})