@html-eslint/parser
Advanced tools
Comparing version
@@ -6,5 +6,2 @@ const { parseForESLint } = require("./parser"); | ||
module.exports.parseForESLint = parseForESLint; | ||
module.exports.NODE_TYPES = NODE_TYPES; | ||
module.exports = { | ||
@@ -11,0 +8,0 @@ TEMPLATE_ENGINE_SYNTAX, |
/** | ||
* @typedef {import("./types").ParserOptions} ParserOptions | ||
* @typedef {import("eslint").AST.Program} Program | ||
*/ | ||
const { parse } = require("es-html-parser"); | ||
const { parse, TokenTypes } = require("es-html-parser"); | ||
const { visitorKeys } = require("./visitor-keys"); | ||
@@ -27,13 +28,21 @@ const { traverse } = require("./traverse"); | ||
/** | ||
* @type {Program} | ||
*/ | ||
const programNode = { | ||
type: "Program", | ||
// @ts-ignore | ||
body: [ast], | ||
loc: ast.loc, | ||
range: ast.range, | ||
// @ts-ignore | ||
tokens: tokens.filter( | ||
(token) => | ||
token.type !== NODE_TYPES.CommentContent && | ||
token.type !== NODE_TYPES.CommentOpen && | ||
token.type !== NODE_TYPES.CommentClose | ||
token.type !== TokenTypes.CommentContent && | ||
token.type !== TokenTypes.CommentOpen && | ||
token.type !== TokenTypes.CommentClose | ||
), | ||
/** | ||
* | ||
*/ | ||
comments: [], | ||
@@ -45,2 +54,3 @@ }; | ||
programNode.comments.push({ | ||
// @ts-ignore | ||
type: node.type, | ||
@@ -47,0 +57,0 @@ range: node.range, |
/** | ||
* @typedef {import("./types").AnyHTMLNode} AnyHTMLNode | ||
* @typedef {import("es-html-parser").AnyNode} AnyNode | ||
* @typedef {import("eslint").AST.Program} Program | ||
*/ | ||
@@ -8,4 +9,4 @@ const { visitorKeys } = require("./visitor-keys"); | ||
* | ||
* @param {AnyHTMLNode} node | ||
* @param {(arg: AnyHTMLNode) => void} visitor | ||
* @param {AnyNode | Program} node | ||
* @param {(arg: AnyNode | Program) => void} visitor | ||
* @returns {void} | ||
@@ -19,2 +20,3 @@ */ | ||
const type = node.type; | ||
// @ts-ignore | ||
const keys = visitorKeys[type]; | ||
@@ -26,2 +28,3 @@ | ||
// @ts-ignore | ||
keys.forEach((key) => { | ||
@@ -28,0 +31,0 @@ // @ts-ignore |
@@ -0,3 +1,5 @@ | ||
export * from "./index"; | ||
export type ParserOptions = { | ||
templateEngineSyntax?: Record<string, string>; | ||
}; |
{ | ||
"name": "@html-eslint/parser", | ||
"version": "0.35.0", | ||
"version": "0.35.1", | ||
"description": "Parser for @html-eslint/eslint-plugin", | ||
@@ -9,11 +9,5 @@ "author": "yeonjuan", | ||
"main": "lib/index.js", | ||
"types": "types/lib/index.d.ts", | ||
"directories": { | ||
"lib": "lib", | ||
"types": "types", | ||
"test": "__tests__" | ||
}, | ||
"types": "lib/types.d.ts", | ||
"files": [ | ||
"lib", | ||
"types" | ||
"lib" | ||
], | ||
@@ -29,8 +23,4 @@ "publishConfig": { | ||
"test": "jest --coverage --updateSnapshot --passWithNoTests", | ||
"ts": "tsc --noEmit", | ||
"build": "tsc -p ./tsconfig.build.json" | ||
"ts": "tsc --noEmit" | ||
}, | ||
"engines": { | ||
"node": ">=8.10.0" | ||
}, | ||
"bugs": { | ||
@@ -40,9 +30,10 @@ "url": "https://github.com/yeonjuan/html-eslint/issues" | ||
"dependencies": { | ||
"@html-eslint/template-syntax-parser": "^0.35.0", | ||
"es-html-parser": "0.1.0" | ||
"@html-eslint/template-syntax-parser": "^0.35.1", | ||
"es-html-parser": "0.1.1" | ||
}, | ||
"devDependencies": { | ||
"@html-eslint/types": "^0.35.1", | ||
"typescript": "^5.7.2" | ||
}, | ||
"gitHead": "2493a6a72eba5e4fca3be33897050a4ea29712dd" | ||
"gitHead": "b11e32e8205e808f8b2712e082d1ece37b5191aa" | ||
} |
7188
-82.37%2
100%11
-57.69%188
-22.31%+ Added
- Removed
Updated