UNPKG

@atlaskit/eslint-plugin-design-system

Version:

The essential plugin for use with the Atlassian Design System.

47 lines 1.46 kB
import { createLintRule } from '../utils/create-lint-rule'; import { errorBoundary } from '../utils/error-boundary'; import { getConfig } from './config'; import { NativeElements } from './transformers/native-elements'; var docsUrl = 'https://atlassian.design/components/heading'; var 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 ".concat(docsUrl, " for additional guidance.") } }, create: function create(context) { // TODO: JFP-2823 - this type cast was added due to Jira's ESLint v9 migration var config = getConfig(context.options[0]); return errorBoundary({ // transforms <h1>...</h1> usages 'JSXElement[openingElement.name.name=/^h[0-6]$/]': function JSXElementOpeningElementNameName_H06$_(node) { return NativeElements.lint(node, { context: context, config: config }); } }, config); } }); export default rule;