Skip to content

Commit

Permalink
Fix selector-type-no-unknown false positives for experimental and d…
Browse files Browse the repository at this point in the history
…eprecated HTML tags (#7612)
  • Loading branch information
Mouvedia committed Apr 18, 2024
1 parent d06a41e commit 1368299
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 14 deletions.
5 changes: 5 additions & 0 deletions .changeset/flat-bananas-hug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"stylelint": patch
---

Fixed: `selector-type-no-unknown` false positives for experimental and deprecated HTML tags
14 changes: 12 additions & 2 deletions lib/reference/selectors.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,25 @@ const deprecatedHtmlTypeSelectors = new Set([
'applet',
'basefont',
'big',
'bgsound',
'blink',
'center',
'content',
'dir',
'font',
'frame',
'frameset',
'hgroup',
'isindex',
'keygen',
'listing',
'marquee',
'multicol',
'nextid',
'nobr',
'noembed',
'noframes',
'plaintext',
'param',
'spacer',
'strike',
'tt',
Expand All @@ -35,7 +39,13 @@ const deprecatedHtmlTypeSelectors = new Set([
/** @type {Set<string>} */
const standardHtmlTypeSelectors = new Set(htmlTags);

const htmlTypeSelectors = uniteSets(deprecatedHtmlTypeSelectors, standardHtmlTypeSelectors);
const experimentalHtmlTypeSelectors = new Set(['fencedframe', 'listbox', 'portal', 'selectlist']);

const htmlTypeSelectors = uniteSets(
deprecatedHtmlTypeSelectors,
standardHtmlTypeSelectors,
experimentalHtmlTypeSelectors,
);

const mixedCaseSvgTypeSelectors = new Set([
'altGlyph',
Expand Down
14 changes: 12 additions & 2 deletions lib/reference/selectors.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,25 @@ const deprecatedHtmlTypeSelectors = new Set([
'applet',
'basefont',
'big',
'bgsound',
'blink',
'center',
'content',
'dir',
'font',
'frame',
'frameset',
'hgroup',
'isindex',
'keygen',
'listing',
'marquee',
'multicol',
'nextid',
'nobr',
'noembed',
'noframes',
'plaintext',
'param',
'spacer',
'strike',
'tt',
Expand All @@ -32,7 +36,13 @@ const deprecatedHtmlTypeSelectors = new Set([
/** @type {Set<string>} */
const standardHtmlTypeSelectors = new Set(htmlTags);

export const htmlTypeSelectors = uniteSets(deprecatedHtmlTypeSelectors, standardHtmlTypeSelectors);
const experimentalHtmlTypeSelectors = new Set(['fencedframe', 'listbox', 'portal', 'selectlist']);

export const htmlTypeSelectors = uniteSets(
deprecatedHtmlTypeSelectors,
standardHtmlTypeSelectors,
experimentalHtmlTypeSelectors,
);

export const mixedCaseSvgTypeSelectors = new Set([
'altGlyph',
Expand Down
3 changes: 3 additions & 0 deletions lib/rules/selector-type-no-unknown/__tests__/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ testRule({
code: 'circle {}',
description: 'svg tags',
},
{
code: 'fencedframe, listbox, portal, selectlist {}',
},
{
code: 'foreignObject {}',
description: 'case-sensitive svg tags',
Expand Down
5 changes: 0 additions & 5 deletions lib/utils/isCustomElement.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
'use strict';

const svgTags = require('svg-tags');
const selectors = require('../reference/selectors.cjs');
const mathMLTags = require('./mathMLTags.cjs');

/**
Expand Down Expand Up @@ -31,10 +30,6 @@ function isCustomElement(selector) {
return false;
}

if (selectors.htmlTypeSelectors.has(selectorLowerCase)) {
return false;
}

if (mathMLTags.includes(selectorLowerCase)) {
return false;
}
Expand Down
5 changes: 0 additions & 5 deletions lib/utils/isCustomElement.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import svgTags from 'svg-tags';

import { htmlTypeSelectors } from '../reference/selectors.mjs';
import mathMLTags from './mathMLTags.mjs';

/**
Expand Down Expand Up @@ -28,10 +27,6 @@ export default function isCustomElement(selector) {
return false;
}

if (htmlTypeSelectors.has(selectorLowerCase)) {
return false;
}

if (mathMLTags.includes(selectorLowerCase)) {
return false;
}
Expand Down

0 comments on commit 1368299

Please sign in to comment.