diff --git a/dist/espree.cjs b/dist/espree.cjs new file mode 100644 index 00000000..437d7bf4 --- /dev/null +++ b/dist/espree.cjs @@ -0,0 +1,1237 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { value: true }); + +var acorn = require('acorn'); +var jsx = require('acorn-jsx'); +var visitorKeys = require('eslint-visitor-keys'); + +function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } + +function _interopNamespace(e) { + if (e && e.__esModule) return e; + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(function (k) { + if (k !== 'default') { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + } + n["default"] = e; + return Object.freeze(n); +} + +var acorn__namespace = /*#__PURE__*/_interopNamespace(acorn); +var jsx__default = /*#__PURE__*/_interopDefaultLegacy(jsx); +var visitorKeys__namespace = /*#__PURE__*/_interopNamespace(visitorKeys); + +/** + * @fileoverview Translates tokens between Acorn format and Esprima format. + * @author Nicholas C. Zakas + */ +/* eslint no-underscore-dangle: 0 */ + +// ---------------------------------------------------------------------------- +// Local type imports +// ---------------------------------------------------------------------------- +/** + * @local + * @typedef {import('acorn')} acorn + * @typedef {import('../lib/espree').EnhancedTokTypes} EnhancedTokTypes + */ + +// ---------------------------------------------------------------------------- +// Local types +// ---------------------------------------------------------------------------- +/** + * Based on the `acorn.Token` class, but without a fixed `type` (since we need + * it to be a string). Avoiding `type` lets us make one extending interface + * more strict and another more lax. + * + * We could make `value` more strict to `string` even though the original is + * `any`. + * + * `start` and `end` are required in `acorn.Token` + * + * `loc` and `range` are from `acorn.Token` + * + * Adds `regex`. + */ +/** + * @local + * + * @typedef {{ + * value: any; + * start?: number; + * end?: number; + * loc?: acorn.SourceLocation; + * range?: [number, number]; + * regex?: {flags: string, pattern: string}; + * }} BaseEsprimaToken + * + * @typedef {{ + * type: string; + * } & BaseEsprimaToken} EsprimaToken + * + * @typedef {{ + * type: string | acorn.TokenType; + * } & BaseEsprimaToken} EsprimaTokenFlexible + * + * @typedef {{ + * jsxAttrValueToken: boolean; + * ecmaVersion: acorn.ecmaVersion; + * }} ExtraNoTokens + * + * @typedef {{ + * tokens: EsprimaTokenFlexible[] + * } & ExtraNoTokens} Extra + */ + +//------------------------------------------------------------------------------ +// Requirements +//------------------------------------------------------------------------------ + +// none! + +//------------------------------------------------------------------------------ +// Private +//------------------------------------------------------------------------------ + + +// Esprima Token Types +const Token = { + Boolean: "Boolean", + EOF: "", + Identifier: "Identifier", + PrivateIdentifier: "PrivateIdentifier", + Keyword: "Keyword", + Null: "Null", + Numeric: "Numeric", + Punctuator: "Punctuator", + String: "String", + RegularExpression: "RegularExpression", + Template: "Template", + JSXIdentifier: "JSXIdentifier", + JSXText: "JSXText" +}; + +/** + * Converts part of a template into an Esprima token. + * @param {(acorn.Token)[]} tokens The Acorn tokens representing the template. + * @param {string} code The source code. + * @returns {EsprimaToken} The Esprima equivalent of the template token. + * @private + */ +function convertTemplatePart(tokens, code) { + const firstToken = tokens[0], + lastTemplateToken = tokens[tokens.length - 1]; + + /** @type {EsprimaToken} */ + const token = { + type: Token.Template, + value: code.slice(firstToken.start, lastTemplateToken.end) + }; + + if (firstToken.loc && lastTemplateToken.loc) { + token.loc = { + start: firstToken.loc.start, + end: lastTemplateToken.loc.end + }; + } + + if (firstToken.range && lastTemplateToken.range) { + token.start = firstToken.range[0]; + token.end = lastTemplateToken.range[1]; + token.range = [token.start, token.end]; + } + + return token; +} + +class TokenTranslator { + + /** + * Contains logic to translate Acorn tokens into Esprima tokens. + * @param {EnhancedTokTypes} acornTokTypes The Acorn token types. + * @param {string} code The source code Acorn is parsing. This is necessary + * to correct the "value" property of some tokens. + */ + constructor(acornTokTypes, code) { + + // token types + this._acornTokTypes = acornTokTypes; + + // token buffer for templates + /** @type {(acorn.Token)[]} */ + this._tokens = []; + + // track the last curly brace + this._curlyBrace = null; + + // the source code + this._code = code; + + } + + /** + * Translates a single Esprima token to a single Acorn token. This may be + * inaccurate due to how templates are handled differently in Esprima and + * Acorn, but should be accurate for all other tokens. + * @param {acorn.Token} token The Acorn token to translate. + * @param {ExtraNoTokens} extra Espree extra object. + * @returns {EsprimaToken} The Esprima version of the token. + */ + translate(token, extra) { + + const type = token.type, + tt = this._acornTokTypes, + + // We use an unknown type because `acorn.Token` is a class whose + // `type` property we cannot override to our desired `string`; + // this also allows us to define a stricter `EsprimaToken` with + // a string-only `type` property + unknownType = /** @type {unknown} */ (token), + newToken = /** @type {EsprimaToken} */ (unknownType); + + if (type === tt.name) { + newToken.type = Token.Identifier; + + // TODO: See if this is an Acorn bug + if (token.value === "static") { + newToken.type = Token.Keyword; + } + + if (extra.ecmaVersion > 5 && (token.value === "yield" || token.value === "let")) { + newToken.type = Token.Keyword; + } + + } else if (type === tt.privateId) { + newToken.type = Token.PrivateIdentifier; + + } else if (type === tt.semi || type === tt.comma || + type === tt.parenL || type === tt.parenR || + type === tt.braceL || type === tt.braceR || + type === tt.dot || type === tt.bracketL || + type === tt.colon || type === tt.question || + type === tt.bracketR || type === tt.ellipsis || + type === tt.arrow || type === tt.jsxTagStart || + type === tt.incDec || type === tt.starstar || + type === tt.jsxTagEnd || type === tt.prefix || + type === tt.questionDot || + (type.binop && !type.keyword) || + type.isAssign) { + + newToken.type = Token.Punctuator; + newToken.value = this._code.slice(token.start, token.end); + } else if (type === tt.jsxName) { + newToken.type = Token.JSXIdentifier; + } else if (type.label === "jsxText" || type === tt.jsxAttrValueToken) { + newToken.type = Token.JSXText; + } else if (type.keyword) { + if (type.keyword === "true" || type.keyword === "false") { + newToken.type = Token.Boolean; + } else if (type.keyword === "null") { + newToken.type = Token.Null; + } else { + newToken.type = Token.Keyword; + } + } else if (type === tt.num) { + newToken.type = Token.Numeric; + newToken.value = this._code.slice(token.start, token.end); + } else if (type === tt.string) { + + if (extra.jsxAttrValueToken) { + extra.jsxAttrValueToken = false; + newToken.type = Token.JSXText; + } else { + newToken.type = Token.String; + } + + newToken.value = this._code.slice(token.start, token.end); + } else if (type === tt.regexp) { + newToken.type = Token.RegularExpression; + const value = token.value; + + newToken.regex = { + flags: value.flags, + pattern: value.pattern + }; + newToken.value = `/${value.pattern}/${value.flags}`; + } + + return newToken; + } + + /** + * Function to call during Acorn's onToken handler. + * @param {acorn.Token} token The Acorn token. + * @param {Extra} extra The Espree extra object. + * @returns {void} + */ + onToken(token, extra) { + + const that = this, + tt = this._acornTokTypes, + tokens = extra.tokens, + templateTokens = this._tokens; + + /** + * Flushes the buffered template tokens and resets the template + * tracking. + * @returns {void} + * @private + */ + function translateTemplateTokens() { + tokens.push(convertTemplatePart(that._tokens, that._code)); + that._tokens = []; + } + + if (token.type === tt.eof) { + + // might be one last curlyBrace + if (this._curlyBrace) { + tokens.push(this.translate(this._curlyBrace, extra)); + } + + return; + } + + if (token.type === tt.backQuote) { + + // if there's already a curly, it's not part of the template + if (this._curlyBrace) { + tokens.push(this.translate(this._curlyBrace, extra)); + this._curlyBrace = null; + } + + templateTokens.push(token); + + // it's the end + if (templateTokens.length > 1) { + translateTemplateTokens(); + } + + return; + } + if (token.type === tt.dollarBraceL) { + templateTokens.push(token); + translateTemplateTokens(); + return; + } + if (token.type === tt.braceR) { + + // if there's already a curly, it's not part of the template + if (this._curlyBrace) { + tokens.push(this.translate(this._curlyBrace, extra)); + } + + // store new curly for later + this._curlyBrace = token; + return; + } + if (token.type === tt.template || token.type === tt.invalidTemplate) { + if (this._curlyBrace) { + templateTokens.push(this._curlyBrace); + this._curlyBrace = null; + } + + templateTokens.push(token); + return; + } + + if (this._curlyBrace) { + tokens.push(this.translate(this._curlyBrace, extra)); + this._curlyBrace = null; + } + + tokens.push(this.translate(token, extra)); + } +} + +/** + * @fileoverview A collection of methods for processing Espree's options. + * @author Kai Cataldo + */ + +// ---------------------------------------------------------------------------- +// Local type imports +// ---------------------------------------------------------------------------- +/** + * @local + * @typedef {import('../espree').ParserOptions} ParserOptions + */ + +// ---------------------------------------------------------------------------- +// Local types +// ---------------------------------------------------------------------------- +/** + * @local + * @typedef {{ + * ecmaVersion: 10 | 9 | 8 | 7 | 6 | 5 | 3 | 11 | 12 | 13 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020 | 2021 | 2022 | "latest", + * sourceType: "script"|"module", + * range?: boolean, + * loc?: boolean, + * allowReserved: boolean | "never", + * ecmaFeatures?: { + * jsx?: boolean, + * globalReturn?: boolean, + * impliedStrict?: boolean + * }, + * ranges: boolean, + * locations: boolean, + * allowReturnOutsideFunction: boolean, + * tokens?: boolean | null, + * comment?: boolean + * }} NormalizedParserOptions + */ + +//------------------------------------------------------------------------------ +// Helpers +//------------------------------------------------------------------------------ + +const SUPPORTED_VERSIONS = [ + 3, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13 +]; + +/** + * Get the latest ECMAScript version supported by Espree. + * @returns {number} The latest ECMAScript version. + */ +function getLatestEcmaVersion() { + return SUPPORTED_VERSIONS[SUPPORTED_VERSIONS.length - 1]; +} + +/** + * Get the list of ECMAScript versions supported by Espree. + * @returns {number[]} An array containing the supported ECMAScript versions. + */ +function getSupportedEcmaVersions() { + return [...SUPPORTED_VERSIONS]; +} + +/** + * Normalize ECMAScript version from the initial config + * @param {number|"latest"} ecmaVersion ECMAScript version from the initial config + * @throws {Error} throws an error if the ecmaVersion is invalid. + * @returns {number} normalized ECMAScript version + */ +function normalizeEcmaVersion(ecmaVersion = 5) { + + let version = ecmaVersion === "latest" ? getLatestEcmaVersion() : ecmaVersion; + + if (typeof version !== "number") { + throw new Error(`ecmaVersion must be a number or "latest". Received value of type ${typeof ecmaVersion} instead.`); + } + + // Calculate ECMAScript edition number from official year version starting with + // ES2015, which corresponds with ES6 (or a difference of 2009). + if (version >= 2015) { + version -= 2009; + } + + if (!SUPPORTED_VERSIONS.includes(version)) { + throw new Error("Invalid ecmaVersion."); + } + + return version; +} + +/** + * Normalize sourceType from the initial config + * @param {"script"|"module"|"commonjs"} sourceType to normalize + * @throws {Error} throw an error if sourceType is invalid + * @returns {"script"|"module"} normalized sourceType + */ +function normalizeSourceType(sourceType = "script") { + if (sourceType === "script" || sourceType === "module") { + return sourceType; + } + + if (sourceType === "commonjs") { + return "script"; + } + + throw new Error("Invalid sourceType."); +} + +/** + * Normalize parserOptions + * @param {ParserOptions} options the parser options to normalize + * @throws {Error} throw an error if found invalid option. + * @returns {NormalizedParserOptions} normalized options + */ +function normalizeOptions(options) { + const ecmaVersion = normalizeEcmaVersion(options.ecmaVersion); + + /** @type {"script"|"module"} */ + const sourceType = normalizeSourceType(options.sourceType); + const ranges = options.range === true; + const locations = options.loc === true; + + if (ecmaVersion !== 3 && options.allowReserved) { + + // a value of `false` is intentionally allowed here, so a shared config can overwrite it when needed + throw new Error("`allowReserved` is only supported when ecmaVersion is 3"); + } + + // Note: value in Acorn can also be "never" but we throw in such a case + if (typeof options.allowReserved !== "undefined" && typeof options.allowReserved !== "boolean") { + throw new Error("`allowReserved`, when present, must be `true` or `false`"); + } + const allowReserved = ecmaVersion === 3 ? (options.allowReserved || "never") : false; + const ecmaFeatures = options.ecmaFeatures || {}; + const allowReturnOutsideFunction = options.sourceType === "commonjs" || + Boolean(ecmaFeatures.globalReturn); + + if (sourceType === "module" && ecmaVersion < 6) { + throw new Error("sourceType 'module' is not supported when ecmaVersion < 2015. Consider adding `{ ecmaVersion: 2015 }` to the parser options."); + } + + return Object.assign({}, options, { + ecmaVersion, + sourceType, + ranges, + locations, + allowReserved, + allowReturnOutsideFunction + }); +} + +/* eslint-disable no-param-reassign*/ + +const STATE = Symbol("espree's internal state"); +const ESPRIMA_FINISH_NODE = Symbol("espree's esprimaFinishNode"); + +// ---------------------------------------------------------------------------- +// Types exported from file +// ---------------------------------------------------------------------------- +/** + * @typedef {{ + * index?: number; + * lineNumber?: number; + * column?: number; + * } & SyntaxError} EnhancedSyntaxError + */ + +// We add `jsxAttrValueToken` ourselves. +/** + * @typedef {{ + * jsxAttrValueToken?: acorn.TokenType; + * } & tokTypesType} EnhancedTokTypes + */ + +// ---------------------------------------------------------------------------- +// Local type imports +// ---------------------------------------------------------------------------- +/** + * @local + * @typedef {import('acorn')} acorn + * @typedef {typeof import('acorn-jsx').tokTypes} tokTypesType + * @typedef {typeof import('acorn-jsx').AcornJsxParser} AcornJsxParser + * @typedef {import('../espree').ParserOptions} ParserOptions + */ + +// ---------------------------------------------------------------------------- +// Local types +// ---------------------------------------------------------------------------- +/** + * @local + * + * @typedef {acorn.ecmaVersion} ecmaVersion + * + * @typedef {{ + * generator?: boolean + * } & acorn.Node} EsprimaNode + */ +/** + * Suggests an integer + * @local + * @typedef {number} int + */ + +/** + * First three properties as in `acorn.Comment`; next two as in `acorn.Comment` + * but optional. Last is different as has to allow `undefined` + */ +/** + * @local + * + * @typedef {{ + * type: string, + * value: string, + * range?: [number, number], + * start?: number, + * end?: number, + * loc?: { + * start: acorn.Position | undefined, + * end: acorn.Position | undefined + * } + * }} EsprimaComment + * + * @typedef {{ + * comments?: EsprimaComment[] + * } & acorn.Token[]} EspreeTokens + * + * @typedef {{ + * tail?: boolean + * } & acorn.Node} AcornTemplateNode + * + * @typedef {{ + * originalSourceType: "script"|"module"|"commonjs"; + * ecmaVersion: ecmaVersion; + * comments: EsprimaComment[]|null; + * impliedStrict: boolean; + * lastToken: acorn.Token|null; + * templateElements: (AcornTemplateNode)[]; + * jsxAttrValueToken: boolean; + * }} BaseStateObject + * + * @typedef {{ + * tokens: null; + * } & BaseStateObject} StateObject + * + * @typedef {{ + * tokens: EspreeTokens; + * } & BaseStateObject} StateObjectWithTokens + * + * @typedef {{ + * sourceType?: "script"|"module"|"commonjs"; + * comments?: EsprimaComment[]; + * tokens?: acorn.Token[]; + * body: acorn.Node[]; + * } & acorn.Node} EsprimaProgramNode + */ +/** + * Converts an Acorn comment to an Esprima comment. + * + * - block True if it's a block comment, false if not. + * - text The text of the comment. + * - start The index at which the comment starts. + * - end The index at which the comment ends. + * - startLoc The location at which the comment starts. + * - endLoc The location at which the comment ends. + * @local + * @typedef {( + * block: boolean, + * text: string, + * start: int, + * end: int, + * startLoc: acorn.Position | undefined, + * endLoc: acorn.Position | undefined + * ) => EsprimaComment | void} AcornToEsprimaCommentConverter + */ + +// ---------------------------------------------------------------------------- +// Utilities +// ---------------------------------------------------------------------------- +/** + * Converts an Acorn comment to an Esprima comment. + * @type {AcornToEsprimaCommentConverter} + * @returns {EsprimaComment} The comment object. + * @private + */ +function convertAcornCommentToEsprimaComment(block, text, start, end, startLoc, endLoc) { + const comment = /** @type {EsprimaComment} */ ({ + type: block ? "Block" : "Line", + value: text + }); + + if (typeof start === "number") { + comment.start = start; + comment.end = end; + comment.range = [start, end]; + } + + if (typeof startLoc === "object") { + comment.loc = { + start: startLoc, + end: endLoc + }; + } + + return comment; +} + +// ---------------------------------------------------------------------------- +// Exports +// ---------------------------------------------------------------------------- +/* eslint-disable arrow-body-style -- Need to supply formatted JSDoc for type info */ +var espree = () => { + + /** + * Returns the Espree parser. + * @param {AcornJsxParser} Parser The Acorn parser + * @returns {typeof EspreeParser} The Espree parser + */ + return Parser => { + const tokTypes = /** @type {EnhancedTokTypes} */ (Object.assign({}, Parser.acorn.tokTypes)); + + if (Parser.acornJsx) { + Object.assign(tokTypes, Parser.acornJsx.tokTypes); + } + + /* eslint-disable no-shadow -- Using first class as type */ + /** + * @export + */ + return class EspreeParser extends Parser { + /* eslint-enable no-shadow -- Using first class as type */ + /* eslint-disable jsdoc/check-types -- Allows generic object */ + /** + * Adapted parser for Espree. + * @param {ParserOptions|null} opts Espree options + * @param {string|object} code The source code + */ + constructor(opts, code) { + /* eslint-enable jsdoc/check-types -- Allows generic object */ + + /** @type {ParserOptions} */ + const newOpts = (typeof opts !== "object" || opts === null) + ? {} + : opts; + + const codeString = typeof code === "string" + ? /** @type {string} */ (code) + : String(code); + + // save original source type in case of commonjs + const originalSourceType = newOpts.sourceType; + const options = normalizeOptions(newOpts); + const ecmaFeatures = options.ecmaFeatures || {}; + const tokenTranslator = + options.tokens === true + ? new TokenTranslator(tokTypes, codeString) + : null; + + // Initialize acorn parser. + super({ + + // do not use spread, because we don't want to pass any unknown options to acorn + ecmaVersion: options.ecmaVersion, + sourceType: options.sourceType, + ranges: options.ranges, + locations: options.locations, + allowReserved: options.allowReserved, + + // Truthy value is true for backward compatibility. + allowReturnOutsideFunction: options.allowReturnOutsideFunction, + + // Collect tokens + /** + * Handler for receiving a token + * @param {acorn.Token} token The token + * @returns {void} + */ + onToken: token => { + if (tokenTranslator) { + + // Use `tokens`, `ecmaVersion`, and `jsxAttrValueToken` in the state. + tokenTranslator.onToken(token, /** @type {StateObjectWithTokens} */ (this[STATE])); + } + if (token.type !== tokTypes.eof) { + this[STATE].lastToken = token; + } + }, + + // Collect comments + /** + * Converts an Acorn comment to an Esprima comment. + * @type {AcornToEsprimaCommentConverter} + */ + onComment: (block, text, start, end, startLoc, endLoc) => { + if (this[STATE].comments) { + const comment = convertAcornCommentToEsprimaComment(block, text, start, end, startLoc, endLoc); + + const comments = /** @type {EsprimaComment[]} */ (this[STATE].comments); + + comments.push(comment); + } + } + }, codeString); + + // Force for TypeScript (indicating that `lineStart` is not undefined) + if (!this.lineStart) { + this.lineStart = 0; + } + + /** + * Data that is unique to Espree and is not represented internally in + * Acorn. We put all of this data into a symbol property as a way to + * avoid potential naming conflicts with future versions of Acorn. + * @type {StateObjectWithTokens|StateObject} + */ + this[STATE] = { + originalSourceType: originalSourceType || options.sourceType, + tokens: tokenTranslator ? /** @type {EspreeTokens} */ ([]) : null, + comments: options.comment === true + ? /** @type {EsprimaComment[]} */ ([]) + : null, + impliedStrict: ecmaFeatures.impliedStrict === true && this.options.ecmaVersion >= 5, + ecmaVersion: this.options.ecmaVersion, + jsxAttrValueToken: false, + + /** @type {acorn.Token|null} */ + lastToken: null, + + /** @type {(AcornTemplateNode)[]} */ + templateElements: [] + }; + } + + /** + * Returns Espree tokens. + * @returns {EspreeTokens|null} Espree tokens + */ + tokenize() { + do { + this.next(); + } while (this.type !== tokTypes.eof); + + // Consume the final eof token + this.next(); + + const extra = this[STATE]; + const tokens = extra.tokens; + + if (extra.comments && tokens) { + tokens.comments = extra.comments; + } + + return tokens; + } + + /** + * Calls parent. + * @param {acorn.Node} node The node + * @param {string} type The type + * @returns {acorn.Node} The altered Node + */ + finishNode(node, type) { + const result = super.finishNode(node, type); + + return this[ESPRIMA_FINISH_NODE](result); + } + + /** + * Calls parent. + * @param {acorn.Node} node The node + * @param {string} type The type + * @param {number} pos The position + * @param {acorn.Position} loc The location + * @returns {acorn.Node} The altered Node + */ + finishNodeAt(node, type, pos, loc) { + const result = super.finishNodeAt(node, type, pos, loc); + + return this[ESPRIMA_FINISH_NODE](result); + } + + /** + * Parses. + * @returns {EsprimaProgramNode} The program Node + */ + parse() { + const extra = this[STATE]; + + const program = /** @type {EsprimaProgramNode} */ (super.parse()); + + program.sourceType = extra.originalSourceType; + + if (extra.comments) { + program.comments = extra.comments; + } + if (extra.tokens) { + program.tokens = extra.tokens; + } + + /* + * Adjust opening and closing position of program to match Esprima. + * Acorn always starts programs at range 0 whereas Esprima starts at the + * first AST node's start (the only real difference is when there's leading + * whitespace or leading comments). Acorn also counts trailing whitespace + * as part of the program whereas Esprima only counts up to the last token. + */ + if (program.body.length) { + const [firstNode] = program.body; + + if (program.range && firstNode.range) { + program.range[0] = firstNode.range[0]; + } + if (program.loc && firstNode.loc) { + program.loc.start = firstNode.loc.start; + } + program.start = firstNode.start; + } + if (extra.lastToken) { + if (program.range && extra.lastToken.range) { + program.range[1] = extra.lastToken.range[1]; + } + if (program.loc && extra.lastToken.loc) { + program.loc.end = extra.lastToken.loc.end; + } + program.end = extra.lastToken.end; + } + + + /* + * https://github.com/eslint/espree/issues/349 + * Ensure that template elements have correct range information. + * This is one location where Acorn produces a different value + * for its start and end properties vs. the values present in the + * range property. In order to avoid confusion, we set the start + * and end properties to the values that are present in range. + * This is done here, instead of in finishNode(), because Acorn + * uses the values of start and end internally while parsing, making + * it dangerous to change those values while parsing is ongoing. + * By waiting until the end of parsing, we can safely change these + * values without affect any other part of the process. + */ + this[STATE].templateElements.forEach(templateElement => { + const startOffset = -1; + const endOffset = templateElement.tail ? 1 : 2; + + templateElement.start += startOffset; + templateElement.end += endOffset; + + if (templateElement.range) { + templateElement.range[0] += startOffset; + templateElement.range[1] += endOffset; + } + + if (templateElement.loc) { + templateElement.loc.start.column += startOffset; + templateElement.loc.end.column += endOffset; + } + }); + + return program; + } + + /** + * Parses top level. + * @param {acorn.Node} node AST Node + * @returns {acorn.Node} The changed node + */ + parseTopLevel(node) { + if (this[STATE].impliedStrict) { + this.strict = true; + } + return super.parseTopLevel(node); + } + + /** + * Overwrites the default raise method to throw Esprima-style errors. + * @param {int} pos The position of the error. + * @param {string} message The error message. + * @throws {EnhancedSyntaxError} A syntax error. + * @returns {void} + */ + raise(pos, message) { + const loc = Parser.acorn.getLineInfo(this.input, pos); + + /** @type {EnhancedSyntaxError} */ + const err = new SyntaxError(message); + + err.index = pos; + err.lineNumber = loc.line; + err.column = loc.column + 1; // acorn uses 0-based columns + throw err; + } + + /** + * Overwrites the default raise method to throw Esprima-style errors. + * @param {int} pos The position of the error. + * @param {string} message The error message. + * @throws {EnhancedSyntaxError} A syntax error. + * @returns {void} + */ + raiseRecoverable(pos, message) { + this.raise(pos, message); + } + + /** + * Overwrites the default unexpected method to throw Esprima-style errors. + * @param {int} pos The position of the error. + * @throws {EnhancedSyntaxError} A syntax error. + * @returns {void} + */ + unexpected(pos) { + let message = "Unexpected token"; + + if (pos !== null && pos !== void 0) { + this.pos = pos; + + if (this.options.locations) { + while (this.pos < /** @type {int} */ (this.lineStart)) { + + /** @type {int} */ + this.lineStart = this.input.lastIndexOf("\n", /** @type {int} */ (this.lineStart) - 2) + 1; + --this.curLine; + } + } + + this.nextToken(); + } + + if (this.end > this.start) { + message += ` ${this.input.slice(this.start, this.end)}`; + } + + this.raise(this.start, message); + } + + /** + * Esprima-FB represents JSX strings as tokens called "JSXText", but Acorn-JSX + * uses regular tt.string without any distinction between this and regular JS + * strings. As such, we intercept an attempt to read a JSX string and set a flag + * on extra so that when tokens are converted, the next token will be switched + * to JSXText via onToken. + * @param {number} quote A character code + * @returns {void} + */ + jsx_readString(quote) { // eslint-disable-line camelcase + if (typeof super.jsx_readString === "undefined") { + throw new Error("Not a JSX parser"); + } + super.jsx_readString(quote); + + if (this.type === tokTypes.string) { + this[STATE].jsxAttrValueToken = true; + } + } + + /** + * Performs last-minute Esprima-specific compatibility checks and fixes. + * @param {acorn.Node} result The node to check. + * @returns {EsprimaNode} The finished node. + */ + [ESPRIMA_FINISH_NODE](result) { + + const esprimaResult = /** @type {EsprimaNode} */ (result); + + // Acorn doesn't count the opening and closing backticks as part of templates + // so we have to adjust ranges/locations appropriately. + if (result.type === "TemplateElement") { + + // save template element references to fix start/end later + this[STATE].templateElements.push(result); + } + + if (result.type.includes("Function") && !esprimaResult.generator) { + esprimaResult.generator = false; + } + + return esprimaResult; + } + }; + }; +}; + +const version$1 = "main"; + +/** + * @fileoverview Main Espree file that converts Acorn into Esprima output. + * + * This file contains code from the following MIT-licensed projects: + * 1. Acorn + * 2. Babylon + * 3. Babel-ESLint + * + * This file also contains code from Esprima, which is BSD licensed. + * + * Acorn is Copyright 2012-2015 Acorn Contributors (https://github.com/marijnh/acorn/blob/master/AUTHORS) + * Babylon is Copyright 2014-2015 various contributors (https://github.com/babel/babel/blob/master/packages/babylon/AUTHORS) + * Babel-ESLint is Copyright 2014-2015 Sebastian McKenzie + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Esprima is Copyright (c) jQuery Foundation, Inc. and Contributors, All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +// To initialize lazily. +const parsers = { + _regular: /** @type {IEspreeParser|null} */ (null), + _jsx: /** @type {IEspreeParser|null} */ (null), + + /** + * Returns regular Parser + * @returns {IEspreeParser} Regular Acorn parser + */ + get regular() { + if (this._regular === null) { + const espreeParserFactory = espree(); + + // Cast the `acorn.Parser` to our own for required properties not specified in *.d.ts + this._regular = espreeParserFactory(/** @type {AcornJsxParser} */ (acorn__namespace.Parser)); + } + return this._regular; + }, + + /** + * Returns JSX Parser + * @returns {IEspreeParser} JSX Acorn parser + */ + get jsx() { + if (this._jsx === null) { + const espreeParserFactory = espree(); + const jsxFactory = jsx__default["default"](); + + // Cast the `acorn.Parser` to our own for required properties not specified in *.d.ts + this._jsx = espreeParserFactory(jsxFactory(acorn__namespace.Parser)); + } + return this._jsx; + }, + + /** + * Returns Regular or JSX Parser + * @param {ParserOptions} options Parser options + * @returns {IEspreeParser} Regular or JSX Acorn parser + */ + get(options) { + const useJsx = Boolean( + options && + options.ecmaFeatures && + options.ecmaFeatures.jsx + ); + + return useJsx ? this.jsx : this.regular; + } +}; + +//------------------------------------------------------------------------------ +// Tokenizer +//------------------------------------------------------------------------------ + +/** + * Tokenizes the given code. + * @param {string} code The code to tokenize. + * @param {ParserOptions} options Options defining how to tokenize. + * @returns {acorn.Token[]|null} An array of tokens. + * @throws {EnhancedSyntaxError} If the input code is invalid. + * @private + */ +function tokenize(code, options) { + const Parser = parsers.get(options); + + // Ensure to collect tokens. + if (!options || options.tokens !== true) { + options = Object.assign({}, options, { tokens: true }); // eslint-disable-line no-param-reassign + } + + return new Parser(options, code).tokenize(); +} + +//------------------------------------------------------------------------------ +// Parser +//------------------------------------------------------------------------------ + +/** + * Parses the given code. + * @param {string} code The code to tokenize. + * @param {ParserOptions} options Options defining how to tokenize. + * @returns {acorn.Node} The "Program" AST node. + * @throws {EnhancedSyntaxError} If the input code is invalid. + */ +function parse(code, options) { + const Parser = parsers.get(options); + + return new Parser(options, code).parse(); +} + +//------------------------------------------------------------------------------ +// Public +//------------------------------------------------------------------------------ + +const version = version$1; + +/* istanbul ignore next */ +const VisitorKeys = (function() { + return visitorKeys__namespace.KEYS; +}()); + +// Derive node types from VisitorKeys +/* istanbul ignore next */ +const Syntax = (function() { + let /** @type {Object} */ + types = {}; + + if (typeof Object.create === "function") { + types = Object.create(null); + } + + for (const name of Object.keys(VisitorKeys)) { + types[name] = name; + } + + if (typeof Object.freeze === "function") { + Object.freeze(types); + } + + return types; +}()); + +const latestEcmaVersion = getLatestEcmaVersion(); + +const supportedEcmaVersions = getSupportedEcmaVersions(); + +exports.Syntax = Syntax; +exports.VisitorKeys = VisitorKeys; +exports.latestEcmaVersion = latestEcmaVersion; +exports.parse = parse; +exports.supportedEcmaVersions = supportedEcmaVersions; +exports.tokenize = tokenize; +exports.version = version; +//# sourceMappingURL=espree.cjs.map diff --git a/dist/espree.cjs.map b/dist/espree.cjs.map new file mode 100644 index 00000000..1a034863 --- /dev/null +++ b/dist/espree.cjs.map @@ -0,0 +1 @@ +{"version":3,"file":"espree.cjs","sources":["../lib/token-translator.js","../lib/options.js","../lib/espree.js","../lib/version.js","../espree.js"],"sourcesContent":["/**\n * @fileoverview Translates tokens between Acorn format and Esprima format.\n * @author Nicholas C. Zakas\n */\n/* eslint no-underscore-dangle: 0 */\n\n// ----------------------------------------------------------------------------\n// Local type imports\n// ----------------------------------------------------------------------------\n/**\n * @local\n * @typedef {import('acorn')} acorn\n * @typedef {import('../lib/espree').EnhancedTokTypes} EnhancedTokTypes\n */\n\n// ----------------------------------------------------------------------------\n// Local types\n// ----------------------------------------------------------------------------\n/**\n * Based on the `acorn.Token` class, but without a fixed `type` (since we need\n * it to be a string). Avoiding `type` lets us make one extending interface\n * more strict and another more lax.\n *\n * We could make `value` more strict to `string` even though the original is\n * `any`.\n *\n * `start` and `end` are required in `acorn.Token`\n *\n * `loc` and `range` are from `acorn.Token`\n *\n * Adds `regex`.\n */\n/**\n * @local\n *\n * @typedef {{\n * value: any;\n * start?: number;\n * end?: number;\n * loc?: acorn.SourceLocation;\n * range?: [number, number];\n * regex?: {flags: string, pattern: string};\n * }} BaseEsprimaToken\n *\n * @typedef {{\n * type: string;\n * } & BaseEsprimaToken} EsprimaToken\n *\n * @typedef {{\n * type: string | acorn.TokenType;\n * } & BaseEsprimaToken} EsprimaTokenFlexible\n *\n * @typedef {{\n * jsxAttrValueToken: boolean;\n * ecmaVersion: acorn.ecmaVersion;\n * }} ExtraNoTokens\n *\n * @typedef {{\n * tokens: EsprimaTokenFlexible[]\n * } & ExtraNoTokens} Extra\n */\n\n//------------------------------------------------------------------------------\n// Requirements\n//------------------------------------------------------------------------------\n\n// none!\n\n//------------------------------------------------------------------------------\n// Private\n//------------------------------------------------------------------------------\n\n\n// Esprima Token Types\nconst Token = {\n Boolean: \"Boolean\",\n EOF: \"\",\n Identifier: \"Identifier\",\n PrivateIdentifier: \"PrivateIdentifier\",\n Keyword: \"Keyword\",\n Null: \"Null\",\n Numeric: \"Numeric\",\n Punctuator: \"Punctuator\",\n String: \"String\",\n RegularExpression: \"RegularExpression\",\n Template: \"Template\",\n JSXIdentifier: \"JSXIdentifier\",\n JSXText: \"JSXText\"\n};\n\n/**\n * Converts part of a template into an Esprima token.\n * @param {(acorn.Token)[]} tokens The Acorn tokens representing the template.\n * @param {string} code The source code.\n * @returns {EsprimaToken} The Esprima equivalent of the template token.\n * @private\n */\nfunction convertTemplatePart(tokens, code) {\n const firstToken = tokens[0],\n lastTemplateToken = tokens[tokens.length - 1];\n\n /** @type {EsprimaToken} */\n const token = {\n type: Token.Template,\n value: code.slice(firstToken.start, lastTemplateToken.end)\n };\n\n if (firstToken.loc && lastTemplateToken.loc) {\n token.loc = {\n start: firstToken.loc.start,\n end: lastTemplateToken.loc.end\n };\n }\n\n if (firstToken.range && lastTemplateToken.range) {\n token.start = firstToken.range[0];\n token.end = lastTemplateToken.range[1];\n token.range = [token.start, token.end];\n }\n\n return token;\n}\n\nclass TokenTranslator {\n\n /**\n * Contains logic to translate Acorn tokens into Esprima tokens.\n * @param {EnhancedTokTypes} acornTokTypes The Acorn token types.\n * @param {string} code The source code Acorn is parsing. This is necessary\n * to correct the \"value\" property of some tokens.\n */\n constructor(acornTokTypes, code) {\n\n // token types\n this._acornTokTypes = acornTokTypes;\n\n // token buffer for templates\n /** @type {(acorn.Token)[]} */\n this._tokens = [];\n\n // track the last curly brace\n this._curlyBrace = null;\n\n // the source code\n this._code = code;\n\n }\n\n /**\n * Translates a single Esprima token to a single Acorn token. This may be\n * inaccurate due to how templates are handled differently in Esprima and\n * Acorn, but should be accurate for all other tokens.\n * @param {acorn.Token} token The Acorn token to translate.\n * @param {ExtraNoTokens} extra Espree extra object.\n * @returns {EsprimaToken} The Esprima version of the token.\n */\n translate(token, extra) {\n\n const type = token.type,\n tt = this._acornTokTypes,\n\n // We use an unknown type because `acorn.Token` is a class whose\n // `type` property we cannot override to our desired `string`;\n // this also allows us to define a stricter `EsprimaToken` with\n // a string-only `type` property\n unknownType = /** @type {unknown} */ (token),\n newToken = /** @type {EsprimaToken} */ (unknownType);\n\n if (type === tt.name) {\n newToken.type = Token.Identifier;\n\n // TODO: See if this is an Acorn bug\n if (token.value === \"static\") {\n newToken.type = Token.Keyword;\n }\n\n if (extra.ecmaVersion > 5 && (token.value === \"yield\" || token.value === \"let\")) {\n newToken.type = Token.Keyword;\n }\n\n } else if (type === tt.privateId) {\n newToken.type = Token.PrivateIdentifier;\n\n } else if (type === tt.semi || type === tt.comma ||\n type === tt.parenL || type === tt.parenR ||\n type === tt.braceL || type === tt.braceR ||\n type === tt.dot || type === tt.bracketL ||\n type === tt.colon || type === tt.question ||\n type === tt.bracketR || type === tt.ellipsis ||\n type === tt.arrow || type === tt.jsxTagStart ||\n type === tt.incDec || type === tt.starstar ||\n type === tt.jsxTagEnd || type === tt.prefix ||\n type === tt.questionDot ||\n (type.binop && !type.keyword) ||\n type.isAssign) {\n\n newToken.type = Token.Punctuator;\n newToken.value = this._code.slice(token.start, token.end);\n } else if (type === tt.jsxName) {\n newToken.type = Token.JSXIdentifier;\n } else if (type.label === \"jsxText\" || type === tt.jsxAttrValueToken) {\n newToken.type = Token.JSXText;\n } else if (type.keyword) {\n if (type.keyword === \"true\" || type.keyword === \"false\") {\n newToken.type = Token.Boolean;\n } else if (type.keyword === \"null\") {\n newToken.type = Token.Null;\n } else {\n newToken.type = Token.Keyword;\n }\n } else if (type === tt.num) {\n newToken.type = Token.Numeric;\n newToken.value = this._code.slice(token.start, token.end);\n } else if (type === tt.string) {\n\n if (extra.jsxAttrValueToken) {\n extra.jsxAttrValueToken = false;\n newToken.type = Token.JSXText;\n } else {\n newToken.type = Token.String;\n }\n\n newToken.value = this._code.slice(token.start, token.end);\n } else if (type === tt.regexp) {\n newToken.type = Token.RegularExpression;\n const value = token.value;\n\n newToken.regex = {\n flags: value.flags,\n pattern: value.pattern\n };\n newToken.value = `/${value.pattern}/${value.flags}`;\n }\n\n return newToken;\n }\n\n /**\n * Function to call during Acorn's onToken handler.\n * @param {acorn.Token} token The Acorn token.\n * @param {Extra} extra The Espree extra object.\n * @returns {void}\n */\n onToken(token, extra) {\n\n const that = this,\n tt = this._acornTokTypes,\n tokens = extra.tokens,\n templateTokens = this._tokens;\n\n /**\n * Flushes the buffered template tokens and resets the template\n * tracking.\n * @returns {void}\n * @private\n */\n function translateTemplateTokens() {\n tokens.push(convertTemplatePart(that._tokens, that._code));\n that._tokens = [];\n }\n\n if (token.type === tt.eof) {\n\n // might be one last curlyBrace\n if (this._curlyBrace) {\n tokens.push(this.translate(this._curlyBrace, extra));\n }\n\n return;\n }\n\n if (token.type === tt.backQuote) {\n\n // if there's already a curly, it's not part of the template\n if (this._curlyBrace) {\n tokens.push(this.translate(this._curlyBrace, extra));\n this._curlyBrace = null;\n }\n\n templateTokens.push(token);\n\n // it's the end\n if (templateTokens.length > 1) {\n translateTemplateTokens();\n }\n\n return;\n }\n if (token.type === tt.dollarBraceL) {\n templateTokens.push(token);\n translateTemplateTokens();\n return;\n }\n if (token.type === tt.braceR) {\n\n // if there's already a curly, it's not part of the template\n if (this._curlyBrace) {\n tokens.push(this.translate(this._curlyBrace, extra));\n }\n\n // store new curly for later\n this._curlyBrace = token;\n return;\n }\n if (token.type === tt.template || token.type === tt.invalidTemplate) {\n if (this._curlyBrace) {\n templateTokens.push(this._curlyBrace);\n this._curlyBrace = null;\n }\n\n templateTokens.push(token);\n return;\n }\n\n if (this._curlyBrace) {\n tokens.push(this.translate(this._curlyBrace, extra));\n this._curlyBrace = null;\n }\n\n tokens.push(this.translate(token, extra));\n }\n}\n\n//------------------------------------------------------------------------------\n// Public\n//------------------------------------------------------------------------------\n\nexport default TokenTranslator;\n","/**\n * @fileoverview A collection of methods for processing Espree's options.\n * @author Kai Cataldo\n */\n\n// ----------------------------------------------------------------------------\n// Local type imports\n// ----------------------------------------------------------------------------\n/**\n * @local\n * @typedef {import('../espree').ParserOptions} ParserOptions\n */\n\n// ----------------------------------------------------------------------------\n// Local types\n// ----------------------------------------------------------------------------\n/**\n * @local\n * @typedef {{\n * ecmaVersion: 10 | 9 | 8 | 7 | 6 | 5 | 3 | 11 | 12 | 13 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020 | 2021 | 2022 | \"latest\",\n * sourceType: \"script\"|\"module\",\n * range?: boolean,\n * loc?: boolean,\n * allowReserved: boolean | \"never\",\n * ecmaFeatures?: {\n * jsx?: boolean,\n * globalReturn?: boolean,\n * impliedStrict?: boolean\n * },\n * ranges: boolean,\n * locations: boolean,\n * allowReturnOutsideFunction: boolean,\n * tokens?: boolean | null,\n * comment?: boolean\n * }} NormalizedParserOptions\n */\n\n//------------------------------------------------------------------------------\n// Helpers\n//------------------------------------------------------------------------------\n\nconst SUPPORTED_VERSIONS = [\n 3,\n 5,\n 6,\n 7,\n 8,\n 9,\n 10,\n 11,\n 12,\n 13\n];\n\n/**\n * Get the latest ECMAScript version supported by Espree.\n * @returns {number} The latest ECMAScript version.\n */\nexport function getLatestEcmaVersion() {\n return SUPPORTED_VERSIONS[SUPPORTED_VERSIONS.length - 1];\n}\n\n/**\n * Get the list of ECMAScript versions supported by Espree.\n * @returns {number[]} An array containing the supported ECMAScript versions.\n */\nexport function getSupportedEcmaVersions() {\n return [...SUPPORTED_VERSIONS];\n}\n\n/**\n * Normalize ECMAScript version from the initial config\n * @param {number|\"latest\"} ecmaVersion ECMAScript version from the initial config\n * @throws {Error} throws an error if the ecmaVersion is invalid.\n * @returns {number} normalized ECMAScript version\n */\nfunction normalizeEcmaVersion(ecmaVersion = 5) {\n\n let version = ecmaVersion === \"latest\" ? getLatestEcmaVersion() : ecmaVersion;\n\n if (typeof version !== \"number\") {\n throw new Error(`ecmaVersion must be a number or \"latest\". Received value of type ${typeof ecmaVersion} instead.`);\n }\n\n // Calculate ECMAScript edition number from official year version starting with\n // ES2015, which corresponds with ES6 (or a difference of 2009).\n if (version >= 2015) {\n version -= 2009;\n }\n\n if (!SUPPORTED_VERSIONS.includes(version)) {\n throw new Error(\"Invalid ecmaVersion.\");\n }\n\n return version;\n}\n\n/**\n * Normalize sourceType from the initial config\n * @param {\"script\"|\"module\"|\"commonjs\"} sourceType to normalize\n * @throws {Error} throw an error if sourceType is invalid\n * @returns {\"script\"|\"module\"} normalized sourceType\n */\nfunction normalizeSourceType(sourceType = \"script\") {\n if (sourceType === \"script\" || sourceType === \"module\") {\n return sourceType;\n }\n\n if (sourceType === \"commonjs\") {\n return \"script\";\n }\n\n throw new Error(\"Invalid sourceType.\");\n}\n\n/**\n * Normalize parserOptions\n * @param {ParserOptions} options the parser options to normalize\n * @throws {Error} throw an error if found invalid option.\n * @returns {NormalizedParserOptions} normalized options\n */\nexport function normalizeOptions(options) {\n const ecmaVersion = normalizeEcmaVersion(options.ecmaVersion);\n\n /** @type {\"script\"|\"module\"} */\n const sourceType = normalizeSourceType(options.sourceType);\n const ranges = options.range === true;\n const locations = options.loc === true;\n\n if (ecmaVersion !== 3 && options.allowReserved) {\n\n // a value of `false` is intentionally allowed here, so a shared config can overwrite it when needed\n throw new Error(\"`allowReserved` is only supported when ecmaVersion is 3\");\n }\n\n // Note: value in Acorn can also be \"never\" but we throw in such a case\n if (typeof options.allowReserved !== \"undefined\" && typeof options.allowReserved !== \"boolean\") {\n throw new Error(\"`allowReserved`, when present, must be `true` or `false`\");\n }\n const allowReserved = ecmaVersion === 3 ? (options.allowReserved || \"never\") : false;\n const ecmaFeatures = options.ecmaFeatures || {};\n const allowReturnOutsideFunction = options.sourceType === \"commonjs\" ||\n Boolean(ecmaFeatures.globalReturn);\n\n if (sourceType === \"module\" && ecmaVersion < 6) {\n throw new Error(\"sourceType 'module' is not supported when ecmaVersion < 2015. Consider adding `{ ecmaVersion: 2015 }` to the parser options.\");\n }\n\n return Object.assign({}, options, {\n ecmaVersion,\n sourceType,\n ranges,\n locations,\n allowReserved,\n allowReturnOutsideFunction\n });\n}\n","/* eslint-disable no-param-reassign*/\nimport TokenTranslator from \"./token-translator.js\";\nimport { normalizeOptions } from \"./options.js\";\n\nconst STATE = Symbol(\"espree's internal state\");\nconst ESPRIMA_FINISH_NODE = Symbol(\"espree's esprimaFinishNode\");\n\n// ----------------------------------------------------------------------------\n// Types exported from file\n// ----------------------------------------------------------------------------\n/**\n * @typedef {{\n * index?: number;\n * lineNumber?: number;\n * column?: number;\n * } & SyntaxError} EnhancedSyntaxError\n */\n\n// We add `jsxAttrValueToken` ourselves.\n/**\n * @typedef {{\n * jsxAttrValueToken?: acorn.TokenType;\n * } & tokTypesType} EnhancedTokTypes\n */\n\n// ----------------------------------------------------------------------------\n// Local type imports\n// ----------------------------------------------------------------------------\n/**\n * @local\n * @typedef {import('acorn')} acorn\n * @typedef {typeof import('acorn-jsx').tokTypes} tokTypesType\n * @typedef {typeof import('acorn-jsx').AcornJsxParser} AcornJsxParser\n * @typedef {import('../espree').ParserOptions} ParserOptions\n */\n\n// ----------------------------------------------------------------------------\n// Local types\n// ----------------------------------------------------------------------------\n/**\n * @local\n *\n * @typedef {acorn.ecmaVersion} ecmaVersion\n *\n * @typedef {{\n * generator?: boolean\n * } & acorn.Node} EsprimaNode\n */\n/**\n * Suggests an integer\n * @local\n * @typedef {number} int\n */\n\n/**\n * First three properties as in `acorn.Comment`; next two as in `acorn.Comment`\n * but optional. Last is different as has to allow `undefined`\n */\n/**\n * @local\n *\n * @typedef {{\n * type: string,\n * value: string,\n * range?: [number, number],\n * start?: number,\n * end?: number,\n * loc?: {\n * start: acorn.Position | undefined,\n * end: acorn.Position | undefined\n * }\n * }} EsprimaComment\n *\n * @typedef {{\n * comments?: EsprimaComment[]\n * } & acorn.Token[]} EspreeTokens\n *\n * @typedef {{\n * tail?: boolean\n * } & acorn.Node} AcornTemplateNode\n *\n * @typedef {{\n * originalSourceType: \"script\"|\"module\"|\"commonjs\";\n * ecmaVersion: ecmaVersion;\n * comments: EsprimaComment[]|null;\n * impliedStrict: boolean;\n * lastToken: acorn.Token|null;\n * templateElements: (AcornTemplateNode)[];\n * jsxAttrValueToken: boolean;\n * }} BaseStateObject\n *\n * @typedef {{\n * tokens: null;\n * } & BaseStateObject} StateObject\n *\n * @typedef {{\n * tokens: EspreeTokens;\n * } & BaseStateObject} StateObjectWithTokens\n *\n * @typedef {{\n * sourceType?: \"script\"|\"module\"|\"commonjs\";\n * comments?: EsprimaComment[];\n * tokens?: acorn.Token[];\n * body: acorn.Node[];\n * } & acorn.Node} EsprimaProgramNode\n */\n/**\n * Converts an Acorn comment to an Esprima comment.\n *\n * - block True if it's a block comment, false if not.\n * - text The text of the comment.\n * - start The index at which the comment starts.\n * - end The index at which the comment ends.\n * - startLoc The location at which the comment starts.\n * - endLoc The location at which the comment ends.\n * @local\n * @typedef {(\n * block: boolean,\n * text: string,\n * start: int,\n * end: int,\n * startLoc: acorn.Position | undefined,\n * endLoc: acorn.Position | undefined\n * ) => EsprimaComment | void} AcornToEsprimaCommentConverter\n */\n\n// ----------------------------------------------------------------------------\n// Utilities\n// ----------------------------------------------------------------------------\n/**\n * Converts an Acorn comment to an Esprima comment.\n * @type {AcornToEsprimaCommentConverter}\n * @returns {EsprimaComment} The comment object.\n * @private\n */\nfunction convertAcornCommentToEsprimaComment(block, text, start, end, startLoc, endLoc) {\n const comment = /** @type {EsprimaComment} */ ({\n type: block ? \"Block\" : \"Line\",\n value: text\n });\n\n if (typeof start === \"number\") {\n comment.start = start;\n comment.end = end;\n comment.range = [start, end];\n }\n\n if (typeof startLoc === \"object\") {\n comment.loc = {\n start: startLoc,\n end: endLoc\n };\n }\n\n return comment;\n}\n\n// ----------------------------------------------------------------------------\n// Exports\n// ----------------------------------------------------------------------------\n/* eslint-disable arrow-body-style -- Need to supply formatted JSDoc for type info */\nexport default () => {\n\n /**\n * Returns the Espree parser.\n * @param {AcornJsxParser} Parser The Acorn parser\n * @returns {typeof EspreeParser} The Espree parser\n */\n return Parser => {\n const tokTypes = /** @type {EnhancedTokTypes} */ (Object.assign({}, Parser.acorn.tokTypes));\n\n if (Parser.acornJsx) {\n Object.assign(tokTypes, Parser.acornJsx.tokTypes);\n }\n\n /* eslint-disable no-shadow -- Using first class as type */\n /**\n * @export\n */\n return class EspreeParser extends Parser {\n /* eslint-enable no-shadow -- Using first class as type */\n /* eslint-disable jsdoc/check-types -- Allows generic object */\n /**\n * Adapted parser for Espree.\n * @param {ParserOptions|null} opts Espree options\n * @param {string|object} code The source code\n */\n constructor(opts, code) {\n /* eslint-enable jsdoc/check-types -- Allows generic object */\n\n /** @type {ParserOptions} */\n const newOpts = (typeof opts !== \"object\" || opts === null)\n ? {}\n : opts;\n\n const codeString = typeof code === \"string\"\n ? /** @type {string} */ (code)\n : String(code);\n\n // save original source type in case of commonjs\n const originalSourceType = newOpts.sourceType;\n const options = normalizeOptions(newOpts);\n const ecmaFeatures = options.ecmaFeatures || {};\n const tokenTranslator =\n options.tokens === true\n ? new TokenTranslator(tokTypes, codeString)\n : null;\n\n // Initialize acorn parser.\n super({\n\n // do not use spread, because we don't want to pass any unknown options to acorn\n ecmaVersion: options.ecmaVersion,\n sourceType: options.sourceType,\n ranges: options.ranges,\n locations: options.locations,\n allowReserved: options.allowReserved,\n\n // Truthy value is true for backward compatibility.\n allowReturnOutsideFunction: options.allowReturnOutsideFunction,\n\n // Collect tokens\n /**\n * Handler for receiving a token\n * @param {acorn.Token} token The token\n * @returns {void}\n */\n onToken: token => {\n if (tokenTranslator) {\n\n // Use `tokens`, `ecmaVersion`, and `jsxAttrValueToken` in the state.\n tokenTranslator.onToken(token, /** @type {StateObjectWithTokens} */ (this[STATE]));\n }\n if (token.type !== tokTypes.eof) {\n this[STATE].lastToken = token;\n }\n },\n\n // Collect comments\n /**\n * Converts an Acorn comment to an Esprima comment.\n * @type {AcornToEsprimaCommentConverter}\n */\n onComment: (block, text, start, end, startLoc, endLoc) => {\n if (this[STATE].comments) {\n const comment = convertAcornCommentToEsprimaComment(block, text, start, end, startLoc, endLoc);\n\n const comments = /** @type {EsprimaComment[]} */ (this[STATE].comments);\n\n comments.push(comment);\n }\n }\n }, codeString);\n\n // Force for TypeScript (indicating that `lineStart` is not undefined)\n if (!this.lineStart) {\n this.lineStart = 0;\n }\n\n /**\n * Data that is unique to Espree and is not represented internally in\n * Acorn. We put all of this data into a symbol property as a way to\n * avoid potential naming conflicts with future versions of Acorn.\n * @type {StateObjectWithTokens|StateObject}\n */\n this[STATE] = {\n originalSourceType: originalSourceType || options.sourceType,\n tokens: tokenTranslator ? /** @type {EspreeTokens} */ ([]) : null,\n comments: options.comment === true\n ? /** @type {EsprimaComment[]} */ ([])\n : null,\n impliedStrict: ecmaFeatures.impliedStrict === true && this.options.ecmaVersion >= 5,\n ecmaVersion: this.options.ecmaVersion,\n jsxAttrValueToken: false,\n\n /** @type {acorn.Token|null} */\n lastToken: null,\n\n /** @type {(AcornTemplateNode)[]} */\n templateElements: []\n };\n }\n\n /**\n * Returns Espree tokens.\n * @returns {EspreeTokens|null} Espree tokens\n */\n tokenize() {\n do {\n this.next();\n } while (this.type !== tokTypes.eof);\n\n // Consume the final eof token\n this.next();\n\n const extra = this[STATE];\n const tokens = extra.tokens;\n\n if (extra.comments && tokens) {\n tokens.comments = extra.comments;\n }\n\n return tokens;\n }\n\n /**\n * Calls parent.\n * @param {acorn.Node} node The node\n * @param {string} type The type\n * @returns {acorn.Node} The altered Node\n */\n finishNode(node, type) {\n const result = super.finishNode(node, type);\n\n return this[ESPRIMA_FINISH_NODE](result);\n }\n\n /**\n * Calls parent.\n * @param {acorn.Node} node The node\n * @param {string} type The type\n * @param {number} pos The position\n * @param {acorn.Position} loc The location\n * @returns {acorn.Node} The altered Node\n */\n finishNodeAt(node, type, pos, loc) {\n const result = super.finishNodeAt(node, type, pos, loc);\n\n return this[ESPRIMA_FINISH_NODE](result);\n }\n\n /**\n * Parses.\n * @returns {EsprimaProgramNode} The program Node\n */\n parse() {\n const extra = this[STATE];\n\n const program = /** @type {EsprimaProgramNode} */ (super.parse());\n\n program.sourceType = extra.originalSourceType;\n\n if (extra.comments) {\n program.comments = extra.comments;\n }\n if (extra.tokens) {\n program.tokens = extra.tokens;\n }\n\n /*\n * Adjust opening and closing position of program to match Esprima.\n * Acorn always starts programs at range 0 whereas Esprima starts at the\n * first AST node's start (the only real difference is when there's leading\n * whitespace or leading comments). Acorn also counts trailing whitespace\n * as part of the program whereas Esprima only counts up to the last token.\n */\n if (program.body.length) {\n const [firstNode] = program.body;\n\n if (program.range && firstNode.range) {\n program.range[0] = firstNode.range[0];\n }\n if (program.loc && firstNode.loc) {\n program.loc.start = firstNode.loc.start;\n }\n program.start = firstNode.start;\n }\n if (extra.lastToken) {\n if (program.range && extra.lastToken.range) {\n program.range[1] = extra.lastToken.range[1];\n }\n if (program.loc && extra.lastToken.loc) {\n program.loc.end = extra.lastToken.loc.end;\n }\n program.end = extra.lastToken.end;\n }\n\n\n /*\n * https://github.com/eslint/espree/issues/349\n * Ensure that template elements have correct range information.\n * This is one location where Acorn produces a different value\n * for its start and end properties vs. the values present in the\n * range property. In order to avoid confusion, we set the start\n * and end properties to the values that are present in range.\n * This is done here, instead of in finishNode(), because Acorn\n * uses the values of start and end internally while parsing, making\n * it dangerous to change those values while parsing is ongoing.\n * By waiting until the end of parsing, we can safely change these\n * values without affect any other part of the process.\n */\n this[STATE].templateElements.forEach(templateElement => {\n const startOffset = -1;\n const endOffset = templateElement.tail ? 1 : 2;\n\n templateElement.start += startOffset;\n templateElement.end += endOffset;\n\n if (templateElement.range) {\n templateElement.range[0] += startOffset;\n templateElement.range[1] += endOffset;\n }\n\n if (templateElement.loc) {\n templateElement.loc.start.column += startOffset;\n templateElement.loc.end.column += endOffset;\n }\n });\n\n return program;\n }\n\n /**\n * Parses top level.\n * @param {acorn.Node} node AST Node\n * @returns {acorn.Node} The changed node\n */\n parseTopLevel(node) {\n if (this[STATE].impliedStrict) {\n this.strict = true;\n }\n return super.parseTopLevel(node);\n }\n\n /**\n * Overwrites the default raise method to throw Esprima-style errors.\n * @param {int} pos The position of the error.\n * @param {string} message The error message.\n * @throws {EnhancedSyntaxError} A syntax error.\n * @returns {void}\n */\n raise(pos, message) {\n const loc = Parser.acorn.getLineInfo(this.input, pos);\n\n /** @type {EnhancedSyntaxError} */\n const err = new SyntaxError(message);\n\n err.index = pos;\n err.lineNumber = loc.line;\n err.column = loc.column + 1; // acorn uses 0-based columns\n throw err;\n }\n\n /**\n * Overwrites the default raise method to throw Esprima-style errors.\n * @param {int} pos The position of the error.\n * @param {string} message The error message.\n * @throws {EnhancedSyntaxError} A syntax error.\n * @returns {void}\n */\n raiseRecoverable(pos, message) {\n this.raise(pos, message);\n }\n\n /**\n * Overwrites the default unexpected method to throw Esprima-style errors.\n * @param {int} pos The position of the error.\n * @throws {EnhancedSyntaxError} A syntax error.\n * @returns {void}\n */\n unexpected(pos) {\n let message = \"Unexpected token\";\n\n if (pos !== null && pos !== void 0) {\n this.pos = pos;\n\n if (this.options.locations) {\n while (this.pos < /** @type {int} */ (this.lineStart)) {\n\n /** @type {int} */\n this.lineStart = this.input.lastIndexOf(\"\\n\", /** @type {int} */ (this.lineStart) - 2) + 1;\n --this.curLine;\n }\n }\n\n this.nextToken();\n }\n\n if (this.end > this.start) {\n message += ` ${this.input.slice(this.start, this.end)}`;\n }\n\n this.raise(this.start, message);\n }\n\n /**\n * Esprima-FB represents JSX strings as tokens called \"JSXText\", but Acorn-JSX\n * uses regular tt.string without any distinction between this and regular JS\n * strings. As such, we intercept an attempt to read a JSX string and set a flag\n * on extra so that when tokens are converted, the next token will be switched\n * to JSXText via onToken.\n * @param {number} quote A character code\n * @returns {void}\n */\n jsx_readString(quote) { // eslint-disable-line camelcase\n if (typeof super.jsx_readString === \"undefined\") {\n throw new Error(\"Not a JSX parser\");\n }\n super.jsx_readString(quote);\n\n if (this.type === tokTypes.string) {\n this[STATE].jsxAttrValueToken = true;\n }\n }\n\n /**\n * Performs last-minute Esprima-specific compatibility checks and fixes.\n * @param {acorn.Node} result The node to check.\n * @returns {EsprimaNode} The finished node.\n */\n [ESPRIMA_FINISH_NODE](result) {\n\n const esprimaResult = /** @type {EsprimaNode} */ (result);\n\n // Acorn doesn't count the opening and closing backticks as part of templates\n // so we have to adjust ranges/locations appropriately.\n if (result.type === \"TemplateElement\") {\n\n // save template element references to fix start/end later\n this[STATE].templateElements.push(result);\n }\n\n if (result.type.includes(\"Function\") && !esprimaResult.generator) {\n esprimaResult.generator = false;\n }\n\n return esprimaResult;\n }\n };\n };\n};\n","const version = \"main\";\n\nexport default version;\n","/**\n * @fileoverview Main Espree file that converts Acorn into Esprima output.\n *\n * This file contains code from the following MIT-licensed projects:\n * 1. Acorn\n * 2. Babylon\n * 3. Babel-ESLint\n *\n * This file also contains code from Esprima, which is BSD licensed.\n *\n * Acorn is Copyright 2012-2015 Acorn Contributors (https://github.com/marijnh/acorn/blob/master/AUTHORS)\n * Babylon is Copyright 2014-2015 various contributors (https://github.com/babel/babel/blob/master/packages/babylon/AUTHORS)\n * Babel-ESLint is Copyright 2014-2015 Sebastian McKenzie \n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are met:\n *\n * * Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer.\n * * Redistributions in binary form must reproduce the above copyright\n * notice, this list of conditions and the following disclaimer in the\n * documentation and/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY\n * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\n * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n * Esprima is Copyright (c) jQuery Foundation, Inc. and Contributors, All Rights Reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are met:\n *\n * * Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer.\n * * Redistributions in binary form must reproduce the above copyright\n * notice, this list of conditions and the following disclaimer in the\n * documentation and/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY\n * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\n * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n/* eslint no-undefined:0, no-use-before-define: 0 */\n\n// ----------------------------------------------------------------------------\n// Types exported from file\n// ----------------------------------------------------------------------------\n/**\n * `jsx.Options` gives us 2 optional properties, so extend it\n *\n * `allowReserved`, `ranges`, `locations`, `allowReturnOutsideFunction`,\n * `onToken`, and `onComment` are as in `acorn.Options`\n *\n * `ecmaVersion` as in `acorn.Options` though optional\n *\n * `sourceType` as in `acorn.Options` but also allows `commonjs`\n *\n * `ecmaFeatures`, `range`, `loc`, `tokens` are not in `acorn.Options`\n *\n * `comment` is not in `acorn.Options` and doesn't err without it, but is used\n */\n/**\n * @typedef {{\n * allowReserved?: boolean,\n * ecmaVersion?: acorn.ecmaVersion,\n * sourceType?: \"script\"|\"module\"|\"commonjs\",\n * ecmaFeatures?: {\n * jsx?: boolean,\n * globalReturn?: boolean,\n * impliedStrict?: boolean\n * },\n * range?: boolean,\n * loc?: boolean,\n * tokens?: boolean | null,\n * comment?: boolean,\n * }} ParserOptions\n */\n\n// ----------------------------------------------------------------------------\n// Local type imports\n// ----------------------------------------------------------------------------\n/**\n * @local\n * @typedef {import('acorn')} acorn\n * @typedef {typeof import('acorn-jsx').AcornJsxParser} AcornJsxParser\n * @typedef {import('./lib/espree').EnhancedSyntaxError} EnhancedSyntaxError\n * @typedef {typeof import('./lib/espree').EspreeParser} IEspreeParser\n */\n\nimport * as acorn from \"acorn\";\nimport jsx from \"acorn-jsx\";\nimport espree from \"./lib/espree.js\";\nimport espreeVersion from \"./lib/version.js\";\nimport * as visitorKeys from \"eslint-visitor-keys\";\nimport { getLatestEcmaVersion, getSupportedEcmaVersions } from \"./lib/options.js\";\n\n\n// To initialize lazily.\nconst parsers = {\n _regular: /** @type {IEspreeParser|null} */ (null),\n _jsx: /** @type {IEspreeParser|null} */ (null),\n\n /**\n * Returns regular Parser\n * @returns {IEspreeParser} Regular Acorn parser\n */\n get regular() {\n if (this._regular === null) {\n const espreeParserFactory = espree();\n\n // Cast the `acorn.Parser` to our own for required properties not specified in *.d.ts\n this._regular = espreeParserFactory(/** @type {AcornJsxParser} */ (acorn.Parser));\n }\n return this._regular;\n },\n\n /**\n * Returns JSX Parser\n * @returns {IEspreeParser} JSX Acorn parser\n */\n get jsx() {\n if (this._jsx === null) {\n const espreeParserFactory = espree();\n const jsxFactory = jsx();\n\n // Cast the `acorn.Parser` to our own for required properties not specified in *.d.ts\n this._jsx = espreeParserFactory(jsxFactory(acorn.Parser));\n }\n return this._jsx;\n },\n\n /**\n * Returns Regular or JSX Parser\n * @param {ParserOptions} options Parser options\n * @returns {IEspreeParser} Regular or JSX Acorn parser\n */\n get(options) {\n const useJsx = Boolean(\n options &&\n options.ecmaFeatures &&\n options.ecmaFeatures.jsx\n );\n\n return useJsx ? this.jsx : this.regular;\n }\n};\n\n//------------------------------------------------------------------------------\n// Tokenizer\n//------------------------------------------------------------------------------\n\n/**\n * Tokenizes the given code.\n * @param {string} code The code to tokenize.\n * @param {ParserOptions} options Options defining how to tokenize.\n * @returns {acorn.Token[]|null} An array of tokens.\n * @throws {EnhancedSyntaxError} If the input code is invalid.\n * @private\n */\nexport function tokenize(code, options) {\n const Parser = parsers.get(options);\n\n // Ensure to collect tokens.\n if (!options || options.tokens !== true) {\n options = Object.assign({}, options, { tokens: true }); // eslint-disable-line no-param-reassign\n }\n\n return new Parser(options, code).tokenize();\n}\n\n//------------------------------------------------------------------------------\n// Parser\n//------------------------------------------------------------------------------\n\n/**\n * Parses the given code.\n * @param {string} code The code to tokenize.\n * @param {ParserOptions} options Options defining how to tokenize.\n * @returns {acorn.Node} The \"Program\" AST node.\n * @throws {EnhancedSyntaxError} If the input code is invalid.\n */\nexport function parse(code, options) {\n const Parser = parsers.get(options);\n\n return new Parser(options, code).parse();\n}\n\n//------------------------------------------------------------------------------\n// Public\n//------------------------------------------------------------------------------\n\nexport const version = espreeVersion;\n\n/* istanbul ignore next */\nexport const VisitorKeys = (function() {\n return visitorKeys.KEYS;\n}());\n\n// Derive node types from VisitorKeys\n/* istanbul ignore next */\nexport const Syntax = (function() {\n let /** @type {Object} */\n types = {};\n\n if (typeof Object.create === \"function\") {\n types = Object.create(null);\n }\n\n for (const name of Object.keys(VisitorKeys)) {\n types[name] = name;\n }\n\n if (typeof Object.freeze === \"function\") {\n Object.freeze(types);\n }\n\n return types;\n}());\n\nexport const latestEcmaVersion = getLatestEcmaVersion();\n\nexport const supportedEcmaVersions = getSupportedEcmaVersions();\n"],"names":["version","acorn","jsx","espreeVersion","visitorKeys"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,KAAK,GAAG;AACd,IAAI,OAAO,EAAE,SAAS;AACtB,IAAI,GAAG,EAAE,OAAO;AAChB,IAAI,UAAU,EAAE,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QAAQ,WAAW;AACnB,QAAQ,UAAU;AAClB,QAAQ,MAAM;AACd,QAAQ,SAAS;AACjB,QAAQ,aAAa;AACrB,QAAQ,0BAA0B;AAClC,KAAK,CAAC,CAAC;AACP;;AC5JA;AAGA;AACA,MAAM,KAAK,GAAG,MAAM,CAAC,yBAAyB,CAAC,CAAC;AAChD,MAAM,mBAAmB,GAAG,MAAM,CAAC,4BAA4B,CAAC,CAAC;AACjE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,mCAAmC,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE;AACxF,IAAI,MAAM,OAAO,kCAAkC;AACnD,QAAQ,IAAI,EAAE,KAAK,GAAG,OAAO,GAAG,MAAM;AACtC,QAAQ,KAAK,EAAE,IAAI;AACnB,KAAK,CAAC,CAAC;AACP;AACA,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;AACnC,QAAQ,OAAO,CAAC,KAAK,GAAG,KAAK,CAA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AAC,GAAG,CAAC,OAAO,CAAC,CAAC;AACxC;AACA,IAAI,OAAO,IAAI,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,KAAK,EAAE,CAAC;AAC7C,CAAC;AACD;AACA;AACA;AACA;AACA;AACY,MAAC,OAAO,GAAGE,UAAc;AACrC;AACA;AACY,MAAC,WAAW,IAAI,WAAW;AACvC,IAAI,OAAOC,sBAAW,CAAC,IAAI,CAAC;AAC5B,CAAC,EAAE,EAAE;AACL;AACA;AACA;AACY,MAAC,MAAM,IAAI,WAAW;AAClC,IAAI;AACJ,QAAQ,KAAK,GAAG,EAAE,CAAC;AACnB;AACA,IAAI,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,UAAU,EAAE;AAC7C,QAAQ,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AACpC,KAAK;AACL;AACA,IAAI,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE;AACjD,QAAQ,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;AAC3B,KAAK;AACL;AACA,IAAI,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,UAAU,EAAE;AAC7C,QAAQ,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC7B,KAAK;AACL;AACA,IAAI,OAAO,KAAK,CAAC;AACjB,CAAC,EAAE,EAAE;AACL;AACY,MAAC,iBAAiB,GAAG,oBAAoB,GAAG;AACxD;AACY,MAAC,qBAAqB,GAAG,wBAAwB;;;;;;;;;;"} \ No newline at end of file diff --git a/dist/espree.d.ts b/dist/espree.d.ts new file mode 100644 index 00000000..543ae9b7 --- /dev/null +++ b/dist/espree.d.ts @@ -0,0 +1,41 @@ +/** + * Tokenizes the given code. + * @param {string} code The code to tokenize. + * @param {ParserOptions} options Options defining how to tokenize. + * @returns {import('acorn').Token[] | null} An array of tokens. + * @throws {import('./lib/espree').EnhancedSyntaxError} If the input code is invalid. + * @private + */ +export function tokenize(code: string, options: ParserOptions): import('acorn').Token[] | null; +/** + * Parses the given code. + * @param {string} code The code to tokenize. + * @param {ParserOptions} options Options defining how to tokenize. + * @returns {import('acorn').Node} The "Program" AST node. + * @throws {import('./lib/espree').EnhancedSyntaxError} If the input code is invalid. + */ +export function parse(code: string, options: ParserOptions): import('acorn').Node; +export const version: "main"; +export const VisitorKeys: visitorKeys.VisitorKeys; +export const Syntax: { + [x: string]: string; +}; +export const latestEcmaVersion: number; +export const supportedEcmaVersions: number[]; +export type ParserOptions = { + allowReserved?: boolean; + ecmaVersion?: import('acorn').ecmaVersion; + sourceType?: "script" | "module" | "commonjs"; + ecmaFeatures?: { + jsx?: boolean; + globalReturn?: boolean; + impliedStrict?: boolean; + }; + range?: boolean; + loc?: boolean; + tokens?: boolean | null; + comment?: boolean; +}; +import * as visitorKeys from "eslint-visitor-keys"; +import jsx from "acorn-jsx"; +//# sourceMappingURL=espree.d.ts.map \ No newline at end of file diff --git a/dist/espree.d.ts.map b/dist/espree.d.ts.map new file mode 100644 index 00000000..8e458c43 --- /dev/null +++ b/dist/espree.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"espree.d.ts","sourceRoot":"","sources":["../tmp/espree.js"],"names":[],"mappings":"AAgHA;;;;;;;GAOG;AACH,+BANW,MAAM,WACN,aAAa,GACX,OAAO,OAAO,EAAE,KAAK,EAAE,GAAG,IAAI,CAU1C;AAED;;;;;;GAMG;AACH,4BALW,MAAM,WACN,aAAa,GACX,OAAO,OAAO,EAAE,IAAI,CAMhC;AACD,6BAAqC;AACrC,kDAEI;AACJ;;EAYI;AACJ,uCAAwD;AACxD,6CAAgE;4BAlGnD;IAAC,aAAa,CAAC,EAAE,OAAO,CAAC;IAAC,WAAW,CAAC,EAAE,OAAO,OAAO,EAAE,WAAW,CAAC;IAAC,UAAU,CAAC,EAAE,QAAQ,GAAG,QAAQ,GAAG,UAAU,CAAC;IAAC,YAAY,CAAC,EAAE;QAAC,GAAG,CAAC,EAAE,OAAO,CAAC;QAAC,YAAY,CAAC,EAAE,OAAO,CAAC;QAAC,aAAa,CAAC,EAAE,OAAO,CAAA;KAAC,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IAAC,GAAG,CAAC,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAC"} \ No newline at end of file diff --git a/dist/lib/espree.d.ts b/dist/lib/espree.d.ts new file mode 100644 index 00000000..e1f2868c --- /dev/null +++ b/dist/lib/espree.d.ts @@ -0,0 +1,75 @@ +declare function _default(): (Parser: typeof import('acorn-jsx').AcornJsxParser) => typeof EspreeParser; +export default _default; +export class EspreeParser extends acorn.Parser { + /** + * Adapted parser for Espree. + * @param {import('../espree').ParserOptions | null} opts Espree options + * @param {string | object} code The source code + */ + constructor(opts: import('../espree').ParserOptions | null, code: string | object); + /** + * Returns Espree tokens. + * @returns {{comments?: {type: string; value: string; range?: [number, number]; start?: number; end?: number; loc?: {start: import('acorn').Position | undefined; end: import('acorn').Position | undefined}}[]} & import('acorn').Token[] | null} Espree tokens + */ + tokenize(): { + comments?: { + type: string; + value: string; + range?: [number, number]; + start?: number; + end?: number; + loc?: { + start: import('acorn').Position | undefined; + end: import('acorn').Position | undefined; + }; + }[]; + } & import('acorn').Token[] | null; + /** + * Parses. + * @returns {{sourceType?: "script" | "module" | "commonjs"; comments?: {type: string; value: string; range?: [number, number]; start?: number; end?: number; loc?: {start: import('acorn').Position | undefined; end: import('acorn').Position | undefined}}[]; tokens?: import('acorn').Token[]; body: import('acorn').Node[]} & import('acorn').Node} The program Node + */ + parse(): { + sourceType?: "script" | "module" | "commonjs"; + comments?: { + type: string; + value: string; + range?: [number, number]; + start?: number; + end?: number; + loc?: { + start: import('acorn').Position | undefined; + end: import('acorn').Position | undefined; + }; + }[]; + tokens?: import('acorn').Token[]; + body: import('acorn').Node[]; + } & import('acorn').Node; + /** + * Overwrites the default raise method to throw Esprima-style errors. + * @param {number} pos The position of the error. + * @param {string} message The error message. + * @throws {EnhancedSyntaxError} A syntax error. + * @returns {void} + */ + raiseRecoverable(pos: number, message: string): void; + /** + * Esprima-FB represents JSX strings as tokens called "JSXText", but Acorn-JSX + * uses regular tt.string without any distinction between this and regular JS + * strings. As such, we intercept an attempt to read a JSX string and set a flag + * on extra so that when tokens are converted, the next token will be switched + * to JSXText via onToken. + * @param {number} quote A character code + * @returns {void} + */ + jsx_readString(quote: number): void; +} +export type EnhancedSyntaxError = { + index?: number; + lineNumber?: number; + column?: number; +} & SyntaxError; +export type EnhancedTokTypes = { + jsxAttrValueToken?: import('acorn').TokenType; +} & typeof import('acorn-jsx').tokTypes; +import * as acorn from "acorn"; +//# sourceMappingURL=espree.d.ts.map \ No newline at end of file diff --git a/dist/lib/espree.d.ts.map b/dist/lib/espree.d.ts.map new file mode 100644 index 00000000..3be68e3d --- /dev/null +++ b/dist/lib/espree.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"espree.d.ts","sourceRoot":"","sources":["../../tmp/lib/espree.js"],"names":[],"mappings":"AAgDe,sCAIA,cAAc,WAAW,EAAE,cAAc,KACvC,mBAAmB,CA+QnC;;AACD;IAEY;;;;OAIG;IACH,kBAHW,OAAO,WAAW,EAAE,aAAa,GAAG,IAAI,QACxC,MAAM,GAAG,MAAM,EAIjC;IAEO;;;OAGG;IACH,YAFa;QAAC,QAAQ,CAAC,EAAE;YAAC,IAAI,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE,MAAM,CAAC;YAAC,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;YAAC,KAAK,CAAC,EAAE,MAAM,CAAC;YAAC,GAAG,CAAC,EAAE,MAAM,CAAC;YAAC,GAAG,CAAC,EAAE;gBAAC,KAAK,EAAE,OAAO,OAAO,EAAE,QAAQ,GAAG,SAAS,CAAC;gBAAC,GAAG,EAAE,OAAO,OAAO,EAAE,QAAQ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token-translator.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"token-translator.d.ts","sourceRoot":"","sources":["../../tmp/lib/token-translator.js"],"names":[],"mappings":";AA+DA;IAEI;;;;;OAKG;IACH,2BAJW,OAAO,eAAe,EAAE,gBAAgB,QACxC,MAAM,EAQhB;IAJG,yDAAmC;IAC3B,wCAAwC,CAAC,SAA9B,CAAC,OAAO,OAAO,EAAE,KAAK,CAAC,EAAE,CAAsB;IAClE,0CAAuB;IACvB,cAAiB;IAGrB;;;;;;;OAOG;IACH,iBAJW,OAAO,OAAO,EAAE,KAAK,SACrB;QAAC,iBAAiB,EAAE,OAAO,CAAC;QAAC,WAAW,EAAE,OAAO,OAAO,EAAE,WAAW,CAAA;KAAC;cAC7D,MAAM;;eAAY,GAAG;;;;;;mBAAgH,MAAM;qBAAW,MAAM;;MAkD/K;IAED;;;;;OAKG;IACH,eAJW,OAAO,OAAO,EAAE,KAAK;gBACZ,CAAC;YAAC,IAAI,EAAE,MAAM,GAAG,OAAO,OAAO,EAAE,SAAS,CAAA;SAAC,GAAG;YAAC,KAAK,EAAE,GAAG,CAAC;YAAC,KAAK,CAAC,EAAE,MAAM,CAAC;YAAC,GAAG,CAAC,EAAE,MAAM,CAAC;YAAC,GAAG,CAAC,EAAE,OAAO,OAAO,EAAE,cAAc,CAAC;YAAC,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;YAAC,KAAK,CAAC,EAAE;gBAAC,KAAK,EAAE,MAAM,CAAC;gBAAC,OAAO,EAAE,MAAM,CAAA;aAAC,CAAA;SAAC,CAAC,EAAE;;2BAAwB,OAAO;qBAAe,OAAO,OAAO,EAAE,WAAW;QACrR,IAAI,CAyDhB;CACJ"} \ No newline at end of file diff --git a/espree.js b/espree.js index da4e3953..84683b8b 100644 --- a/espree.js +++ b/espree.js @@ -72,6 +72,8 @@ * `ecmaFeatures`, `range`, `loc`, `tokens` are not in `acorn.Options` * * `comment` is not in `acorn.Options` and doesn't err without it, but is used + */ +/** * @typedef {{ * allowReserved?: boolean, * ecmaVersion?: acorn.ecmaVersion, diff --git a/lib/espree.js b/lib/espree.js index 57cb1c80..d0ff4ecc 100644 --- a/lib/espree.js +++ b/lib/espree.js @@ -15,8 +15,9 @@ const ESPRIMA_FINISH_NODE = Symbol("espree's esprimaFinishNode"); * column?: number; * } & SyntaxError} EnhancedSyntaxError */ + +// We add `jsxAttrValueToken` ourselves. /** - * We add `jsxAttrValueToken` ourselves. * @typedef {{ * jsxAttrValueToken?: acorn.TokenType; * } & tokTypesType} EnhancedTokTypes @@ -50,9 +51,12 @@ const ESPRIMA_FINISH_NODE = Symbol("espree's esprimaFinishNode"); * @local * @typedef {number} int */ + +/** + * First three properties as in `acorn.Comment`; next two as in `acorn.Comment` + * but optional. Last is different as has to allow `undefined` + */ /** - * First three properties as in `acorn.Comment`; next two as in `acorn.Comment` - * but optional. Last is different as has to allow `undefined` * @local * * @typedef {{ diff --git a/lib/token-translator.js b/lib/token-translator.js index ec0747f8..a4585691 100644 --- a/lib/token-translator.js +++ b/lib/token-translator.js @@ -29,6 +29,8 @@ * `loc` and `range` are from `acorn.Token` * * Adds `regex`. + */ +/** * @local * * @typedef {{