UNPKG

@atlaskit/eslint-plugin-design-system

Version:

The essential plugin for use with the Atlassian Design System.

47 lines 1.37 kB
import { createLintRule } from '../utils/create-lint-rule'; import { errorBoundary } from '../utils/error-boundary'; import { getConfig } from './config'; import { NativeElements } from './transformers/native-elements'; const docsUrl = 'https://atlassian.design/components/heading'; const rule = createLintRule({ meta: { name: 'use-heading', type: 'suggestion', fixable: 'code', hasSuggestions: true, schema: [{ type: 'object', properties: { enableUnsafeReport: { type: 'boolean' }, enableUnsafeAutofix: { type: 'boolean' } }, additionalProperties: false }], docs: { description: 'Encourage the usage of heading components.', recommended: true, severity: 'warn' }, messages: { preferHeading: `This element can be replaced with a "Heading" component. See ${docsUrl} for additional guidance.` } }, create(context) { // TODO: JFP-2823 - this type cast was added due to Jira's ESLint v9 migration const config = getConfig(context.options[0]); return errorBoundary({ // transforms <h1>...</h1> usages 'JSXElement[openingElement.name.name=/^h[0-6]$/]': node => { return NativeElements.lint(node, { context, config }); } }, config); } }); export default rule;