workflow: setup eslint for prohibited syntax and globals

fix #1285
This commit is contained in:
Evan You
2020-06-10 16:54:23 -04:00
parent e4dc03a8b1
commit 80c868aefe
20 changed files with 697 additions and 149 deletions

View File

@@ -14,7 +14,8 @@ import {
makeMap,
isReservedProp,
EMPTY_ARR,
def
def,
extend
} from '@vue/shared'
import { warn } from './warning'
import {
@@ -308,7 +309,7 @@ export function normalizePropsOptions(
if (__FEATURE_OPTIONS__ && !isFunction(comp)) {
const extendProps = (raw: ComponentOptions) => {
const [props, keys] = normalizePropsOptions(raw)
Object.assign(normalized, props)
extend(normalized, props)
if (keys) needCastKeys.push(...keys)
}
if (comp.extends) {

View File

@@ -1,7 +1,13 @@
import { ComponentInternalInstance, Data } from './component'
import { nextTick, queueJob } from './scheduler'
import { instanceWatch } from './apiWatch'
import { EMPTY_OBJ, hasOwn, isGloballyWhitelisted, NOOP } from '@vue/shared'
import {
EMPTY_OBJ,
hasOwn,
isGloballyWhitelisted,
NOOP,
extend
} from '@vue/shared'
import {
ReactiveEffect,
UnwrapRef,
@@ -365,27 +371,30 @@ if (__DEV__ && !__TEST__) {
}
}
export const RuntimeCompiledPublicInstanceProxyHandlers = {
...PublicInstanceProxyHandlers,
get(target: ComponentRenderContext, key: string) {
// fast path for unscopables when using `with` block
if ((key as any) === Symbol.unscopables) {
return
export const RuntimeCompiledPublicInstanceProxyHandlers = extend(
{},
PublicInstanceProxyHandlers,
{
get(target: ComponentRenderContext, key: string) {
// fast path for unscopables when using `with` block
if ((key as any) === Symbol.unscopables) {
return
}
return PublicInstanceProxyHandlers.get!(target, key, target)
},
has(_: ComponentRenderContext, key: string) {
const has = key[0] !== '_' && !isGloballyWhitelisted(key)
if (__DEV__ && !has && PublicInstanceProxyHandlers.has!(_, key)) {
warn(
`Property ${JSON.stringify(
key
)} should not start with _ which is a reserved prefix for Vue internals.`
)
}
return has
}
return PublicInstanceProxyHandlers.get!(target, key, target)
},
has(_: ComponentRenderContext, key: string) {
const has = key[0] !== '_' && !isGloballyWhitelisted(key)
if (__DEV__ && !has && PublicInstanceProxyHandlers.has!(_, key)) {
warn(
`Property ${JSON.stringify(
key
)} should not start with _ which is a reserved prefix for Vue internals.`
)
}
return has
}
}
)
// In dev mode, the proxy target exposes the same properties as seen on `this`
// for easier console inspection. In prod mode it will be an empty object so

View File

@@ -495,6 +495,7 @@ function hydrateSuspense(
optimized: boolean
) => Node | null
): Node | null {
/* eslint-disable no-restricted-globals */
const suspense = (vnode.suspense = createSuspenseBoundary(
vnode,
parentSuspense,
@@ -524,6 +525,7 @@ function hydrateSuspense(
suspense.resolve()
}
return result
/* eslint-enable no-restricted-globals */
}
export function normalizeSuspenseChildren(

View File

@@ -1,9 +1,11 @@
/* eslint-disable no-restricted-globals */
import {
ComponentInternalInstance,
ComponentOptions,
InternalRenderFunction
} from './component'
import { queueJob, queuePostFlushCb } from './scheduler'
import { extend } from '@vue/shared'
export interface HMRRuntime {
createRecord: typeof createRecord
@@ -85,7 +87,7 @@ function reload(id: string, newComp: ComponentOptions) {
const comp = instance.type
if (!comp.__hmrUpdated) {
// 1. Update existing comp definition to match new one
Object.assign(comp, newComp)
extend(comp, newComp)
for (const key in comp) {
if (!(key in newComp)) {
delete (comp as any)[key]

View File

@@ -31,11 +31,13 @@ function isSupported() {
if (supported !== undefined) {
return supported
}
/* eslint-disable no-restricted-globals */
if (typeof window !== 'undefined' && window.performance) {
supported = true
perf = window.performance
} else {
supported = false
}
/* eslint-enable no-restricted-globals */
return supported
}