@markuplint/astro-parser 3.4.0 → 3.5.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.
@@ -5,7 +5,7 @@ export type ASTNode = TemplateNode;
5
5
  export type ASTStyleNode = Style;
6
6
  export type ASTAttribute = Attribute;
7
7
  export type AstroAST = {
8
- html?: ASTNode;
9
- style?: ASTStyleNode[];
8
+ html?: ASTNode;
9
+ style?: ASTStyleNode[];
10
10
  };
11
11
  export declare function astroParse(code: string): AstroAST | AstroCompileError;
@@ -2,7 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.attrTokenizer = void 0;
4
4
  const parser_utils_1 = require("@markuplint/parser-utils");
5
- function attrTokenizer(attr, rawHtml, codeOffset) {
5
+ function attrTokenizer(
6
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
7
+ attr, rawHtml, codeOffset) {
6
8
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
7
9
  const { raw, startOffset } = (0, parser_utils_1.sliceFragment)(rawHtml, attr.start + codeOffset, attr.end + codeOffset);
8
10
  const isDynamicValue = ((_b = (_a = attr.value) === null || _a === void 0 ? void 0 : _a.some) === null || _b === void 0 ? void 0 : _b.call(_a, v => {
package/lib/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  export { parse } from './parse';
2
- export declare const endTag = 'xml';
2
+ export declare const endTag = "xml";
package/lib/parse.js CHANGED
@@ -25,7 +25,7 @@ const parse = (rawCode, options) => {
25
25
  const styleNodes = parseStyle(ast.style, 'http://www.w3.org/1999/xhtml', rawCode, 0, options);
26
26
  htmlRawNodeList.push(...styleNodes);
27
27
  }
28
- const nodeList = (0, html_parser_1.flattenNodes)(htmlRawNodeList, rawCode);
28
+ const nodeList = (0, parser_utils_1.flattenNodes)(htmlRawNodeList, rawCode);
29
29
  // Remove `</template>`
30
30
  const templateEndTagIndex = nodeList.findIndex(node => /\s*<\/\s*template\s*>\s*/i.test(node.raw));
31
31
  if (templateEndTagIndex !== -1) {
@@ -43,7 +43,9 @@ const parse = (rawCode, options) => {
43
43
  };
44
44
  };
45
45
  exports.parse = parse;
46
- function traverse(rootNode, parentNode = null, scopeNS, rawHtml, offset, options) {
46
+ function traverse(
47
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
48
+ rootNode, parentNode = null, scopeNS, rawHtml, offset, options) {
47
49
  const nodeList = [];
48
50
  if (!rootNode.children) {
49
51
  return nodeList;
@@ -68,7 +70,13 @@ function traverse(rootNode, parentNode = null, scopeNS, rawHtml, offset, options
68
70
  }
69
71
  return nodeList;
70
72
  }
71
- function nodeize(originNode, prevNode, parentNode, scopeNS, rawHtml, offset = 0, options) {
73
+ function nodeize(
74
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
75
+ originNode,
76
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
77
+ prevNode,
78
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
79
+ parentNode, scopeNS, rawHtml, offset = 0, options) {
72
80
  var _a, _b;
73
81
  const nextNode = null;
74
82
  const startOffset = originNode.start + offset;
@@ -222,7 +230,15 @@ function nodeize(originNode, prevNode, parentNode, scopeNS, rawHtml, offset = 0,
222
230
  }
223
231
  }
224
232
  }
225
- function parseElement(nodeName, originNode, scopeNS, rawHtml, startLine, startCol, startOffset, parentNode, prevNode, nextNode, offset, options) {
233
+ function parseElement(nodeName,
234
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
235
+ originNode, scopeNS, rawHtml, startLine, startCol, startOffset,
236
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
237
+ parentNode,
238
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
239
+ prevNode,
240
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
241
+ nextNode, offset, options) {
226
242
  var _a, _b;
227
243
  const { raw } = (0, parser_utils_1.sliceFragment)(rawHtml, originNode.start + offset, originNode.end + offset);
228
244
  let childrenStart;
@@ -291,7 +307,9 @@ function parseElement(nodeName, originNode, scopeNS, rawHtml, startLine, startCo
291
307
  type: 'starttag',
292
308
  namespace: scopeNS,
293
309
  elementType: (0, parser_utils_1.detectElementType)(tagName, options === null || options === void 0 ? void 0 : options.authoredElementName, /^[A-Z]|\./),
294
- attributes: originNode.attributes.map((attr) => (0, attr_tokenizer_1.attrTokenizer)(attr, rawHtml, offset)),
310
+ attributes: originNode.attributes.map((
311
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
312
+ attr) => (0, attr_tokenizer_1.attrTokenizer)(attr, rawHtml, offset)),
295
313
  hasSpreadAttr: false,
296
314
  parentNode,
297
315
  prevNode,
@@ -310,7 +328,9 @@ function parseElement(nodeName, originNode, scopeNS, rawHtml, startLine, startCo
310
328
  startTag.childNodes = traverse(originNode, startTag, scopeNS, rawHtml, offset);
311
329
  return startTag;
312
330
  }
313
- function parseStyle(nodes, scopeNS, rawHtml, offset, options) {
331
+ function parseStyle(
332
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
333
+ nodes, scopeNS, rawHtml, offset, options) {
314
334
  const result = [];
315
335
  for (const node of nodes) {
316
336
  const { startLine, startCol, startOffset } = (0, parser_utils_1.sliceFragment)(rawHtml, node.start, node.end);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@markuplint/astro-parser",
3
- "version": "3.4.0",
3
+ "version": "3.5.0",
4
4
  "description": "astro parser for markuplint",
5
5
  "repository": "git@github.com:markuplint/markuplint.git",
6
6
  "author": "Yusuke Hirao <yusukehirao@me.com>",
@@ -17,10 +17,10 @@
17
17
  },
18
18
  "dependencies": {
19
19
  "@astrojs/parser": "0.20",
20
- "@markuplint/html-parser": "3.4.0",
21
- "@markuplint/ml-ast": "3.0.0",
22
- "@markuplint/parser-utils": "3.4.0",
20
+ "@markuplint/html-parser": "3.5.0",
21
+ "@markuplint/ml-ast": "3.1.0",
22
+ "@markuplint/parser-utils": "3.5.0",
23
23
  "tslib": "^2.4.1"
24
24
  },
25
- "gitHead": "a83e0f5f214a9bbcc0286b9e269074ddca6189e7"
25
+ "gitHead": "0c47b2c2722f6823a17f36edbab98486275f8ab4"
26
26
  }