-
-
Notifications
You must be signed in to change notification settings - Fork 195
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: move notes on types out of typedef blocks
- Loading branch information
Showing
10 changed files
with
1,368 additions
and
3 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,8 @@ | |
* `loc` and `range` are from `acorn.Token` | ||
* | ||
* Adds `regex`. | ||
*/ | ||
/** | ||
* @local | ||
* | ||
* @typedef {{ | ||
|