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: Catch literal colors when theme top level #19571

Merged
merged 2 commits into from
Apr 8, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions superset-frontend/tools/eslint-plugin-theme-colors/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,19 @@ module.exports = {
return {
TemplateElement(node) {
const rawValue = node?.value?.raw;
const isParentProperty =
const isChildParentTagged =
node?.parent?.parent?.type === 'TaggedTemplateExpression';
const isChildParentArrow =
node?.parent?.parent?.type === 'ArrowFunctionExpression';
const isParentTemplateLiteral =
node?.parent?.type === 'TemplateLiteral';
const loc = node?.parent?.parent?.loc;
const locId = loc && JSON.stringify(loc);
const hasWarned = warned.includes(locId);
if (
!hasWarned &&
isParentProperty &&
(isChildParentTagged ||
(isChildParentArrow && isParentTemplateLiteral)) &&
rawValue &&
(hasLiteralColor(rawValue) ||
hasHexColor(rawValue) ||
Expand Down