UNPKG

@atlaskit/eslint-plugin-design-system

Version:

The essential plugin for use with the Atlassian Design System.

40 lines (39 loc) 1.08 kB
/* eslint-disable @repo/internal/react/require-jsdoc */ import { isNodeOfType } from 'eslint-codemod-utils'; import { isDecendantOfStyleBlock } from '../../utils/is-decendant-of-style-block'; import { isDecendantOfType } from '../../utils/is-decendant-of-type'; export const BannedProperties = { lint(node, { context, config }) { // Check whether all criteria needed to make a transformation are met const success = BannedProperties._check(node, { context, config }); if (success) { return context.report({ node, messageId: 'noBannedProperties', data: { property: isNodeOfType(node.key, 'Identifier') ? node.key.name : 'this property' } }); } }, _check(node, { config }) { if (!config.patterns.includes('banned-properties')) { return false; } if (!isNodeOfType(node, 'Property')) { return false; } if (!isDecendantOfStyleBlock(node) && !isDecendantOfType(node, 'JSXExpressionContainer')) { return false; } return true; } };