sourceType: 'module'
},
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: 'after-used' }
+ ],
// most of the codebase are expected to be env agnostic
'no-restricted-globals': ['error', ...DOMGlobals, ...NodeGlobals],
// since we target ES2015 for baseline support, we need to forbid object
+++ /dev/null
-import { NodeTransform, TransformContext } from '../transform'
-import { NodeTypes, SimpleExpressionNode } from '../ast'
-
-/**
- * When using the runtime compiler in function mode, some expressions will
- * become invalid (e.g. using keyworkds like `class` in expressions) so we need
- * to detect them.
- *
- * This transform is browser-only and dev-only.
- */
-export const validateExpression: NodeTransform = (node, context) => {
- if (node.type === NodeTypes.INTERPOLATION) {
- validateBrowserExpression(node.content as SimpleExpressionNode, context)
- } else if (node.type === NodeTypes.ELEMENT) {
- // handle directives on element
- for (let i = 0; i < node.props.length; i++) {
- const dir = node.props[i]
- // do not process for v-on & v-for since they are special handled
- if (dir.type === NodeTypes.DIRECTIVE && dir.name !== 'for') {
- const exp = dir.exp
- const arg = dir.arg
- // do not process exp if this is v-on:arg - we need special handling
- // for wrapping inline statements.
- if (
- exp &&
- exp.type === NodeTypes.SIMPLE_EXPRESSION &&
- !(dir.name === 'on' && arg)
- ) {
- validateBrowserExpression(
- exp,
- context,
- // slot args must be processed as function params
- dir.name === 'slot'
- )
- }
- if (arg && arg.type === NodeTypes.SIMPLE_EXPRESSION && !arg.isStatic) {
- validateBrowserExpression(arg, context)
- }
- }
- }
- }
-}
-
-export function validateBrowserExpression(
- node: SimpleExpressionNode,
- context: TransformContext,
- asParams = false,
- asRawStatements = false
-) {}
// style="color: red" -> :style='{ "color": "red" }'
// It is then processed by `transformElement` and included in the generated
// props.
-export const transformStyle: NodeTransform = (node, context) => {
+export const transformStyle: NodeTransform = node => {
if (node.type === NodeTypes.ELEMENT) {
node.props.forEach((p, i) => {
if (p.type === NodeTypes.ATTRIBUTE && p.name === 'style' && p.value) {
if (options.base) {
const base = options.base
const set: string[] = []
- imageCandidates.forEach(({ url, descriptor }, index) => {
+ imageCandidates.forEach(({ url, descriptor }) => {
descriptor = descriptor ? ` ${descriptor}` : ``
if (isRelativeUrl(url)) {
set.push((path.posix || path).join(base, url) + descriptor)
export function shouldUpdateComponent(
prevVNode: VNode,
nextVNode: VNode,
- parentComponent: ComponentInternalInstance | null,
optimized?: boolean
): boolean {
const { props: prevProps, children: prevChildren } = prevVNode
const id = instance.type.__hmrId!
let record = map.get(id)
if (!record) {
- createRecord(id, instance.type as ComponentOptions)
+ createRecord(id)
record = map.get(id)!
}
record.add(instance)
map.get(instance.type.__hmrId!)!.delete(instance)
}
-function createRecord(id: string, comp: ComponentOptions): boolean {
+function createRecord(id: string): boolean {
if (map.has(id)) {
return false
}
)
}
} else {
- updateComponent(n1, n2, parentComponent, optimized)
+ updateComponent(n1, n2, optimized)
}
}
}
}
- const updateComponent = (
- n1: VNode,
- n2: VNode,
- parentComponent: ComponentInternalInstance | null,
- optimized: boolean
- ) => {
+ const updateComponent = (n1: VNode, n2: VNode, optimized: boolean) => {
const instance = (n2.component = n1.component)!
- if (shouldUpdateComponent(n1, n2, parentComponent, optimized)) {
+ if (shouldUpdateComponent(n1, n2, optimized)) {
if (
__FEATURE_SUSPENSE__ &&
instance.asyncDep &&