]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
chore: fix typo for `babelParserDefautPlugins` (#1897)
authoredison <daiwei521@126.com>
Wed, 19 Aug 2020 13:53:09 +0000 (21:53 +0800)
committerGitHub <noreply@github.com>
Wed, 19 Aug 2020 13:53:09 +0000 (09:53 -0400)
packages/compiler-core/src/transforms/transformExpression.ts
packages/compiler-dom/src/transforms/vModel.ts
packages/compiler-sfc/__tests__/compileScript.spec.ts
packages/compiler-sfc/src/compileScript.ts
packages/shared/src/index.ts

index a4dd94d06fcb6fd7779a06c13f22e16034dc603b..a671c563f7077d95d2268740414d07c161f693ba 100644 (file)
@@ -20,7 +20,7 @@ import { advancePositionWithClone, isSimpleIdentifier } from '../utils'
 import {
   isGloballyWhitelisted,
   makeMap,
-  babelParserDefautPlugins,
+  babelParserDefaultPlugins,
   hasOwn
 } from '@vue/shared'
 import { createCompilerError, ErrorCodes } from '../errors'
@@ -135,7 +135,7 @@ export function processExpression(
     : `(${rawExp})${asParams ? `=>{}` : ``}`
   try {
     ast = parse(source, {
-      plugins: [...context.expressionPlugins, ...babelParserDefautPlugins]
+      plugins: [...context.expressionPlugins, ...babelParserDefaultPlugins]
     }).program
   } catch (e) {
     context.onError(
index 0aa9dca1eb8750bb94cdbf648bd18fac21ae0d9c..5dff390d3d89b234e6b1d2bc64adf2b2f64ae44c 100644 (file)
@@ -113,15 +113,13 @@ export const transformModel: DirectiveTransform = (dir, node, context) => {
 
   // native vmodel doesn't need the `modelValue` props since they are also
   // passed to the runtime as `binding.value`. removing it reduces code size.
-  baseResult.props = baseResult.props.filter(p => {
-    if (
-      p.key.type === NodeTypes.SIMPLE_EXPRESSION &&
-      p.key.content === 'modelValue'
-    ) {
-      return false
-    }
-    return true
-  })
+  baseResult.props = baseResult.props.filter(
+    p =>
+      !(
+        p.key.type === NodeTypes.SIMPLE_EXPRESSION &&
+        p.key.content === 'modelValue'
+      )
+  )
 
   return baseResult
 }
index bdaef0249777747ba8bfbf0d7c8c40814f606539..01f0d32899b49dd921e89348c04772a93131be55 100644 (file)
@@ -1,6 +1,6 @@
 import { parse, SFCScriptCompileOptions, compileScript } from '../src'
 import { parse as babelParse } from '@babel/parser'
-import { babelParserDefautPlugins } from '@vue/shared'
+import { babelParserDefaultPlugins } from '@vue/shared'
 
 function compile(src: string, options?: SFCScriptCompileOptions) {
   const { descriptor } = parse(src)
@@ -12,7 +12,7 @@ function assertCode(code: string) {
   try {
     babelParse(code, {
       sourceType: 'module',
-      plugins: [...babelParserDefautPlugins, 'typescript']
+      plugins: [...babelParserDefaultPlugins, 'typescript']
     })
   } catch (e) {
     console.log(code)
index 05c8de4ff8b2d06adea49401b2b0b8a3685b9a5d..a8e378d0f71f7796b9e255a1b5983999199b63dc 100644 (file)
@@ -2,7 +2,7 @@ import MagicString from 'magic-string'
 import { BindingMetadata } from '@vue/compiler-core'
 import { SFCDescriptor, SFCScriptBlock } from './parse'
 import { parse, ParserPlugin } from '@babel/parser'
-import { babelParserDefautPlugins, generateCodeFrame } from '@vue/shared'
+import { babelParserDefaultPlugins, generateCodeFrame } from '@vue/shared'
 import {
   Node,
   Declaration,
@@ -58,7 +58,7 @@ export function compileScript(
   const isTS = scriptLang === 'ts' || scriptSetupLang === 'ts'
   const plugins: ParserPlugin[] = [
     ...(options.babelParserPlugins || []),
-    ...babelParserDefautPlugins,
+    ...babelParserDefaultPlugins,
     ...(isTS ? (['typescript'] as const) : [])
   ]
 
index bd7abd127b02a3727c4b8af43f4ff2b278bee8c9..8f8bd9df7a9512868e39a81d70522e3f20f98966 100644 (file)
@@ -19,7 +19,7 @@ export * from './toDisplayString'
  * for ES2020. This will need to be updated as the spec moves forward.
  * Full list at https://babeljs.io/docs/en/next/babel-parser#plugins
  */
-export const babelParserDefautPlugins = [
+export const babelParserDefaultPlugins = [
   'bigInt',
   'optionalChaining',
   'nullishCoalescingOperator'