@vue-vine/eslint-parser 0.1.30 → 0.1.32

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.d.mts CHANGED
@@ -1,6 +1,8 @@
1
- import { parseForESLint as parseForESLint$1, ParserOptions } from '@typescript-eslint/parser';
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
- * The type of basic ESLint custom parser.
764
- * e.g. espree
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
- interface EnhancedParserObject<R = ESLintExtendedProgram> {
775
- parseForESLint: (code: string, options: any) => R;
776
- parse: undefined;
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
- * The type of ESLint (custom) parsers.
844
+ * Traverse the given AST tree.
845
+ * @param node Root node to traverse.
846
+ * @param visitor Visitor.
780
847
  */
781
- type ParserObject<R1 = ESLintExtendedProgram, R2 = ESLintProgram> = EnhancedParserObject<R1> | BasicParserObject<R2>;
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): VineESLintAST;
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 { parseForESLint as parseForESLint$1, ParserOptions } from '@typescript-eslint/parser';
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
- * The type of basic ESLint custom parser.
764
- * e.g. espree
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
- interface EnhancedParserObject<R = ESLintExtendedProgram> {
775
- parseForESLint: (code: string, options: any) => R;
776
- parse: undefined;
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
- * The type of ESLint (custom) parsers.
844
+ * Traverse the given AST tree.
845
+ * @param node Root node to traverse.
846
+ * @param visitor Visitor.
780
847
  */
781
- type ParserObject<R1 = ESLintExtendedProgram, R2 = ESLintProgram> = EnhancedParserObject<R1> | BasicParserObject<R2>;
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): VineESLintAST;
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
@@ -3160,6 +3160,10 @@ function collectVariablesForVCF(tsFileScopeManager, templateRoot) {
3160
3160
  foundVCF = foundVCF.parent;
3161
3161
  } while (foundVCF && foundVCF.type !== "FunctionDeclaration" && foundVCF.type !== "FunctionExpression" && foundVCF.type !== "ArrowFunctionExpression");
