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

@@ -4,7 +4,7 @@ import './devCheck'
import { compile, CompilerOptions, CompilerError } from '@vue/compiler-dom'
import { registerRuntimeCompiler, RenderFunction, warn } from '@vue/runtime-dom'
import * as runtimeDom from '@vue/runtime-dom'
import { isString, NOOP, generateCodeFrame } from '@vue/shared'
import { isString, NOOP, generateCodeFrame, extend } from '@vue/shared'
const compileCache: Record<string, RenderFunction> = Object.create(null)
@@ -39,25 +39,30 @@ function compileToFunction(
template = el ? el.innerHTML : ``
}
const { code } = compile(template, {
hoistStatic: true,
onError(err: CompilerError) {
if (__DEV__) {
const message = `Template compilation error: ${err.message}`
const codeFrame =
err.loc &&
generateCodeFrame(
template as string,
err.loc.start.offset,
err.loc.end.offset
)
warn(codeFrame ? `${message}\n${codeFrame}` : message)
} else {
throw err
}
},
...options
})
const { code } = compile(
template,
extend(
{
hoistStatic: true,
onError(err: CompilerError) {
if (__DEV__) {
const message = `Template compilation error: ${err.message}`
const codeFrame =
err.loc &&
generateCodeFrame(
template as string,
err.loc.start.offset,
err.loc.end.offset
)
warn(codeFrame ? `${message}\n${codeFrame}` : message)
} else {
throw err
}
}
},
options
)
)
// The wildcard import results in a huge object with every export
// with keys that cannot be mangled, and can be quite heavy size-wise.