Skip to content

Commit

Permalink
Bump html-tags from 3.1.0 to 3.2.0 (#6013)
Browse files Browse the repository at this point in the history
* Bump html-tags from 3.1.0 to 3.2.0

Bumps [html-tags](https://github.com/sindresorhus/html-tags) from 3.1.0 to 3.2.0.
- [Release notes](https://github.com/sindresorhus/html-tags/releases)
- [Commits](sindresorhus/html-tags@v3.1.0...v3.2.0)

---
updated-dependencies:
- dependency-name: html-tags
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* resolves TS errors with new htmlTags typing

uses the 3rd option from this SO post as a suggestion:
https://stackoverflow.com/questions/36836011/checking-validity-of-string-literal-union-type-at-runtime

* adds a string-typed htmlTags as an export in keywordSets

thanks to ybiquitous for the suggestion! this should maintain the
performance benefit of a set.

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Matt Wang <matt@matthewwang.me>
  • Loading branch information
dependabot[bot] and mattxwang committed Apr 14, 2022
1 parent b417a45 commit 0b8717c
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 12 deletions.
6 changes: 6 additions & 0 deletions lib/reference/keywordSets.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use strict';

const htmlTags = require('html-tags');

const keywordSets = {};

keywordSets.nonLengthUnits = new Set([
Expand Down Expand Up @@ -740,6 +742,10 @@ keywordSets.systemColors = new Set([
'windowtext',
]);

// typecasting htmlTags to be more generic; see https://github.com/stylelint/stylelint/pull/6013 for discussion
/** @type {Set<string>} */
keywordSets.standardHtmlTags = new Set(htmlTags);

// htmlTags includes only "standard" tags. So we augment it with older tags etc.
keywordSets.nonStandardHtmlTags = new Set([
'acronym',
Expand Down
3 changes: 1 addition & 2 deletions lib/rules/selector-type-no-unknown/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict';

const htmlTags = require('html-tags');
const isCustomElement = require('../../utils/isCustomElement');
const isKeyframeSelector = require('../../utils/isKeyframeSelector');
const isStandardSyntaxRule = require('../../utils/isStandardSyntaxRule');
Expand Down Expand Up @@ -91,7 +90,7 @@ const rule = (primary, secondaryOptions) => {
const tagNameLowerCase = tagName.toLowerCase();

if (
htmlTags.includes(tagNameLowerCase) ||
keywordSets.standardHtmlTags.has(tagNameLowerCase) ||
// SVG tags are case-sensitive
svgTags.includes(tagName) ||
keywordSets.nonStandardHtmlTags.has(tagNameLowerCase) ||
Expand Down
3 changes: 1 addition & 2 deletions lib/utils/isCustomElement.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict';

const htmlTags = require('html-tags');
const keywordSets = require('../reference/keywordSets');
const mathMLTags = require('mathml-tag-names');
const svgTags = require('svg-tags');
Expand Down Expand Up @@ -30,7 +29,7 @@ module.exports = function (selector) {
return false;
}

if (htmlTags.includes(selectorLowerCase)) {
if (keywordSets.standardHtmlTags.has(selectorLowerCase)) {
return false;
}

Expand Down
17 changes: 10 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
"global-modules": "^2.0.0",
"globby": "^11.1.0",
"globjoin": "^0.1.4",
"html-tags": "^3.1.0",
"html-tags": "^3.2.0",
"ignore": "^5.2.0",
"import-lazy": "^4.0.0",
"imurmurhash": "^0.1.4",
Expand Down

0 comments on commit 0b8717c

Please sign in to comment.