Betterer: Add noMargin prop check (#105409)

* Chore: Add a betterer rule for noMargin prop

* Use existing file selector

* Check for grafana/ui import

* Update results

* Update results
pull/105596/head^2
Alex Khomenko 7 months ago committed by GitHub
parent b674c31579
commit f83fb35bfb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 12
      .betterer.eslint.config.js
  2. 1183
      .betterer.results
  3. 2
      public/app/features/auth-config/components/ProviderCard.tsx

@ -128,6 +128,18 @@ module.exports = [
selector: 'MemberExpression[object.name=localStorage]', selector: 'MemberExpression[object.name=localStorage]',
message: 'Direct usage of localStorage is not allowed. Use `Store` from @grafana/data instead.', message: 'Direct usage of localStorage is not allowed. Use `Store` from @grafana/data instead.',
}, },
{
selector:
'Program:has(ImportDeclaration[source.value="@grafana/ui"] ImportSpecifier[imported.name="Card"]) JSXOpeningElement[name.name="Card"]:not(:has(JSXAttribute[name.name="noMargin"]))',
message:
'Add noMargin prop to Card components to remove built-in margins. Use layout components like Stack or Grid with the gap prop instead for consistent spacing.',
},
{
selector:
'Program:has(ImportDeclaration[source.value="@grafana/ui"] ImportSpecifier[imported.name="Field"]) JSXOpeningElement[name.name="Field"]:not(:has(JSXAttribute[name.name="noMargin"]))',
message:
'Add noMargin prop to Field components to remove built-in margins. Use layout components like Stack or Grid with the gap prop instead for consistent spacing.',
},
], ],
}, },
}, },

File diff suppressed because it is too large Load Diff

@ -19,7 +19,7 @@ export function ProviderCard({ providerId, enabled, configPath, authType, onClic
const url = getProviderUrl({ configPath, id: providerId }); const url = getProviderUrl({ configPath, id: providerId });
const [iconName, displayName] = UIMap[providerId] || ['lock', providerId.toUpperCase()]; const [iconName, displayName] = UIMap[providerId] || ['lock', providerId.toUpperCase()];
return ( return (
<Card href={url} onClick={onClick}> <Card href={url} onClick={onClick} noMargin>
<Card.Heading>{displayName}</Card.Heading> <Card.Heading>{displayName}</Card.Heading>
<Card.Meta>{authType}</Card.Meta> <Card.Meta>{authType}</Card.Meta>
{isIconName(iconName) && ( {isIconName(iconName) && (

Loading…
Cancel
Save