Add meriyah parser (#9514)

This commit is contained in:
fisker Cheung authored and GitHub committed 2020-11-05 14:08:37 +08:00
1 parent d58407668c
commit 3d7016e2dc
65 files changed
+348 -75

No files matched your search

+7 -3
View File
@@ -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).
+4
View File
@@ -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",
+1
View File
@@ -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",
+3
View File
@@ -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",
},
+1
View File
@@ -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") &&
+3 -1
View File
@@ -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" &&
+6
View File
@@ -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 = {
+3 -1
View File
@@ -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" ||
+87
View File
@@ -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 },
},
};
+2 -1
View File
@@ -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();
+9 -2
View File
@@ -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(";");
+19 -1
View File
@@ -14,7 +14,25 @@ type AdditionalFields = {
leadingComments?: ReadonlyArray<Comment> | 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;
+20 -4
View File
@@ -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")))
);
}
+1
View File
@@ -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" },
+1
View File
@@ -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);
+1 -1
View File
@@ -1 +1 @@
run_spec(__dirname, ["babel"], { errors: { espree: true } });
run_spec(__dirname, ["babel"], { errors: { espree: true, meriyah: true } });
@@ -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"],
},
});
+25
View File
@@ -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",
],
},
});
+5 -2
View File
@@ -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 },
});
+1 -1
View File
@@ -1 +1 @@
run_spec(__dirname, ["babel"], { errors: { espree: true } });
run_spec(__dirname, ["babel"], { errors: { espree: true, meriyah: true } });
@@ -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"] },
});
@@ -1 +1,3 @@
run_spec(__dirname, ["babel", "typescript"], { errors: { espree: true } });
run_spec(__dirname, ["babel", "typescript"], {
errors: { espree: true, meriyah: true },
});
@@ -1 +1 @@
run_spec(__dirname, ["babel"], { errors: { espree: true } });
run_spec(__dirname, ["babel"], { errors: { espree: true, meriyah: true } });
@@ -0,0 +1,18 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`comment.js format 1`] = `
====================================options=====================================
parsers: ["meriyah"]
printWidth: 80
| printWidth
=====================================input======================================
<!--
alert(1)
-->
=====================================output=====================================
<!--
alert(1);
-->
================================================================================
`;
+3
View File
@@ -0,0 +1,3 @@
<!--
alert(1)
-->
@@ -0,0 +1 @@
run_spec(__dirname, ["meriyah"]);
+3 -1
View File
@@ -1 +1,3 @@
run_spec(__dirname, ["babel", "typescript"], { errors: { espree: true } });
run_spec(__dirname, ["babel", "typescript"], {
errors: { espree: true, meriyah: true },
});
+3 -1
View File
@@ -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"] },
});
+3 -1
View File
@@ -1 +1,3 @@
run_spec(__dirname, ["babel"], { errors: { espree: true } });
run_spec(__dirname, ["babel"], {
errors: { espree: true, meriyah: ["multiple.js", "mobx.js"] },
});
+1 -1
View File
@@ -1 +1 @@
run_spec(__dirname, ["babel"], { errors: { espree: true } });
run_spec(__dirname, ["babel"], { errors: { espree: true, meriyah: true } });
+1
View File
@@ -3,5 +3,6 @@ run_spec(__dirname, ["babel", "flow", "typescript"], {
flow: ["assertions.js"],
typescript: ["assertions.js"],
espree: ["assertions.js"],
meriyah: ["assertions.js"],
},
});
@@ -1,3 +1,3 @@
run_spec(__dirname, ["babel"], {
errors: { espree: true },
errors: { espree: true, meriyah: true },
});
+1 -1
View File
@@ -1 +1 @@
run_spec(__dirname, ["babel"], { errors: { espree: true } });
run_spec(__dirname, ["babel"], { errors: { espree: true, meriyah: true } });
+1 -1
View File
@@ -1 +1 @@
run_spec(__dirname, ["babel"], { errors: { espree: true } });
run_spec(__dirname, ["babel"], { errors: { espree: true, meriyah: true } });
+5
View File
@@ -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",
],
},
});
+1 -1
View File
@@ -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"] },
});
+1 -1
View File
@@ -1,3 +1,3 @@
run_spec(__dirname, ["babel", "typescript"], {
errors: { espree: ["invalid.js"] },
errors: { espree: ["invalid.js"], meriyah: true },
});
+1 -1
View File
@@ -1 +1 @@
run_spec(__dirname, ["babel"], { errors: { espree: true } });
run_spec(__dirname, ["babel"], { errors: { espree: true, meriyah: true } });
+1 -1
View File
@@ -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 },
});
@@ -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 },
});
@@ -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]() {}
+2 -2
View File
@@ -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](){}
+5
View File
@@ -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",
],
},
});
+1 -1
View File
@@ -1 +1 @@
run_spec(__dirname, ["babel"], { errors: { espree: true } });
run_spec(__dirname, ["babel"], { errors: { espree: true, meriyah: true } });
+1 -1
View File
@@ -1 +1 @@
run_spec(__dirname, ["babel"], { errors: { espree: true } });
run_spec(__dirname, ["babel"], { errors: { espree: true, meriyah: true } });
+3 -1
View File
@@ -1,4 +1,6 @@
const errors = { espree: ["classes.js"] };
const errors = {
espree: ["classes.js"],
};
run_spec(__dirname, ["babel"], {
quoteProps: "as-needed",
+1 -1
View File
@@ -1 +1 @@
run_spec(__dirname, ["babel"], { errors: { espree: true } });
run_spec(__dirname, ["babel"], { errors: { espree: true, meriyah: true } });
+1 -1
View File
@@ -1,4 +1,4 @@
run_spec(__dirname, ["babel", "flow"], {
trailingComma: "all",
errors: { espree: true },
errors: { espree: true, meriyah: true },
});
+1 -1
View File
@@ -1 +1 @@
run_spec(__dirname, ["babel"], { errors: { espree: true } });
run_spec(__dirname, ["babel"], { errors: { espree: true, meriyah: true } });
+3 -1
View File
@@ -1 +1,3 @@
run_spec(__dirname, ["babel", "typescript"], { errors: { espree: true } });
run_spec(__dirname, ["babel", "typescript"], {
errors: { espree: true, meriyah: true },
});
+1 -1
View File
@@ -1,3 +1,3 @@
run_spec(__dirname, ["babel", "flow", "typescript"], {
errors: { espree: true },
errors: { espree: true, meriyah: true },
});
+1 -1
View File
@@ -1 +1 @@
run_spec(__dirname, ["babel"], { errors: { espree: true } });
run_spec(__dirname, ["babel"], { errors: { espree: true, meriyah: true } });
+1 -1
View File
@@ -1 +1 @@
run_spec(__dirname, ["babel"], { errors: { espree: true } });
run_spec(__dirname, ["babel"], { errors: { espree: true, meriyah: true } });
@@ -2,5 +2,6 @@ run_spec(__dirname, ["babel", "flow", "typescript"], {
errors: {
espree: ["invalid-const.js"],
flow: ["invalid-const.js"],
meriyah: ["invalid-const.js"],
},
});
+3 -1
View File
@@ -1 +1,3 @@
run_spec(__dirname, ["babel", "typescript"]);
run_spec(__dirname, ["babel", "typescript"], {
errors: { meriyah: ["arrow.js"] },
});
+10 -7
View File
@@ -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);
+10 -2
View File
@@ -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"],
},
],
@@ -84,7 +84,7 @@ Format options:
Defaults to false.
--jsx-single-quote Use single quotes in JSX.
Defaults to false.
--parser <flow|babel|babel-flow|babel-ts|typescript|espree|css|less|scss|json|json5|json-stringify|graphql|markdown|mdx|vue|yaml|html|angular|lwc>
--parser <flow|babel|babel-flow|babel-ts|typescript|espree|meriyah|css|less|scss|json|json5|json-stringify|graphql|markdown|mdx|vue|yaml|html|angular|lwc>
Which parser to use.
--print-width <int> 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 <flow|babel|babel-flow|babel-ts|typescript|espree|css|less|scss|json|json5|json-stringify|graphql|markdown|mdx|vue|yaml|html|angular|lwc>
"--parser <flow|babel|babel-flow|babel-ts|typescript|espree|meriyah|css|less|scss|json|json5|json-stringify|graphql|markdown|mdx|vue|yaml|html|angular|lwc>
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 <flow|babel|babel-flow|babel-ts|typescript|espree|css|less|scss|json|json5|json-stringify|graphql|markdown|mdx|vue|yaml|html|angular|lwc>
--parser <flow|babel|babel-flow|babel-ts|typescript|espree|meriyah|css|less|scss|json|json5|json-stringify|graphql|markdown|mdx|vue|yaml|html|angular|lwc>
Which parser to use.
--print-width <int> The line length where Prettier will try wrap.
Defaults to 80.
@@ -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 <flow|babel|babel-flow|babel-ts|typescript|espree|css|less|scss|json|json5|json-stringify|graphql|markdown|mdx|vue|yaml|html|angular|lwc>
"--parser <flow|babel|babel-flow|babel-ts|typescript|espree|meriyah|css|less|scss|json|json5|json-stringify|graphql|markdown|mdx|vue|yaml|html|angular|lwc>
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
@@ -20,8 +20,8 @@ exports[` 1`] = `
Defaults to false.
--jsx-single-quote Use single quotes in JSX.
Defaults to false.
- --parser <flow|babel|babel-flow|babel-ts|typescript|espree|css|less|scss|json|json5|json-stringify|graphql|markdown|mdx|vue|yaml|html|angular|lwc>
+ --parser <flow|babel|babel-flow|babel-ts|typescript|espree|css|less|scss|json|json5|json-stringify|graphql|markdown|mdx|vue|yaml|html|angular|lwc|foo-parser>
- --parser <flow|babel|babel-flow|babel-ts|typescript|espree|meriyah|css|less|scss|json|json5|json-stringify|graphql|markdown|mdx|vue|yaml|html|angular|lwc>
+ --parser <flow|babel|babel-flow|babel-ts|typescript|espree|meriyah|css|less|scss|json|json5|json-stringify|graphql|markdown|mdx|vue|yaml|html|angular|lwc|foo-parser>
Which parser to use.
--print-width <int> The line length where Prettier will try wrap.
Defaults to 80.
@@ -20,8 +20,8 @@ exports[` 1`] = `
Defaults to false.
--jsx-single-quote Use single quotes in JSX.
Defaults to false.
- --parser <flow|babel|babel-flow|babel-ts|typescript|espree|css|less|scss|json|json5|json-stringify|graphql|markdown|mdx|vue|yaml|html|angular|lwc>
+ --parser <flow|babel|babel-flow|babel-ts|typescript|espree|css|less|scss|json|json5|json-stringify|graphql|markdown|mdx|vue|yaml|html|angular|lwc|foo-parser>
- --parser <flow|babel|babel-flow|babel-ts|typescript|espree|meriyah|css|less|scss|json|json5|json-stringify|graphql|markdown|mdx|vue|yaml|html|angular|lwc>
+ --parser <flow|babel|babel-flow|babel-ts|typescript|espree|meriyah|css|less|scss|json|json5|json-stringify|graphql|markdown|mdx|vue|yaml|html|angular|lwc|foo-parser>
Which parser to use.
--print-width <int> 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 <flow|babel|babel-flow|babel-ts|typescript|espree|css|less|scss|json|json5|json-stringify|graphql|markdown|mdx|vue|yaml|html|angular|lwc|foo-parser>
"--parser <flow|babel|babel-flow|babel-ts|typescript|espree|meriyah|css|less|scss|json|json5|json-stringify|graphql|markdown|mdx|vue|yaml|html|angular|lwc|foo-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
@@ -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 [
@@ -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\\" },
+1
View File
@@ -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,}) {',
"",
+5
View File
@@ -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"