From c86b36718b99f4d49615befb96e071060682e231 Mon Sep 17 00:00:00 2001 From: srijan-paul Date: Tue, 18 Jan 2022 16:20:39 +0530 Subject: [PATCH] docs: added ecmafeatures property to parser options --- espree.js | 2 +- lib/espree.js | 10 +++++----- lib/features.js | 10 ++++++++++ lib/options.js | 1 + 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/espree.js b/espree.js index 36e14b51..466678e5 100644 --- a/espree.js +++ b/espree.js @@ -108,7 +108,7 @@ const parsers = { * Tokenizes the given code. * @param {string} code The code to tokenize. * @param {ParserOptions} options Options defining how to tokenize. - * @returns {Token[]} An array of tokens. + * @returns {import("./lib/token-translator.js").EsprimaToken[]} An array of tokens. * @throws {SyntaxError} If the input code is invalid. * @private */ diff --git a/lib/espree.js b/lib/espree.js index 0511ed2b..67d46be3 100644 --- a/lib/espree.js +++ b/lib/espree.js @@ -251,7 +251,7 @@ function extendAcornParser(Parser) { /** * Overwrites the default raise method to throw Esprima-style errors. - * @param {int} pos The position of the error. + * @param {number} pos The position of the error. * @param {string} message The error message. * @throws {SyntaxError} A syntax error. * @returns {void} @@ -268,7 +268,7 @@ function extendAcornParser(Parser) { /** * Overwrites the default raise method to throw Esprima-style errors. - * @param {int} pos The position of the error. + * @param {number} pos The position of the error. * @param {string} message The error message. * @throws {SyntaxError} A syntax error. * @returns {void} @@ -279,7 +279,7 @@ function extendAcornParser(Parser) { /** * Overwrites the default unexpected method to throw Esprima-style errors. - * @param {int} pos The position of the error. + * @param {number} pos The position of the error. * @throws {SyntaxError} A syntax error. * @returns {void} */ @@ -324,8 +324,8 @@ function extendAcornParser(Parser) { /** * Performs last-minute Esprima-specific compatibility checks and fixes. - * @param {ASTNode} result The node to check. - * @returns {ASTNode} The finished node. + * @param {acorn.Node} result The node to check. + * @returns {acorn.Node} The finished node. */ [ESPRIMA_FINISH_NODE](result) { diff --git a/lib/features.js b/lib/features.js index 31467d28..f22719c6 100644 --- a/lib/features.js +++ b/lib/features.js @@ -14,6 +14,16 @@ // Public //------------------------------------------------------------------------------ +/** + * @typedef {Object} EcmaFeatures + * @property {boolean} jsx + * @property {boolean} globalReturn + * @property {boolean} impliedStrict + */ + +/** + * @type {EcmaFeatures} + */ export default { // React JSX parsing diff --git a/lib/options.js b/lib/options.js index 399bc00e..c881b7d1 100644 --- a/lib/options.js +++ b/lib/options.js @@ -90,6 +90,7 @@ function normalizeSourceType(sourceType = "script") { * @property {number|"latest"} ecmaVersion The ECMAScript version to use (between 3 and 13, or 2015 and 2022, or "latest"). * @property {boolean} allowReserved Only allowed when `ecmaVersion` is set to 3. * @property {"script"|"module"|"commonjs"} sourceType The kind of the source string being parsed. + * @property {import("./features").EcmaFeatures} ecmaFeatures The additional features to enable. */ /**