astro-eslint-parser 0.5.1 → 0.6.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/lib/index.d.ts +345 -9
- package/lib/index.js +1745 -42
- package/lib/index.mjs +1719 -0
- package/package.json +9 -7
- package/lib/ast/astro.d.ts +0 -49
- package/lib/ast/astro.js +0 -2
- package/lib/ast/base.d.ts +0 -6
- package/lib/ast/base.js +0 -2
- package/lib/ast/index.d.ts +0 -8
- package/lib/ast/index.js +0 -18
- package/lib/ast/jsx.d.ts +0 -91
- package/lib/ast/jsx.js +0 -2
- package/lib/astro/index.d.ts +0 -56
- package/lib/astro/index.js +0 -357
- package/lib/astro-tools/index.d.ts +0 -21
- package/lib/astro-tools/index.js +0 -26
- package/lib/context/index.d.ts +0 -55
- package/lib/context/index.js +0 -158
- package/lib/context/parser-options.d.ts +0 -8
- package/lib/context/parser-options.js +0 -77
- package/lib/context/resolve-parser/espree.d.ts +0 -6
- package/lib/context/resolve-parser/espree.js +0 -41
- package/lib/context/resolve-parser/index.d.ts +0 -7
- package/lib/context/resolve-parser/index.js +0 -34
- package/lib/context/resolve-parser/parser-object.d.ts +0 -33
- package/lib/context/resolve-parser/parser-object.js +0 -27
- package/lib/context/script.d.ts +0 -34
- package/lib/context/script.js +0 -178
- package/lib/debug.d.ts +0 -2
- package/lib/debug.js +0 -8
- package/lib/errors.d.ts +0 -14
- package/lib/errors.js +0 -20
- package/lib/parser/astro-parser/astrojs-compiler-service.d.ts +0 -5
- package/lib/parser/astro-parser/astrojs-compiler-service.js +0 -12
- package/lib/parser/astro-parser/astrojs-compiler-worker.d.ts +0 -1
- package/lib/parser/astro-parser/astrojs-compiler-worker.js +0 -11
- package/lib/parser/astro-parser/parse.d.ts +0 -6
- package/lib/parser/astro-parser/parse.js +0 -270
- package/lib/parser/index.d.ts +0 -21
- package/lib/parser/index.js +0 -72
- package/lib/parser/lru-cache.d.ts +0 -7
- package/lib/parser/lru-cache.js +0 -32
- package/lib/parser/process-template.d.ts +0 -7
- package/lib/parser/process-template.js +0 -390
- package/lib/parser/script.d.ts +0 -7
- package/lib/parser/script.js +0 -44
- package/lib/parser/sort.d.ts +0 -6
- package/lib/parser/sort.js +0 -15
- package/lib/parser/template.d.ts +0 -10
- package/lib/parser/template.js +0 -102
- package/lib/parser/ts-patch.d.ts +0 -8
- package/lib/parser/ts-patch.js +0 -65
- package/lib/traverse.d.ts +0 -27
- package/lib/traverse.js +0 -93
- package/lib/types.d.ts +0 -17
- package/lib/types.js +0 -2
- package/lib/visitor-keys.d.ts +0 -2
- package/lib/visitor-keys.js +0 -14
package/lib/traverse.js
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.traverseNodes = exports.getNodes = exports.getKeys = exports.getFallbackKeys = void 0;
|
|
4
|
-
const visitor_keys_1 = require("./visitor-keys");
|
|
5
|
-
/**
|
|
6
|
-
* Check that the given key should be traversed or not.
|
|
7
|
-
* @this {Traversable}
|
|
8
|
-
* @param key The key to check.
|
|
9
|
-
* @returns `true` if the key should be traversed.
|
|
10
|
-
*/
|
|
11
|
-
function fallbackKeysFilter(key) {
|
|
12
|
-
let value = null;
|
|
13
|
-
return (key !== "comments" &&
|
|
14
|
-
key !== "leadingComments" &&
|
|
15
|
-
key !== "loc" &&
|
|
16
|
-
key !== "parent" &&
|
|
17
|
-
key !== "range" &&
|
|
18
|
-
key !== "tokens" &&
|
|
19
|
-
key !== "trailingComments" &&
|
|
20
|
-
(value = this[key]) !== null &&
|
|
21
|
-
typeof value === "object" &&
|
|
22
|
-
(typeof value.type === "string" || Array.isArray(value)));
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Get the keys of the given node to traverse it.
|
|
26
|
-
* @param node The node to get.
|
|
27
|
-
* @returns The keys to traverse.
|
|
28
|
-
*/
|
|
29
|
-
function getFallbackKeys(node) {
|
|
30
|
-
return Object.keys(node).filter(fallbackKeysFilter, node);
|
|
31
|
-
}
|
|
32
|
-
exports.getFallbackKeys = getFallbackKeys;
|
|
33
|
-
/**
|
|
34
|
-
* Get the keys of the given node to traverse it.
|
|
35
|
-
* @param node The node to get.
|
|
36
|
-
* @returns The keys to traverse.
|
|
37
|
-
*/
|
|
38
|
-
function getKeys(node, visitorKeys) {
|
|
39
|
-
const keys = (visitorKeys || visitor_keys_1.KEYS)[node.type] || getFallbackKeys(node);
|
|
40
|
-
return keys.filter((key) => !getNodes(node, key).next().done);
|
|
41
|
-
}
|
|
42
|
-
exports.getKeys = getKeys;
|
|
43
|
-
/**
|
|
44
|
-
* Get the nodes of the given node.
|
|
45
|
-
* @param node The node to get.
|
|
46
|
-
*/
|
|
47
|
-
function* getNodes(node, key) {
|
|
48
|
-
const child = node[key];
|
|
49
|
-
if (Array.isArray(child)) {
|
|
50
|
-
for (const c of child) {
|
|
51
|
-
if (isNode(c)) {
|
|
52
|
-
yield c;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
else if (isNode(child)) {
|
|
57
|
-
yield child;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
exports.getNodes = getNodes;
|
|
61
|
-
/**
|
|
62
|
-
* Check whether a given value is a node.
|
|
63
|
-
* @param x The value to check.
|
|
64
|
-
* @returns `true` if the value is a node.
|
|
65
|
-
*/
|
|
66
|
-
function isNode(x) {
|
|
67
|
-
return x !== null && typeof x === "object" && typeof x.type === "string";
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Traverse the given node.
|
|
71
|
-
* @param node The node to traverse.
|
|
72
|
-
* @param parent The parent node.
|
|
73
|
-
* @param visitor The node visitor.
|
|
74
|
-
*/
|
|
75
|
-
function traverse(node, parent, visitor) {
|
|
76
|
-
visitor.enterNode(node, parent);
|
|
77
|
-
const keys = getKeys(node, visitor.visitorKeys);
|
|
78
|
-
for (const key of keys) {
|
|
79
|
-
for (const child of getNodes(node, key)) {
|
|
80
|
-
traverse(child, node, visitor);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
visitor.leaveNode(node, parent);
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Traverse the given AST tree.
|
|
87
|
-
* @param node Root node to traverse.
|
|
88
|
-
* @param visitor Visitor.
|
|
89
|
-
*/
|
|
90
|
-
function traverseNodes(node, visitor) {
|
|
91
|
-
traverse(node, null, visitor);
|
|
92
|
-
}
|
|
93
|
-
exports.traverseNodes = traverseNodes;
|
package/lib/types.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { TSESTree } from "@typescript-eslint/types";
|
|
2
|
-
import type { ScopeManager } from "eslint-scope";
|
|
3
|
-
/**
|
|
4
|
-
* The parsing result of ESLint custom parsers.
|
|
5
|
-
*/
|
|
6
|
-
export interface ESLintExtendedProgram {
|
|
7
|
-
ast: TSESTree.Program;
|
|
8
|
-
services?: Record<string, any>;
|
|
9
|
-
visitorKeys?: {
|
|
10
|
-
[type: string]: string[];
|
|
11
|
-
};
|
|
12
|
-
scopeManager?: ScopeManager;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* The interface of a result of ESLint custom parser.
|
|
16
|
-
*/
|
|
17
|
-
export declare type ESLintCustomParserResult = ESLintExtendedProgram["ast"] | ESLintExtendedProgram;
|
package/lib/types.js
DELETED
package/lib/visitor-keys.d.ts
DELETED
package/lib/visitor-keys.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.KEYS = void 0;
|
|
4
|
-
const eslint_visitor_keys_1 = require("eslint-visitor-keys");
|
|
5
|
-
const astroKeys = {
|
|
6
|
-
Program: ["body"],
|
|
7
|
-
AstroFragment: ["children"],
|
|
8
|
-
AstroHTMLComment: [],
|
|
9
|
-
AstroDoctype: [],
|
|
10
|
-
AstroShorthandAttribute: ["name", "value"],
|
|
11
|
-
AstroTemplateLiteralAttribute: ["name", "value"],
|
|
12
|
-
AstroRawText: [],
|
|
13
|
-
};
|
|
14
|
-
exports.KEYS = (0, eslint_visitor_keys_1.unionWith)(astroKeys);
|