@atlaskit/eslint-plugin-design-system
Version:
The essential plugin for use with the Atlassian Design System.
33 lines (31 loc) • 849 B
JavaScript
/* eslint-disable @repo/internal/react/require-jsdoc */
import { isNodeOfType } from 'eslint-codemod-utils';
import { isPropertyName } from './common';
export const RestrictedCapitalisation = {
lint(node, {
context,
config
}) {
if (RestrictedCapitalisation._check(node, {
context,
config
})) {
context.report({
node,
messageId: 'noRestrictedCapitalisation'
});
}
},
_check(node, {
config
}) {
if (!config.patterns.includes('restricted-capitalisation')) {
return false;
}
// Prevent text transform being used to uppercase all characters
if (isPropertyName(node, 'textTransform') && isNodeOfType(node.parent, 'Property') && isNodeOfType(node.parent.value, 'Literal')) {
return node.parent.value.value === 'uppercase';
}
return true;
}
};