-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(devex) Add types for renameProps helper #607
chore(devex) Add types for renameProps helper #607
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome work 🚀
I've got a good amount of comments here, but many are just general refactor things that I'm absolutely fine with being a followup.
packages/eslint-plugin-pf-codemods/src/rules/helpers/renamePropsOnNode.ts
Outdated
Show resolved
Hide resolved
packages/eslint-plugin-pf-codemods/src/rules/helpers/renamePropsOnNode.ts
Outdated
Show resolved
Hide resolved
packages/eslint-plugin-pf-codemods/src/rules/helpers/renamePropsOnNode.ts
Outdated
Show resolved
Hide resolved
packages/eslint-plugin-pf-codemods/src/rules/helpers/renamePropsOnNode.ts
Outdated
Show resolved
Hide resolved
packages/eslint-plugin-pf-codemods/src/rules/helpers/renamePropsOnNode.ts
Outdated
Show resolved
Hide resolved
packages/eslint-plugin-pf-codemods/src/rules/helpers/renamePropsOnNode.ts
Outdated
Show resolved
Hide resolved
packages/eslint-plugin-pf-codemods/src/rules/helpers/renamePropsOnNode.ts
Outdated
Show resolved
Hide resolved
packages/eslint-plugin-pf-codemods/src/rules/helpers/renamePropsOnNode.ts
Outdated
Show resolved
Hide resolved
packages/eslint-plugin-pf-codemods/src/rules/helpers/renamePropsOnNode.ts
Outdated
Show resolved
Hide resolved
packages/eslint-plugin-pf-codemods/src/rules/helpers/renamePropsOnNode.ts
Outdated
Show resolved
Hide resolved
7474460
to
25fbd5a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking GREAT 🔥 🔥 🔥, just a few more small things
packages/eslint-plugin-pf-codemods/src/rules/helpers/renamePropsOnNode.ts
Outdated
Show resolved
Hide resolved
propRename: RenameConfig | string | Record<PropertyKey, never>, | ||
defaultMessage: string | ||
) => { | ||
if (!(isRenameConfig(propRename) && propRename.message)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: IMO it's really easy to misread a notted multi conditional like this and think the logic is actually !isRenameConfig(propRename) && propRename.message
, I would not both expressions.
if (!(isRenameConfig(propRename) && propRename.message)) | |
if (!isRenameConfig(propRename) && !propRename.message) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might be wrong but these two statements are not equal, are they? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think if (!isRenameConfig(propRename) || !propRename.message)
is the right one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And Record<PropertyKey, never>
should be a correct way to type an empty object {}
, which can be passed as a shorthand for removing a prop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shoot I totally missed these messages, my bad. And yep you're right about the logic!
For the Record type TIL about empty object types, thanks for linking that! I do question the API a bit here, using an empty object for prop removal feels a bit odd for me, but that's something we can discuss later.
packages/eslint-plugin-pf-codemods/src/rules/helpers/renameSinglePropOnNode.ts
Outdated
Show resolved
Hide resolved
packages/eslint-plugin-pf-codemods/src/rules/helpers/renameSinglePropOnNode.ts
Outdated
Show resolved
Hide resolved
packages/eslint-plugin-pf-codemods/src/rules/helpers/renameSinglePropOnNode.ts
Outdated
Show resolved
Hide resolved
25fbd5a
to
9d76b0a
Compare
packages/eslint-plugin-pf-codemods/src/rules/helpers/renameSinglePropOnNode.ts
Outdated
Show resolved
Hide resolved
packages/eslint-plugin-pf-codemods/src/rules/helpers/renameSinglePropOnNode.ts
Outdated
Show resolved
Hide resolved
packages/eslint-plugin-pf-codemods/src/rules/helpers/renameSinglePropOnNode.ts
Outdated
Show resolved
Hide resolved
packages/eslint-plugin-pf-codemods/src/rules/helpers/renameSinglePropOnNode.ts
Outdated
Show resolved
Hide resolved
9d76b0a
to
11941ea
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀 🚀 🚀 B E A U T I F U L 🚀 🚀 🚀
Towards #573