Skip to content

Commit

Permalink
Fix false negatives for SVG properties in alpha-value-notation (#6284)
Browse files Browse the repository at this point in the history
fix: add support for flood-opacity, fill-opacity, stroke-opacity and stop-opacity to alpha-value-notation
  • Loading branch information
Mouvedia committed Aug 21, 2022
1 parent d70f21a commit 791cb34
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
9 changes: 9 additions & 0 deletions lib/rules/alpha-value-notation/__tests__/index.js
Expand Up @@ -79,6 +79,15 @@ testRule({
endLine: 1,
endColumn: 31,
},
{
code: 'feDropShadow { flood-opacity: 50% }',
fixed: 'feDropShadow { flood-opacity: 0.5 }',
message: messages.expected('50%', '0.5'),
line: 1,
column: 31,
endLine: 1,
endColumn: 34,
},
{
code: 'a { color: rgba(0, 0, 0, 50%) }',
fixed: 'a { color: rgba(0, 0, 0, 0.5) }',
Expand Down
10 changes: 9 additions & 1 deletion lib/rules/alpha-value-notation/index.js
Expand Up @@ -23,7 +23,15 @@ const meta = {
fixable: true,
};

const ALPHA_PROPS = new Set(['opacity', 'shape-image-threshold']);
const ALPHA_PROPS = new Set([
'opacity',
'shape-image-threshold',
// SVG properties
'fill-opacity',
'flood-opacity',
'stop-opacity',
'stroke-opacity',
]);
const ALPHA_FUNCS = new Set(['hsl', 'hsla', 'hwb', 'lab', 'lch', 'rgb', 'rgba']);

/** @type {import('stylelint').Rule} */
Expand Down

0 comments on commit 791cb34

Please sign in to comment.