3162
3162
  if (foundVCF) {
3163
+ Object.assign(
3164
+ foundVCF,
3165
+ { __isVine__: true }
3166
+ );
3163
3167
  const tryGetVCFScope = tsFileScopeManager.nodeToScope.get(foundVCF);
3164
3168
  if (_optionalChain([tryGetVCFScope, 'optionalAccess', _7 => _7[0]])) {
3165
3169
  foundVCFScope = tryGetVCFScope[0];
@@ -3948,16 +3952,18 @@ function extractForVineTemplate(ast) {
3948
3952
  if (_optionalChain([parent, 'optionalAccess', _14 => _14.type]) === _typescriptestree.TSESTree.AST_NODE_TYPES.ReturnStatement) {
3949
3953
  parent.argument = null;
3950
3954
  parentOfTemplate = parent;
3951
- bindVineTemplateESTree = (vineESTree) => {
3955
+ bindVineTemplateESTree = ({ templateRootAST: vineESTree, templateMeta: _, ...templateInfo }) => {
3952
3956
  parent.argument = vineESTree;
3953
3957
  vineESTree.parent = parent;
3958
+ vineESTree.templateInfo = templateInfo;
3954
3959
  };
3955
3960
  } else if (_optionalChain([parent, 'optionalAccess', _15 => _15.type]) === _typescriptestree.TSESTree.AST_NODE_TYPES.ArrowFunctionExpression) {
3956
3961
  parent.body = null;
3957
3962
  parentOfTemplate = parent;
3958
- bindVineTemplateESTree = (vineESTree) => {
3963
+ bindVineTemplateESTree = ({ templateRootAST: vineESTree, templateMeta: _, ...templateInfo }) => {
3959
3964
  parent.body = vineESTree;
3960
3965
  vineESTree.parent = parent;
3966
+ vineESTree.templateInfo = templateInfo;
3961
3967
  };
3962
3968
  }
3963
3969
  ast.tokens = _optionalChain([ast, 'access', _16 => _16.tokens, 'optionalAccess', _17 => _17.filter, 'call', _18 => _18(
@@ -6070,13 +6076,13 @@ var VineTemplateParser = (_class = class {
6070
6076
  this[token.type](token);
6071
6077
  } while (token != null);
6072
6078
  this.popElementStackUntil(0);
6079
+ this.correctMetaTokenPos();
6073
6080
  const templateRoot = this.vTemplateRoot;
6074
6081
  const templateMeta = this.vTemplateMeta;
6075
6082
  for (const proc of this.postProcessForScript) {
6076
6083
  proc(this.baseParserOptions);
6077
6084
  }
6078
6085
  this.postProcessForScript = [];
6079
- this.correctMetaTokenPos();
6080
6086
  return [templateRoot, templateMeta];
6081
6087
  }
6082
6088
  }, _class);
@@ -10074,21 +10080,30 @@ function getTemplateRootDataList(prepareResult, parserOptions) {
10074
10080
  );
10075
10081
  return templateParser.parse();
10076
10082
  }
10077
- function finalProcessForTSFileAST(bindVineTemplateESTree, templateRootAST, templateMeta, tsFileAST) {
10078
- bindVineTemplateESTree(templateRootAST);
10083
+ function finalProcessForTSFileAST(bindVineTemplateESTree, tsFileAST, templateInfo) {
10084
+ bindVineTemplateESTree(templateInfo);
10079
10085
  tsFileAST.tokens = [
10080
10086
  ..._nullishCoalesce(tsFileAST.tokens, () => ( [])),
10081
- ...templateMeta.tokens
10087
+ ...templateInfo.templateMeta.tokens
10082
10088
  ].sort((a, b) => a.range[0] - b.range[0]);
10083
10089
  }
10084
10090
  function runParse(code, parserOptions) {
10085
- const { ast, services, scopeManager, visitorKeys: tsESLintVisitorKeys } = typescriptBasicESLintParse(
10091
+ const {
10092
+ ast: tsESLintAST,
10093
+ scopeManager,
10094
+ services: tsESLintParserServices,
10095
+ visitorKeys: tsESLintVisitorKeys
10096
+ } = typescriptBasicESLintParse(
10086
10097
  code,
10087
10098
  parserOptions
10088
10099
  );
10089
- const prepareResults = prepareForTemplateRootAST(ast);
10100
+ const prepareResults = prepareForTemplateRootAST(tsESLintAST);
10090
10101
  for (const prepareResult of prepareResults) {
10091
- const { bindVineTemplateESTree } = prepareResult;
10102
+ const {
10103
+ bindVineTemplateESTree,
10104
+ templatePositionInfo,
10105
+ templateRawContent
10106
+ } = prepareResult;
10092
10107
  const rootData = getTemplateRootDataList(
10093
10108
  prepareResult,
10094
10109
  {
@@ -10102,19 +10117,28 @@ function runParse(code, parserOptions) {
10102
10117
  const [templateRootAST, templateMeta] = rootData;
10103
10118
  finalProcessForTSFileAST(
10104
10119
  bindVineTemplateESTree,
10105
- templateRootAST,
10106
- templateMeta,
10107
- ast
10120
+ tsESLintAST,
10121
+ {
10122
+ templateRootAST,
10123
+ templateMeta,
10124
+ templatePositionInfo,
10125
+ templateRawContent
10126
+ }
10108
10127
  );
10109
10128
  analyzeUsedInTemplateVariables(
10110
10129
  scopeManager,
10111
10130
  templateRootAST
10112
10131
  );
10113
10132
  }
10133
+ const ast = tsESLintAST;
10114
10134
  const visitorKeys = {
10115
10135
  ...tsESLintVisitorKeys,
10116
10136
  ...KEYS2
10117
10137
  };
10138
+ const services = {
10139
+ ...tsESLintParserServices
10140
+ // Todo: Maybe additional services specific to Vue Vine
10141
+ };
10118
10142
  return {
10119
10143
  ast,
10120
10144
  services,
package/dist/index.mjs CHANGED
@@ -3160,6 +3160,10 @@ function collectVariablesForVCF(tsFileScopeManager, templateRoot) {
3160
3160
  foundVCF = foundVCF.parent;
3161
3161
  } while (foundVCF && foundVCF.type !== "FunctionDeclaration" && foundVCF.type !== "FunctionExpression" && foundVCF.type !== "ArrowFunctionExpression");
3162
3162
  if (foundVCF) {
3163
+ Object.assign(
3164
+ foundVCF,
3165
+ { __isVine__: true }
3166
+ );
3163
3167
  const tryGetVCFScope = tsFileScopeManager.nodeToScope.get(foundVCF);
3164
3168
  if (tryGetVCFScope?.[0]) {
3165
3169
  foundVCFScope = tryGetVCFScope[0];
@@ -3948,16 +3952,18 @@ function extractForVineTemplate(ast) {
3948
3952
  if (parent?.type === TSESTree.AST_NODE_TYPES.ReturnStatement) {
3949
3953
  parent.argument = null;
3950
3954
  parentOfTemplate = parent;
3951
- bindVineTemplateESTree = (vineESTree) => {
3955
+ bindVineTemplateESTree = ({ templateRootAST: vineESTree, templateMeta: _, ...templateInfo }) => {
3952
3956
  parent.argument = vineESTree;
3953
3957
  vineESTree.parent = parent;
3958
+ vineESTree.templateInfo = templateInfo;
3954
3959
  };
3955
3960
  } else if (parent?.type === TSESTree.AST_NODE_TYPES.ArrowFunctionExpression) {
3956
3961
  parent.body = null;
3957
3962
  parentOfTemplate = parent;
3958
- bindVineTemplateESTree = (vineESTree) => {
3963
+ bindVineTemplateESTree = ({ templateRootAST: vineESTree, templateMeta: _, ...templateInfo }) => {
3959
3964
  parent.body = vineESTree;
3960
3965
  vineESTree.parent = parent;
3966
+ vineESTree.templateInfo = templateInfo;
3961
3967
  };
3962
3968
  }
3963
3969
  ast.tokens = ast.tokens?.filter(
@@ -6070,13 +6076,13 @@ var VineTemplateParser = class {
6070
6076
  this[token.type](token);
6071
6077
  } while (token != null);
6072
6078
  this.popElementStackUntil(0);
6079
+ this.correctMetaTokenPos();
6073
6080
  const templateRoot = this.vTemplateRoot;
6074
6081
  const templateMeta = this.vTemplateMeta;
6075
6082
  for (const proc of this.postProcessForScript) {
6076
6083
  proc(this.baseParserOptions);
6077
6084
  }
6078
6085
  this.postProcessForScript = [];
6079
- this.correctMetaTokenPos();
6080
6086
  return [templateRoot, templateMeta];
6081
6087
  }
6082
6088
  };
@@ -10074,21 +10080,30 @@ function getTemplateRootDataList(prepareResult, parserOptions) {
10074
10080
  );
10075
10081
  return templateParser.parse();
10076
10082
  }
10077
- function finalProcessForTSFileAST(bindVineTemplateESTree, templateRootAST, templateMeta, tsFileAST) {
10078
- bindVineTemplateESTree(templateRootAST);
10083
+ function finalProcessForTSFileAST(bindVineTemplateESTree, tsFileAST, templateInfo) {
10084
+ bindVineTemplateESTree(templateInfo);
10079
10085
  tsFileAST.tokens = [
10080
10086
  ...tsFileAST.tokens ?? [],
10081
- ...templateMeta.tokens
10087
+ ...templateInfo.templateMeta.tokens
10082
10088
  ].sort((a, b) => a.range[0] - b.range[0]);
10083
10089
  }
10084
10090
  function runParse(code, parserOptions) {
10085
- const { ast, services, scopeManager, visitorKeys: tsESLintVisitorKeys } = typescriptBasicESLintParse(
10091
+ const {
10092
+ ast: tsESLintAST,
10093
+ scopeManager,
10094
+ services: tsESLintParserServices,
10095
+ visitorKeys: tsESLintVisitorKeys
10096
+ } = typescriptBasicESLintParse(
10086
10097
  code,
10087
10098
  parserOptions
10088
10099
  );
10089
- const prepareResults = prepareForTemplateRootAST(ast);
10100
+ const prepareResults = prepareForTemplateRootAST(tsESLintAST);
10090
10101
  for (const prepareResult of prepareResults) {
10091
- const { bindVineTemplateESTree } = prepareResult;
10102
+ const {
10103
+ bindVineTemplateESTree,
10104
+ templatePositionInfo,
10105
+ templateRawContent
10106
+ } = prepareResult;
10092
10107
  const rootData = getTemplateRootDataList(
10093
10108
  prepareResult,
10094
10109
  {
@@ -10102,19 +10117,28 @@ function runParse(code, parserOptions) {
10102
10117
  const [templateRootAST, templateMeta] = rootData;
10103
10118
  finalProcessForTSFileAST(
10104
10119
  bindVineTemplateESTree,
10105
- templateRootAST,
10106
- templateMeta,
10107
- ast
10120
+ tsESLintAST,
10121
+ {
10122
+ templateRootAST,
10123
+ templateMeta,
10124
+ templatePositionInfo,
10125
+ templateRawContent
10126
+ }
10108
10127
  );
10109
10128
  analyzeUsedInTemplateVariables(
10110
10129
  scopeManager,
10111
10130
  templateRootAST
10112
10131
  );
10113
10132
  }
10133
+ const ast = tsESLintAST;
10114
10134
  const visitorKeys = {
10115
10135
  ...tsESLintVisitorKeys,
10116
10136
  ...KEYS2
10117
10137
  };
10138
+ const services = {
10139
+ ...tsESLintParserServices
10140
+ // Todo: Maybe additional services specific to Vue Vine
10141
+ };
10118
10142
  return {
10119
10143
  ast,
10120
10144
  services,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue-vine/eslint-parser",
3
- "version": "0.1.30",
3
+ "version": "0.1.32",
4
4
  "description": "ESLint parser for Vue Vine",
5
5
  "author": "ShenQingchuan",
6
6
  "license": "MIT",
@@ -23,11 +23,11 @@
23
23
  "dist"
24
24
  ],
25
25
  "dependencies": {
26
- "@typescript-eslint/parser": "^6.21.0",
27
- "@typescript-eslint/scope-manager": "^6.21.0",
28
- "@typescript-eslint/typescript-estree": "^6.21.0",
26
+ "@typescript-eslint/parser": "^8.11.0",
27
+ "@typescript-eslint/scope-manager": "^8.11.0",
28
+ "@typescript-eslint/typescript-estree": "^8.11.0",
29
29
  "debug": "^4.3.4",
30
- "eslint-scope": "^7.2.2",
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"