@atlaskit/eslint-plugin-design-system
Version:
The essential plugin for use with the Atlassian Design System.
53 lines (52 loc) • 1.65 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _createLintRule = require("../utils/create-lint-rule");
var _errorBoundary = require("../utils/error-boundary");
var _config = require("./config");
var _nativeElements = require("./transformers/native-elements");
var docsUrl = 'https://atlassian.design/components/heading';
var rule = (0, _createLintRule.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 = (0, _config.getConfig)(context.options[0]);
return (0, _errorBoundary.errorBoundary)({
// transforms <h1>...</h1> usages
'JSXElement[openingElement.name.name=/^h[0-6]$/]': function JSXElementOpeningElementNameName_H06$_(node) {
return _nativeElements.NativeElements.lint(node, {
context: context,
config: config
});
}
}, config);
}
});
var _default = exports.default = rule;