import { getFromPackage } from "../../helpers"; import { Rule } from "eslint"; import { JSXOpeningElement } from "estree-jsx"; // https://github.com/patternfly/patternfly-react/pull/9848 module.exports = { meta: {}, create: function (context: Rule.RuleContext) { const { imports } = getFromPackage(context, "@patternfly/react-core"); const pageSectionImport = imports.find( (specifier) => specifier.imported.name === "PageSection" ); return !pageSectionImport ? {} : { JSXOpeningElement(node: JSXOpeningElement) { if ( node.name.type === "JSXIdentifier" && pageSectionImport.local.name === node.name.name ) { const attribute = node.attributes.find( (attr) => attr.type === "JSXAttribute" && attr.name.name === "variant" ); if (attribute) { context.report({ node, message: 'Classes from the `variant` prop will now only be applied to PageSection when the `type` prop has a value of "default".', }); } } }, }; }, };