Skip to content

Commit d86c507

Browse files
committed
impl
1 parent f2e53ca commit d86c507

File tree

4 files changed

+17
-1
lines changed

4 files changed

+17
-1
lines changed

packages/eslint-plugin/lib/rules/use-standard-html/check-content-model.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ function oneOrMore(model, context, state, node) {
183183
continue;
184184
}
185185
const name = getNodeName(child);
186-
if (model.contents.has(name)) {
186+
if (model.contents.has(name) || model.contents.has("#transparent")) {
187187
count++;
188188
state.childIndex++;
189189
} else {

packages/eslint-plugin/lib/rules/use-standard-html/use-standard-html.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
const { RULE_CATEGORY } = require("../../constants");
1515
const { getElementSpec } = require("html-standard");
1616
const { checkContentModel, MESSAGE_IDS } = require("./check-content-model");
17+
const { isText } = require("../utils/node");
1718

1819
/**
1920
* @type {RuleModule}
@@ -54,6 +55,13 @@ module.exports = {
5455
if (name === "template") {
5556
return;
5657
}
58+
if (
59+
node.children.some(
60+
(child) => isText(child) && child.parts && !!child.parts.length
61+
)
62+
) {
63+
return;
64+
}
5765
const spec = getElementSpec(node.name);
5866
if (!spec) {
5967
return;

packages/eslint-plugin/tests/rules/use-standard-html.test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,13 @@ ruleTester.run("use-standard-html", rule, {
5050
{
5151
code: "<head><style> div {} </style> <script> console.log('hello'); </script></head>",
5252
},
53+
{
54+
code: `
55+
<a href="https://github.com/yeonjuan/html-eslint">
56+
<img src="~/src/assets/github.svg" alt="github">
57+
</a>
58+
`,
59+
},
5360
],
5461
invalid: [
5562
// required

packages/website/eslint.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ module.exports = [{
6262
},
6363

6464
rules: {
65+
"@html-eslint/use-standard-html": "error",
6566
"@html-eslint/indent": ["error", 2],
6667
"@html-eslint/require-doctype": "off",
6768
"@html-eslint/no-target-blank": "error",

0 commit comments

Comments
 (0)