@vue-vine/eslint-parser 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +312 -296
- package/dist/index.js +65 -51
- package/package.json +1 -1
package/dist/index.js
CHANGED
@@ -37,6 +37,11 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
37
37
|
enumerable: true
|
38
38
|
}) : target, mod));
|
39
39
|
|
40
|
+
//#endregion
|
41
|
+
//#region package.json
|
42
|
+
var name = "@vue-vine/eslint-parser";
|
43
|
+
var version = "1.1.0";
|
44
|
+
|
40
45
|
//#endregion
|
41
46
|
//#region src/ast/errors.ts
|
42
47
|
/**
|
@@ -491,9 +496,9 @@ function getDefaultEcmaVersion() {
|
|
491
496
|
/**
|
492
497
|
* Normalize ECMAScript version
|
493
498
|
*/
|
494
|
-
function normalizeEcmaVersion(version) {
|
495
|
-
if (version > 5 && version < 2015) return version + 2009;
|
496
|
-
return version;
|
499
|
+
function normalizeEcmaVersion(version$1) {
|
500
|
+
if (version$1 > 5 && version$1 < 2015) return version$1 + 2009;
|
501
|
+
return version$1;
|
497
502
|
}
|
498
503
|
function getLatestEcmaVersion(espree) {
|
499
504
|
if (espree.latestEcmaVersion == null) {
|
@@ -3651,8 +3656,8 @@ function throwEmptyError(locationCalculator, expected) {
|
|
3651
3656
|
* @param name The token name.
|
3652
3657
|
* @param token The token object to get that location.
|
3653
3658
|
*/
|
3654
|
-
function throwUnexpectedTokenError(name, token) {
|
3655
|
-
const err = new ParseError(`Unexpected token '${name}'.`, void 0, token.range[0], token.loc.start.line, token.loc.start.column);
|
3659
|
+
function throwUnexpectedTokenError(name$1, token) {
|
3660
|
+
const err = new ParseError(`Unexpected token '${name$1}'.`, void 0, token.range[0], token.loc.start.line, token.loc.start.column);
|
3656
3661
|
throw err;
|
3657
3662
|
}
|
3658
3663
|
/**
|
@@ -4369,7 +4374,7 @@ function parseDirectiveKeyStatically(node, templateMeta) {
|
|
4369
4374
|
modifiers: []
|
4370
4375
|
};
|
4371
4376
|
let i = 0;
|
4372
|
-
function createIdentifier(start, end, name) {
|
4377
|
+
function createIdentifier(start, end, name$1) {
|
4373
4378
|
const id = {
|
4374
4379
|
type: "VIdentifier",
|
4375
4380
|
parent: directiveKey,
|
@@ -4384,7 +4389,7 @@ function parseDirectiveKeyStatically(node, templateMeta) {
|
|
4384
4389
|
line
|
4385
4390
|
}
|
4386
4391
|
},
|
4387
|
-
name: name || text.slice(start, end),
|
4392
|
+
name: name$1 || text.slice(start, end),
|
4388
4393
|
rawName: rawText.slice(start, end)
|
4389
4394
|
};
|
4390
4395
|
return id;
|
@@ -4429,27 +4434,27 @@ function parseDirectiveKeyStatically(node, templateMeta) {
|
|
4429
4434
|
* @param node The key node to parse.
|
4430
4435
|
*/
|
4431
4436
|
function parseDirectiveKeyTokens(node) {
|
4432
|
-
const { name, argument, modifiers } = node;
|
4433
|
-
const shorthand = name.range[1] - name.range[0] === 1;
|
4437
|
+
const { name: name$1, argument, modifiers } = node;
|
4438
|
+
const shorthand = name$1.range[1] - name$1.range[0] === 1;
|
4434
4439
|
const tokens = [];
|
4435
4440
|
if (shorthand) tokens.push({
|
4436
4441
|
type: "Punctuator",
|
4437
|
-
range: name.range,
|
4438
|
-
loc: name.loc,
|
4439
|
-
value: name.rawName
|
4442
|
+
range: name$1.range,
|
4443
|
+
loc: name$1.loc,
|
4444
|
+
value: name$1.rawName
|
4440
4445
|
});
|
4441
4446
|
else {
|
4442
4447
|
tokens.push({
|
4443
4448
|
type: "HTMLIdentifier",
|
4444
|
-
range: name.range,
|
4445
|
-
loc: name.loc,
|
4446
|
-
value: name.rawName
|
4449
|
+
range: name$1.range,
|
4450
|
+
loc: name$1.loc,
|
4451
|
+
value: name$1.rawName
|
4447
4452
|
});
|
4448
4453
|
if (argument) tokens.push({
|
4449
4454
|
type: "Punctuator",
|
4450
|
-
range: [name.range[1], argument.range[0]],
|
4455
|
+
range: [name$1.range[1], argument.range[0]],
|
4451
4456
|
loc: {
|
4452
|
-
start: name.loc.end,
|
4457
|
+
start: name$1.loc.end,
|
4453
4458
|
end: argument.loc.start
|
4454
4459
|
},
|
4455
4460
|
value: ":"
|
@@ -4461,7 +4466,7 @@ function parseDirectiveKeyTokens(node) {
|
|
4461
4466
|
loc: argument.loc,
|
4462
4467
|
value: argument.rawName
|
4463
4468
|
});
|
4464
|
-
let lastNode = argument || name;
|
4469
|
+
let lastNode = argument || name$1;
|
4465
4470
|
for (const modifier of modifiers) {
|
4466
4471
|
if (modifier.rawName === "") continue;
|
4467
4472
|
tokens.push({
|
@@ -4863,12 +4868,12 @@ function analyzeUsedInTemplateVariables(scopeManager, templateRoot) {
|
|
4863
4868
|
/**
|
4864
4869
|
* @see https://github.com/vuejs/vue-next/blob/48de8a42b7fed7a03f7f1ff5d53d6a704252cafe/packages/compiler-core/src/transforms/transformElement.ts#L335
|
4865
4870
|
*/
|
4866
|
-
function markSetupReferenceVariableAsUsed(name) {
|
4867
|
-
if (scriptVariables.has(name)) {
|
4868
|
-
markVariableAsUsed(name);
|
4871
|
+
function markSetupReferenceVariableAsUsed(name$1) {
|
4872
|
+
if (scriptVariables.has(name$1)) {
|
4873
|
+
markVariableAsUsed(name$1);
|
4869
4874
|
return true;
|
4870
4875
|
}
|
4871
|
-
const camelName = camelize(name);
|
4876
|
+
const camelName = camelize(name$1);
|
4872
4877
|
if (scriptVariables.has(camelName)) {
|
4873
4878
|
markVariableAsUsed(camelName);
|
4874
4879
|
return true;
|
@@ -4881,19 +4886,19 @@ function analyzeUsedInTemplateVariables(scopeManager, templateRoot) {
|
|
4881
4886
|
return false;
|
4882
4887
|
}
|
4883
4888
|
function markVariableAsUsed(nameOrRef) {
|
4884
|
-
let name;
|
4889
|
+
let name$1;
|
4885
4890
|
let isValueReference;
|
4886
4891
|
let isTypeReference;
|
4887
|
-
if (typeof nameOrRef === "string") name = nameOrRef;
|
4892
|
+
if (typeof nameOrRef === "string") name$1 = nameOrRef;
|
4888
4893
|
else {
|
4889
|
-
name = nameOrRef.id.name;
|
4894
|
+
name$1 = nameOrRef.id.name;
|
4890
4895
|
isValueReference = nameOrRef.isValueReference;
|
4891
4896
|
isTypeReference = nameOrRef.isTypeReference;
|
4892
4897
|
}
|
4893
|
-
const variable = scriptVariables.get(name);
|
4898
|
+
const variable = scriptVariables.get(name$1);
|
4894
4899
|
if (!variable || variable.identifiers.length === 0) return;
|
4895
|
-
if (markedVariables.has(name)) return;
|
4896
|
-
markedVariables.add(name);
|
4900
|
+
if (markedVariables.has(name$1)) return;
|
4901
|
+
markedVariables.add(name$1);
|
4897
4902
|
const reference = new tsEscopeTypes.Reference(variable.identifiers[0], variable.scope, ReferenceFlag.Read, void 0, void 0, void 0, isValueReference ? ReferenceTypeFlag.Value : isTypeReference ? ReferenceTypeFlag.Type : void 0);
|
4898
4903
|
reference.vueUsedInTemplate = true;
|
4899
4904
|
reference.isWrite = () => false;
|
@@ -6172,7 +6177,7 @@ const SVG_TAGS = new Set([
|
|
6172
6177
|
* The map from lowercase names to actual names in SVG.
|
6173
6178
|
*/
|
6174
6179
|
const SVG_ELEMENT_NAME_MAP = new Map();
|
6175
|
-
for (const name of SVG_TAGS) if (/[A-Z]/.test(name)) SVG_ELEMENT_NAME_MAP.set(name.toLowerCase(), name);
|
6180
|
+
for (const name$1 of SVG_TAGS) if (/[A-Z]/.test(name$1)) SVG_ELEMENT_NAME_MAP.set(name$1.toLowerCase(), name$1);
|
6176
6181
|
|
6177
6182
|
//#endregion
|
6178
6183
|
//#region src/template/parser.ts
|
@@ -6198,10 +6203,10 @@ function propagateEndLocation(node) {
|
|
6198
6203
|
* @param namespace The current namespace.
|
6199
6204
|
* @returns The adjusted attribute name.
|
6200
6205
|
*/
|
6201
|
-
function adjustAttributeName(name, namespace) {
|
6202
|
-
if (namespace === NS.SVG) return SVG_ATTRIBUTE_NAME_MAP.get(name) || name;
|
6203
|
-
if (namespace === NS.MathML) return MATHML_ATTRIBUTE_NAME_MAP.get(name) || name;
|
6204
|
-
return name;
|
6206
|
+
function adjustAttributeName(name$1, namespace) {
|
6207
|
+
if (namespace === NS.SVG) return SVG_ATTRIBUTE_NAME_MAP.get(name$1) || name$1;
|
6208
|
+
if (namespace === NS.MathML) return MATHML_ATTRIBUTE_NAME_MAP.get(name$1) || name$1;
|
6209
|
+
return name$1;
|
6205
6210
|
}
|
6206
6211
|
/**
|
6207
6212
|
* Check whether the element is a MathML text integration point or not.
|
@@ -6211,8 +6216,8 @@ function adjustAttributeName(name, namespace) {
|
|
6211
6216
|
*/
|
6212
6217
|
function isMathMLIntegrationPoint(element) {
|
6213
6218
|
if (element.namespace === NS.MathML) {
|
6214
|
-
const name = element.rawName;
|
6215
|
-
return name === "mi" || name === "mo" || name === "mn" || name === "ms" || name === "mtext";
|
6219
|
+
const name$1 = element.rawName;
|
6220
|
+
return name$1 === "mi" || name$1 === "mo" || name$1 === "mn" || name$1 === "ms" || name$1 === "mtext";
|
6216
6221
|
}
|
6217
6222
|
return false;
|
6218
6223
|
}
|
@@ -6225,8 +6230,8 @@ function isMathMLIntegrationPoint(element) {
|
|
6225
6230
|
function isHTMLIntegrationPoint(element) {
|
6226
6231
|
if (element.namespace === NS.MathML) return element.rawName === "annotation-xml" && element.startTag.attributes.some((a) => a.directive === false && a.key.name === "encoding" && a.value != null && (a.value.value === "text/html" || a.value.value === "application/xhtml+xml"));
|
6227
6232
|
if (element.namespace === NS.SVG) {
|
6228
|
-
const name = element.rawName;
|
6229
|
-
return name === "foreignObject" || name === "desc" || name === "title";
|
6233
|
+
const name$1 = element.rawName;
|
6234
|
+
return name$1 === "foreignObject" || name$1 === "desc" || name$1 === "title";
|
6230
6235
|
}
|
6231
6236
|
return false;
|
6232
6237
|
}
|
@@ -6236,9 +6241,9 @@ function isHTMLIntegrationPoint(element) {
|
|
6236
6241
|
* @param namespace The current namespace.
|
6237
6242
|
* @returns The adjusted element name.
|
6238
6243
|
*/
|
6239
|
-
function adjustElementName(name, namespace) {
|
6240
|
-
if (namespace === NS.SVG) return SVG_ELEMENT_NAME_MAP.get(name) || name;
|
6241
|
-
return name;
|
6244
|
+
function adjustElementName(name$1, namespace) {
|
6245
|
+
if (namespace === NS.SVG) return SVG_ELEMENT_NAME_MAP.get(name$1) || name$1;
|
6246
|
+
return name$1;
|
6242
6247
|
}
|
6243
6248
|
/**
|
6244
6249
|
* Vine ESLint parser for Vue template.
|
@@ -6367,20 +6372,20 @@ var VineTemplateParser = class {
|
|
6367
6372
|
* @returns The namespace of the new element.
|
6368
6373
|
*/
|
6369
6374
|
detectNamespace(token) {
|
6370
|
-
const name = token.rawName;
|
6375
|
+
const name$1 = token.rawName;
|
6371
6376
|
let ns = this.namespace;
|
6372
6377
|
if (ns === NS.MathML || ns === NS.SVG) {
|
6373
6378
|
const element = this.currentNode;
|
6374
6379
|
if (element.type === "VElement") {
|
6375
|
-
if (element.namespace === NS.MathML && element.rawName === "annotation-xml" && name === "svg") return NS.SVG;
|
6376
|
-
if (isHTMLIntegrationPoint(element) || isMathMLIntegrationPoint(element) && name !== "mglyph" && name !== "malignmark") ns = NS.HTML;
|
6380
|
+
if (element.namespace === NS.MathML && element.rawName === "annotation-xml" && name$1 === "svg") return NS.SVG;
|
6381
|
+
if (isHTMLIntegrationPoint(element) || isMathMLIntegrationPoint(element) && name$1 !== "mglyph" && name$1 !== "malignmark") ns = NS.HTML;
|
6377
6382
|
}
|
6378
6383
|
}
|
6379
6384
|
if (ns === NS.HTML) {
|
6380
|
-
if (name === "svg") return NS.SVG;
|
6381
|
-
if (name === "math") return NS.MathML;
|
6385
|
+
if (name$1 === "svg") return NS.SVG;
|
6386
|
+
if (name$1 === "math") return NS.MathML;
|
6382
6387
|
}
|
6383
|
-
if (name === "template") {
|
6388
|
+
if (name$1 === "template") {
|
6384
6389
|
const xmlns = token.attributes.find((a) => a.key.name === "xmlns");
|
6385
6390
|
const value = xmlns && xmlns.value && xmlns.value.value;
|
6386
6391
|
if (value === NS.HTML || value === NS.MathML || value === NS.SVG) return value;
|
@@ -6431,11 +6436,11 @@ var VineTemplateParser = class {
|
|
6431
6436
|
closeCurrentElementIfNecessary(token) {
|
6432
6437
|
const element = this.currentNode;
|
6433
6438
|
if (element.type !== "VElement") return;
|
6434
|
-
const name = token.rawName;
|
6439
|
+
const name$1 = token.rawName;
|
6435
6440
|
const elementName = element.rawName;
|
6436
|
-
if (elementName === "p" && HTML_NON_FHRASING_TAGS.has(name)) this.popElementStack();
|
6437
|
-
if (elementName === name && HTML_CAN_BE_LEFT_OPEN_TAGS.has(name)) this.popElementStack();
|
6438
|
-
if (DT_DD.test(elementName) && DT_DD.test(name)) this.popElementStack();
|
6441
|
+
if (elementName === "p" && HTML_NON_FHRASING_TAGS.has(name$1)) this.popElementStack();
|
6442
|
+
if (elementName === name$1 && HTML_CAN_BE_LEFT_OPEN_TAGS.has(name$1)) this.popElementStack();
|
6443
|
+
if (DT_DD.test(elementName) && DT_DD.test(name$1)) this.popElementStack();
|
6439
6444
|
}
|
6440
6445
|
StartTag(token) {
|
6441
6446
|
debug("[html] StartTag %j", token);
|
@@ -10494,6 +10499,10 @@ function runParse(code, parserOptions) {
|
|
10494
10499
|
|
10495
10500
|
//#endregion
|
10496
10501
|
//#region src/index.ts
|
10502
|
+
const meta = {
|
10503
|
+
name,
|
10504
|
+
version
|
10505
|
+
};
|
10497
10506
|
function parse(code, parserOptions) {
|
10498
10507
|
return parseForESLint(code, parserOptions).ast;
|
10499
10508
|
}
|
@@ -10512,6 +10521,11 @@ function parseForESLint(code, parserOptions) {
|
|
10512
10521
|
visitorKeys
|
10513
10522
|
};
|
10514
10523
|
}
|
10524
|
+
var src_default = {
|
10525
|
+
meta,
|
10526
|
+
parse,
|
10527
|
+
parseForESLint
|
10528
|
+
};
|
10515
10529
|
|
10516
10530
|
//#endregion
|
10517
|
-
export { KEYS, NS, ParseError, getFallbackKeys, parse, parseForESLint, traverseNodes };
|
10531
|
+
export { KEYS, NS, ParseError, src_default as default, getFallbackKeys, meta, parse, parseForESLint, traverseNodes };
|