diff --git a/espree.js b/espree.js index fa664b84..2615112c 100644 --- a/espree.js +++ b/espree.js @@ -68,6 +68,7 @@ import { getLatestEcmaVersion, getSupportedEcmaVersions } from "./lib/options.js * @typedef {import("./lib/options").ParserOptions} ParserOptions * @typedef {import("./lib/token-translator").EsprimaToken} EsprimaToken * @typedef {import("./lib/token-translator").TokenRange} TokenRange + * @typedef {import("@types/estree").Program} Program */ @@ -131,8 +132,8 @@ export function tokenize(code, options) { /** * 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. + * @param {ParserOptions} options Options defining how to parse. + * @returns {Program} The "Program" AST node. * @throws {SyntaxError} If the input code is invalid. */ export function parse(code, options) { diff --git a/lib/espree.js b/lib/espree.js index 53a4130b..467aca66 100644 --- a/lib/espree.js +++ b/lib/espree.js @@ -5,7 +5,8 @@ import { normalizeOptions } from "./options.js"; /** * @typedef {import("acorn")} acorn - * @typedef {import("./token-translator").TokenRange} TokenRange + * @typedef {import("./token-translator").Range} Range + * @typedef {import("./token-translator").Location} Location */ const STATE = Symbol("espree's internal state"); @@ -15,11 +16,10 @@ const ESPRIMA_FINISH_NODE = Symbol("espree's esprimaFinishNode"); * @typedef {Object} EsprimaComment * @property {"Block"|"Line"} type Type of the comment, can either be "Block" (multiline) or "Line" (single line). * @property {string} text Contents of the comment. - * @property {number|undefined} start Start column of a comment. - * @property {number|undefined} end End column of the comment. - * @property {TokenRange|undefined} range The [start, end] range of a comment. - * @property {acorn.Position} startLoc Start location of the comment. - * @property {acorn.Position} endLoc End location of the comment. + * @property {number|undefined} start Start index of the comment in source code. + * @property {number|undefined} end End index of the comment in source code. + * @property {Range|undefined} range The [start, end] range of a comment. + * @property {Location} loc Location of the comment. */ /** diff --git a/lib/token-translator.js b/lib/token-translator.js index 97b42ae1..c9e4e922 100644 --- a/lib/token-translator.js +++ b/lib/token-translator.js @@ -25,7 +25,7 @@ */ /** - * @typedef {[number, number]} TokenRange + * @typedef {[number, number]} Range */ /** @@ -33,9 +33,9 @@ * @property {string} type The type of this token. * @property {string} value The string content of the token. * @property {Location|undefined} loc Location in source text. - * @property {number|undefined} start start column. - * @property {number|undefined} end end column. - * @property {TokenRange|undefined} range [start, end] range + * @property {number|undefined} start start index of the token in source code. + * @property {number|undefined} end end index of the token in source code. + * @property {Range|undefined} range [start, end] range */ // Esprima Token Types diff --git a/package.json b/package.json index 7be2943e..6273d49e 100644 --- a/package.json +++ b/package.json @@ -33,14 +33,15 @@ }, "license": "BSD-2-Clause", "dependencies": { - "acorn": "^8.7.0", - "acorn-jsx": "^5.3.1", + "acorn": "^8.7.1", + "acorn-jsx": "^5.3.2", "eslint-visitor-keys": "^3.3.0" }, "devDependencies": { "@rollup/plugin-commonjs": "^17.1.0", "@rollup/plugin-json": "^4.1.0", "@rollup/plugin-node-resolve": "^11.2.0", + "@types/estree": "^0.0.51", "c8": "^7.11.0", "chai": "^4.3.4", "eslint": "^7.22.0",