@atlaskit/eslint-plugin-design-system
Version:
The essential plugin for use with the Atlassian Design System.
38 lines (37 loc) • 1.19 kB
JavaScript
/* 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 var BannedProperties = {
lint: function lint(node, _ref) {
var context = _ref.context,
config = _ref.config;
// Check whether all criteria needed to make a transformation are met
var success = BannedProperties._check(node, {
context: context,
config: config
});
if (success) {
return context.report({
node: node,
messageId: 'noBannedProperties',
data: {
property: isNodeOfType(node.key, 'Identifier') ? node.key.name : 'this property'
}
});
}
},
_check: function _check(node, _ref2) {
var config = _ref2.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;
}
};