@atlaskit/eslint-plugin-design-system
Version:
The essential plugin for use with the Atlassian Design System.
23 lines • 777 B
JavaScript
import { getIsException } from '../utils/get-is-exception';
import { includesHardCodedColor } from '../utils/includes-hard-coded-color';
import { isLegacyColor } from '../utils/is-legacy-color';
import { getTokenSuggestion } from './get-token-suggestion';
// JSXExpressionContainer > Identifier
export const lintJSXIdentifierForColor = (node, context, config) => {
// To force the correct node type
if (node.type !== 'Identifier') {
return;
}
const isException = getIsException(config.exceptions);
if (isException(node)) {
return;
}
if (isLegacyColor(node.name) || includesHardCodedColor(node.name)) {
context.report({
messageId: 'hardCodedColor',
node,
suggest: getTokenSuggestion(node, node.name, config)
});
return;
}
};