UNPKG

@atlaskit/eslint-plugin-design-system

Version:

The essential plugin for use with the Atlassian Design System.

35 lines • 1.18 kB
import { createLintRule } from '../utils/create-lint-rule'; import { JSXElement as _JSXElement } from './node-types/jsx-element'; import { StyledComponent } from './node-types/styled-component'; var rule = createLintRule({ meta: { name: 'no-html-anchor', type: 'suggestion', hasSuggestions: true, docs: { description: 'Discourage direct usage of HTML anchor elements in favor of Atlassian Design System link components.', recommended: true, severity: 'warn' }, messages: { noHtmlAnchor: 'Replace <{{ name }}> with Link from @atlaskit/link/link, or named Anchor from @atlaskit/primitives/compiled/anchor for a custom link. Preserve href, navigation behavior and link text.' } }, create: function create(context) { return { // transforms styled.<anchor>(...) usages CallExpression: function CallExpression(node) { StyledComponent.lint(node, { context: context }); }, // transforms <anchor css={...}> usages JSXElement: function JSXElement(node) { _JSXElement.lint(node, { context: context }); } }; } }); export default rule;