Skip to content

VBC-208: hardcoded-colors ​

warning

Category: ux-dx
Analysis: Regex (line by line)
File types: .css, .scss
Scope: source code only, ignoring anything inside strings and comments
Excluded paths: **/theme.css, **/vars.css, **/variables.css, **/tokens.css, **/*.tokens.*
Tags: design maintainability

What it reports ​

Hardcoded color value detected at line {line}. Consider using a CSS variable or theme token.

Flagged ​

css
.card { color: #ff0044; }
css
.card { background-color: #ff0044; }
css
.card { --gap: 4px; color: #ff0044; }

Not flagged ​

css
.card { color: var(--text); }
css
.card { color: #ff0044; }
css
:root { --text-color: #1a202c; }
css
  --background-color: rgba(18, 18, 18, 0.85);
scss
$brand-color: #ff0044;

Pattern ​

regex
(?<!(?:--|[$@])[\w-]{0,40})color:\s*(#[0-9a-fA-F]{3,6}|rgba?\(.*?\))

Released under the MIT License.