From 3d7016e2dc38e3b03df8129c52dd85b1ff9aec60 Mon Sep 17 00:00:00 2001 From: fisker Cheung Date: Thu, 5 Nov 2020 14:08:37 +0800 Subject: [PATCH] Add `meriyah` parser (#9514) --- changelog_unreleased/javascript/pr-9000.md | 10 ++- cspell.json | 4 + package.json | 1 + scripts/build/config.js | 3 + src/language-js/clean.js | 1 + src/language-js/comments.js | 4 +- src/language-js/index.js | 6 ++ src/language-js/needs-parens.js | 4 +- src/language-js/parser-meriyah.js | 87 +++++++++++++++++++ src/language-js/postprocess.js | 3 +- src/language-js/printer-estree.js | 11 ++- src/language-js/types/estree.d.ts | 20 ++++- src/language-js/utils.js | 24 ++++- src/main/core-options.js | 1 + src/main/range-util.js | 1 + tests/js/arrows-bind/jsfmt.spec.js | 2 +- .../arrows/newline-before-arrow/jsfmt.spec.js | 5 +- tests/js/babel-plugins/jsfmt.spec.js | 25 ++++++ tests/js/bind-expressions/jsfmt.spec.js | 7 +- tests/js/class-static-block/jsfmt.spec.js | 2 +- tests/js/classes-private-fields/jsfmt.spec.js | 9 +- .../js/classes/top-level-super/jsfmt.spec.js | 4 +- .../comments-pipeline-own-line/jsfmt.spec.js | 2 +- .../__snapshots__/jsfmt.spec.js.snap | 18 ++++ tests/js/comments/html-like/comment.js | 3 + tests/js/comments/html-like/jsfmt.spec.js | 1 + tests/js/decorator-comments/jsfmt.spec.js | 4 +- tests/js/decorators-export/jsfmt.spec.js | 4 +- tests/js/decorators/jsfmt.spec.js | 4 +- tests/js/do/jsfmt.spec.js | 2 +- tests/js/dynamic-import/jsfmt.spec.js | 1 + tests/js/export-default/escaped/jsfmt.spec.js | 2 +- tests/js/export-extension/jsfmt.spec.js | 2 +- tests/js/exports/jsfmt.spec.js | 2 +- tests/js/import-assertions/jsfmt.spec.js | 5 ++ tests/js/literal/jsfmt.spec.js | 2 +- tests/js/logical-assignment/jsfmt.spec.js | 2 +- tests/js/module-string-names/jsfmt.spec.js | 2 +- tests/js/multiparser-invalid/jsfmt.spec.js | 2 +- .../no-semi-babylon-extensions/jsfmt.spec.js | 7 +- .../no-semi/__snapshots__/jsfmt.spec.js.snap | 16 ++-- tests/js/no-semi/class.js | 4 +- tests/js/objects/jsfmt.spec.js | 5 ++ tests/js/partial-application/jsfmt.spec.js | 2 +- tests/js/pipeline-operator/jsfmt.spec.js | 2 +- tests/js/quote-props/jsfmt.spec.js | 4 +- tests/js/record/jsfmt.spec.js | 2 +- tests/js/rest/jsfmt.spec.js | 2 +- tests/js/throw_expressions/jsfmt.spec.js | 2 +- tests/js/top-level-await/jsfmt.spec.js | 4 +- tests/js/trailing-whitespace/jsfmt.spec.js | 2 +- tests/js/tuple/jsfmt.spec.js | 2 +- tests/js/v8_intrinsic/jsfmt.spec.js | 2 +- tests/js/variable_declarator/jsfmt.spec.js | 1 + tests/js/yield/jsfmt.spec.js | 4 +- tests_config/run_spec.js | 17 ++-- tests_config/utils/check-parsers.js | 12 ++- .../__snapshots__/early-exit.js.snap | 7 +- .../__snapshots__/help-options.js.snap | 3 +- .../plugin-options-string.js.snap | 4 +- .../__snapshots__/plugin-options.js.snap | 7 +- .../__tests__/__snapshots__/schema.js.snap | 6 ++ .../__snapshots__/support-info.js.snap | 8 +- website/playground/codeSamples.js | 1 + yarn.lock | 5 ++ 65 files changed, 348 insertions(+), 75 deletions(-) create mode 100644 src/language-js/parser-meriyah.js create mode 100644 tests/js/comments/html-like/__snapshots__/jsfmt.spec.js.snap create mode 100644 tests/js/comments/html-like/comment.js create mode 100644 tests/js/comments/html-like/jsfmt.spec.js diff --git a/changelog_unreleased/javascript/pr-9000.md b/changelog_unreleased/javascript/pr-9000.md index 789d55a96..283afdd1e 100644 --- a/changelog_unreleased/javascript/pr-9000.md +++ b/changelog_unreleased/javascript/pr-9000.md @@ -1,5 +1,9 @@ -#### [HIGHLIGHT]Add `espree` parser (#9000 by @fisker) +#### [HIGHLIGHT]Add `espree` and `meriyah` parser (#9000, #9514 by @fisker) -A new value for the `parser` option has been added: [`espree`](https://github.com/eslint/espree) - which is the default parser used by [`ESLint`](https://github.com/eslint/eslint). +Two new values for the `parser` option has been added: -Note that `espree` only works for [Finished ECMAScript Proposals](https://github.com/tc39/proposals/blob/master/finished-proposals.md), and is stricter than the `babel` parser. +- [`espree`](https://github.com/eslint/espree) - which is the default parser used by [`ESLint`](https://github.com/eslint/eslint). + + Note that `espree` only works for [Finished ECMAScript Proposals](https://github.com/tc39/proposals/blob/master/finished-proposals.md), and is stricter than the `babel` parser. + +- [`meriyah`](https://github.com/meriyah/meriyah) - A [fast](https://meriyah.github.io/meriyah/performance/) JavaScript parser, successor of [cherow](https://github.com/cherow/cherow). diff --git a/cspell.json b/cspell.json index b1b6ce5f9..3bc57e559 100644 --- a/cspell.json +++ b/cspell.json @@ -51,6 +51,7 @@ "camelcase", "camelified", "chedeau", + "cherow", "chrzosel", "Clemmons", "cliify", @@ -212,6 +213,7 @@ "mdast", "Memberish", "memoized", + "meriyah", "Michał", "Microsyntax", "Mikael", @@ -222,6 +224,7 @@ "mixins", "mjml", "mkdir", + "mobx", "Moeller", "Monteiro", "Morrell", @@ -394,6 +397,7 @@ "Vue's", "Wadler", "Wadler's", + "webcompat", "webstorm", "Weixin", "whitespaces", diff --git a/package.json b/package.json index f863d2cf8..0aedffc4f 100644 --- a/package.json +++ b/package.json @@ -59,6 +59,7 @@ "linguist-languages": "7.11.1", "lodash": "4.17.20", "mem": "8.0.0", + "meriyah": "3.1.2", "minimatch": "3.0.4", "minimist": "1.2.5", "n-readlines": "1.0.0", diff --git a/scripts/build/config.js b/scripts/build/config.js index 808bb71e5..5e527e6a4 100644 --- a/scripts/build/config.js +++ b/scripts/build/config.js @@ -45,6 +45,9 @@ const parsers = [ { input: "src/language-js/parser-espree.js", }, + { + input: "src/language-js/parser-meriyah.js", + }, { input: "src/language-js/parser-angular.js", }, diff --git a/src/language-js/clean.js b/src/language-js/clean.js index efacac3aa..45d300feb 100644 --- a/src/language-js/clean.js +++ b/src/language-js/clean.js @@ -68,6 +68,7 @@ function clean(ast, newObj, parent) { ast.type === "MethodDefinition" || ast.type === "ClassProperty" || ast.type === "ClassMethod" || + ast.type === "FieldDefinition" || ast.type === "TSDeclareMethod" || ast.type === "TSPropertySignature" || ast.type === "ObjectTypeProperty") && diff --git a/src/language-js/comments.js b/src/language-js/comments.js index 9190a0592..c33bff504 100644 --- a/src/language-js/comments.js +++ b/src/language-js/comments.js @@ -492,6 +492,7 @@ function handleMethodNameComments(text, enclosingNode, precedingNode, comment) { precedingNode.type === "Decorator" && (enclosingNode.type === "ClassMethod" || enclosingNode.type === "ClassProperty" || + enclosingNode.type === "FieldDefinition" || enclosingNode.type === "TSAbstractClassProperty" || enclosingNode.type === "TSAbstractMethodDefinition" || enclosingNode.type === "TSDeclareMethod" || @@ -934,7 +935,8 @@ function getCommentChildNodes(node, options) { if ( (options.parser === "typescript" || options.parser === "flow" || - options.parser === "espree") && + options.parser === "espree" || + options.parser === "meriyah") && node.type === "MethodDefinition" && node.value && node.value.type === "FunctionExpression" && diff --git a/src/language-js/index.js b/src/language-js/index.js index 00c22e142..f6e9c3c00 100644 --- a/src/language-js/index.js +++ b/src/language-js/index.js @@ -13,6 +13,7 @@ const languages = [ parsers: [ "babel", "espree", + "meriyah", "babel-flow", "babel-ts", "flow", @@ -45,6 +46,7 @@ const languages = [ "flow", "typescript", "espree", + "meriyah", ], vscodeLanguageIds: ["javascriptreact"], })), @@ -151,6 +153,10 @@ const parsers = { get espree() { return require("./parser-espree").parsers.espree; }, + // JS - meriyah + get meriyah() { + return require("./parser-meriyah").parsers.meriyah; + }, }; module.exports = { diff --git a/src/language-js/needs-parens.js b/src/language-js/needs-parens.js index ee53df705..a30c38144 100644 --- a/src/language-js/needs-parens.js +++ b/src/language-js/needs-parens.js @@ -494,7 +494,8 @@ function needsParens(path, options) { return true; } else if ( name === "key" && - parent.type === "ClassProperty" && + (parent.type === "ClassProperty" || + parent.type === "FieldDefinition") && parent.computed ) { return false; @@ -745,6 +746,7 @@ function isStatement(node) { node.type === "ClassDeclaration" || node.type === "ClassMethod" || node.type === "ClassProperty" || + node.type === "FieldDefinition" || node.type === "ClassPrivateProperty" || node.type === "ContinueStatement" || node.type === "DebuggerStatement" || diff --git a/src/language-js/parser-meriyah.js b/src/language-js/parser-meriyah.js new file mode 100644 index 000000000..743eb11fd --- /dev/null +++ b/src/language-js/parser-meriyah.js @@ -0,0 +1,87 @@ +"use strict"; + +const createError = require("../common/parser-create-error"); +const { hasPragma } = require("./pragma"); +const { locStart, locEnd } = require("./loc"); +const postprocess = require("./postprocess"); + +// https://github.com/meriyah/meriyah/blob/4676f60b6c149d7082bde2c9147f9ae2359c8075/src/parser.ts#L185 +const parseOptions = { + // Allow module code + module: true, + // Enable stage 3 support (ESNext) + next: true, + // Enable start and end offsets to each node + ranges: true, + // Enable web compatibility + webcompat: true, + // Enable line/column location information to each node + loc: true, + // Attach raw property to each literal and identifier node + raw: true, + // Enabled directives + directives: true, + // Allow return in the global scope + globalReturn: true, + // Enable implied strict mode + impliedStrict: false, + // Enable non-standard parenthesized expression node + preserveParens: false, + // Enable lexical binding and scope tracking + lexical: false, + // Adds a source attribute in every node’s loc object when the locations option is `true` + // source: '', + // Distinguish Identifier from IdentifierPattern + identifierPattern: false, + // Enable React JSX parsing + jsx: true, + // Allow edge cases that deviate from the spec + specDeviation: true, + // Creates unique key for in ObjectPattern when key value are same + uniqueKeyInPattern: false, +}; + +function parseWithOptions(text, module) { + const { parse } = require("meriyah"); + const comments = []; + const tokens = []; + const ast = parse(text, { + ...parseOptions, + module, + onComment: comments, + onToken: tokens, + }); + ast.comments = comments; + ast.tokens = tokens; + + return ast; +} + +function parse(text, parsers, options) { + let ast; + + try { + ast = parseWithOptions(text /* module */, true); + } catch (moduleError) { + try { + ast = parseWithOptions(text, /* module */ false); + } catch (_) { + // throw the error for `module` parsing + if (typeof moduleError.loc !== "number") { + throw moduleError; + } + + throw createError(moduleError.message, { + start: moduleError.loc, + }); + } + } + + return postprocess(ast, { ...options, originalText: text }); +} + +module.exports = { + parsers: { + meriyah: { parse, astFormat: "estree", hasPragma, locStart, locEnd }, + }, +}; diff --git a/src/language-js/postprocess.js b/src/language-js/postprocess.js index 26f4049cf..3efece636 100644 --- a/src/language-js/postprocess.js +++ b/src/language-js/postprocess.js @@ -21,7 +21,8 @@ function postprocess(ast, options) { if ( options.parser !== "typescript" && options.parser !== "flow" && - options.parser !== "espree" + options.parser !== "espree" && + options.parser !== "meriyah" ) { const startOffsetsOfTypeCastedNodes = new Set(); diff --git a/src/language-js/printer-estree.js b/src/language-js/printer-estree.js index ccead2459..3f0fd9441 100644 --- a/src/language-js/printer-estree.js +++ b/src/language-js/printer-estree.js @@ -146,6 +146,7 @@ function genericPrint(path, options, printPath, args) { node.type === "ClassMethod" || node.type === "ClassPrivateMethod" || node.type === "ClassProperty" || + node.type === "FieldDefinition" || node.type === "TSAbstractClassProperty" || node.type === "ClassPrivateProperty" || node.type === "MethodDefinition" || @@ -458,6 +459,7 @@ function printPathNoParens(path, options, print, args) { parent.type === "AssignmentExpression" || parent.type === "VariableDeclarator" || parent.type === "ClassProperty" || + parent.type === "FieldDefinition" || parent.type === "TSAbstractClassProperty" || parent.type === "ClassPrivateProperty" || parent.type === "ObjectProperty" || @@ -2167,6 +2169,7 @@ function printPathNoParens(path, options, print, args) { "}", ]); case "ClassProperty": + case "FieldDefinition": case "TSAbstractClassProperty": case "ClassPrivateProperty": { if (n.decorators && n.decorators.length !== 0) { @@ -3402,7 +3405,8 @@ function printPathNoParens(path, options, print, args) { } case "PrivateName": - return concat(["#", path.call(print, "id")]); + // babel use `id`, meriyah use `name` + return concat(["#", path.call(print, n.id ? "id" : "name")]); // TODO: Temporary auto-generated node type. To remove when typescript-estree has proper support for private fields. case "TSPrivateIdentifier": @@ -3599,7 +3603,10 @@ function printStatementSequence(path, options, print) { if (!options.semi && isClass) { if (classPropMayCauseASIProblems(stmtPath)) { parts.push(";"); - } else if (stmt.type === "ClassProperty") { + } else if ( + stmt.type === "ClassProperty" || + stmt.type === "FieldDefinition" + ) { const nextChild = bodyNode.body[i + 1]; if (classChildNeedsASIProtection(nextChild)) { parts.push(";"); diff --git a/src/language-js/types/estree.d.ts b/src/language-js/types/estree.d.ts index f017e17e9..793932d95 100644 --- a/src/language-js/types/estree.d.ts +++ b/src/language-js/types/estree.d.ts @@ -14,7 +14,25 @@ type AdditionalFields = { leadingComments?: ReadonlyArray | Comment[]; }; -export type Comment = (ESTree.Comment | Babel.Comment | TSESTree.Comment) & { +type MeriyahComment = { + value: string; + start: number; + end: number; + range: number[]; + type: + | "MultiLine" + | "SingleLine" + | "HashbangComment" + | "HTMLOpen" + | "HTMLClose"; +}; + +export type Comment = ( + | ESTree.Comment + | Babel.Comment + | TSESTree.Comment + | MeriyahComment +) & { printed?: boolean; trailing?: boolean; leading?: boolean; diff --git a/src/language-js/utils.js b/src/language-js/utils.js index 1a8f95b27..098c13813 100644 --- a/src/language-js/utils.js +++ b/src/language-js/utils.js @@ -158,7 +158,12 @@ function getLeftSidePathName(path, node) { * @returns {boolean} */ function isBlockComment(comment) { - return comment.type === "Block" || comment.type === "CommentBlock"; + return ( + comment.type === "Block" || + comment.type === "CommentBlock" || + // `meriyah` + comment.type === "MultiLine" + ); } /** @@ -166,7 +171,15 @@ function isBlockComment(comment) { * @returns {boolean} */ function isLineComment(comment) { - return comment.type === "Line" || comment.type === "CommentLine"; + return ( + comment.type === "Line" || + comment.type === "CommentLine" || + // `meriyah` has `SingleLine`, `HashbangComment`, `HTMLOpen`, and `HTMLClose` + comment.type === "SingleLine" || + comment.type === "HashbangComment" || + comment.type === "HTMLOpen" || + comment.type === "HTMLClose" + ); } const exportDeclarationTypes = new Set([ @@ -712,7 +725,7 @@ function getFlowVariance(node) { function classPropMayCauseASIProblems(path) { const node = path.getNode(); - if (node.type !== "ClassProperty") { + if (node.type !== "ClassProperty" && node.type !== "FieldDefinition") { return false; } @@ -749,6 +762,7 @@ function classChildNeedsASIProtection(node) { } switch (node.type) { case "ClassProperty": + case "FieldDefinition": case "TSAbstractClassProperty": return node.computed; case "MethodDefinition": // Flow @@ -992,7 +1006,9 @@ function isStringPropSafeToUnquote(node, options) { )) || (isSimpleNumber(node.key.value) && String(Number(node.key.value)) === node.key.value && - (options.parser === "babel" || options.parser === "espree"))) + (options.parser === "babel" || + options.parser === "espree" || + options.parser === "meriyah"))) ); } diff --git a/src/main/core-options.js b/src/main/core-options.js index 70e8d8d40..3f3039bd3 100644 --- a/src/main/core-options.js +++ b/src/main/core-options.js @@ -130,6 +130,7 @@ const options = { { value: "babel-ts", since: "2.0.0", description: "TypeScript" }, { value: "typescript", since: "1.4.0", description: "TypeScript" }, { value: "espree", since: "2.2.0", description: "JavaScript" }, + { value: "meriyah", since: "2.2.0", description: "JavaScript" }, { value: "css", since: "1.7.1", description: "CSS" }, { value: "less", since: "1.7.1", description: "Less" }, { value: "scss", since: "1.7.1", description: "SCSS" }, diff --git a/src/main/range-util.js b/src/main/range-util.js index c66b1fed6..344926dd0 100644 --- a/src/main/range-util.js +++ b/src/main/range-util.js @@ -120,6 +120,7 @@ function isSourceElement(opts, node) { case "babel-ts": case "typescript": case "espree": + case "meriyah": return isJsSourceElement(node.type); case "json": return jsonSourceElements.has(node.type); diff --git a/tests/js/arrows-bind/jsfmt.spec.js b/tests/js/arrows-bind/jsfmt.spec.js index 726eaec01..0fab4456d 100644 --- a/tests/js/arrows-bind/jsfmt.spec.js +++ b/tests/js/arrows-bind/jsfmt.spec.js @@ -1 +1 @@ -run_spec(__dirname, ["babel"], { errors: { espree: true } }); +run_spec(__dirname, ["babel"], { errors: { espree: true, meriyah: true } }); diff --git a/tests/js/arrows/newline-before-arrow/jsfmt.spec.js b/tests/js/arrows/newline-before-arrow/jsfmt.spec.js index 29283fa30..4ce5f6e24 100644 --- a/tests/js/arrows/newline-before-arrow/jsfmt.spec.js +++ b/tests/js/arrows/newline-before-arrow/jsfmt.spec.js @@ -1,3 +1,6 @@ run_spec(__dirname, ["babel"], { - errors: { espree: ["newline-before-arrow.js"] }, + errors: { + espree: ["newline-before-arrow.js"], + meriyah: ["newline-before-arrow.js"], + }, }); diff --git a/tests/js/babel-plugins/jsfmt.spec.js b/tests/js/babel-plugins/jsfmt.spec.js index 0e1838e07..0d5680faa 100644 --- a/tests/js/babel-plugins/jsfmt.spec.js +++ b/tests/js/babel-plugins/jsfmt.spec.js @@ -29,5 +29,30 @@ run_spec(__dirname, ["babel", "babel-ts", "babel-flow"], { "module-string-names.js", "class-static-block.js", ], + meriyah: [ + "decimal.js", + "do-expressions.js", + "export-default-from.js", + "flow.js", + "function-bind.js", + "function-sent.js", + "logical-assignment-operators.js", + "module-attributes-dynamic.js", + "module-attributes-static.js", + "partial-application.js", + "pipeline-operator-fsharp.js", + "pipeline-operator-minimal.js", + "pipeline-operator-smart.js", + "record-tuple-record.js", + "record-tuple-tuple.js", + "throw-expressions.js", + "typescript.js", + "v8intrinsic.js", + "optional-chaining.js", + "class-static-block.js", + "import-assertions-dynamic.js", + "import-assertions-static.js", + "module-string-names.js", + ], }, }); diff --git a/tests/js/bind-expressions/jsfmt.spec.js b/tests/js/bind-expressions/jsfmt.spec.js index 18153a1a9..3eb482d30 100644 --- a/tests/js/bind-expressions/jsfmt.spec.js +++ b/tests/js/bind-expressions/jsfmt.spec.js @@ -1,2 +1,5 @@ -run_spec(__dirname, ["babel"], { errors: { espree: true } }); -run_spec(__dirname, ["babel"], { semi: false, errors: { espree: true } }); +run_spec(__dirname, ["babel"], { errors: { espree: true, meriyah: true } }); +run_spec(__dirname, ["babel"], { + semi: false, + errors: { espree: true, meriyah: true }, +}); diff --git a/tests/js/class-static-block/jsfmt.spec.js b/tests/js/class-static-block/jsfmt.spec.js index 726eaec01..0fab4456d 100644 --- a/tests/js/class-static-block/jsfmt.spec.js +++ b/tests/js/class-static-block/jsfmt.spec.js @@ -1 +1 @@ -run_spec(__dirname, ["babel"], { errors: { espree: true } }); +run_spec(__dirname, ["babel"], { errors: { espree: true, meriyah: true } }); diff --git a/tests/js/classes-private-fields/jsfmt.spec.js b/tests/js/classes-private-fields/jsfmt.spec.js index 18153a1a9..4085f7737 100644 --- a/tests/js/classes-private-fields/jsfmt.spec.js +++ b/tests/js/classes-private-fields/jsfmt.spec.js @@ -1,2 +1,7 @@ -run_spec(__dirname, ["babel"], { errors: { espree: true } }); -run_spec(__dirname, ["babel"], { semi: false, errors: { espree: true } }); +run_spec(__dirname, ["babel"], { + errors: { espree: true, meriyah: ["optional-chaining.js"] }, +}); +run_spec(__dirname, ["babel"], { + semi: false, + errors: { espree: true, meriyah: ["optional-chaining.js"] }, +}); diff --git a/tests/js/classes/top-level-super/jsfmt.spec.js b/tests/js/classes/top-level-super/jsfmt.spec.js index 7d3544f4b..93e955c84 100644 --- a/tests/js/classes/top-level-super/jsfmt.spec.js +++ b/tests/js/classes/top-level-super/jsfmt.spec.js @@ -1 +1,3 @@ -run_spec(__dirname, ["babel", "typescript"], { errors: { espree: true } }); +run_spec(__dirname, ["babel", "typescript"], { + errors: { espree: true, meriyah: true }, +}); diff --git a/tests/js/comments-pipeline-own-line/jsfmt.spec.js b/tests/js/comments-pipeline-own-line/jsfmt.spec.js index 726eaec01..0fab4456d 100644 --- a/tests/js/comments-pipeline-own-line/jsfmt.spec.js +++ b/tests/js/comments-pipeline-own-line/jsfmt.spec.js @@ -1 +1 @@ -run_spec(__dirname, ["babel"], { errors: { espree: true } }); +run_spec(__dirname, ["babel"], { errors: { espree: true, meriyah: true } }); diff --git a/tests/js/comments/html-like/__snapshots__/jsfmt.spec.js.snap b/tests/js/comments/html-like/__snapshots__/jsfmt.spec.js.snap new file mode 100644 index 000000000..71586d45c --- /dev/null +++ b/tests/js/comments/html-like/__snapshots__/jsfmt.spec.js.snap @@ -0,0 +1,18 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`comment.js format 1`] = ` +====================================options===================================== +parsers: ["meriyah"] +printWidth: 80 + | printWidth +=====================================input====================================== + +=====================================output===================================== + + +================================================================================ +`; diff --git a/tests/js/comments/html-like/comment.js b/tests/js/comments/html-like/comment.js new file mode 100644 index 000000000..5ef7d5b6c --- /dev/null +++ b/tests/js/comments/html-like/comment.js @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/tests/js/comments/html-like/jsfmt.spec.js b/tests/js/comments/html-like/jsfmt.spec.js new file mode 100644 index 000000000..15a55dd5a --- /dev/null +++ b/tests/js/comments/html-like/jsfmt.spec.js @@ -0,0 +1 @@ +run_spec(__dirname, ["meriyah"]); diff --git a/tests/js/decorator-comments/jsfmt.spec.js b/tests/js/decorator-comments/jsfmt.spec.js index 7d3544f4b..93e955c84 100644 --- a/tests/js/decorator-comments/jsfmt.spec.js +++ b/tests/js/decorator-comments/jsfmt.spec.js @@ -1 +1,3 @@ -run_spec(__dirname, ["babel", "typescript"], { errors: { espree: true } }); +run_spec(__dirname, ["babel", "typescript"], { + errors: { espree: true, meriyah: true }, +}); diff --git a/tests/js/decorators-export/jsfmt.spec.js b/tests/js/decorators-export/jsfmt.spec.js index b7b6d7808..defe51cfd 100644 --- a/tests/js/decorators-export/jsfmt.spec.js +++ b/tests/js/decorators-export/jsfmt.spec.js @@ -1,2 +1,4 @@ // TypeScript and Flow don't accept decorator after export -run_spec(__dirname, ["babel"], { errors: { espree: true } }); +run_spec(__dirname, ["babel"], { + errors: { espree: true, meriyah: ["after_export.js"] }, +}); diff --git a/tests/js/decorators/jsfmt.spec.js b/tests/js/decorators/jsfmt.spec.js index 726eaec01..85e8b037a 100644 --- a/tests/js/decorators/jsfmt.spec.js +++ b/tests/js/decorators/jsfmt.spec.js @@ -1 +1,3 @@ -run_spec(__dirname, ["babel"], { errors: { espree: true } }); +run_spec(__dirname, ["babel"], { + errors: { espree: true, meriyah: ["multiple.js", "mobx.js"] }, +}); diff --git a/tests/js/do/jsfmt.spec.js b/tests/js/do/jsfmt.spec.js index 726eaec01..0fab4456d 100644 --- a/tests/js/do/jsfmt.spec.js +++ b/tests/js/do/jsfmt.spec.js @@ -1 +1 @@ -run_spec(__dirname, ["babel"], { errors: { espree: true } }); +run_spec(__dirname, ["babel"], { errors: { espree: true, meriyah: true } }); diff --git a/tests/js/dynamic-import/jsfmt.spec.js b/tests/js/dynamic-import/jsfmt.spec.js index 0d480115c..4fffde987 100644 --- a/tests/js/dynamic-import/jsfmt.spec.js +++ b/tests/js/dynamic-import/jsfmt.spec.js @@ -3,5 +3,6 @@ run_spec(__dirname, ["babel", "flow", "typescript"], { flow: ["assertions.js"], typescript: ["assertions.js"], espree: ["assertions.js"], + meriyah: ["assertions.js"], }, }); diff --git a/tests/js/export-default/escaped/jsfmt.spec.js b/tests/js/export-default/escaped/jsfmt.spec.js index 302810e99..d60e0b525 100644 --- a/tests/js/export-default/escaped/jsfmt.spec.js +++ b/tests/js/export-default/escaped/jsfmt.spec.js @@ -1,3 +1,3 @@ run_spec(__dirname, ["babel"], { - errors: { espree: true }, + errors: { espree: true, meriyah: true }, }); diff --git a/tests/js/export-extension/jsfmt.spec.js b/tests/js/export-extension/jsfmt.spec.js index 726eaec01..0fab4456d 100644 --- a/tests/js/export-extension/jsfmt.spec.js +++ b/tests/js/export-extension/jsfmt.spec.js @@ -1 +1 @@ -run_spec(__dirname, ["babel"], { errors: { espree: true } }); +run_spec(__dirname, ["babel"], { errors: { espree: true, meriyah: true } }); diff --git a/tests/js/exports/jsfmt.spec.js b/tests/js/exports/jsfmt.spec.js index 726eaec01..0fab4456d 100644 --- a/tests/js/exports/jsfmt.spec.js +++ b/tests/js/exports/jsfmt.spec.js @@ -1 +1 @@ -run_spec(__dirname, ["babel"], { errors: { espree: true } }); +run_spec(__dirname, ["babel"], { errors: { espree: true, meriyah: true } }); diff --git a/tests/js/import-assertions/jsfmt.spec.js b/tests/js/import-assertions/jsfmt.spec.js index c3095e9d8..7599ddea9 100644 --- a/tests/js/import-assertions/jsfmt.spec.js +++ b/tests/js/import-assertions/jsfmt.spec.js @@ -5,5 +5,10 @@ run_spec(__dirname, ["babel"], { "import-assertions-multi-types.js", "import-assertions-static.js", ], + meriyah: [ + "import-assertions-dynamic.js", + "import-assertions-multi-types.js", + "import-assertions-static.js", + ], }, }); diff --git a/tests/js/literal/jsfmt.spec.js b/tests/js/literal/jsfmt.spec.js index 6c46c013d..fc211ea90 100644 --- a/tests/js/literal/jsfmt.spec.js +++ b/tests/js/literal/jsfmt.spec.js @@ -1,4 +1,4 @@ // flow-parser@0.38.0 fails to parse `1.e1`, so use babel here. run_spec(__dirname, ["babel", "typescript"], { - errors: { espree: true, typescript: ["invalid-exponent.js"] }, + errors: { espree: true, meriyah: true, typescript: ["invalid-exponent.js"] }, }); diff --git a/tests/js/logical-assignment/jsfmt.spec.js b/tests/js/logical-assignment/jsfmt.spec.js index 70359a9d2..77c17c6e6 100644 --- a/tests/js/logical-assignment/jsfmt.spec.js +++ b/tests/js/logical-assignment/jsfmt.spec.js @@ -1,3 +1,3 @@ run_spec(__dirname, ["babel", "typescript"], { - errors: { espree: ["invalid.js"] }, + errors: { espree: ["invalid.js"], meriyah: true }, }); diff --git a/tests/js/module-string-names/jsfmt.spec.js b/tests/js/module-string-names/jsfmt.spec.js index 726eaec01..0fab4456d 100644 --- a/tests/js/module-string-names/jsfmt.spec.js +++ b/tests/js/module-string-names/jsfmt.spec.js @@ -1 +1 @@ -run_spec(__dirname, ["babel"], { errors: { espree: true } }); +run_spec(__dirname, ["babel"], { errors: { espree: true, meriyah: true } }); diff --git a/tests/js/multiparser-invalid/jsfmt.spec.js b/tests/js/multiparser-invalid/jsfmt.spec.js index 6e2b8e1a6..06a6e2a3d 100644 --- a/tests/js/multiparser-invalid/jsfmt.spec.js +++ b/tests/js/multiparser-invalid/jsfmt.spec.js @@ -1,3 +1,3 @@ run_spec(__dirname, ["babel", "flow", "typescript"], { - errors: { espree: true, flow: true, typescript: true }, + errors: { espree: true, flow: true, typescript: true, meriyah: true }, }); diff --git a/tests/js/no-semi-babylon-extensions/jsfmt.spec.js b/tests/js/no-semi-babylon-extensions/jsfmt.spec.js index 18153a1a9..3eb482d30 100644 --- a/tests/js/no-semi-babylon-extensions/jsfmt.spec.js +++ b/tests/js/no-semi-babylon-extensions/jsfmt.spec.js @@ -1,2 +1,5 @@ -run_spec(__dirname, ["babel"], { errors: { espree: true } }); -run_spec(__dirname, ["babel"], { semi: false, errors: { espree: true } }); +run_spec(__dirname, ["babel"], { errors: { espree: true, meriyah: true } }); +run_spec(__dirname, ["babel"], { + semi: false, + errors: { espree: true, meriyah: true }, +}); diff --git a/tests/js/no-semi/__snapshots__/jsfmt.spec.js.snap b/tests/js/no-semi/__snapshots__/jsfmt.spec.js.snap index d50c33308..70f4d457d 100644 --- a/tests/js/no-semi/__snapshots__/jsfmt.spec.js.snap +++ b/tests/js/no-semi/__snapshots__/jsfmt.spec.js.snap @@ -36,7 +36,7 @@ class C4 { -class A { +class A1 { a = 0; [b](){} @@ -74,7 +74,7 @@ class A { b = 1; } -class A { +class A2 { a = 0; [b](){} @@ -154,7 +154,7 @@ class C4 { x() {} } -class A { +class A1 { a = 0; [b]() {} @@ -192,7 +192,7 @@ class A { b = 1 } -class A { +class A2 { a = 0; [b]() {} @@ -282,7 +282,7 @@ class C4 { -class A { +class A1 { a = 0; [b](){} @@ -320,7 +320,7 @@ class A { b = 1; } -class A { +class A2 { a = 0; [b](){} @@ -400,7 +400,7 @@ class C4 { x() {} } -class A { +class A1 { a = 0; [b]() {} @@ -438,7 +438,7 @@ class A { b = 1; } -class A { +class A2 { a = 0; [b]() {} diff --git a/tests/js/no-semi/class.js b/tests/js/no-semi/class.js index 1747fe083..586ea4ef6 100644 --- a/tests/js/no-semi/class.js +++ b/tests/js/no-semi/class.js @@ -27,7 +27,7 @@ class C4 { -class A { +class A1 { a = 0; [b](){} @@ -65,7 +65,7 @@ class A { b = 1; } -class A { +class A2 { a = 0; [b](){} diff --git a/tests/js/objects/jsfmt.spec.js b/tests/js/objects/jsfmt.spec.js index 74867c290..432d0d511 100644 --- a/tests/js/objects/jsfmt.spec.js +++ b/tests/js/objects/jsfmt.spec.js @@ -5,5 +5,10 @@ run_spec(__dirname, ["babel"], { "invalid-accessor-generator.js", "invalid-setter.js", ], + meriyah: [ + "expression.js", + "invalid-accessor-generator.js", + "invalid-setter.js", + ], }, }); diff --git a/tests/js/partial-application/jsfmt.spec.js b/tests/js/partial-application/jsfmt.spec.js index 726eaec01..0fab4456d 100644 --- a/tests/js/partial-application/jsfmt.spec.js +++ b/tests/js/partial-application/jsfmt.spec.js @@ -1 +1 @@ -run_spec(__dirname, ["babel"], { errors: { espree: true } }); +run_spec(__dirname, ["babel"], { errors: { espree: true, meriyah: true } }); diff --git a/tests/js/pipeline-operator/jsfmt.spec.js b/tests/js/pipeline-operator/jsfmt.spec.js index 726eaec01..0fab4456d 100644 --- a/tests/js/pipeline-operator/jsfmt.spec.js +++ b/tests/js/pipeline-operator/jsfmt.spec.js @@ -1 +1 @@ -run_spec(__dirname, ["babel"], { errors: { espree: true } }); +run_spec(__dirname, ["babel"], { errors: { espree: true, meriyah: true } }); diff --git a/tests/js/quote-props/jsfmt.spec.js b/tests/js/quote-props/jsfmt.spec.js index cec36fee1..3939c465a 100644 --- a/tests/js/quote-props/jsfmt.spec.js +++ b/tests/js/quote-props/jsfmt.spec.js @@ -1,4 +1,6 @@ -const errors = { espree: ["classes.js"] }; +const errors = { + espree: ["classes.js"], +}; run_spec(__dirname, ["babel"], { quoteProps: "as-needed", diff --git a/tests/js/record/jsfmt.spec.js b/tests/js/record/jsfmt.spec.js index 726eaec01..0fab4456d 100644 --- a/tests/js/record/jsfmt.spec.js +++ b/tests/js/record/jsfmt.spec.js @@ -1 +1 @@ -run_spec(__dirname, ["babel"], { errors: { espree: true } }); +run_spec(__dirname, ["babel"], { errors: { espree: true, meriyah: true } }); diff --git a/tests/js/rest/jsfmt.spec.js b/tests/js/rest/jsfmt.spec.js index 98fb7f5ca..2a762db04 100644 --- a/tests/js/rest/jsfmt.spec.js +++ b/tests/js/rest/jsfmt.spec.js @@ -1,4 +1,4 @@ run_spec(__dirname, ["babel", "flow"], { trailingComma: "all", - errors: { espree: true }, + errors: { espree: true, meriyah: true }, }); diff --git a/tests/js/throw_expressions/jsfmt.spec.js b/tests/js/throw_expressions/jsfmt.spec.js index 726eaec01..0fab4456d 100644 --- a/tests/js/throw_expressions/jsfmt.spec.js +++ b/tests/js/throw_expressions/jsfmt.spec.js @@ -1 +1 @@ -run_spec(__dirname, ["babel"], { errors: { espree: true } }); +run_spec(__dirname, ["babel"], { errors: { espree: true, meriyah: true } }); diff --git a/tests/js/top-level-await/jsfmt.spec.js b/tests/js/top-level-await/jsfmt.spec.js index 7d3544f4b..93e955c84 100644 --- a/tests/js/top-level-await/jsfmt.spec.js +++ b/tests/js/top-level-await/jsfmt.spec.js @@ -1 +1,3 @@ -run_spec(__dirname, ["babel", "typescript"], { errors: { espree: true } }); +run_spec(__dirname, ["babel", "typescript"], { + errors: { espree: true, meriyah: true }, +}); diff --git a/tests/js/trailing-whitespace/jsfmt.spec.js b/tests/js/trailing-whitespace/jsfmt.spec.js index 4e2e79672..5a410ee23 100644 --- a/tests/js/trailing-whitespace/jsfmt.spec.js +++ b/tests/js/trailing-whitespace/jsfmt.spec.js @@ -1,3 +1,3 @@ run_spec(__dirname, ["babel", "flow", "typescript"], { - errors: { espree: true }, + errors: { espree: true, meriyah: true }, }); diff --git a/tests/js/tuple/jsfmt.spec.js b/tests/js/tuple/jsfmt.spec.js index 726eaec01..0fab4456d 100644 --- a/tests/js/tuple/jsfmt.spec.js +++ b/tests/js/tuple/jsfmt.spec.js @@ -1 +1 @@ -run_spec(__dirname, ["babel"], { errors: { espree: true } }); +run_spec(__dirname, ["babel"], { errors: { espree: true, meriyah: true } }); diff --git a/tests/js/v8_intrinsic/jsfmt.spec.js b/tests/js/v8_intrinsic/jsfmt.spec.js index 726eaec01..0fab4456d 100644 --- a/tests/js/v8_intrinsic/jsfmt.spec.js +++ b/tests/js/v8_intrinsic/jsfmt.spec.js @@ -1 +1 @@ -run_spec(__dirname, ["babel"], { errors: { espree: true } }); +run_spec(__dirname, ["babel"], { errors: { espree: true, meriyah: true } }); diff --git a/tests/js/variable_declarator/jsfmt.spec.js b/tests/js/variable_declarator/jsfmt.spec.js index 7ad187763..4bc05ead0 100644 --- a/tests/js/variable_declarator/jsfmt.spec.js +++ b/tests/js/variable_declarator/jsfmt.spec.js @@ -2,5 +2,6 @@ run_spec(__dirname, ["babel", "flow", "typescript"], { errors: { espree: ["invalid-const.js"], flow: ["invalid-const.js"], + meriyah: ["invalid-const.js"], }, }); diff --git a/tests/js/yield/jsfmt.spec.js b/tests/js/yield/jsfmt.spec.js index 858ac91aa..b5e48a428 100644 --- a/tests/js/yield/jsfmt.spec.js +++ b/tests/js/yield/jsfmt.spec.js @@ -1 +1,3 @@ -run_spec(__dirname, ["babel", "typescript"]); +run_spec(__dirname, ["babel", "typescript"], { + errors: { meriyah: ["arrow.js"] }, +}); diff --git a/tests_config/run_spec.js b/tests_config/run_spec.js index 01f596247..d42d96772 100644 --- a/tests_config/run_spec.js +++ b/tests_config/run_spec.js @@ -40,6 +40,7 @@ const unstableTests = new Map( ], ["js/no-semi/comments.js", (options) => options.semi === false], ["flow/no-semi/comments.js", (options) => options.semi === false], + "js/comments/html-like/comment.js", ].map((fixture) => { const [file, isUnstable = () => true] = Array.isArray(fixture) ? fixture @@ -54,6 +55,7 @@ const espreeDisabledTests = new Set( "comments-closure-typecast", ].map((directory) => path.join(__dirname, "../tests/js", directory)) ); +const meriyahDisabledTests = espreeDisabledTests; const isUnstable = (filename, options) => { const testFunction = unstableTests.get(filename); @@ -142,17 +144,18 @@ function runSpec(fixtures, parsers, options) { const [parser] = parsers; const allParsers = [...parsers]; + if (parsers.includes("typescript") && !parsers.includes("babel-ts")) { allParsers.push("babel-ts"); } - if ( - parsers.includes("babel") && - !parsers.includes("espree") && - isTestDirectory(dirname, "js") && - !espreeDisabledTests.has(dirname) - ) { - allParsers.push("espree"); + if (parsers.includes("babel") && isTestDirectory(dirname, "js")) { + if (!parsers.includes("espree") && !espreeDisabledTests.has(dirname)) { + allParsers.push("espree"); + } + if (!parsers.includes("meriyah") && !meriyahDisabledTests.has(dirname)) { + allParsers.push("meriyah"); + } } const stringifiedOptions = stringifyOptionsForTitle(options); diff --git a/tests_config/utils/check-parsers.js b/tests_config/utils/check-parsers.js index b55f2b37c..dfd2b683c 100644 --- a/tests_config/utils/check-parsers.js +++ b/tests_config/utils/check-parsers.js @@ -50,8 +50,16 @@ const categoryParsers = new Map([ [ "js", { - parsers: ["babel"], - verifyParsers: ["babel", "flow", "babel-flow", "typescript", "babel-ts"], + parsers: ["babel", "meriyah", "espree"], + verifyParsers: [ + "babel", + "meriyah", + "espree", + "flow", + "babel-flow", + "typescript", + "babel-ts", + ], extensions: [".js"], }, ], diff --git a/tests_integration/__tests__/__snapshots__/early-exit.js.snap b/tests_integration/__tests__/__snapshots__/early-exit.js.snap index 21fa7cb0a..eb58ce63e 100644 --- a/tests_integration/__tests__/__snapshots__/early-exit.js.snap +++ b/tests_integration/__tests__/__snapshots__/early-exit.js.snap @@ -84,7 +84,7 @@ Format options: Defaults to false. --jsx-single-quote Use single quotes in JSX. Defaults to false. - --parser + --parser Which parser to use. --print-width The line length where Prettier will try wrap. Defaults to 80. @@ -180,7 +180,7 @@ exports[`show warning with --help not-found (typo) (stderr) 1`] = ` `; exports[`show warning with --help not-found (typo) (stdout) 1`] = ` -"--parser +"--parser Which parser to use. @@ -192,6 +192,7 @@ Valid options: babel-ts TypeScript typescript TypeScript espree JavaScript + meriyah JavaScript css CSS less Less scss SCSS @@ -245,7 +246,7 @@ Format options: Defaults to false. --jsx-single-quote Use single quotes in JSX. Defaults to false. - --parser + --parser Which parser to use. --print-width The line length where Prettier will try wrap. Defaults to 80. diff --git a/tests_integration/__tests__/__snapshots__/help-options.js.snap b/tests_integration/__tests__/__snapshots__/help-options.js.snap index a262c6533..0b8f6343b 100644 --- a/tests_integration/__tests__/__snapshots__/help-options.js.snap +++ b/tests_integration/__tests__/__snapshots__/help-options.js.snap @@ -361,7 +361,7 @@ exports[`show detailed usage with --help no-semi (write) 1`] = `Array []`; exports[`show detailed usage with --help parser (stderr) 1`] = `""`; exports[`show detailed usage with --help parser (stdout) 1`] = ` -"--parser +"--parser Which parser to use. @@ -373,6 +373,7 @@ Valid options: babel-ts TypeScript typescript TypeScript espree JavaScript + meriyah JavaScript css CSS less Less scss SCSS diff --git a/tests_integration/__tests__/__snapshots__/plugin-options-string.js.snap b/tests_integration/__tests__/__snapshots__/plugin-options-string.js.snap index d5c3c6014..a26fe7ba3 100644 --- a/tests_integration/__tests__/__snapshots__/plugin-options-string.js.snap +++ b/tests_integration/__tests__/__snapshots__/plugin-options-string.js.snap @@ -20,8 +20,8 @@ exports[` 1`] = ` Defaults to false. --jsx-single-quote Use single quotes in JSX. Defaults to false. -- --parser -+ --parser +- --parser ++ --parser Which parser to use. --print-width The line length where Prettier will try wrap. Defaults to 80. diff --git a/tests_integration/__tests__/__snapshots__/plugin-options.js.snap b/tests_integration/__tests__/__snapshots__/plugin-options.js.snap index 641cdbbb9..37d71257b 100644 --- a/tests_integration/__tests__/__snapshots__/plugin-options.js.snap +++ b/tests_integration/__tests__/__snapshots__/plugin-options.js.snap @@ -20,8 +20,8 @@ exports[` 1`] = ` Defaults to false. --jsx-single-quote Use single quotes in JSX. Defaults to false. -- --parser -+ --parser +- --parser ++ --parser Which parser to use. --print-width The line length where Prettier will try wrap. Defaults to 80. @@ -32,7 +32,7 @@ exports[` 1`] = ` exports[`include plugin's parsers to the values of the \`parser\` option\` (stderr) 1`] = `""`; exports[`include plugin's parsers to the values of the \`parser\` option\` (stdout) 1`] = ` -"--parser +"--parser Which parser to use. @@ -44,6 +44,7 @@ Valid options: babel-ts TypeScript typescript TypeScript espree JavaScript + meriyah JavaScript css CSS less Less scss SCSS diff --git a/tests_integration/__tests__/__snapshots__/schema.js.snap b/tests_integration/__tests__/__snapshots__/schema.js.snap index 74f5bda0b..337ebad5d 100644 --- a/tests_integration/__tests__/__snapshots__/schema.js.snap +++ b/tests_integration/__tests__/__snapshots__/schema.js.snap @@ -168,6 +168,12 @@ This option cannot be used with --range-start and --range-end.", "espree", ], }, + Object { + "description": "JavaScript", + "enum": Array [ + "meriyah", + ], + }, Object { "description": "CSS", "enum": Array [ diff --git a/tests_integration/__tests__/__snapshots__/support-info.js.snap b/tests_integration/__tests__/__snapshots__/support-info.js.snap index e71ffe151..5d9431681 100644 --- a/tests_integration/__tests__/__snapshots__/support-info.js.snap +++ b/tests_integration/__tests__/__snapshots__/support-info.js.snap @@ -38,10 +38,12 @@ Object { "flow", "typescript", "espree", + "meriyah", ], "JavaScript": Array [ "babel", "espree", + "meriyah", "babel-flow", "babel-ts", "flow", @@ -153,6 +155,7 @@ Object { "babel-ts", "typescript", "espree", + "meriyah", "css", "less", "scss", @@ -319,6 +322,7 @@ exports[`CLI --support-info (stdout) 1`] = ` \\"parsers\\": [ \\"babel\\", \\"espree\\", + \\"meriyah\\", \\"babel-flow\\", \\"babel-ts\\", \\"flow\\", @@ -371,7 +375,8 @@ exports[`CLI --support-info (stdout) 1`] = ` \\"babel-ts\\", \\"flow\\", \\"typescript\\", - \\"espree\\" + \\"espree\\", + \\"meriyah\\" ], \\"since\\": \\"0.0.0\\", \\"tmScope\\": \\"source.js.jsx\\", @@ -881,6 +886,7 @@ exports[`CLI --support-info (stdout) 1`] = ` \\"value\\": \\"typescript\\" }, { \\"description\\": \\"JavaScript\\", \\"since\\": \\"2.2.0\\", \\"value\\": \\"espree\\" }, + { \\"description\\": \\"JavaScript\\", \\"since\\": \\"2.2.0\\", \\"value\\": \\"meriyah\\" }, { \\"description\\": \\"CSS\\", \\"since\\": \\"1.7.1\\", \\"value\\": \\"css\\" }, { \\"description\\": \\"Less\\", \\"since\\": \\"1.7.1\\", \\"value\\": \\"less\\" }, { \\"description\\": \\"SCSS\\", \\"since\\": \\"1.7.1\\", \\"value\\": \\"scss\\" }, diff --git a/website/playground/codeSamples.js b/website/playground/codeSamples.js index 0b3e978e4..e5b258633 100644 --- a/website/playground/codeSamples.js +++ b/website/playground/codeSamples.js @@ -2,6 +2,7 @@ export default function (parser) { switch (parser) { case "babel": case "espree": + case "meriyah": return [ 'function HelloWorld({greeting = "hello", greeted = \'"World"\', silent = false, onMouseOver,}) {', "", diff --git a/yarn.lock b/yarn.lock index d4d0e255a..1dd0527d9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5278,6 +5278,11 @@ merge2@^1.3.0: resolved "https://registry.yarnpkg.com/merge2/-/merge2-1.4.1.tgz#4368892f885e907455a6fd7dc55c0c9d404990ae" integrity sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg== +meriyah@3.1.2: + version "3.1.2" + resolved "https://registry.yarnpkg.com/meriyah/-/meriyah-3.1.2.tgz#42aac8a1e05b186f8e08b74b2ee47ea00306b7b9" + integrity sha512-CXPkXT3xdk7KAVdrOV9SDvKUkE8r24aQe4ee/Uj7UJQcoNAS+Bz2QjOpDyrFiLD81GyJ3e5SrKn/125Ow0Ryqg== + micromatch@^3.1.4: version "3.1.10" resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-3.1.10.tgz#70859bc95c9840952f359a068a3fc49f9ecfac23"