Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SVG tags whitelist in selector-type-no-unknown rule (#4472) #4495

Merged
merged 4 commits into from Dec 27, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
@@ -1,3 +1,4 @@
.idea
hudochenkov marked this conversation as resolved.
Show resolved Hide resolved
node_modules
*.log
.coverage
Expand Down
4 changes: 4 additions & 0 deletions lib/rules/selector-type-no-unknown/__tests__/index.js
Expand Up @@ -85,6 +85,10 @@ testRule(rule, {
code: 'circle {}',
description: 'svg tags',
},
{
code: '.test foreignObject { color: white }',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, didn't spot it right away:

Suggested change
code: '.test foreignObject { color: white }',
code: 'foreignObject { }',

It's for consistency with other test cases. Could you also adjust description to case-sensitive svg tags, please?

description: 'svg tags',
},
{
code: '@media keyframes { 0.0% {} 49.1% {} 100% {} }',
description: 'standard usage of keyframe selectors',
Expand Down
10 changes: 9 additions & 1 deletion lib/rules/selector-type-no-unknown/index.js
Expand Up @@ -9,12 +9,20 @@ const isStandardSyntaxTypeSelector = require('../../utils/isStandardSyntaxTypeSe
const keywordSets = require('../../reference/keywordSets');
const mathMLTags = require('mathml-tag-names');
const optionsMatches = require('../../utils/optionsMatches');
const originSvgTags = require('svg-tags');
const parseSelector = require('../../utils/parseSelector');
const report = require('../../utils/report');
const ruleMessages = require('../../utils/ruleMessages');
const svgTags = require('svg-tags');
const validateOptions = require('../../utils/validateOptions');

/**
* @description Normalize SVG tags.
* 'svg-tags' module exports tags in camelCase format while other tags modules
* (e.g. 'html-tags', 'mathml-tag-names') contain only lower-cased strings
* @type {string[]}
*/
const svgTags = originSvgTags.map((tag) => tag.toLowerCase());

const ruleName = 'selector-type-no-unknown';

const messages = ruleMessages(ruleName, {
Expand Down