pf-3-to-4
v1.0.1
Published
Codemods for v4 breaking change release 2020.07
Downloads
4
Readme
pf-3-to-4
CLI utility to help ease products transitioning to our new major @patternfly/react-core 4.0.0 release.
Goals
- We want to minimize code changes and respect existing code
- We only want to make safe modifications
- Don't touch code that we aren't sure is PatternFly
redallen rationale
- Most consumers are using JSX
- When they're using React.createElement or React.cloneElement that introduces unsafe complications
Design
- Use a JSX parser that leaves formatting alone as much as possible
- Add basic ESM import parsing to make sure we're only modifying PatternFly
<Button>
s
Development
This is what @redallen does to develop a rule:
- Copy a rule at
lib/rules/*
- Add it to
.eslintrc.json
- Copy a test at
test/rules/*
- Put code into an AST explorer like https://astexplorer.net/ . Add code to "failing" version of test.
- Write rule targeting specific AST node. Confirm AST node exists in
lib/rules/ast-node-types.d.ts
. - Amend
test/test.tsx
with code that requires fixing. - Develop fixer while testing it with
npm run test -- --fix