@vue-vine/eslint-parser 0.1.31 → 0.1.33
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.d.mts +88 -30
- package/dist/index.d.ts +88 -30
- package/dist/index.js +38 -39
- package/dist/index.mjs +38 -39
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
-
import {
|
2
|
-
import { TSESTree } from '@typescript-eslint/types';
|
1
|
+
import { TSESTree as TSESTree$1 } from '@typescript-eslint/types';
|
3
2
|
import { ScopeManager } from 'eslint-scope';
|
3
|
+
import { ParserOptions, parseForESLint as parseForESLint$1 } from '@typescript-eslint/parser';
|
4
|
+
import { TSESTree } from '@typescript-eslint/typescript-estree';
|
5
|
+
import { VisitorKeys } from 'eslint-visitor-keys';
|
4
6
|
|
5
7
|
/**
|
6
8
|
* HTML parse errors.
|
@@ -94,6 +96,65 @@ interface HasLocation {
|
|
94
96
|
end?: number;
|
95
97
|
}
|
96
98
|
|
99
|
+
/**
|
100
|
+
* The type of basic ESLint custom parser.
|
101
|
+
* e.g. espree
|
102
|
+
*/
|
103
|
+
interface BasicParserObject<R = ESLintProgram> {
|
104
|
+
parse: (code: string, options: any) => R;
|
105
|
+
parseForESLint: undefined;
|
106
|
+
}
|
107
|
+
/**
|
108
|
+
* The type of ESLint custom parser enhanced for ESLint.
|
109
|
+
* e.g. @babel/eslint-parser, @typescript-eslint/parser
|
110
|
+
*/
|
111
|
+
interface EnhancedParserObject<R = ESLintExtendedProgram> {
|
112
|
+
parseForESLint: (code: string, options: any) => R;
|
113
|
+
parse: undefined;
|
114
|
+
}
|
115
|
+
/**
|
116
|
+
* The type of ESLint (custom) parsers.
|
117
|
+
*/
|
118
|
+
type ParserObject<R1 = ESLintExtendedProgram, R2 = ESLintProgram> = EnhancedParserObject<R1> | BasicParserObject<R2>;
|
119
|
+
|
120
|
+
declare function prepareTemplate(templateNode: TSESTree.TaggedTemplateExpression): {
|
121
|
+
templatePositionInfo: {
|
122
|
+
templateStartLine: number;
|
123
|
+
templateStartColumn: number;
|
124
|
+
templateStartOffset: number;
|
125
|
+
templateEndOffset: number;
|
126
|
+
templateEndLine: number;
|
127
|
+
templateEndColumn: number;
|
128
|
+
};
|
129
|
+
templateRawContent: string;
|
130
|
+
};
|
131
|
+
|
132
|
+
type PrettierType<T> = {
|
133
|
+
[K in keyof T]: T[K];
|
134
|
+
} & {};
|
135
|
+
type TsESLintParseForESLint = ReturnType<typeof parseForESLint$1>;
|
136
|
+
interface ParseForESLintResult {
|
137
|
+
ast: ESLintProgram;
|
138
|
+
services: TsESLintParseForESLint['services'];
|
139
|
+
scopeManager: TsESLintParseForESLint['scopeManager'];
|
140
|
+
visitorKeys: TsESLintParseForESLint['visitorKeys'];
|
141
|
+
}
|
142
|
+
type VineESLintParserOptions = ParserOptions & {
|
143
|
+
parser?: boolean | string | ParserObject | Record<string, string | ParserObject | undefined>;
|
144
|
+
ecmaFeatures?: ParserOptions['ecmaFeatures'] & {
|
145
|
+
[key: string]: any;
|
146
|
+
};
|
147
|
+
};
|
148
|
+
interface VineTemplateMeta {
|
149
|
+
tokens: Token[];
|
150
|
+
comments: Token[];
|
151
|
+
errors: ParseError[];
|
152
|
+
}
|
153
|
+
type FinalProcessTemplateInfo = ReturnType<typeof prepareTemplate> & {
|
154
|
+
templateRootAST: VTemplateRoot;
|
155
|
+
templateMeta: VineTemplateMeta;
|
156
|
+
};
|
157
|
+
|
97
158
|
/**
|
98
159
|
* Tokens.
|
99
160
|
*/
|
@@ -142,7 +203,7 @@ interface ESLintProgram extends HasLocation, HasParent {
|
|
142
203
|
comments?: Token[];
|
143
204
|
errors?: ParseError[];
|
144
205
|
}
|
145
|
-
type ESLintStatement = ESLintExpressionStatement | ESLintBlockStatement | ESLintEmptyStatement | ESLintDebuggerStatement | ESLintWithStatement | ESLintReturnStatement | ESLintLabeledStatement | ESLintBreakStatement | ESLintContinueStatement | ESLintIfStatement | ESLintSwitchStatement | ESLintThrowStatement | ESLintTryStatement | ESLintWhileStatement | ESLintDoWhileStatement | ESLintForStatement | ESLintForInStatement | ESLintForOfStatement | ESLintDeclaration;
|
206
|
+
type ESLintStatement = ESLintExpressionStatement | ESLintDirective | ESLintBlockStatement | ESLintEmptyStatement | ESLintDebuggerStatement | ESLintWithStatement | ESLintReturnStatement | ESLintLabeledStatement | ESLintBreakStatement | ESLintContinueStatement | ESLintIfStatement | ESLintSwitchStatement | ESLintThrowStatement | ESLintTryStatement | ESLintWhileStatement | ESLintDoWhileStatement | ESLintForStatement | ESLintForInStatement | ESLintForOfStatement | ESLintDeclaration;
|
146
207
|
interface ESLintEmptyStatement extends HasLocation, HasParent {
|
147
208
|
type: 'EmptyStatement';
|
148
209
|
}
|
@@ -154,6 +215,11 @@ interface ESLintExpressionStatement extends HasLocation, HasParent {
|
|
154
215
|
type: 'ExpressionStatement';
|
155
216
|
expression: ESLintExpression;
|
156
217
|
}
|
218
|
+
interface ESLintDirective extends HasLocation, HasParent {
|
219
|
+
type: 'ExpressionStatement';
|
220
|
+
expression: ESLintLiteral;
|
221
|
+
directive: string;
|
222
|
+
}
|
157
223
|
interface ESLintIfStatement extends HasLocation, HasParent {
|
158
224
|
type: 'IfStatement';
|
159
225
|
test: ESLintExpression;
|
@@ -755,41 +821,33 @@ interface VElement extends HasLocation, HasParent {
|
|
755
821
|
*/
|
756
822
|
interface VTemplateRoot extends HasLocation {
|
757
823
|
type: 'VTemplateRoot';
|
758
|
-
parent: TSESTree.Node;
|
824
|
+
parent: TSESTree$1.Node;
|
759
825
|
children: (VElement | VText | VExpressionContainer)[];
|
826
|
+
templateInfo?: PrettierType<Omit<FinalProcessTemplateInfo, 'templateMeta' | 'templateRootAST'>>;
|
760
827
|
}
|
761
828
|
|
829
|
+
declare const KEYS: {
|
830
|
+
readonly [type: string]: readonly string[];
|
831
|
+
};
|
762
832
|
/**
|
763
|
-
*
|
764
|
-
*
|
765
|
-
|
766
|
-
interface BasicParserObject<R = ESLintProgram> {
|
767
|
-
parse: (code: string, options: any) => R;
|
768
|
-
parseForESLint: undefined;
|
769
|
-
}
|
770
|
-
/**
|
771
|
-
* The type of ESLint custom parser enhanced for ESLint.
|
772
|
-
* e.g. @babel/eslint-parser, @typescript-eslint/parser
|
833
|
+
* Get the keys of the given node to traverse it.
|
834
|
+
* @param node The node to get.
|
835
|
+
* @returns The keys to traverse.
|
773
836
|
*/
|
774
|
-
|
775
|
-
|
776
|
-
|
837
|
+
declare function getFallbackKeys(node: Node): string[];
|
838
|
+
interface Visitor {
|
839
|
+
visitorKeys?: VisitorKeys;
|
840
|
+
enterNode: (node: Node, parent: Node | null) => void;
|
841
|
+
leaveNode: (node: Node, parent: Node | null) => void;
|
777
842
|
}
|
778
843
|
/**
|
779
|
-
*
|
844
|
+
* Traverse the given AST tree.
|
845
|
+
* @param node Root node to traverse.
|
846
|
+
* @param visitor Visitor.
|
780
847
|
*/
|
781
|
-
|
782
|
-
|
783
|
-
type VineESLintAST = TSESTree.Program;
|
784
|
-
type ParseForESLintResult = ReturnType<typeof parseForESLint$1>;
|
785
|
-
type VineESLintParserOptions = ParserOptions & {
|
786
|
-
parser?: boolean | string | ParserObject | Record<string, string | ParserObject | undefined>;
|
787
|
-
ecmaFeatures?: ParserOptions['ecmaFeatures'] & {
|
788
|
-
[key: string]: any;
|
789
|
-
};
|
790
|
-
};
|
848
|
+
declare function traverseNodes(node: Node, visitor: Visitor): void;
|
791
849
|
|
792
|
-
declare function parse(code: string, parserOptions: VineESLintParserOptions):
|
850
|
+
declare function parse(code: string, parserOptions: VineESLintParserOptions): ESLintProgram;
|
793
851
|
declare function parseForESLint(code: string, parserOptions: VineESLintParserOptions): ParseForESLintResult;
|
794
852
|
|
795
|
-
export { parse, parseForESLint };
|
853
|
+
export { type ESLintArrayExpression, type ESLintArrayPattern, type ESLintArrowFunctionExpression, type ESLintAssignmentExpression, type ESLintAssignmentPattern, type ESLintAssignmentProperty, type ESLintAwaitExpression, type ESLintBigIntLiteral, type ESLintBinaryExpression, type ESLintBlockStatement, type ESLintBooleanLiteral, type ESLintBreakStatement, type ESLintCallExpression, type ESLintCatchClause, type ESLintChainElement, type ESLintChainExpression, type ESLintClassBody, type ESLintClassDeclaration, type ESLintClassExpression, type ESLintConditionalExpression, type ESLintContinueStatement, type ESLintDebuggerStatement, type ESLintDeclaration, type ESLintDirective, type ESLintDoWhileStatement, type ESLintEmptyStatement, type ESLintExportAllDeclaration, type ESLintExportDefaultDeclaration, type ESLintExportNamedDeclaration, type ESLintExportSpecifier, type ESLintExpression, type ESLintExpressionStatement, type ESLintExtendedProgram, type ESLintForInStatement, type ESLintForOfStatement, type ESLintForStatement, type ESLintFunctionDeclaration, type ESLintFunctionExpression, type ESLintIdentifier, type ESLintIfStatement, type ESLintImportDeclaration, type ESLintImportDefaultSpecifier, type ESLintImportExpression, type ESLintImportNamespaceSpecifier, type ESLintImportSpecifier, type ESLintLabeledStatement, type ESLintLegacyRestProperty, type ESLintLegacySpreadProperty, type ESLintLiteral, type ESLintLogicalExpression, type ESLintMemberExpression, type ESLintMetaProperty, type ESLintMethodDefinition, type ESLintModuleDeclaration, type ESLintModuleSpecifier, type ESLintNewExpression, type ESLintNode, type ESLintNullLiteral, type ESLintNumberLiteral, type ESLintObjectExpression, type ESLintObjectPattern, type ESLintPattern, type ESLintPrivateIdentifier, type ESLintProgram, type ESLintProperty, type ESLintPropertyDefinition, type ESLintRegExpLiteral, type ESLintRestElement, type ESLintReturnStatement, type ESLintSequenceExpression, type ESLintSpreadElement, type ESLintStatement, type ESLintStaticBlock, type ESLintStringLiteral, type ESLintSuper, type ESLintSwitchCase, type ESLintSwitchStatement, type ESLintTaggedTemplateExpression, type ESLintTemplateElement, type ESLintTemplateLiteral, type ESLintThisExpression, type ESLintThrowStatement, type ESLintTryStatement, type ESLintUnaryExpression, type ESLintUpdateExpression, type ESLintVariableDeclaration, type ESLintVariableDeclarator, type ESLintWhileStatement, type ESLintWithStatement, type ESLintYieldExpression, type ErrorCode, type HasConcreteInfo, type HasLocation, type HasParent, KEYS, type Location, type LocationRange, NS, type Namespace, type Node, type Offset, type OffsetRange, ParseError, type Reference, type Token, type VAttribute, type VDirective, type VDirectiveKey, type VElement, type VEndTag, type VExpressionContainer, type VFilter, type VFilterSequenceExpression, type VForExpression, type VIdentifier, type VLiteral, type VNode, type VOnExpression, type VSlotScopeExpression, type VStartTag, type VTemplateRoot, type VText, type Variable, type Visitor, getFallbackKeys, parse, parseForESLint, traverseNodes };
|
package/dist/index.d.ts
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
-
import {
|
2
|
-
import { TSESTree } from '@typescript-eslint/types';
|
1
|
+
import { TSESTree as TSESTree$1 } from '@typescript-eslint/types';
|
3
2
|
import { ScopeManager } from 'eslint-scope';
|
3
|
+
import { ParserOptions, parseForESLint as parseForESLint$1 } from '@typescript-eslint/parser';
|
4
|
+
import { TSESTree } from '@typescript-eslint/typescript-estree';
|
5
|
+
import { VisitorKeys } from 'eslint-visitor-keys';
|
4
6
|
|
5
7
|
/**
|
6
8
|
* HTML parse errors.
|
@@ -94,6 +96,65 @@ interface HasLocation {
|
|
94
96
|
end?: number;
|
95
97
|
}
|
96
98
|
|
99
|
+
/**
|
100
|
+
* The type of basic ESLint custom parser.
|
101
|
+
* e.g. espree
|
102
|
+
*/
|
103
|
+
interface BasicParserObject<R = ESLintProgram> {
|
104
|
+
parse: (code: string, options: any) => R;
|
105
|
+
parseForESLint: undefined;
|
106
|
+
}
|
107
|
+
/**
|
108
|
+
* The type of ESLint custom parser enhanced for ESLint.
|
109
|
+
* e.g. @babel/eslint-parser, @typescript-eslint/parser
|
110
|
+
*/
|
111
|
+
interface EnhancedParserObject<R = ESLintExtendedProgram> {
|
112
|
+
parseForESLint: (code: string, options: any) => R;
|
113
|
+
parse: undefined;
|
114
|
+
}
|
115
|
+
/**
|
116
|
+
* The type of ESLint (custom) parsers.
|
117
|
+
*/
|
118
|
+
type ParserObject<R1 = ESLintExtendedProgram, R2 = ESLintProgram> = EnhancedParserObject<R1> | BasicParserObject<R2>;
|
119
|
+
|
120
|
+
declare function prepareTemplate(templateNode: TSESTree.TaggedTemplateExpression): {
|
121
|
+
templatePositionInfo: {
|
122
|
+
templateStartLine: number;
|
123
|
+
templateStartColumn: number;
|
124
|
+
templateStartOffset: number;
|
125
|
+
templateEndOffset: number;
|
126
|
+
templateEndLine: number;
|
127
|
+
templateEndColumn: number;
|
128
|
+
};
|
129
|
+
templateRawContent: string;
|
130
|
+
};
|
131
|
+
|
132
|
+
type PrettierType<T> = {
|
133
|
+
[K in keyof T]: T[K];
|
134
|
+
} & {};
|
135
|
+
type TsESLintParseForESLint = ReturnType<typeof parseForESLint$1>;
|
136
|
+
interface ParseForESLintResult {
|
137
|
+
ast: ESLintProgram;
|
138
|
+
services: TsESLintParseForESLint['services'];
|
139
|
+
scopeManager: TsESLintParseForESLint['scopeManager'];
|
140
|
+
visitorKeys: TsESLintParseForESLint['visitorKeys'];
|
141
|
+
}
|
142
|
+
type VineESLintParserOptions = ParserOptions & {
|
143
|
+
parser?: boolean | string | ParserObject | Record<string, string | ParserObject | undefined>;
|
144
|
+
ecmaFeatures?: ParserOptions['ecmaFeatures'] & {
|
145
|
+
[key: string]: any;
|
146
|
+
};
|
147
|
+
};
|
148
|
+
interface VineTemplateMeta {
|
149
|
+
tokens: Token[];
|
150
|
+
comments: Token[];
|
151
|
+
errors: ParseError[];
|
152
|
+
}
|
153
|
+
type FinalProcessTemplateInfo = ReturnType<typeof prepareTemplate> & {
|
154
|
+
templateRootAST: VTemplateRoot;
|
155
|
+
templateMeta: VineTemplateMeta;
|
156
|
+
};
|
157
|
+
|
97
158
|
/**
|
98
159
|
* Tokens.
|
99
160
|
*/
|
@@ -142,7 +203,7 @@ interface ESLintProgram extends HasLocation, HasParent {
|
|
142
203
|
comments?: Token[];
|
143
204
|
errors?: ParseError[];
|
144
205
|
}
|
145
|
-
type ESLintStatement = ESLintExpressionStatement | ESLintBlockStatement | ESLintEmptyStatement | ESLintDebuggerStatement | ESLintWithStatement | ESLintReturnStatement | ESLintLabeledStatement | ESLintBreakStatement | ESLintContinueStatement | ESLintIfStatement | ESLintSwitchStatement | ESLintThrowStatement | ESLintTryStatement | ESLintWhileStatement | ESLintDoWhileStatement | ESLintForStatement | ESLintForInStatement | ESLintForOfStatement | ESLintDeclaration;
|
206
|
+
type ESLintStatement = ESLintExpressionStatement | ESLintDirective | ESLintBlockStatement | ESLintEmptyStatement | ESLintDebuggerStatement | ESLintWithStatement | ESLintReturnStatement | ESLintLabeledStatement | ESLintBreakStatement | ESLintContinueStatement | ESLintIfStatement | ESLintSwitchStatement | ESLintThrowStatement | ESLintTryStatement | ESLintWhileStatement | ESLintDoWhileStatement | ESLintForStatement | ESLintForInStatement | ESLintForOfStatement | ESLintDeclaration;
|
146
207
|
interface ESLintEmptyStatement extends HasLocation, HasParent {
|
147
208
|
type: 'EmptyStatement';
|
148
209
|
}
|
@@ -154,6 +215,11 @@ interface ESLintExpressionStatement extends HasLocation, HasParent {
|
|
154
215
|
type: 'ExpressionStatement';
|
155
216
|
expression: ESLintExpression;
|
156
217
|
}
|
218
|
+
interface ESLintDirective extends HasLocation, HasParent {
|
219
|
+
type: 'ExpressionStatement';
|
220
|
+
expression: ESLintLiteral;
|
221
|
+
directive: string;
|
222
|
+
}
|
157
223
|
interface ESLintIfStatement extends HasLocation, HasParent {
|
158
224
|
type: 'IfStatement';
|
159
225
|
test: ESLintExpression;
|
@@ -755,41 +821,33 @@ interface VElement extends HasLocation, HasParent {
|
|
755
821
|
*/
|
756
822
|
interface VTemplateRoot extends HasLocation {
|
757
823
|
type: 'VTemplateRoot';
|
758
|
-
parent: TSESTree.Node;
|
824
|
+
parent: TSESTree$1.Node;
|
759
825
|
children: (VElement | VText | VExpressionContainer)[];
|
826
|
+
templateInfo?: PrettierType<Omit<FinalProcessTemplateInfo, 'templateMeta' | 'templateRootAST'>>;
|
760
827
|
}
|
761
828
|
|
829
|
+
declare const KEYS: {
|
830
|
+
readonly [type: string]: readonly string[];
|
831
|
+
};
|
762
832
|
/**
|
763
|
-
*
|
764
|
-
*
|
765
|
-
|
766
|
-
interface BasicParserObject<R = ESLintProgram> {
|
767
|
-
parse: (code: string, options: any) => R;
|
768
|
-
parseForESLint: undefined;
|
769
|
-
}
|
770
|
-
/**
|
771
|
-
* The type of ESLint custom parser enhanced for ESLint.
|
772
|
-
* e.g. @babel/eslint-parser, @typescript-eslint/parser
|
833
|
+
* Get the keys of the given node to traverse it.
|
834
|
+
* @param node The node to get.
|
835
|
+
* @returns The keys to traverse.
|
773
836
|
*/
|
774
|
-
|
775
|
-
|
776
|
-
|
837
|
+
declare function getFallbackKeys(node: Node): string[];
|
838
|
+
interface Visitor {
|
839
|
+
visitorKeys?: VisitorKeys;
|
840
|
+
enterNode: (node: Node, parent: Node | null) => void;
|
841
|
+
leaveNode: (node: Node, parent: Node | null) => void;
|
777
842
|
}
|
778
843
|
/**
|
779
|
-
*
|
844
|
+
* Traverse the given AST tree.
|
845
|
+
* @param node Root node to traverse.
|
846
|
+
* @param visitor Visitor.
|
780
847
|
*/
|
781
|
-
|
782
|
-
|
783
|
-
type VineESLintAST = TSESTree.Program;
|
784
|
-
type ParseForESLintResult = ReturnType<typeof parseForESLint$1>;
|
785
|
-
type VineESLintParserOptions = ParserOptions & {
|
786
|
-
parser?: boolean | string | ParserObject | Record<string, string | ParserObject | undefined>;
|
787
|
-
ecmaFeatures?: ParserOptions['ecmaFeatures'] & {
|
788
|
-
[key: string]: any;
|
789
|
-
};
|
790
|
-
};
|
848
|
+
declare function traverseNodes(node: Node, visitor: Visitor): void;
|
791
849
|
|
792
|
-
declare function parse(code: string, parserOptions: VineESLintParserOptions):
|
850
|
+
declare function parse(code: string, parserOptions: VineESLintParserOptions): ESLintProgram;
|
793
851
|
declare function parseForESLint(code: string, parserOptions: VineESLintParserOptions): ParseForESLintResult;
|
794
852
|
|
795
|
-
export { parse, parseForESLint };
|
853
|
+
export { type ESLintArrayExpression, type ESLintArrayPattern, type ESLintArrowFunctionExpression, type ESLintAssignmentExpression, type ESLintAssignmentPattern, type ESLintAssignmentProperty, type ESLintAwaitExpression, type ESLintBigIntLiteral, type ESLintBinaryExpression, type ESLintBlockStatement, type ESLintBooleanLiteral, type ESLintBreakStatement, type ESLintCallExpression, type ESLintCatchClause, type ESLintChainElement, type ESLintChainExpression, type ESLintClassBody, type ESLintClassDeclaration, type ESLintClassExpression, type ESLintConditionalExpression, type ESLintContinueStatement, type ESLintDebuggerStatement, type ESLintDeclaration, type ESLintDirective, type ESLintDoWhileStatement, type ESLintEmptyStatement, type ESLintExportAllDeclaration, type ESLintExportDefaultDeclaration, type ESLintExportNamedDeclaration, type ESLintExportSpecifier, type ESLintExpression, type ESLintExpressionStatement, type ESLintExtendedProgram, type ESLintForInStatement, type ESLintForOfStatement, type ESLintForStatement, type ESLintFunctionDeclaration, type ESLintFunctionExpression, type ESLintIdentifier, type ESLintIfStatement, type ESLintImportDeclaration, type ESLintImportDefaultSpecifier, type ESLintImportExpression, type ESLintImportNamespaceSpecifier, type ESLintImportSpecifier, type ESLintLabeledStatement, type ESLintLegacyRestProperty, type ESLintLegacySpreadProperty, type ESLintLiteral, type ESLintLogicalExpression, type ESLintMemberExpression, type ESLintMetaProperty, type ESLintMethodDefinition, type ESLintModuleDeclaration, type ESLintModuleSpecifier, type ESLintNewExpression, type ESLintNode, type ESLintNullLiteral, type ESLintNumberLiteral, type ESLintObjectExpression, type ESLintObjectPattern, type ESLintPattern, type ESLintPrivateIdentifier, type ESLintProgram, type ESLintProperty, type ESLintPropertyDefinition, type ESLintRegExpLiteral, type ESLintRestElement, type ESLintReturnStatement, type ESLintSequenceExpression, type ESLintSpreadElement, type ESLintStatement, type ESLintStaticBlock, type ESLintStringLiteral, type ESLintSuper, type ESLintSwitchCase, type ESLintSwitchStatement, type ESLintTaggedTemplateExpression, type ESLintTemplateElement, type ESLintTemplateLiteral, type ESLintThisExpression, type ESLintThrowStatement, type ESLintTryStatement, type ESLintUnaryExpression, type ESLintUpdateExpression, type ESLintVariableDeclaration, type ESLintVariableDeclarator, type ESLintWhileStatement, type ESLintWithStatement, type ESLintYieldExpression, type ErrorCode, type HasConcreteInfo, type HasLocation, type HasParent, KEYS, type Location, type LocationRange, NS, type Namespace, type Node, type Offset, type OffsetRange, ParseError, type Reference, type Token, type VAttribute, type VDirective, type VDirectiveKey, type VElement, type VEndTag, type VExpressionContainer, type VFilter, type VFilterSequenceExpression, type VForExpression, type VIdentifier, type VLiteral, type VNode, type VOnExpression, type VSlotScopeExpression, type VStartTag, type VTemplateRoot, type VText, type Variable, type Visitor, getFallbackKeys, parse, parseForESLint, traverseNodes };
|
package/dist/index.js
CHANGED
@@ -2346,23 +2346,10 @@ var require_sortedIndexBy = __commonJS({
|
|
2346
2346
|
"use strict";
|
2347
2347
|
var baseIteratee = require_baseIteratee();
|
2348
2348
|
var baseSortedIndexBy = require_baseSortedIndexBy();
|
2349
|
-
function
|
2349
|
+
function sortedIndexBy3(array, value, iteratee) {
|
2350
2350
|
return baseSortedIndexBy(array, value, baseIteratee(iteratee, 2));
|
2351
2351
|
}
|
2352
|
-
module.exports =
|
2353
|
-
}
|
2354
|
-
});
|
2355
|
-
|
2356
|
-
// ../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/sortedLastIndexBy.js
|
2357
|
-
var require_sortedLastIndexBy = __commonJS({
|
2358
|
-
"../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/sortedLastIndexBy.js"(exports, module) {
|
2359
|
-
"use strict";
|
2360
|
-
var baseIteratee = require_baseIteratee();
|
2361
|
-
var baseSortedIndexBy = require_baseSortedIndexBy();
|
2362
|
-
function sortedLastIndexBy2(array, value, iteratee) {
|
2363
|
-
return baseSortedIndexBy(array, value, baseIteratee(iteratee, 2), true);
|
2364
|
-
}
|
2365
|
-
module.exports = sortedLastIndexBy2;
|
2352
|
+
module.exports = sortedIndexBy3;
|
2366
2353
|
}
|
2367
2354
|
});
|
2368
2355
|
|
@@ -3868,14 +3855,6 @@ function insertError(templateMeta, error) {
|
|
3868
3855
|
}
|
3869
3856
|
|
3870
3857
|
// src/common/token-utils.ts
|
3871
|
-
var import_sortedIndexBy2 = __toESM(require_sortedIndexBy());
|
3872
|
-
var import_sortedLastIndexBy = __toESM(require_sortedLastIndexBy());
|
3873
|
-
function byRange0(x) {
|
3874
|
-
return x.range[0];
|
3875
|
-
}
|
3876
|
-
function byRange1(x) {
|
3877
|
-
return x.range[1];
|
3878
|
-
}
|
3879
3858
|
function createSimpleToken(type, start, end, value, linesAndColumns) {
|
3880
3859
|
return {
|
3881
3860
|
type,
|
@@ -3891,19 +3870,19 @@ function insertComments(templateMeta, newComments) {
|
|
3891
3870
|
if (newComments.length === 0) {
|
3892
3871
|
return;
|
3893
3872
|
}
|
3894
|
-
const index =
|
3873
|
+
const index = templateMeta.comments.findIndex((comment) => comment.range[0] === newComments[0].range[0]);
|
3895
3874
|
templateMeta.comments.splice(index, 0, ...newComments);
|
3896
3875
|
}
|
3897
3876
|
function replaceTokens(templateMeta, node, newTokens) {
|
3898
|
-
const index =
|
3899
|
-
const count =
|
3877
|
+
const index = templateMeta.tokens.findIndex((token) => token.range[0] === node.range[0]);
|
3878
|
+
const count = templateMeta.tokens.findIndex((token) => token.range[1] === node.range[1]) - index + 1;
|
3900
3879
|
templateMeta.tokens.splice(index, count, ...newTokens);
|
3901
3880
|
}
|
3902
3881
|
|
3903
3882
|
// src/script/index.ts
|
3904
3883
|
var import_first = __toESM(require_first());
|
3905
3884
|
var import_last2 = __toESM(require_last());
|
3906
|
-
var
|
3885
|
+
var import_sortedIndexBy2 = __toESM(require_sortedIndexBy());
|
3907
3886
|
|
3908
3887
|
|
3909
3888
|
// src/template/utils/process-vine-template-node.ts
|
@@ -3952,16 +3931,18 @@ function extractForVineTemplate(ast) {
|
|
3952
3931
|
if (_optionalChain([parent, 'optionalAccess', _14 => _14.type]) === _typescriptestree.TSESTree.AST_NODE_TYPES.ReturnStatement) {
|
3953
3932
|
parent.argument = null;
|
3954
3933
|
parentOfTemplate = parent;
|
3955
|
-
bindVineTemplateESTree = (vineESTree) => {
|
3934
|
+
bindVineTemplateESTree = ({ templateRootAST: vineESTree, templateMeta: _, ...templateInfo }) => {
|
3956
3935
|
parent.argument = vineESTree;
|
3957
3936
|
vineESTree.parent = parent;
|
3937
|
+
vineESTree.templateInfo = templateInfo;
|
3958
3938
|
};
|
3959
3939
|
} else if (_optionalChain([parent, 'optionalAccess', _15 => _15.type]) === _typescriptestree.TSESTree.AST_NODE_TYPES.ArrowFunctionExpression) {
|
3960
3940
|
parent.body = null;
|
3961
3941
|
parentOfTemplate = parent;
|
3962
|
-
bindVineTemplateESTree = (vineESTree) => {
|
3942
|
+
bindVineTemplateESTree = ({ templateRootAST: vineESTree, templateMeta: _, ...templateInfo }) => {
|
3963
3943
|
parent.body = vineESTree;
|
3964
3944
|
vineESTree.parent = parent;
|
3945
|
+
vineESTree.templateInfo = templateInfo;
|
3965
3946
|
};
|
3966
3947
|
}
|
3967
3948
|
ast.tokens = _optionalChain([ast, 'access', _16 => _16.tokens, 'optionalAccess', _17 => _17.filter, 'call', _18 => _18(
|
@@ -4139,7 +4120,7 @@ function processVForAliasAndIterator(code) {
|
|
4139
4120
|
};
|
4140
4121
|
}
|
4141
4122
|
function getCommaTokenBeforeNode(tokens, node) {
|
4142
|
-
let tokenIndex = (0,
|
4123
|
+
let tokenIndex = (0, import_sortedIndexBy2.default)(
|
4143
4124
|
tokens,
|
4144
4125
|
{ range: node.range },
|
4145
4126
|
(t) => t.range[0]
|
@@ -10078,21 +10059,30 @@ function getTemplateRootDataList(prepareResult, parserOptions) {
|
|
10078
10059
|
);
|
10079
10060
|
return templateParser.parse();
|
10080
10061
|
}
|
10081
|
-
function finalProcessForTSFileAST(bindVineTemplateESTree,
|
10082
|
-
bindVineTemplateESTree(
|
10062
|
+
function finalProcessForTSFileAST(bindVineTemplateESTree, tsFileAST, templateInfo) {
|
10063
|
+
bindVineTemplateESTree(templateInfo);
|
10083
10064
|
tsFileAST.tokens = [
|
10084
10065
|
..._nullishCoalesce(tsFileAST.tokens, () => ( [])),
|
10085
|
-
...templateMeta.tokens
|
10066
|
+
...templateInfo.templateMeta.tokens
|
10086
10067
|
].sort((a, b) => a.range[0] - b.range[0]);
|
10087
10068
|
}
|
10088
10069
|
function runParse(code, parserOptions) {
|
10089
|
-
const {
|
10070
|
+
const {
|
10071
|
+
ast: tsESLintAST,
|
10072
|
+
scopeManager,
|
10073
|
+
services: tsESLintParserServices,
|
10074
|
+
visitorKeys: tsESLintVisitorKeys
|
10075
|
+
} = typescriptBasicESLintParse(
|
10090
10076
|
code,
|
10091
10077
|
parserOptions
|
10092
10078
|
);
|
10093
|
-
const prepareResults = prepareForTemplateRootAST(
|
10079
|
+
const prepareResults = prepareForTemplateRootAST(tsESLintAST);
|
10094
10080
|
for (const prepareResult of prepareResults) {
|
10095
|
-
const {
|
10081
|
+
const {
|
10082
|
+
bindVineTemplateESTree,
|
10083
|
+
templatePositionInfo,
|
10084
|
+
templateRawContent
|
10085
|
+
} = prepareResult;
|
10096
10086
|
const rootData = getTemplateRootDataList(
|
10097
10087
|
prepareResult,
|
10098
10088
|
{
|
@@ -10106,19 +10096,28 @@ function runParse(code, parserOptions) {
|
|
10106
10096
|
const [templateRootAST, templateMeta] = rootData;
|
10107
10097
|
finalProcessForTSFileAST(
|
10108
10098
|
bindVineTemplateESTree,
|
10109
|
-
|
10110
|
-
|
10111
|
-
|
10099
|
+
tsESLintAST,
|
10100
|
+
{
|
10101
|
+
templateRootAST,
|
10102
|
+
templateMeta,
|
10103
|
+
templatePositionInfo,
|
10104
|
+
templateRawContent
|
10105
|
+
}
|
10112
10106
|
);
|
10113
10107
|
analyzeUsedInTemplateVariables(
|
10114
10108
|
scopeManager,
|
10115
10109
|
templateRootAST
|
10116
10110
|
);
|
10117
10111
|
}
|
10112
|
+
const ast = tsESLintAST;
|
10118
10113
|
const visitorKeys = {
|
10119
10114
|
...tsESLintVisitorKeys,
|
10120
10115
|
...KEYS2
|
10121
10116
|
};
|
10117
|
+
const services = {
|
10118
|
+
...tsESLintParserServices
|
10119
|
+
// Todo: Maybe additional services specific to Vue Vine
|
10120
|
+
};
|
10122
10121
|
return {
|
10123
10122
|
ast,
|
10124
10123
|
services,
|
package/dist/index.mjs
CHANGED
@@ -2346,23 +2346,10 @@ var require_sortedIndexBy = __commonJS({
|
|
2346
2346
|
"use strict";
|
2347
2347
|
var baseIteratee = require_baseIteratee();
|
2348
2348
|
var baseSortedIndexBy = require_baseSortedIndexBy();
|
2349
|
-
function
|
2349
|
+
function sortedIndexBy3(array, value, iteratee) {
|
2350
2350
|
return baseSortedIndexBy(array, value, baseIteratee(iteratee, 2));
|
2351
2351
|
}
|
2352
|
-
module.exports =
|
2353
|
-
}
|
2354
|
-
});
|
2355
|
-
|
2356
|
-
// ../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/sortedLastIndexBy.js
|
2357
|
-
var require_sortedLastIndexBy = __commonJS({
|
2358
|
-
"../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/sortedLastIndexBy.js"(exports, module) {
|
2359
|
-
"use strict";
|
2360
|
-
var baseIteratee = require_baseIteratee();
|
2361
|
-
var baseSortedIndexBy = require_baseSortedIndexBy();
|
2362
|
-
function sortedLastIndexBy2(array, value, iteratee) {
|
2363
|
-
return baseSortedIndexBy(array, value, baseIteratee(iteratee, 2), true);
|
2364
|
-
}
|
2365
|
-
module.exports = sortedLastIndexBy2;
|
2352
|
+
module.exports = sortedIndexBy3;
|
2366
2353
|
}
|
2367
2354
|
});
|
2368
2355
|
|
@@ -3868,14 +3855,6 @@ function insertError(templateMeta, error) {
|
|
3868
3855
|
}
|
3869
3856
|
|
3870
3857
|
// src/common/token-utils.ts
|
3871
|
-
var import_sortedIndexBy2 = __toESM(require_sortedIndexBy());
|
3872
|
-
var import_sortedLastIndexBy = __toESM(require_sortedLastIndexBy());
|
3873
|
-
function byRange0(x) {
|
3874
|
-
return x.range[0];
|
3875
|
-
}
|
3876
|
-
function byRange1(x) {
|
3877
|
-
return x.range[1];
|
3878
|
-
}
|
3879
3858
|
function createSimpleToken(type, start, end, value, linesAndColumns) {
|
3880
3859
|
return {
|
3881
3860
|
type,
|
@@ -3891,19 +3870,19 @@ function insertComments(templateMeta, newComments) {
|
|
3891
3870
|
if (newComments.length === 0) {
|
3892
3871
|
return;
|
3893
3872
|
}
|
3894
|
-
const index =
|
3873
|
+
const index = templateMeta.comments.findIndex((comment) => comment.range[0] === newComments[0].range[0]);
|
3895
3874
|
templateMeta.comments.splice(index, 0, ...newComments);
|
3896
3875
|
}
|
3897
3876
|
function replaceTokens(templateMeta, node, newTokens) {
|
3898
|
-
const index =
|
3899
|
-
const count =
|
3877
|
+
const index = templateMeta.tokens.findIndex((token) => token.range[0] === node.range[0]);
|
3878
|
+
const count = templateMeta.tokens.findIndex((token) => token.range[1] === node.range[1]) - index + 1;
|
3900
3879
|
templateMeta.tokens.splice(index, count, ...newTokens);
|
3901
3880
|
}
|
3902
3881
|
|
3903
3882
|
// src/script/index.ts
|
3904
3883
|
var import_first = __toESM(require_first());
|
3905
3884
|
var import_last2 = __toESM(require_last());
|
3906
|
-
var
|
3885
|
+
var import_sortedIndexBy2 = __toESM(require_sortedIndexBy());
|
3907
3886
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
3908
3887
|
|
3909
3888
|
// src/template/utils/process-vine-template-node.ts
|
@@ -3952,16 +3931,18 @@ function extractForVineTemplate(ast) {
|
|
3952
3931
|
if (parent?.type === TSESTree.AST_NODE_TYPES.ReturnStatement) {
|
3953
3932
|
parent.argument = null;
|
3954
3933
|
parentOfTemplate = parent;
|
3955
|
-
bindVineTemplateESTree = (vineESTree) => {
|
3934
|
+
bindVineTemplateESTree = ({ templateRootAST: vineESTree, templateMeta: _, ...templateInfo }) => {
|
3956
3935
|
parent.argument = vineESTree;
|
3957
3936
|
vineESTree.parent = parent;
|
3937
|
+
vineESTree.templateInfo = templateInfo;
|
3958
3938
|
};
|
3959
3939
|
} else if (parent?.type === TSESTree.AST_NODE_TYPES.ArrowFunctionExpression) {
|
3960
3940
|
parent.body = null;
|
3961
3941
|
parentOfTemplate = parent;
|
3962
|
-
bindVineTemplateESTree = (vineESTree) => {
|
3942
|
+
bindVineTemplateESTree = ({ templateRootAST: vineESTree, templateMeta: _, ...templateInfo }) => {
|
3963
3943
|
parent.body = vineESTree;
|
3964
3944
|
vineESTree.parent = parent;
|
3945
|
+
vineESTree.templateInfo = templateInfo;
|
3965
3946
|
};
|
3966
3947
|
}
|
3967
3948
|
ast.tokens = ast.tokens?.filter(
|
@@ -4139,7 +4120,7 @@ function processVForAliasAndIterator(code) {
|
|
4139
4120
|
};
|
4140
4121
|
}
|
4141
4122
|
function getCommaTokenBeforeNode(tokens, node) {
|
4142
|
-
let tokenIndex = (0,
|
4123
|
+
let tokenIndex = (0, import_sortedIndexBy2.default)(
|
4143
4124
|
tokens,
|
4144
4125
|
{ range: node.range },
|
4145
4126
|
(t) => t.range[0]
|
@@ -10078,21 +10059,30 @@ function getTemplateRootDataList(prepareResult, parserOptions) {
|
|
10078
10059
|
);
|
10079
10060
|
return templateParser.parse();
|
10080
10061
|
}
|
10081
|
-
function finalProcessForTSFileAST(bindVineTemplateESTree,
|
10082
|
-
bindVineTemplateESTree(
|
10062
|
+
function finalProcessForTSFileAST(bindVineTemplateESTree, tsFileAST, templateInfo) {
|
10063
|
+
bindVineTemplateESTree(templateInfo);
|
10083
10064
|
tsFileAST.tokens = [
|
10084
10065
|
...tsFileAST.tokens ?? [],
|
10085
|
-
...templateMeta.tokens
|
10066
|
+
...templateInfo.templateMeta.tokens
|
10086
10067
|
].sort((a, b) => a.range[0] - b.range[0]);
|
10087
10068
|
}
|
10088
10069
|
function runParse(code, parserOptions) {
|
10089
|
-
const {
|
10070
|
+
const {
|
10071
|
+
ast: tsESLintAST,
|
10072
|
+
scopeManager,
|
10073
|
+
services: tsESLintParserServices,
|
10074
|
+
visitorKeys: tsESLintVisitorKeys
|
10075
|
+
} = typescriptBasicESLintParse(
|
10090
10076
|
code,
|
10091
10077
|
parserOptions
|
10092
10078
|
);
|
10093
|
-
const prepareResults = prepareForTemplateRootAST(
|
10079
|
+
const prepareResults = prepareForTemplateRootAST(tsESLintAST);
|
10094
10080
|
for (const prepareResult of prepareResults) {
|
10095
|
-
const {
|
10081
|
+
const {
|
10082
|
+
bindVineTemplateESTree,
|
10083
|
+
templatePositionInfo,
|
10084
|
+
templateRawContent
|
10085
|
+
} = prepareResult;
|
10096
10086
|
const rootData = getTemplateRootDataList(
|
10097
10087
|
prepareResult,
|
10098
10088
|
{
|
@@ -10106,19 +10096,28 @@ function runParse(code, parserOptions) {
|
|
10106
10096
|
const [templateRootAST, templateMeta] = rootData;
|
10107
10097
|
finalProcessForTSFileAST(
|
10108
10098
|
bindVineTemplateESTree,
|
10109
|
-
|
10110
|
-
|
10111
|
-
|
10099
|
+
tsESLintAST,
|
10100
|
+
{
|
10101
|
+
templateRootAST,
|
10102
|
+
templateMeta,
|
10103
|
+
templatePositionInfo,
|
10104
|
+
templateRawContent
|
10105
|
+
}
|
10112
10106
|
);
|
10113
10107
|
analyzeUsedInTemplateVariables(
|
10114
10108
|
scopeManager,
|
10115
10109
|
templateRootAST
|
10116
10110
|
);
|
10117
10111
|
}
|
10112
|
+
const ast = tsESLintAST;
|
10118
10113
|
const visitorKeys = {
|
10119
10114
|
...tsESLintVisitorKeys,
|
10120
10115
|
...KEYS2
|
10121
10116
|
};
|
10117
|
+
const services = {
|
10118
|
+
...tsESLintParserServices
|
10119
|
+
// Todo: Maybe additional services specific to Vue Vine
|
10120
|
+
};
|
10122
10121
|
return {
|
10123
10122
|
ast,
|
10124
10123
|
services,
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@vue-vine/eslint-parser",
|
3
|
-
"version": "0.1.
|
3
|
+
"version": "0.1.33",
|
4
4
|
"description": "ESLint parser for Vue Vine",
|
5
5
|
"author": "ShenQingchuan",
|
6
6
|
"license": "MIT",
|
@@ -27,7 +27,7 @@
|
|
27
27
|
"@typescript-eslint/scope-manager": "^8.11.0",
|
28
28
|
"@typescript-eslint/typescript-estree": "^8.11.0",
|
29
29
|
"debug": "^4.3.4",
|
30
|
-
"eslint-scope": "^
|
30
|
+
"eslint-scope": "^8.2.0",
|
31
31
|
"espree": "^9.6.1",
|
32
32
|
"line-column": "^1.0.2",
|
33
33
|
"semver": "^7.5.4"
|