File tree 1 file changed +10
-5
lines changed
src/rules/sort-attribute-content
1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change 1
- import { type TmplAstTextAttribute } from "@angular/compiler" ;
2
- import { type TemplateParserServices } from "@angular-eslint/utils" ;
3
- import { AttributeNode , AttributeValueNode , TokenTypes } from "es-html-parser" ;
1
+ import type { TmplAstTextAttribute } from "@angular/compiler" ;
2
+ import type { TemplateParserServices } from "@angular-eslint/utils" ;
3
+ import type { AttributeNode , AttributeValueNode } from "es-html-parser" ;
4
4
import { Rule } from "eslint" ;
5
5
6
6
import {
@@ -174,11 +174,16 @@ export const sortAttributeContentRule: Rule.RuleModule = {
174
174
) ;
175
175
}
176
176
177
- // Default choice, use of the `@html-eslint/parser`. TODO: throw error if not set
177
+ // Default choice, use of the `@html-eslint/parser` with dynamic modules.
178
+
179
+ // Throw an error if the module does not exist
180
+ require ( "@html-eslint/parser" ) ;
181
+ // eslint-disable-next-line @typescript-eslint/no-var-requires -- Dynamic loading
182
+ const { TokenTypes } = require ( "es-html-parser" ) as typeof import ( "es-html-parser" ) ;
183
+
178
184
type HtmlNode < T , P = never > = T & { parent ?: HtmlNode < P > } ;
179
185
return {
180
186
[ TokenTypes . AttributeValue ] ( nodeRaw : Rule . Node ) {
181
- // Only to satisfy TS
182
187
const node = nodeRaw as unknown as HtmlNode < AttributeValueNode , AttributeNode > ;
183
188
184
189
const attributeName = node . parent ?. key . value ;
You can’t perform that action at this time.
0 commit comments