@vue-vine/eslint-parser 0.1.33 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.mjs CHANGED
@@ -2340,19 +2340,6 @@ var require_sortedLastIndex = __commonJS({
2340
2340
  }
2341
2341
  });
2342
2342
 
2343
- // ../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/sortedIndexBy.js
2344
- var require_sortedIndexBy = __commonJS({
2345
- "../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/sortedIndexBy.js"(exports, module) {
2346
- "use strict";
2347
- var baseIteratee = require_baseIteratee();
2348
- var baseSortedIndexBy = require_baseSortedIndexBy();
2349
- function sortedIndexBy3(array, value, iteratee) {
2350
- return baseSortedIndexBy(array, value, baseIteratee(iteratee, 2));
2351
- }
2352
- module.exports = sortedIndexBy3;
2353
- }
2354
- });
2355
-
2356
2343
  // ../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/head.js
2357
2344
  var require_head = __commonJS({
2358
2345
  "../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/head.js"(exports, module) {
@@ -2372,6 +2359,19 @@ var require_first = __commonJS({
2372
2359
  }
2373
2360
  });
2374
2361
 
2362
+ // ../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/sortedIndexBy.js
2363
+ var require_sortedIndexBy = __commonJS({
2364
+ "../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/sortedIndexBy.js"(exports, module) {
2365
+ "use strict";
2366
+ var baseIteratee = require_baseIteratee();
2367
+ var baseSortedIndexBy = require_baseSortedIndexBy();
2368
+ function sortedIndexBy2(array, value, iteratee) {
2369
+ return baseSortedIndexBy(array, value, baseIteratee(iteratee, 2));
2370
+ }
2371
+ module.exports = sortedIndexBy2;
2372
+ }
2373
+ });
2374
+
2375
2375
  // src/parse.ts
2376
2376
  import { parseForESLint as tsParseForESLint } from "@typescript-eslint/parser";
2377
2377
 
@@ -3845,12 +3845,8 @@ var IntermediateTokenizer = class {
3845
3845
  };
3846
3846
 
3847
3847
  // src/common/error-utils.ts
3848
- var import_sortedIndexBy = __toESM(require_sortedIndexBy());
3849
- function byIndex(x) {
3850
- return x.index;
3851
- }
3852
3848
  function insertError(templateMeta, error) {
3853
- const index = (0, import_sortedIndexBy.default)(templateMeta.errors, error, byIndex);
3849
+ const index = templateMeta.errors.findIndex((e) => e.index === error.index);
3854
3850
  templateMeta.errors.splice(index, 0, error);
3855
3851
  }
3856
3852
 
@@ -3882,132 +3878,10 @@ function replaceTokens(templateMeta, node, newTokens) {
3882
3878
  // src/script/index.ts
3883
3879
  var import_first = __toESM(require_first());
3884
3880
  var import_last2 = __toESM(require_last());
3885
- var import_sortedIndexBy2 = __toESM(require_sortedIndexBy());
3881
+ var import_sortedIndexBy = __toESM(require_sortedIndexBy());
3886
3882
  import { fileURLToPath as fileURLToPath2 } from "node:url";
3887
3883
 
3888
- // src/template/utils/process-vine-template-node.ts
3889
- import { simpleTraverse as traverse2, TSESTree } from "@typescript-eslint/typescript-estree";
3890
- function fixVineOffset(token, fixCtx) {
3891
- const {
3892
- posInfo: {
3893
- templateStartOffset,
3894
- templateStartLine,
3895
- templateStartColumn
3896
- },
3897
- fixedCache: cache
3898
- } = fixCtx;
3899
- if (token.type !== "VTemplateRoot") {
3900
- if (!cache.has(token.range)) {
3901
- token.range[0] += templateStartOffset;
3902
- token.range[1] += templateStartOffset;
3903
- cache.add(token.range);
3904
- }
3905
- if (!cache.has(token.loc.start)) {
3906
- token.loc.start.line += templateStartLine - 1;
3907
- token.loc.start.column = token.loc.start.line === templateStartLine ? templateStartColumn + token.loc.start.column : token.loc.start.column;
3908
- cache.add(token.loc.start);
3909
- }
3910
- if (!cache.has(token.loc.end)) {
3911
- token.loc.end.line += templateStartLine - 1;
3912
- token.loc.end.column = token.loc.end.line === templateStartLine ? templateStartColumn + token.loc.end.column : token.loc.end.column;
3913
- cache.add(token.loc.end);
3914
- }
3915
- }
3916
- }
3917
- function extractForVineTemplate(ast) {
3918
- const extractVineTemplateResult = [];
3919
- const extractedTemplateNodes = /* @__PURE__ */ new WeakSet();
3920
- try {
3921
- traverse2(ast, {
3922
- enter(node, parent) {
3923
- if (node.type === "TaggedTemplateExpression" && node.tag.type === "Identifier" && node.tag.name === "vine") {
3924
- const templateNode = node;
3925
- if (extractedTemplateNodes.has(templateNode)) {
3926
- return;
3927
- }
3928
- extractedTemplateNodes.add(templateNode);
3929
- let parentOfTemplate;
3930
- let bindVineTemplateESTree;
3931
- if (parent?.type === TSESTree.AST_NODE_TYPES.ReturnStatement) {
3932
- parent.argument = null;
3933
- parentOfTemplate = parent;
3934
- bindVineTemplateESTree = ({ templateRootAST: vineESTree, templateMeta: _, ...templateInfo }) => {
3935
- parent.argument = vineESTree;
3936
- vineESTree.parent = parent;
3937
- vineESTree.templateInfo = templateInfo;
3938
- };
3939
- } else if (parent?.type === TSESTree.AST_NODE_TYPES.ArrowFunctionExpression) {
3940
- parent.body = null;
3941
- parentOfTemplate = parent;
3942
- bindVineTemplateESTree = ({ templateRootAST: vineESTree, templateMeta: _, ...templateInfo }) => {
3943
- parent.body = vineESTree;
3944
- vineESTree.parent = parent;
3945
- vineESTree.templateInfo = templateInfo;
3946
- };
3947
- }
3948
- ast.tokens = ast.tokens?.filter(
3949
- (token) => token.range[0] < node.range[0] || token.range[1] > node.range[1]
3950
- );
3951
- if (parentOfTemplate && bindVineTemplateESTree) {
3952
- extractVineTemplateResult.push({
3953
- templateNode,
3954
- parentOfTemplate,
3955
- bindVineTemplateESTree
3956
- });
3957
- }
3958
- }
3959
- }
3960
- }, true);
3961
- } catch (err) {
3962
- if (!(err instanceof Error) || err.message !== "BREAK_TRAVERSE") {
3963
- throw err;
3964
- }
3965
- }
3966
- return extractVineTemplateResult;
3967
- }
3968
- function prepareTemplate(templateNode) {
3969
- const { quasi: { quasis } } = templateNode;
3970
- const templateRawNode = quasis[0];
3971
- const templateRawContent = templateRawNode.value.raw;
3972
- const templateStartLine = templateRawNode.loc.start.line;
3973
- const templateEndLine = templateRawNode.loc.end.line;
3974
- const templateStartColumn = templateRawNode.loc.start.column + 1;
3975
- const templateStartOffset = templateRawNode.range[0] + 1;
3976
- const templateEndColumn = templateRawNode.loc.end.column - 1;
3977
- const templateEndOffset = templateRawNode.range[1] - 1;
3978
- return {
3979
- templatePositionInfo: {
3980
- templateStartLine,
3981
- templateStartColumn,
3982
- templateStartOffset,
3983
- templateEndOffset,
3984
- templateEndLine,
3985
- templateEndColumn
3986
- },
3987
- templateRawContent
3988
- };
3989
- }
3990
-
3991
3884
  // src/common/fix-locations.ts
3992
- function fixVineOffsetForScript(result, vineFixLocationContext) {
3993
- const traversed = /* @__PURE__ */ new WeakSet();
3994
- traverseNodes(result.ast, {
3995
- visitorKeys: result.visitorKeys,
3996
- enterNode(node) {
3997
- if (!traversed.has(node)) {
3998
- fixVineOffset(node, vineFixLocationContext);
3999
- }
4000
- },
4001
- leaveNode() {
4002
- }
4003
- });
4004
- for (const token of result.ast.tokens || []) {
4005
- fixVineOffset(token, vineFixLocationContext);
4006
- }
4007
- for (const comment of result.ast.comments || []) {
4008
- fixVineOffset(comment, vineFixLocationContext);
4009
- }
4010
- }
4011
3885
  function fixLocations(result, locationCalculator) {
4012
3886
  fixNodeLocations(result.ast, result.visitorKeys, locationCalculator);
4013
3887
  for (const token of result.ast.tokens || []) {
@@ -4120,7 +3994,7 @@ function processVForAliasAndIterator(code) {
4120
3994
  };
4121
3995
  }
4122
3996
  function getCommaTokenBeforeNode(tokens, node) {
4123
- let tokenIndex = (0, import_sortedIndexBy2.default)(
3997
+ let tokenIndex = (0, import_sortedIndexBy.default)(
4124
3998
  tokens,
4125
3999
  { range: node.range },
4126
4000
  (t) => t.range[0]
@@ -4165,14 +4039,13 @@ function throwErrorAsAdjustingOutsideOfCode(err, code, locationCalculator) {
4165
4039
  }
4166
4040
  throw err;
4167
4041
  }
4168
- function parseScriptFragment(code, locationCalculator, vineFixLocationContext, parserOptions) {
4042
+ function parseScriptFragment(code, locationCalculator, parserOptions) {
4169
4043
  try {
4170
4044
  const result = parseScript(
4171
4045
  code,
4172
4046
  parserOptions
4173
4047
  );
4174
4048
  fixLocations(result, locationCalculator);
4175
- fixVineOffsetForScript(result, vineFixLocationContext);
4176
4049
  return result;
4177
4050
  } catch (err) {
4178
4051
  const perr = ParseError.normalize(err);
@@ -4266,13 +4139,12 @@ function splitFilters(exp) {
4266
4139
  result.push(exp.slice(lastFilterIndex));
4267
4140
  return result;
4268
4141
  }
4269
- function parseExpressionBody(code, locationCalculator, vineFixLocationContext, parserOptions, allowEmpty = false) {
4142
+ function parseExpressionBody(code, locationCalculator, parserOptions, allowEmpty = false) {
4270
4143
  debug('[script] parse expression: "0(%s)"', code);
4271
4144
  try {
4272
4145
  const result = parseScriptFragment(
4273
4146
  `0(${code})`,
4274
4147
  locationCalculator.getSubCalculatorShift(-2),
4275
- vineFixLocationContext,
4276
4148
  parserOptions
4277
4149
  );
4278
4150
  const { ast } = result;
@@ -4298,13 +4170,12 @@ function parseExpressionBody(code, locationCalculator, vineFixLocationContext, p
4298
4170
  tokens.shift();
4299
4171
  tokens.shift();
4300
4172
  tokens.pop();
4301
- fixVineOffset(expression, vineFixLocationContext);
4302
4173
  return { expression, tokens, comments, references, variables: [] };
4303
4174
  } catch (err) {
4304
4175
  return throwErrorAsAdjustingOutsideOfCode(err, code, locationCalculator);
4305
4176
  }
4306
4177
  }
4307
- function parseFilter(code, locationCalculator, vineFixLocationContext, parserOptions) {
4178
+ function parseFilter(code, locationCalculator, parserOptions) {
4308
4179
  debug('[script] parse filter: "%s"', code);
4309
4180
  try {
4310
4181
  const expression = {
@@ -4329,7 +4200,6 @@ function parseFilter(code, locationCalculator, vineFixLocationContext, parserOpt
4329
4200
  const { ast } = parseScriptFragment(
4330
4201
  `"${calleeCode.trim()}"`,
4331
4202
  subCalculator,
4332
- vineFixLocationContext,
4333
4203
  parserOptions
4334
4204
  );
4335
4205
  const statement = ast.body[0];
@@ -4373,7 +4243,6 @@ function parseFilter(code, locationCalculator, vineFixLocationContext, parserOpt
4373
4243
  const result = parseScriptFragment(
4374
4244
  `0${argsCode}`,
4375
4245
  locationCalculator.getSubCalculatorAfter(paren).getSubCalculatorShift(-1),
4376
- vineFixLocationContext,
4377
4246
  parserOptions
4378
4247
  );
4379
4248
  const { ast } = result;
@@ -4430,14 +4299,13 @@ function parseScript(code, parserOptions) {
4430
4299
  }
4431
4300
  return { ast: result };
4432
4301
  }
4433
- function parseExpression(code, locationCalculator, vineFixLocationContext, parserOptions, { allowEmpty = false, allowFilters = false } = {}) {
4302
+ function parseExpression(code, locationCalculator, parserOptions, { allowEmpty = false, allowFilters = false } = {}) {
4434
4303
  debug('[script] parse expression: "%s"', code);
4435
4304
  const [mainCode, ...filterCodes] = allowFilters ? splitFilters(code) : [code];
4436
4305
  if (filterCodes.length === 0) {
4437
4306
  return parseExpressionBody(
4438
4307
  code,
4439
4308
  locationCalculator,
4440
- vineFixLocationContext,
4441
4309
  parserOptions,
4442
4310
  allowEmpty
4443
4311
  );
@@ -4445,7 +4313,6 @@ function parseExpression(code, locationCalculator, vineFixLocationContext, parse
4445
4313
  const retB = parseExpressionBody(
4446
4314
  mainCode,
4447
4315
  locationCalculator,
4448
- vineFixLocationContext,
4449
4316
  parserOptions
4450
4317
  );
4451
4318
  if (!retB.expression) {
@@ -4477,7 +4344,6 @@ function parseExpression(code, locationCalculator, vineFixLocationContext, parse
4477
4344
  const retF = parseFilter(
4478
4345
  filterCode,
4479
4346
  locationCalculator.getSubCalculatorShift(prevLoc + 1),
4480
- vineFixLocationContext,
4481
4347
  parserOptions
4482
4348
  );
4483
4349
  if (retF) {
@@ -4496,7 +4362,7 @@ function parseExpression(code, locationCalculator, vineFixLocationContext, parse
4496
4362
  ret.expression.loc.end = lastToken.loc.end;
4497
4363
  return ret;
4498
4364
  }
4499
- function parseVForExpression(code, locationCalculator, vineFixLocationContext, parserOptions) {
4365
+ function parseVForExpression(code, locationCalculator, parserOptions) {
4500
4366
  if (code.trim() === "") {
4501
4367
  throwEmptyError(locationCalculator, "'<alias> in <expression>'");
4502
4368
  }
@@ -4504,7 +4370,6 @@ function parseVForExpression(code, locationCalculator, vineFixLocationContext, p
4504
4370
  return parseVForExpressionForEcmaVersion5(
4505
4371
  code,
4506
4372
  locationCalculator,
4507
- vineFixLocationContext,
4508
4373
  parserOptions
4509
4374
  );
4510
4375
  }
@@ -4524,7 +4389,6 @@ function parseVForExpression(code, locationCalculator, vineFixLocationContext, p
4524
4389
  locationCalculator.getSubCalculatorShift(
4525
4390
  processed.hasParens ? -8 : -9
4526
4391
  ),
4527
- vineFixLocationContext,
4528
4392
  parserOptions
4529
4393
  );
4530
4394
  const { ast } = result;
@@ -4581,7 +4445,6 @@ function parseVForExpression(code, locationCalculator, vineFixLocationContext, p
4581
4445
  }
4582
4446
  }
4583
4447
  right.parent = expression;
4584
- fixVineOffset(expression, vineFixLocationContext);
4585
4448
  return { expression, tokens, comments, references, variables };
4586
4449
  } catch (err) {
4587
4450
  return throwErrorAsAdjustingOutsideOfCode(err, code, locationCalculator);
@@ -4591,7 +4454,7 @@ function isEcmaVersion5(parserOptions) {
4591
4454
  const ecmaVersion = getEcmaVersionIfUseEspree(parserOptions);
4592
4455
  return ecmaVersion != null && ecmaVersion <= 5;
4593
4456
  }
4594
- function parseVForExpressionForEcmaVersion5(code, locationCalculator, vineFixLocationContext, parserOptions) {
4457
+ function parseVForExpressionForEcmaVersion5(code, locationCalculator, parserOptions) {
4595
4458
  const processed = processVForAliasAndIterator(code);
4596
4459
  if (!processed.aliases.trim()) {
4597
4460
  return throwEmptyError(locationCalculator, "an alias");
@@ -4604,7 +4467,6 @@ function parseVForExpressionForEcmaVersion5(code, locationCalculator, vineFixLoc
4604
4467
  locationCalculator.getSubCalculatorShift(
4605
4468
  processed.hasParens ? 0 : -1
4606
4469
  ),
4607
- vineFixLocationContext,
4608
4470
  parserOptions
4609
4471
  );
4610
4472
  if (processed.hasParens) {
@@ -4644,7 +4506,6 @@ function parseVForExpressionForEcmaVersion5(code, locationCalculator, vineFixLoc
4644
4506
  const parsedIterator = parseVForIteratorForEcmaVersion5(
4645
4507
  processed.iterator,
4646
4508
  locationCalculator.getSubCalculatorShift(delimiterEnd),
4647
- vineFixLocationContext,
4648
4509
  parserOptions
4649
4510
  );
4650
4511
  tokens.push(...parsedIterator.tokens);
@@ -4671,11 +4532,10 @@ function parseVForExpressionForEcmaVersion5(code, locationCalculator, vineFixLoc
4671
4532
  return throwErrorAsAdjustingOutsideOfCode(err, code, locationCalculator);
4672
4533
  }
4673
4534
  }
4674
- function parseVForAliasesForEcmaVersion5(code, locationCalculator, vineFixLocationContext, parserOptions) {
4535
+ function parseVForAliasesForEcmaVersion5(code, locationCalculator, parserOptions) {
4675
4536
  const result = parseScriptFragment(
4676
4537
  `0(${code})`,
4677
4538
  locationCalculator.getSubCalculatorShift(-2),
4678
- vineFixLocationContext,
4679
4539
  parserOptions
4680
4540
  );
4681
4541
  const { ast } = result;
@@ -4712,11 +4572,10 @@ function parseVForAliasesForEcmaVersion5(code, locationCalculator, vineFixLocati
4712
4572
  return ret;
4713
4573
  }
4714
4574
  }
4715
- function parseVForIteratorForEcmaVersion5(code, locationCalculator, vineFixLocationContext, parserOptions) {
4575
+ function parseVForIteratorForEcmaVersion5(code, locationCalculator, parserOptions) {
4716
4576
  const result = parseScriptFragment(
4717
4577
  `0(${code})`,
4718
4578
  locationCalculator.getSubCalculatorShift(-2),
4719
- vineFixLocationContext,
4720
4579
  parserOptions
4721
4580
  );
4722
4581
  const { ast } = result;
@@ -4738,23 +4597,21 @@ function parseVForIteratorForEcmaVersion5(code, locationCalculator, vineFixLocat
4738
4597
  tokens.pop();
4739
4598
  return { right, tokens, comments, references };
4740
4599
  }
4741
- function parseVOnExpression(code, locationCalculator, vineFixLocationContext, parserOptions) {
4600
+ function parseVOnExpression(code, locationCalculator, parserOptions) {
4742
4601
  if (IS_FUNCTION_EXPRESSION.test(code) || IS_SIMPLE_PATH.test(code)) {
4743
4602
  return parseExpressionBody(
4744
4603
  code,
4745
4604
  locationCalculator,
4746
- vineFixLocationContext,
4747
4605
  parserOptions
4748
4606
  );
4749
4607
  }
4750
4608
  return parseVOnExpressionBody(
4751
4609
  code,
4752
4610
  locationCalculator,
4753
- vineFixLocationContext,
4754
4611
  parserOptions
4755
4612
  );
4756
4613
  }
4757
- function parseVOnExpressionBody(code, locationCalculator, vineFixLocationContext, parserOptions) {
4614
+ function parseVOnExpressionBody(code, locationCalculator, parserOptions) {
4758
4615
  debug('[script] parse v-on expression: "void function($event){%s}"', code);
4759
4616
  if (code.trim() === "") {
4760
4617
  throwEmptyError(locationCalculator, "statements");
@@ -4763,7 +4620,6 @@ function parseVOnExpressionBody(code, locationCalculator, vineFixLocationContext
4763
4620
  const result = parseScriptFragment(
4764
4621
  `void function($event){${code}}`,
4765
4622
  locationCalculator.getSubCalculatorShift(-22),
4766
- vineFixLocationContext,
4767
4623
  parserOptions
4768
4624
  );
4769
4625
  const { ast } = result;
@@ -4794,13 +4650,12 @@ function parseVOnExpressionBody(code, locationCalculator, vineFixLocationContext
4794
4650
  }
4795
4651
  tokens.splice(0, 6);
4796
4652
  tokens.pop();
4797
- fixVineOffset(expression, vineFixLocationContext);
4798
4653
  return { expression, tokens, comments, references, variables: [] };
4799
4654
  } catch (err) {
4800
4655
  return throwErrorAsAdjustingOutsideOfCode(err, code, locationCalculator);
4801
4656
  }
4802
4657
  }
4803
- function parseSlotScopeExpression(code, locationCalculator, vineFixLocationContext, parserOptions) {
4658
+ function parseSlotScopeExpression(code, locationCalculator, parserOptions) {
4804
4659
  debug('[script] parse slot-scope expression: "void function(%s) {}"', code);
4805
4660
  if (code.trim() === "") {
4806
4661
  throwEmptyError(
@@ -4812,7 +4667,6 @@ function parseSlotScopeExpression(code, locationCalculator, vineFixLocationConte
4812
4667
  const result = parseScriptFragment(
4813
4668
  `void function(${code}) {}`,
4814
4669
  locationCalculator.getSubCalculatorShift(-14),
4815
- vineFixLocationContext,
4816
4670
  parserOptions
4817
4671
  );
4818
4672
  const { ast } = result;
@@ -4885,7 +4739,7 @@ function getStandardDirectiveKind(element, directiveKey) {
4885
4739
  }
4886
4740
  return null;
4887
4741
  }
4888
- function parseAttributeValue(code, parserOptions, globalLocationCalculator, vineFixLocationContext, node, element, directiveKey) {
4742
+ function parseAttributeValue(code, parserOptions, globalLocationCalculator, node, element, directiveKey) {
4889
4743
  const firstChar = code[node.range[0]];
4890
4744
  const quoted = firstChar === '"' || firstChar === "'";
4891
4745
  const locationCalculator = globalLocationCalculator.getSubCalculatorAfter(
@@ -4908,28 +4762,24 @@ function parseAttributeValue(code, parserOptions, globalLocationCalculator, vine
4908
4762
  result = parseVForExpression(
4909
4763
  node.value,
4910
4764
  locationCalculator,
4911
- vineFixLocationContext,
4912
4765
  parserOptions
4913
4766
  );
4914
4767
  } else if (directiveKind === "on" && directiveKey.argument != null) {
4915
4768
  result = parseVOnExpression(
4916
4769
  node.value,
4917
4770
  locationCalculator,
4918
- vineFixLocationContext,
4919
4771
  parserOptions
4920
4772
  );
4921
4773
  } else if (directiveKind === "slot") {
4922
4774
  result = parseSlotScopeExpression(
4923
4775
  node.value,
4924
4776
  locationCalculator,
4925
- vineFixLocationContext,
4926
4777
  parserOptions
4927
4778
  );
4928
4779
  } else if (directiveKind === "bind") {
4929
4780
  result = parseExpression(
4930
4781
  node.value,
4931
4782
  locationCalculator,
4932
- vineFixLocationContext,
4933
4783
  parserOptions,
4934
4784
  { allowFilters: true }
4935
4785
  );
@@ -4937,7 +4787,6 @@ function parseAttributeValue(code, parserOptions, globalLocationCalculator, vine
4937
4787
  result = parseExpression(
4938
4788
  node.value,
4939
4789
  locationCalculator,
4940
- vineFixLocationContext,
4941
4790
  parserOptions
4942
4791
  );
4943
4792
  }
@@ -4963,7 +4812,7 @@ function parseAttributeValue(code, parserOptions, globalLocationCalculator, vine
4963
4812
  }
4964
4813
  return result;
4965
4814
  }
4966
- function parseDirectiveKeyStatically(node, templateMeta, vineFixLocationContext) {
4815
+ function parseDirectiveKeyStatically(node, templateMeta) {
4967
4816
  const {
4968
4817
  name: text,
4969
4818
  rawName: rawText,
@@ -4981,9 +4830,8 @@ function parseDirectiveKeyStatically(node, templateMeta, vineFixLocationContext)
4981
4830
  argument: null,
4982
4831
  modifiers: []
4983
4832
  };
4984
- fixVineOffset(directiveKey, vineFixLocationContext);
4985
4833
  let i = 0;
4986
- function createIdentifier(vineFixLocationContext2, start, end, name) {
4834
+ function createIdentifier(start, end, name) {
4987
4835
  const id = {
4988
4836
  type: "VIdentifier",
4989
4837
  parent: directiveKey,
@@ -4995,29 +4843,28 @@ function parseDirectiveKeyStatically(node, templateMeta, vineFixLocationContext)
4995
4843
  name: name || text.slice(start, end),
4996
4844
  rawName: rawText.slice(start, end)
4997
4845
  };
4998
- fixVineOffset(id, vineFixLocationContext2);
4999
4846
  return id;
5000
4847
  }
5001
4848
  if (shorthandSign.test(text)) {
5002
4849
  const sign = text[0];
5003
- directiveKey.name = createIdentifier(vineFixLocationContext, 0, 1, shorthandNameMap[sign]);
4850
+ directiveKey.name = createIdentifier(0, 1, shorthandNameMap[sign]);
5004
4851
  i = 1;
5005
4852
  } else {
5006
4853
  const colon = text.indexOf(":");
5007
4854
  if (colon !== -1) {
5008
- directiveKey.name = createIdentifier(vineFixLocationContext, 0, colon);
4855
+ directiveKey.name = createIdentifier(0, colon);
5009
4856
  i = colon + 1;
5010
4857
  }
5011
4858
  }
5012
4859
  if (directiveKey.name != null && text[i] === "[") {
5013
4860
  const len = text.slice(i).lastIndexOf("]");
5014
4861
  if (len !== -1) {
5015
- directiveKey.argument = createIdentifier(vineFixLocationContext, i, i + len + 1);
4862
+ directiveKey.argument = createIdentifier(i, i + len + 1);
5016
4863
  i = i + len + 1 + (text[i + len + 1] === "." ? 1 : 0);
5017
4864
  }
5018
4865
  }
5019
4866
  const modifiers = text.slice(i).split(".").map((modifierName) => {
5020
- const modifier = createIdentifier(vineFixLocationContext, i, i + modifierName.length);
4867
+ const modifier = createIdentifier(i, i + modifierName.length);
5021
4868
  if (modifierName === "" && i < text.length) {
5022
4869
  insertError(
5023
4870
  templateMeta,
@@ -5053,7 +4900,7 @@ function parseDirectiveKeyStatically(node, templateMeta, vineFixLocationContext)
5053
4900
  }
5054
4901
  if (directiveKey.name.rawName === "." && !directiveKey.modifiers.some(isPropModifier)) {
5055
4902
  const pos = (directiveKey.argument || directiveKey.name).range[1] - offset;
5056
- const propModifier = createIdentifier(vineFixLocationContext, pos, pos, "prop");
4903
+ const propModifier = createIdentifier(pos, pos, "prop");
5057
4904
  directiveKey.modifiers.unshift(propModifier);
5058
4905
  }
5059
4906
  return directiveKey;
@@ -5116,7 +4963,7 @@ function parseDirectiveKeyTokens(node) {
5116
4963
  }
5117
4964
  return tokens;
5118
4965
  }
5119
- function convertDynamicArgument(node, templateMeta, parserOptions, locationCalculator, vineFixLocationContext) {
4966
+ function convertDynamicArgument(node, templateMeta, parserOptions, locationCalculator) {
5120
4967
  const { argument } = node;
5121
4968
  if (!(argument != null && argument.type === "VIdentifier" && argument.name.startsWith("[") && argument.name.endsWith("]"))) {
5122
4969
  return;
@@ -5126,7 +4973,6 @@ function convertDynamicArgument(node, templateMeta, parserOptions, locationCalcu
5126
4973
  const { comments, expression, references, tokens } = parseExpression(
5127
4974
  rawName.slice(1, -1),
5128
4975
  locationCalculator.getSubCalculatorAfter(range[0] + 1),
5129
- vineFixLocationContext,
5130
4976
  parserOptions
5131
4977
  );
5132
4978
  node.argument = {
@@ -5137,7 +4983,6 @@ function convertDynamicArgument(node, templateMeta, parserOptions, locationCalcu
5137
4983
  expression,
5138
4984
  references
5139
4985
  };
5140
- fixVineOffset(node.argument, vineFixLocationContext);
5141
4986
  if (expression != null) {
5142
4987
  expression.parent = node.argument;
5143
4988
  }
@@ -5178,8 +5023,8 @@ function convertDynamicArgument(node, templateMeta, parserOptions, locationCalcu
5178
5023
  }
5179
5024
  }
5180
5025
  }
5181
- function createDirectiveKey(node, templateMeta, parserOptions, locationCalculator, vineFixLocationContext) {
5182
- const directiveKey = parseDirectiveKeyStatically(node, templateMeta, vineFixLocationContext);
5026
+ function createDirectiveKey(node, templateMeta, parserOptions, locationCalculator) {
5027
+ const directiveKey = parseDirectiveKeyStatically(node, templateMeta);
5183
5028
  const tokens = parseDirectiveKeyTokens(directiveKey);
5184
5029
  replaceTokens(templateMeta, directiveKey, tokens);
5185
5030
  if (directiveKey.name.name.startsWith("v-")) {
@@ -5192,8 +5037,7 @@ function createDirectiveKey(node, templateMeta, parserOptions, locationCalculato
5192
5037
  directiveKey,
5193
5038
  templateMeta,
5194
5039
  parserOptions,
5195
- locationCalculator,
5196
- vineFixLocationContext
5040
+ locationCalculator
5197
5041
  );
5198
5042
  return directiveKey;
5199
5043
  }
@@ -5210,12 +5054,7 @@ function convertToDirective(node, code, templateMeta, locationCalculator, vineFi
5210
5054
  node.key,
5211
5055
  templateMeta,
5212
5056
  parserOptions,
5213
- locationCalculator,
5214
- vineFixLocationContext
5215
- );
5216
- fixVineOffset(
5217
- directive.key,
5218
- vineFixLocationContext
5057
+ locationCalculator
5219
5058
  );
5220
5059
  const { argument } = directive.key;
5221
5060
  if (argument && argument.type === "VIdentifier" && argument.name.startsWith("[")) {
@@ -5242,7 +5081,6 @@ function convertToDirective(node, code, templateMeta, locationCalculator, vineFi
5242
5081
  code,
5243
5082
  parserOptions,
5244
5083
  locationCalculator,
5245
- vineFixLocationContext,
5246
5084
  node.value,
5247
5085
  node.parent.parent,
5248
5086
  directive.key
@@ -5255,10 +5093,6 @@ function convertToDirective(node, code, templateMeta, locationCalculator, vineFi
5255
5093
  expression: ret.expression,
5256
5094
  references: ret.references
5257
5095
  };
5258
- fixVineOffset(
5259
- directive.value,
5260
- vineFixLocationContext
5261
- );
5262
5096
  if (ret.expression != null) {
5263
5097
  ret.expression.parent = directive.value;
5264
5098
  }
@@ -5295,7 +5129,6 @@ function processMustache(parserOptions, globalLocationCalculator, vineFixLocatio
5295
5129
  const ret = parseExpression(
5296
5130
  mustache.value,
5297
5131
  locationCalculator,
5298
- vineFixLocationContext,
5299
5132
  parserOptions,
5300
5133
  { allowEmpty: true, allowFilters: true }
5301
5134
  );
@@ -5405,6 +5238,128 @@ var MATHML_ATTRIBUTE_NAME_MAP = /* @__PURE__ */ new Map([
5405
5238
  ["definitionurl", "definitionUrl"]
5406
5239
  ]);
5407
5240
 
5241
+ // src/template/utils/process-vine-template-node.ts
5242
+ import { simpleTraverse as tsESLintTravese, TSESTree } from "@typescript-eslint/typescript-estree";
5243
+ function fixVineOffset(token, fixCtx) {
5244
+ const {
5245
+ posInfo: {
5246
+ templateStartOffset,
5247
+ templateStartLine,
5248
+ templateStartColumn
5249
+ },
5250
+ fixedCache: cache
5251
+ } = fixCtx;
5252
+ if (!cache.has(token.range)) {
5253
+ token.range[0] += templateStartOffset;
5254
+ token.range[1] += templateStartOffset;
5255
+ cache.add(token.range);
5256
+ if ("start" in token) {
5257
+ token.start = token.range[0];
5258
+ }
5259
+ if ("end" in token) {
5260
+ token.end = token.range[1];
5261
+ }
5262
+ }
5263
+ if (!cache.has(token.loc.start)) {
5264
+ token.loc.start.line += templateStartLine - 1;
5265
+ token.loc.start.column = token.loc.start.line === templateStartLine ? templateStartColumn + token.loc.start.column : token.loc.start.column;
5266
+ cache.add(token.loc.start);
5267
+ }
5268
+ if (!cache.has(token.loc.end)) {
5269
+ token.loc.end.line += templateStartLine - 1;
5270
+ token.loc.end.column = token.loc.end.line === templateStartLine ? templateStartColumn + token.loc.end.column : token.loc.end.column;
5271
+ cache.add(token.loc.end);
5272
+ }
5273
+ }
5274
+ function fixFromVineTemplateRoot(root, fixCtx) {
5275
+ traverseNodes(
5276
+ root,
5277
+ {
5278
+ enterNode: (node) => {
5279
+ if (node.type === "VTemplateRoot") {
5280
+ return;
5281
+ }
5282
+ fixVineOffset(node, fixCtx);
5283
+ },
5284
+ leaveNode: () => {
5285
+ }
5286
+ }
5287
+ );
5288
+ }
5289
+ function extractForVineTemplate(ast) {
5290
+ const extractVineTemplateResult = [];
5291
+ const extractedTemplateNodes = /* @__PURE__ */ new WeakSet();
5292
+ try {
5293
+ tsESLintTravese(ast, {
5294
+ enter(node, parent) {
5295
+ if (node.type === "TaggedTemplateExpression" && node.tag.type === "Identifier" && node.tag.name === "vine") {
5296
+ const templateNode = node;
5297
+ if (extractedTemplateNodes.has(templateNode)) {
5298
+ return;
5299
+ }
5300
+ extractedTemplateNodes.add(templateNode);
5301
+ let parentOfTemplate;
5302
+ let bindVineTemplateESTree;
5303
+ if (parent?.type === TSESTree.AST_NODE_TYPES.ReturnStatement) {
5304
+ parent.argument = null;
5305
+ parentOfTemplate = parent;
5306
+ bindVineTemplateESTree = ({ templateRootAST: vineESTree, templateMeta: _, ...templateInfo }) => {
5307
+ parent.argument = vineESTree;
5308
+ vineESTree.parent = parent;
5309
+ vineESTree.templateInfo = templateInfo;
5310
+ };
5311
+ } else if (parent?.type === TSESTree.AST_NODE_TYPES.ArrowFunctionExpression) {
5312
+ parent.body = null;
5313
+ parentOfTemplate = parent;
5314
+ bindVineTemplateESTree = ({ templateRootAST: vineESTree, templateMeta: _, ...templateInfo }) => {
5315
+ parent.body = vineESTree;
5316
+ vineESTree.parent = parent;
5317
+ vineESTree.templateInfo = templateInfo;
5318
+ };
5319
+ }
5320
+ ast.tokens = ast.tokens?.filter(
5321
+ (token) => token.range[0] < node.range[0] || token.range[1] > node.range[1]
5322
+ );
5323
+ if (parentOfTemplate && bindVineTemplateESTree) {
5324
+ extractVineTemplateResult.push({
5325
+ templateNode,
5326
+ parentOfTemplate,
5327
+ bindVineTemplateESTree
5328
+ });
5329
+ }
5330
+ }
5331
+ }
5332
+ }, true);
5333
+ } catch (err) {
5334
+ if (!(err instanceof Error) || err.message !== "BREAK_TRAVERSE") {
5335
+ throw err;
5336
+ }
5337
+ }
5338
+ return extractVineTemplateResult;
5339
+ }
5340
+ function prepareTemplate(templateNode) {
5341
+ const { quasi: { quasis } } = templateNode;
5342
+ const templateRawNode = quasis[0];
5343
+ const templateRawContent = templateRawNode.value.raw;
5344
+ const templateStartLine = templateRawNode.loc.start.line;
5345
+ const templateEndLine = templateRawNode.loc.end.line;
5346
+ const templateStartColumn = templateRawNode.loc.start.column + 1;
5347
+ const templateStartOffset = templateRawNode.range[0] + 1;
5348
+ const templateEndColumn = templateRawNode.loc.end.column - 1;
5349
+ const templateEndOffset = templateRawNode.range[1] - 1;
5350
+ return {
5351
+ templatePositionInfo: {
5352
+ templateStartLine,
5353
+ templateStartColumn,
5354
+ templateStartOffset,
5355
+ templateEndOffset,
5356
+ templateEndLine,
5357
+ templateEndColumn
5358
+ },
5359
+ templateRawContent
5360
+ };
5361
+ }
5362
+
5408
5363
  // src/template/utils/tag-names.ts
5409
5364
  var HTML_VOID_ELEMENT_TAGS = /* @__PURE__ */ new Set([
5410
5365
  "area",
@@ -5665,9 +5620,10 @@ var VineTemplateParser = class {
5665
5620
  vTemplateMeta;
5666
5621
  templatePos;
5667
5622
  postProcessForScript = [];
5668
- offsetFixedTokenSet = /* @__PURE__ */ new WeakSet();
5669
- constructor(parserOptions, tokenizer, parentOfTemplate, templatePos) {
5623
+ offsetFixedTokenSet;
5624
+ constructor(parserOptions, tokenizer, parentOfTemplate, templatePos, offsetFixedTokenSet) {
5670
5625
  this.baseParserOptions = parserOptions;
5626
+ this.offsetFixedTokenSet = offsetFixedTokenSet;
5671
5627
  this.tokenizer = new IntermediateTokenizer(tokenizer, parserOptions);
5672
5628
  this.locationCalculator = new LocationCalculatorForHtml(
5673
5629
  tokenizer.gaps,
@@ -5717,7 +5673,10 @@ var VineTemplateParser = class {
5717
5673
  comment,
5718
5674
  this.fixVineOffsetCtx
5719
5675
  ));
5720
- fixVineOffset(this.vTemplateRoot, this.fixVineOffsetCtx);
5676
+ fixFromVineTemplateRoot(
5677
+ this.vTemplateRoot,
5678
+ this.fixVineOffsetCtx
5679
+ );
5721
5680
  }
5722
5681
  /**
5723
5682
  * Get the current node.
@@ -10045,7 +10004,7 @@ function prepareForTemplateRootAST(tsFileAST) {
10045
10004
  };
10046
10005
  });
10047
10006
  }
10048
- function getTemplateRootDataList(prepareResult, parserOptions) {
10007
+ function getTemplateRootDataList(prepareResult, offsetFixedTokenSet, parserOptions) {
10049
10008
  if (!prepareResult) {
10050
10009
  return null;
10051
10010
  }
@@ -10055,7 +10014,8 @@ function getTemplateRootDataList(prepareResult, parserOptions) {
10055
10014
  parserOptions,
10056
10015
  tokenizer,
10057
10016
  parentOfTemplate,
10058
- templatePositionInfo
10017
+ templatePositionInfo,
10018
+ offsetFixedTokenSet
10059
10019
  );
10060
10020
  return templateParser.parse();
10061
10021
  }
@@ -10076,6 +10036,7 @@ function runParse(code, parserOptions) {
10076
10036
  code,
10077
10037
  parserOptions
10078
10038
  );
10039
+ const offsetFixedTokenSet = /* @__PURE__ */ new WeakSet();
10079
10040
  const prepareResults = prepareForTemplateRootAST(tsESLintAST);
10080
10041
  for (const prepareResult of prepareResults) {
10081
10042
  const {
@@ -10085,6 +10046,7 @@ function runParse(code, parserOptions) {
10085
10046
  } = prepareResult;
10086
10047
  const rootData = getTemplateRootDataList(
10087
10048
  prepareResult,
10049
+ offsetFixedTokenSet,
10088
10050
  {
10089
10051
  ...parserOptions,
10090
10052
  ...forceEnableLocationOptions