Skip to content

Commit

Permalink
Merge pull request #71 from primer/mkt/more-css-var-scan-fixes
Browse files Browse the repository at this point in the history
Fix variable recognition when fallback values present
  • Loading branch information
Michelle Tilley authored Oct 29, 2020
2 parents bf6099f + a74c4c9 commit 17bb30d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
6 changes: 6 additions & 0 deletions __tests__/no-undefined-vars.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ testRule({
message: messages.rejected('--color-foo'),
line: 1,
column: 6
},
{
code: '.x { color: var(--color-bar, #000000); }',
message: messages.rejected('--color-bar'),
line: 1,
column: 6
}
]
})
2 changes: 1 addition & 1 deletion 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
@@ -1,6 +1,6 @@
{
"name": "stylelint-config-primer",
"version": "9.2.3",
"version": "9.2.4",
"description": "Sharable stylelint config used by GitHub's CSS",
"homepage": "http://primer.style/css/tools/linting",
"author": "GitHub, Inc.",
Expand Down
2 changes: 1 addition & 1 deletion plugins/no-undefined-vars.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const variableDefinitionRegex = /(--[\w|-]*):/g

// Match CSS variable references (e.g var(--color-text-primary))
// eslint-disable-next-line no-useless-escape
const variableReferenceRegex = /var\(([^\),]*)\)/g
const variableReferenceRegex = /var\(([^\),]+)(,.*)?\)/g

module.exports = stylelint.createPlugin(ruleName, (enabled, options = {}) => {
if (!enabled) {
Expand Down

0 comments on commit 17bb30d

Please sign in to comment.