diff --git a/packages/eslint-plugin-pf-codemods/index.js b/packages/eslint-plugin-pf-codemods/index.js index 695552dd5..5d78871c4 100644 --- a/packages/eslint-plugin-pf-codemods/index.js +++ b/packages/eslint-plugin-pf-codemods/index.js @@ -12,6 +12,7 @@ const rules = { "title-require-heading-level": require('./lib/rules/title-require-heading-level'), "title-size": require('./lib/rules/title-size'), "wizard-text": require('./lib/rules/wizard-text'), + "wizard-rename-hasBodyPadding": require('./lib/rules/wizard-rename-hasBodyPadding'), }; module.exports = { diff --git a/packages/eslint-plugin-pf-codemods/lib/rules/wizard-rename-hasBodyPadding.js b/packages/eslint-plugin-pf-codemods/lib/rules/wizard-rename-hasBodyPadding.js new file mode 100644 index 000000000..e3f1f2ed2 --- /dev/null +++ b/packages/eslint-plugin-pf-codemods/lib/rules/wizard-rename-hasBodyPadding.js @@ -0,0 +1,10 @@ +const { renameProp } = require('../helpers'); + +// https://github.com/patternfly/patternfly-react/pull/4136 +module.exports = { + create: renameProp( + ['Wizard', 'WizardBody', 'WizardToggle'], + {'hasBodyPadding': 'hasNoBodyPadding'}, + node => `hasBodyPadding prop has been removed for ${node.name.name}. Use hasNoBodyPadding instead` + ) +}; \ No newline at end of file diff --git a/packages/eslint-plugin-pf-codemods/test/rules/wizard-rename-hasBodyPadding.js b/packages/eslint-plugin-pf-codemods/test/rules/wizard-rename-hasBodyPadding.js new file mode 100644 index 000000000..02b47c065 --- /dev/null +++ b/packages/eslint-plugin-pf-codemods/test/rules/wizard-rename-hasBodyPadding.js @@ -0,0 +1,24 @@ +const ruleTester = require('./ruletester'); +const rule = require('../../lib/rules/wizard-rename-hasBodyPadding'); + +ruleTester.run("wizard-rename-hasBodyPadding", rule, { + valid: [ + { + code: `import { Wizard } from '@patternfly/react-core'; `, + }, + { + // No @patternfly/react-core import + code: ``, + } + ], + invalid: [ + { + code: `import { Wizard } from '@patternfly/react-core'; `, + output: `import { Wizard } from '@patternfly/react-core'; `, + errors: [{ + message: "hasBodyPadding prop has been removed for Wizard. Use hasNoBodyPadding instead", + type: "JSXOpeningElement", + }] + } + ] +}); \ No newline at end of file