diff --git a/.eslintrc.js b/.eslintrc.js index 14641a81..f54843bc 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -7,6 +7,12 @@ module.exports = { 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 diff --git a/packages/compiler-core/src/transforms/validateExpression.ts b/packages/compiler-core/src/transforms/validateExpression.ts deleted file mode 100644 index 49096254..00000000 --- a/packages/compiler-core/src/transforms/validateExpression.ts +++ /dev/null @@ -1,49 +0,0 @@ -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 -) {} diff --git a/packages/compiler-dom/src/transforms/transformStyle.ts b/packages/compiler-dom/src/transforms/transformStyle.ts index 2767debf..b226f260 100644 --- a/packages/compiler-dom/src/transforms/transformStyle.ts +++ b/packages/compiler-dom/src/transforms/transformStyle.ts @@ -13,7 +13,7 @@ import { parseStringStyle } from '@vue/shared' // 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) { diff --git a/packages/compiler-sfc/src/templateTransformSrcset.ts b/packages/compiler-sfc/src/templateTransformSrcset.ts index aa7a4008..9790f896 100644 --- a/packages/compiler-sfc/src/templateTransformSrcset.ts +++ b/packages/compiler-sfc/src/templateTransformSrcset.ts @@ -62,7 +62,7 @@ export const transformSrcset: NodeTransform = ( 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) diff --git a/packages/runtime-core/src/componentRenderUtils.ts b/packages/runtime-core/src/componentRenderUtils.ts index 645f2110..060e07f7 100644 --- a/packages/runtime-core/src/componentRenderUtils.ts +++ b/packages/runtime-core/src/componentRenderUtils.ts @@ -239,7 +239,6 @@ const isElementRoot = (vnode: VNode) => { export function shouldUpdateComponent( prevVNode: VNode, nextVNode: VNode, - parentComponent: ComponentInternalInstance | null, optimized?: boolean ): boolean { const { props: prevProps, children: prevChildren } = prevVNode diff --git a/packages/runtime-core/src/hmr.ts b/packages/runtime-core/src/hmr.ts index 27a19854..a2f0022d 100644 --- a/packages/runtime-core/src/hmr.ts +++ b/packages/runtime-core/src/hmr.ts @@ -48,7 +48,7 @@ export function registerHMR(instance: ComponentInternalInstance) { 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) @@ -58,7 +58,7 @@ export function unregisterHMR(instance: ComponentInternalInstance) { 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 } diff --git a/packages/runtime-core/src/renderer.ts b/packages/runtime-core/src/renderer.ts index f3ec8011..1d8bc712 100644 --- a/packages/runtime-core/src/renderer.ts +++ b/packages/runtime-core/src/renderer.ts @@ -1109,7 +1109,7 @@ function baseCreateRenderer( ) } } else { - updateComponent(n1, n2, parentComponent, optimized) + updateComponent(n1, n2, optimized) } } @@ -1185,14 +1185,9 @@ function baseCreateRenderer( } } - 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 &&