@vue-vine/eslint-parser
Version:
ESLint parser for Vue Vine
905 lines (904 loc) • 32.7 kB
TypeScript
import { ParserOptions, parseForESLint as parseForESLint$1 } from "@typescript-eslint/parser";
import { ScopeManager } from "eslint-scope";
import { TSESTree } from "@typescript-eslint/typescript-estree";
import { ESLint, Linter } from "eslint";
import { TSESTree as TSESTree$1 } from "@typescript-eslint/types";
//#region src/ast/errors.d.ts
/**
* HTML parse errors.
*/
declare class ParseError extends SyntaxError {
code?: ErrorCode;
index: number;
lineNumber: number;
column: number;
/**
* Create new parser error object.
* @param code The error code. See also: https://html.spec.whatwg.org/multipage/parsing.html#parse-errors
* @param offset The offset number of this error.
* @param line The line number of this error.
* @param column The column number of this error.
*/
static fromCode(code: ErrorCode, offset: number, line: number, column: number): ParseError;
/**
* Normalize the error object.
* @param x The error object to normalize.
*/
static normalize(x: any): ParseError | null;
/**
* Initialize this ParseError instance.
* @param message The error message.
* @param code The error code. See also: https://html.spec.whatwg.org/multipage/parsing.html#parse-errors
* @param offset The offset number of this error.
* @param line The line number of this error.
* @param column The column number of this error.
*/
constructor(message: string, code: ErrorCode | undefined, offset: number, line: number, column: number);
/**
* Type guard for ParseError.
* @param x The value to check.
* @returns `true` if the value has `message`, `pos`, `loc` properties.
*/
static isParseError(x: any): x is ParseError;
}
/**
* The error codes of HTML syntax errors.
* https://html.spec.whatwg.org/multipage/parsing.html#parse-errors
*/
type ErrorCode = "abrupt-closing-of-empty-comment" | "absence-of-digits-in-numeric-character-reference" | "cdata-in-html-content" | "character-reference-outside-unicode-range" | "control-character-in-input-stream" | "control-character-reference" | "eof-before-tag-name" | "eof-in-cdata" | "eof-in-comment" | "eof-in-tag" | "incorrectly-closed-comment" | "incorrectly-opened-comment" | "invalid-first-character-of-tag-name" | "missing-attribute-value" | "missing-end-tag-name" | "missing-semicolon-after-character-reference" | "missing-whitespace-between-attributes" | "nested-comment" | "noncharacter-character-reference" | "noncharacter-in-input-stream" | "null-character-reference" | "surrogate-character-reference" | "surrogate-in-input-stream" | "unexpected-character-in-attribute-name" | "unexpected-character-in-unquoted-attribute-value" | "unexpected-equals-sign-before-attribute-name" | "unexpected-null-character" | "unexpected-question-mark-instead-of-tag-name" | "unexpected-solidus-in-tag" | "unknown-named-character-reference" | "end-tag-with-attributes" | "duplicate-attribute" | "end-tag-with-trailing-solidus" | "non-void-html-element-start-tag-with-trailing-solidus" | "x-invalid-end-tag" | "x-invalid-namespace" | "x-missing-interpolation-end";
//#endregion
//#region src/ast/locations.d.ts
/**
* Location information in lines and columns.
*/
interface Location {
/**
* The line number. This is 1-based.
*/
line: number;
/**
* The column number. This is 0-based.
*/
column: number;
}
/**
* Range information in lines and columns.
*/
interface LocationRange {
/**
* The start location.
*/
start: Location;
/**
* The end location.
*/
end: Location;
}
/**
* Location information in offsets.
* This is 0-based.
*/
type Offset = number;
/**
* Range information in offsets.
* The 1st element is the start offset.
* The 2nd element is the end offset.
*
* This is 0-based.
*/
type OffsetRange = [Offset, Offset];
/**
* Objects which have their location.
*/
interface HasLocation {
range: OffsetRange;
loc: LocationRange;
start?: number;
end?: number;
}
//#endregion
//#region src/ast/tokens.d.ts
/**
* Tokens.
*/
interface Token extends HasLocation {
/**
* Token types.
*/
type: string;
/**
* Processed values.
*/
value: string;
}
//#endregion
//#region src/ast/nodes.d.ts
// ------------------------------------------------------------------------------
// Common
// ------------------------------------------------------------------------------
/**
* Objects which have their parent.
*/
interface HasParent {
parent?: Node | null;
}
/**
* The union type for all nodes.
*/
type Node = ESLintNode | VNode | VForExpression | VOnExpression | VSlotScopeExpression | VFilterSequenceExpression | VFilter;
/**
* The union type for all template nodes.
*/
type VTemplateNode = VNode | VForExpression | VOnExpression | VSlotScopeExpression | VFilterSequenceExpression | VFilter;
// ------------------------------------------------------------------------------
// Script
// ------------------------------------------------------------------------------
/**
* The union type for ESLint nodes.
*/
type ESLintNode = ESLintIdentifier | ESLintLiteral | ESLintProgram | ESLintSwitchCase | ESLintCatchClause | ESLintVariableDeclarator | ESLintStatement | ESLintExpression | ESLintProperty | ESLintAssignmentProperty | ESLintSuper | ESLintTemplateElement | ESLintSpreadElement | ESLintPattern | ESLintClassBody | ESLintMethodDefinition | ESLintPropertyDefinition | ESLintStaticBlock | ESLintPrivateIdentifier | ESLintModuleDeclaration | ESLintModuleSpecifier | ESLintImportExpression | ESLintLegacyRestProperty;
/**
* The parsing result of ESLint custom parsers.
*/
interface ESLintExtendedProgram {
ast: ESLintProgram;
services?: Record<string, unknown>;
visitorKeys?: {
[type: string]: string[];
};
scopeManager?: ScopeManager;
}
interface ESLintProgram extends HasLocation, HasParent {
type: "Program";
sourceType: "script" | "module";
body: (ESLintStatement | ESLintModuleDeclaration)[];
templateBody?: VElement & HasConcreteInfo;
tokens?: Token[];
comments?: Token[];
errors?: ParseError[];
}
type ESLintStatement = ESLintExpressionStatement | ESLintDirective | ESLintBlockStatement | ESLintEmptyStatement | ESLintDebuggerStatement | ESLintWithStatement | ESLintReturnStatement | ESLintLabeledStatement | ESLintBreakStatement | ESLintContinueStatement | ESLintIfStatement | ESLintSwitchStatement | ESLintThrowStatement | ESLintTryStatement | ESLintWhileStatement | ESLintDoWhileStatement | ESLintForStatement | ESLintForInStatement | ESLintForOfStatement | ESLintDeclaration;
interface ESLintEmptyStatement extends HasLocation, HasParent {
type: "EmptyStatement";
}
interface ESLintBlockStatement extends HasLocation, HasParent {
type: "BlockStatement";
body: ESLintStatement[];
}
interface ESLintExpressionStatement extends HasLocation, HasParent {
type: "ExpressionStatement";
expression: ESLintExpression;
}
interface ESLintDirective extends HasLocation, HasParent {
type: "ExpressionStatement";
expression: ESLintLiteral;
directive: string;
}
interface ESLintIfStatement extends HasLocation, HasParent {
type: "IfStatement";
test: ESLintExpression;
consequent: ESLintStatement;
alternate: ESLintStatement | null;
}
interface ESLintSwitchStatement extends HasLocation, HasParent {
type: "SwitchStatement";
discriminant: ESLintExpression;
cases: ESLintSwitchCase[];
}
interface ESLintSwitchCase extends HasLocation, HasParent {
type: "SwitchCase";
test: ESLintExpression | null;
consequent: ESLintStatement[];
}
interface ESLintWhileStatement extends HasLocation, HasParent {
type: "WhileStatement";
test: ESLintExpression;
body: ESLintStatement;
}
interface ESLintDoWhileStatement extends HasLocation, HasParent {
type: "DoWhileStatement";
body: ESLintStatement;
test: ESLintExpression;
}
interface ESLintForStatement extends HasLocation, HasParent {
type: "ForStatement";
init: ESLintVariableDeclaration | ESLintExpression | null;
test: ESLintExpression | null;
update: ESLintExpression | null;
body: ESLintStatement;
}
interface ESLintForInStatement extends HasLocation, HasParent {
type: "ForInStatement";
left: ESLintVariableDeclaration | ESLintPattern;
right: ESLintExpression;
body: ESLintStatement;
}
interface ESLintForOfStatement extends HasLocation, HasParent {
type: "ForOfStatement";
left: ESLintVariableDeclaration | ESLintPattern;
right: ESLintExpression;
body: ESLintStatement;
await: boolean;
}
interface ESLintLabeledStatement extends HasLocation, HasParent {
type: "LabeledStatement";
label: ESLintIdentifier;
body: ESLintStatement;
}
interface ESLintBreakStatement extends HasLocation, HasParent {
type: "BreakStatement";
label: ESLintIdentifier | null;
}
interface ESLintContinueStatement extends HasLocation, HasParent {
type: "ContinueStatement";
label: ESLintIdentifier | null;
}
interface ESLintReturnStatement extends HasLocation, HasParent {
type: "ReturnStatement";
argument: ESLintExpression | null;
}
interface ESLintThrowStatement extends HasLocation, HasParent {
type: "ThrowStatement";
argument: ESLintExpression;
}
interface ESLintTryStatement extends HasLocation, HasParent {
type: "TryStatement";
block: ESLintBlockStatement;
handler: ESLintCatchClause | null;
finalizer: ESLintBlockStatement | null;
}
interface ESLintCatchClause extends HasLocation, HasParent {
type: "CatchClause";
param: ESLintPattern | null;
body: ESLintBlockStatement;
}
interface ESLintWithStatement extends HasLocation, HasParent {
type: "WithStatement";
object: ESLintExpression;
body: ESLintStatement;
}
interface ESLintDebuggerStatement extends HasLocation, HasParent {
type: "DebuggerStatement";
}
type ESLintDeclaration = ESLintFunctionDeclaration | ESLintVariableDeclaration | ESLintClassDeclaration;
interface ESLintFunctionDeclaration extends HasLocation, HasParent {
type: "FunctionDeclaration";
async: boolean;
generator: boolean;
id: ESLintIdentifier | null;
params: ESLintPattern[];
body: ESLintBlockStatement;
}
interface ESLintVariableDeclaration extends HasLocation, HasParent {
type: "VariableDeclaration";
kind: "var" | "let" | "const";
declarations: ESLintVariableDeclarator[];
}
interface ESLintVariableDeclarator extends HasLocation, HasParent {
type: "VariableDeclarator";
id: ESLintPattern;
init: ESLintExpression | null;
}
interface ESLintClassDeclaration extends HasLocation, HasParent {
type: "ClassDeclaration";
id: ESLintIdentifier | null;
superClass: ESLintExpression | null;
body: ESLintClassBody;
}
interface ESLintClassBody extends HasLocation, HasParent {
type: "ClassBody";
body: (ESLintMethodDefinition | ESLintPropertyDefinition | ESLintStaticBlock)[];
}
interface ESLintMethodDefinition extends HasLocation, HasParent {
type: "MethodDefinition";
kind: "constructor" | "method" | "get" | "set";
computed: boolean;
static: boolean;
key: ESLintExpression | ESLintPrivateIdentifier;
value: ESLintFunctionExpression;
}
interface ESLintPropertyDefinition extends HasLocation, HasParent {
type: "PropertyDefinition";
computed: boolean;
static: boolean;
key: ESLintExpression | ESLintPrivateIdentifier;
value: ESLintExpression | null;
}
interface ESLintStaticBlock extends HasLocation, HasParent, Omit<ESLintBlockStatement, "type"> {
type: "StaticBlock";
body: ESLintStatement[];
}
interface ESLintPrivateIdentifier extends HasLocation, HasParent {
type: "PrivateIdentifier";
name: string;
}
type ESLintModuleDeclaration = ESLintImportDeclaration | ESLintExportNamedDeclaration | ESLintExportDefaultDeclaration | ESLintExportAllDeclaration;
type ESLintModuleSpecifier = ESLintImportSpecifier | ESLintImportDefaultSpecifier | ESLintImportNamespaceSpecifier | ESLintExportSpecifier;
interface ESLintImportDeclaration extends HasLocation, HasParent {
type: "ImportDeclaration";
specifiers: (ESLintImportSpecifier | ESLintImportDefaultSpecifier | ESLintImportNamespaceSpecifier)[];
source: ESLintLiteral;
}
interface ESLintImportSpecifier extends HasLocation, HasParent {
type: "ImportSpecifier";
imported: ESLintIdentifier | ESLintStringLiteral;
local: ESLintIdentifier;
}
interface ESLintImportDefaultSpecifier extends HasLocation, HasParent {
type: "ImportDefaultSpecifier";
local: ESLintIdentifier;
}
interface ESLintImportNamespaceSpecifier extends HasLocation, HasParent {
type: "ImportNamespaceSpecifier";
local: ESLintIdentifier;
}
interface ESLintImportExpression extends HasLocation, HasParent {
type: "ImportExpression";
source: ESLintExpression;
}
interface ESLintExportNamedDeclaration extends HasLocation, HasParent {
type: "ExportNamedDeclaration";
declaration?: ESLintDeclaration | null;
specifiers: ESLintExportSpecifier[];
source?: ESLintLiteral | null;
}
interface ESLintExportSpecifier extends HasLocation, HasParent {
type: "ExportSpecifier";
local: ESLintIdentifier | ESLintStringLiteral;
exported: ESLintIdentifier | ESLintStringLiteral;
}
interface ESLintExportDefaultDeclaration extends HasLocation, HasParent {
type: "ExportDefaultDeclaration";
declaration: ESLintDeclaration | ESLintExpression;
}
interface ESLintExportAllDeclaration extends HasLocation, HasParent {
type: "ExportAllDeclaration";
exported: ESLintIdentifier | ESLintStringLiteral | null;
source: ESLintLiteral;
}
type ESLintExpression = ESLintThisExpression | ESLintArrayExpression | ESLintObjectExpression | ESLintFunctionExpression | ESLintArrowFunctionExpression | ESLintYieldExpression | ESLintLiteral | ESLintUnaryExpression | ESLintUpdateExpression | ESLintBinaryExpression | ESLintAssignmentExpression | ESLintLogicalExpression | ESLintMemberExpression | ESLintConditionalExpression | ESLintCallExpression | ESLintNewExpression | ESLintSequenceExpression | ESLintTemplateLiteral | ESLintTaggedTemplateExpression | ESLintClassExpression | ESLintMetaProperty | ESLintIdentifier | ESLintAwaitExpression | ESLintChainExpression;
interface ESLintIdentifier extends HasLocation, HasParent {
type: "Identifier";
name: string;
}
interface ESLintLiteralBase extends HasLocation, HasParent {
type: "Literal";
value: string | boolean | null | number | RegExp | bigint;
raw: string;
regex?: {
pattern: string;
flags: string;
};
bigint?: string;
}
interface ESLintStringLiteral extends ESLintLiteralBase {
value: string;
regex?: undefined;
bigint?: undefined;
}
interface ESLintBooleanLiteral extends ESLintLiteralBase {
value: boolean;
regex?: undefined;
bigint?: undefined;
}
interface ESLintNullLiteral extends ESLintLiteralBase {
value: null;
regex?: undefined;
bigint?: undefined;
}
interface ESLintNumberLiteral extends ESLintLiteralBase {
value: number;
regex?: undefined;
bigint?: undefined;
}
interface ESLintRegExpLiteral extends ESLintLiteralBase {
value: null | RegExp;
regex: {
pattern: string;
flags: string;
};
bigint?: undefined;
}
interface ESLintBigIntLiteral extends ESLintLiteralBase {
value: null | bigint;
regex?: undefined;
bigint: string;
}
type ESLintLiteral = ESLintStringLiteral | ESLintBooleanLiteral | ESLintNullLiteral | ESLintNumberLiteral | ESLintRegExpLiteral | ESLintBigIntLiteral;
interface ESLintThisExpression extends HasLocation, HasParent {
type: "ThisExpression";
}
interface ESLintArrayExpression extends HasLocation, HasParent {
type: "ArrayExpression";
elements: (ESLintExpression | ESLintSpreadElement)[];
}
interface ESLintObjectExpression extends HasLocation, HasParent {
type: "ObjectExpression";
properties: (ESLintProperty | ESLintSpreadElement | ESLintLegacySpreadProperty)[];
}
interface ESLintProperty extends HasLocation, HasParent {
type: "Property";
kind: "init" | "get" | "set";
method: boolean;
shorthand: boolean;
computed: boolean;
key: ESLintExpression;
value: ESLintExpression | ESLintPattern;
}
interface ESLintFunctionExpression extends HasLocation, HasParent {
type: "FunctionExpression";
async: boolean;
generator: boolean;
id: ESLintIdentifier | null;
params: ESLintPattern[];
body: ESLintBlockStatement;
}
interface ESLintArrowFunctionExpression extends HasLocation, HasParent {
type: "ArrowFunctionExpression";
async: boolean;
generator: boolean;
id: ESLintIdentifier | null;
params: ESLintPattern[];
body: ESLintBlockStatement;
}
interface ESLintSequenceExpression extends HasLocation, HasParent {
type: "SequenceExpression";
expressions: ESLintExpression[];
}
interface ESLintUnaryExpression extends HasLocation, HasParent {
type: "UnaryExpression";
operator: "-" | "+" | "!" | "~" | "typeof" | "void" | "delete";
prefix: boolean;
argument: ESLintExpression;
}
interface ESLintBinaryExpression extends HasLocation, HasParent {
type: "BinaryExpression";
operator: "==" | "!=" | "===" | "!==" | "<" | "<=" | ">" | ">=" | "<<" | ">>" | ">>>" | "+" | "-" | "*" | "/" | "%" | "**" | "|" | "^" | "&" | "in" | "instanceof";
left: ESLintExpression | ESLintPrivateIdentifier;
right: ESLintExpression;
}
interface ESLintAssignmentExpression extends HasLocation, HasParent {
type: "AssignmentExpression";
operator: "=" | "+=" | "-=" | "*=" | "/=" | "%=" | "**=" | "<<=" | ">>=" | ">>>=" | "|=" | "^=" | "&=" | "||=" | "&&=" | "??=";
left: ESLintPattern;
right: ESLintExpression;
}
interface ESLintUpdateExpression extends HasLocation, HasParent {
type: "UpdateExpression";
operator: "++" | "--";
argument: ESLintExpression;
prefix: boolean;
}
interface ESLintLogicalExpression extends HasLocation, HasParent {
type: "LogicalExpression";
operator: "||" | "&&" | "??";
left: ESLintExpression;
right: ESLintExpression;
}
interface ESLintConditionalExpression extends HasLocation, HasParent {
type: "ConditionalExpression";
test: ESLintExpression;
alternate: ESLintExpression;
consequent: ESLintExpression;
}
interface ESLintCallExpression extends HasLocation, HasParent {
type: "CallExpression";
optional: boolean;
callee: ESLintExpression | ESLintSuper;
arguments: (ESLintExpression | ESLintSpreadElement)[];
}
interface ESLintSuper extends HasLocation, HasParent {
type: "Super";
}
interface ESLintNewExpression extends HasLocation, HasParent {
type: "NewExpression";
callee: ESLintExpression;
arguments: (ESLintExpression | ESLintSpreadElement)[];
}
interface ESLintMemberExpression extends HasLocation, HasParent {
type: "MemberExpression";
optional: boolean;
computed: boolean;
object: ESLintExpression | ESLintSuper;
property: ESLintExpression | ESLintPrivateIdentifier;
}
interface ESLintYieldExpression extends HasLocation, HasParent {
type: "YieldExpression";
delegate: boolean;
argument: ESLintExpression | null;
}
interface ESLintAwaitExpression extends HasLocation, HasParent {
type: "AwaitExpression";
argument: ESLintExpression;
}
interface ESLintTemplateLiteral extends HasLocation, HasParent {
type: "TemplateLiteral";
quasis: ESLintTemplateElement[];
expressions: ESLintExpression[];
}
interface ESLintTaggedTemplateExpression extends HasLocation, HasParent {
type: "TaggedTemplateExpression";
tag: ESLintExpression;
quasi: ESLintTemplateLiteral;
}
interface ESLintTemplateElement extends HasLocation, HasParent {
type: "TemplateElement";
tail: boolean;
value: {
cooked: string | null;
raw: string;
};
}
interface ESLintClassExpression extends HasLocation, HasParent {
type: "ClassExpression";
id: ESLintIdentifier | null;
superClass: ESLintExpression | null;
body: ESLintClassBody;
}
interface ESLintMetaProperty extends HasLocation, HasParent {
type: "MetaProperty";
meta: ESLintIdentifier;
property: ESLintIdentifier;
}
type ESLintPattern = ESLintIdentifier | ESLintObjectPattern | ESLintArrayPattern | ESLintRestElement | ESLintAssignmentPattern | ESLintMemberExpression | ESLintLegacyRestProperty;
interface ESLintObjectPattern extends HasLocation, HasParent {
type: "ObjectPattern";
properties: (ESLintAssignmentProperty | ESLintRestElement | ESLintLegacyRestProperty)[];
}
interface ESLintAssignmentProperty extends ESLintProperty {
value: ESLintPattern;
kind: "init";
method: false;
}
interface ESLintArrayPattern extends HasLocation, HasParent {
type: "ArrayPattern";
elements: ESLintPattern[];
}
interface ESLintRestElement extends HasLocation, HasParent {
type: "RestElement";
argument: ESLintPattern;
}
interface ESLintSpreadElement extends HasLocation, HasParent {
type: "SpreadElement";
argument: ESLintExpression;
}
interface ESLintAssignmentPattern extends HasLocation, HasParent {
type: "AssignmentPattern";
left: ESLintPattern;
right: ESLintExpression;
}
type ESLintChainElement = ESLintCallExpression | ESLintMemberExpression;
interface ESLintChainExpression extends HasLocation, HasParent {
type: "ChainExpression";
expression: ESLintChainElement;
}
/**
* Legacy for babel-eslint and espree.
*/
interface ESLintLegacyRestProperty extends HasLocation, HasParent {
type: "RestProperty" | "ExperimentalRestProperty";
argument: ESLintPattern;
}
/**
* Legacy for babel-eslint and espree.
*/
interface ESLintLegacySpreadProperty extends HasLocation, HasParent {
type: "SpreadProperty" | "ExperimentalSpreadProperty";
argument: ESLintExpression;
}
// ------------------------------------------------------------------------------
// Template
// ------------------------------------------------------------------------------
/**
* Constants of namespaces.
* @see https://infra.spec.whatwg.org/#namespaces
*/
declare const NS: Readonly<{
HTML: "http://www.w3.org/1999/xhtml";
MathML: "http://www.w3.org/1998/Math/MathML";
SVG: "http://www.w3.org/2000/svg";
XLink: "http://www.w3.org/1999/xlink";
XML: "http://www.w3.org/XML/1998/namespace";
XMLNS: "http://www.w3.org/2000/xmlns/";
}>;
/**
* Type of namespaces.
*/
type Namespace = typeof NS.HTML | typeof NS.MathML | typeof NS.SVG | typeof NS.XLink | typeof NS.XML | typeof NS.XMLNS;
/**
* Type of variable definitions.
*/
interface Variable {
id: ESLintIdentifier;
kind: "v-for" | "scope";
references: Reference[];
}
/**
* Type of variable references.
*/
interface Reference {
id: ESLintIdentifier;
mode: "rw" | "r" | "w";
variable: Variable | null;
// For typescript-eslint
isValueReference?: boolean;
isTypeReference?: boolean;
}
/**
* The node of `v-for` directives.
*/
interface VForExpression extends HasLocation, HasParent {
type: "VForExpression";
parent: VExpressionContainer;
left: ESLintPattern[];
right: ESLintExpression;
}
/**
* The node of `v-on` directives.
*/
interface VOnExpression extends HasLocation, HasParent {
type: "VOnExpression";
parent: VExpressionContainer;
body: ESLintStatement[];
}
/**
* The node of `slot-scope` directives.
*/
interface VSlotScopeExpression extends HasLocation, HasParent {
type: "VSlotScopeExpression";
parent: VExpressionContainer;
params: ESLintPattern[];
}
/**
* The node of a filter sequence which is separated by `|`.
*/
interface VFilterSequenceExpression extends HasLocation, HasParent {
type: "VFilterSequenceExpression";
parent: VExpressionContainer;
expression: ESLintExpression;
filters: VFilter[];
}
/**
* The node of a filter sequence which is separated by `|`.
*/
interface VFilter extends HasLocation, HasParent {
type: "VFilter";
parent: VFilterSequenceExpression;
callee: ESLintIdentifier;
arguments: (ESLintExpression | ESLintSpreadElement)[];
}
/**
* The union type of any nodes.
*/
type VNode = VAttribute | VDirective | VDirectiveKey | VTemplateRoot | VElement | VEndTag | VExpressionContainer | VIdentifier | VLiteral | VStartTag | VText;
type VExpression = ESLintExpression | VFilterSequenceExpression | VForExpression | VOnExpression | VSlotScopeExpression;
/**
* Text nodes.
*/
interface VText extends HasLocation, HasParent {
type: "VText";
parent: VTemplateRoot | VElement;
value: string;
}
/**
* The node of JavaScript expression in text.
* e.g. `{{ name }}`
*/
interface VExpressionContainer extends HasLocation, HasParent {
type: "VExpressionContainer";
parent: VTemplateRoot | VElement | VDirective | VDirectiveKey;
expression: VExpression | null;
references: Reference[];
}
/**
* Attribute name nodes.
*/
interface VIdentifier extends HasLocation, HasParent {
type: "VIdentifier";
parent: VAttribute | VDirectiveKey;
name: string;
rawName: string;
}
/**
* Attribute name nodes.
*/
interface VDirectiveKey extends HasLocation, HasParent {
type: "VDirectiveKey";
parent: VDirective;
name: VIdentifier;
argument: VExpressionContainer | VIdentifier | null;
modifiers: VIdentifier[];
}
/**
* Attribute value nodes.
*/
interface VLiteral extends HasLocation, HasParent {
type: "VLiteral";
parent: VAttribute;
value: string;
}
/**
* Static attribute nodes.
*/
interface VAttribute extends HasLocation, HasParent {
type: "VAttribute";
parent: VStartTag;
directive: false;
key: VIdentifier;
value: VLiteral | null;
}
/**
* Directive nodes.
*/
interface VDirective extends HasLocation, HasParent {
type: "VAttribute";
parent: VStartTag;
directive: true;
key: VDirectiveKey;
value: VExpressionContainer | null;
}
/**
* Start tag nodes.
*/
interface VStartTag extends HasLocation, HasParent {
type: "VStartTag";
parent: VElement;
selfClosing: boolean;
attributes: (VAttribute | VDirective)[];
}
/**
* End tag nodes.
*/
interface VEndTag extends HasLocation, HasParent {
type: "VEndTag";
parent: VElement;
}
/**
* The property which has concrete information.
*/
interface HasConcreteInfo {
tokens: Token[];
comments: Token[];
errors: ParseError[];
}
/**
* Element nodes.
*/
interface VElement extends HasLocation, HasParent {
type: "VElement";
parent: VTemplateRoot | VElement;
namespace: Namespace;
name: string;
rawName: string;
startTag: VStartTag;
children: (VElement | VText | VExpressionContainer)[];
endTag: VEndTag | null;
variables: Variable[];
}
/**
* Root nodes.
*/
interface VTemplateRoot extends HasLocation {
type: "VTemplateRoot";
parent: TSESTree$1.Node;
children: (VElement | VText | VExpressionContainer)[];
templateInfo?: PrettierType<Omit<FinalProcessTemplateInfo, "templateMeta" | "templateRootAST">>;
}
//#endregion
//#region src/ast/traverse.d.ts
// ------------------------------------------------------------------------------
// Helpers
// ------------------------------------------------------------------------------
interface VisitorKeys {
readonly [type: string]: readonly string[];
}
// Only export Vue template visitor keys, don't merge with standard ESLint keys
// to avoid overriding TypeScript visitor keys
declare const KEYS: VisitorKeys;
/**
* Get the keys of the given node to traverse it.
* @param node The node to get.
* @returns The keys to traverse.
*/
declare function getFallbackKeys(node: any): string[];
// ------------------------------------------------------------------------------
// Exports
// ------------------------------------------------------------------------------
interface Visitor {
visitorKeys?: VisitorKeys;
enterNode: (node: Node, parent: Node | null) => void;
leaveNode: (node: Node, parent: Node | null) => void;
}
/**
* Traverse the given AST tree.
* @param node Root node to traverse.
* @param visitor Visitor.
*/
declare function traverseNodes(node: Node, visitor: Visitor): void;
//#endregion
//#region src/common/parser-object.d.ts
/**
* The type of basic ESLint custom parser.
* e.g. espree
*/
interface BasicParserObject<R = ESLintProgram> {
parse: (code: string, options: any) => R;
parseForESLint: undefined;
}
/**
* The type of ESLint custom parser enhanced for ESLint.
* e.g. @babel/eslint-parser, @typescript-eslint/parser
*/
interface EnhancedParserObject<R = ESLintExtendedProgram> {
parseForESLint: (code: string, options: any) => R;
parse: undefined;
}
/**
* The type of ESLint (custom) parsers.
*/
type ParserObject<R1 = ESLintExtendedProgram, R2 = ESLintProgram> = EnhancedParserObject<R1> | BasicParserObject<R2>;
//#endregion
//#region src/template/utils/process-vine-template-node.d.ts
declare function prepareTemplate(templateNode: TSESTree.TaggedTemplateExpression): {
templatePositionInfo: VineTemplatePositionInfo;
templateRawContent: string;
};
//#endregion
//#region src/types.d.ts
type PrettierType<T> = { [K in keyof T]: T[K] } & {};
type TsESLintParseForESLint = ReturnType<typeof parseForESLint$1>;
interface ParseForESLintResult {
ast: ESLintProgram;
services: TsESLintParseForESLint["services"];
scopeManager: TsESLintParseForESLint["scopeManager"];
visitorKeys: TsESLintParseForESLint["visitorKeys"];
}
type VineESLintParserOptions = ParserOptions & {
// ...To be extended
parser?: boolean | string | ParserObject | Record<string, string | ParserObject | undefined>;
ecmaFeatures?: ParserOptions["ecmaFeatures"] & {
[key: string]: any;
};
sourceType?: "module" | "script";
};
interface VineTemplatePositionInfo {
templateStartLine: number;
templateStartColumn: number;
templateStartOffset: number;
templateEndOffset: number;
templateEndLine: number;
templateEndColumn: number;
}
interface VineTemplateMeta {
tokens: Token[];
comments: Token[];
errors: ParseError[];
}
type NeedFixToken = HasLocation & {
type: string;
};
interface VineFixLocationContext {
posInfo: VineTemplatePositionInfo;
fixedCache: WeakSet<Location | OffsetRange>;
}
declare enum ReferenceFlag {
Read = 1,
Write = 2,
ReadWrite = 3,
}
declare enum ReferenceTypeFlag {
Value = 1,
Type = 2,
}
type FinalProcessTemplateInfo = ReturnType<typeof prepareTemplate> & {
templateRootAST: VTemplateRoot;
templateMeta: VineTemplateMeta;
};
//#endregion
//#region src/index.d.ts
declare const meta: ESLint.ObjectMetaProperties;
declare function parse(code: string, parserOptions: VineESLintParserOptions): ParseForESLintResult["ast"];
declare function parseForESLint(code: string, parserOptions: VineESLintParserOptions): ParseForESLintResult;
declare const _default: Linter.Parser;
//#endregion
export { ESLintArrayExpression, ESLintArrayPattern, ESLintArrowFunctionExpression, ESLintAssignmentExpression, ESLintAssignmentPattern, ESLintAssignmentProperty, ESLintAwaitExpression, ESLintBigIntLiteral, ESLintBinaryExpression, ESLintBlockStatement, ESLintBooleanLiteral, ESLintBreakStatement, ESLintCallExpression, ESLintCatchClause, ESLintChainElement, ESLintChainExpression, ESLintClassBody, ESLintClassDeclaration, ESLintClassExpression, ESLintConditionalExpression, ESLintContinueStatement, ESLintDebuggerStatement, ESLintDeclaration, ESLintDirective, ESLintDoWhileStatement, ESLintEmptyStatement, ESLintExportAllDeclaration, ESLintExportDefaultDeclaration, ESLintExportNamedDeclaration, ESLintExportSpecifier, ESLintExpression, ESLintExpressionStatement, ESLintExtendedProgram, ESLintForInStatement, ESLintForOfStatement, ESLintForStatement, ESLintFunctionDeclaration, ESLintFunctionExpression, ESLintIdentifier, ESLintIfStatement, ESLintImportDeclaration, ESLintImportDefaultSpecifier, ESLintImportExpression, ESLintImportNamespaceSpecifier, ESLintImportSpecifier, ESLintLabeledStatement, ESLintLegacyRestProperty, ESLintLegacySpreadProperty, ESLintLiteral, ESLintLogicalExpression, ESLintMemberExpression, ESLintMetaProperty, ESLintMethodDefinition, ESLintModuleDeclaration, ESLintModuleSpecifier, ESLintNewExpression, ESLintNode, ESLintNullLiteral, ESLintNumberLiteral, ESLintObjectExpression, ESLintObjectPattern, ESLintPattern, ESLintPrivateIdentifier, ESLintProgram, ESLintProperty, ESLintPropertyDefinition, ESLintRegExpLiteral, ESLintRestElement, ESLintReturnStatement, ESLintSequenceExpression, ESLintSpreadElement, ESLintStatement, ESLintStaticBlock, ESLintStringLiteral, ESLintSuper, ESLintSwitchCase, ESLintSwitchStatement, ESLintTaggedTemplateExpression, ESLintTemplateElement, ESLintTemplateLiteral, ESLintThisExpression, ESLintThrowStatement, ESLintTryStatement, ESLintUnaryExpression, ESLintUpdateExpression, ESLintVariableDeclaration, ESLintVariableDeclarator, ESLintWhileStatement, ESLintWithStatement, ESLintYieldExpression, ErrorCode, FinalProcessTemplateInfo, HasConcreteInfo, HasLocation, HasParent, KEYS, Location, LocationRange, NS, Namespace, NeedFixToken, Node, Offset, OffsetRange, ParseError, ParseForESLintResult, PrettierType, Reference, ReferenceFlag, ReferenceTypeFlag, Token, TsESLintParseForESLint, VAttribute, VDirective, VDirectiveKey, VElement, VEndTag, VExpression, VExpressionContainer, VFilter, VFilterSequenceExpression, VForExpression, VIdentifier, VLiteral, VNode, VOnExpression, VSlotScopeExpression, VStartTag, VTemplateNode, VTemplateRoot, VText, Variable, VineESLintParserOptions, VineFixLocationContext, VineTemplateMeta, VineTemplatePositionInfo, Visitor, _default as default, getFallbackKeys, meta, parse, parseForESLint, traverseNodes };