-
-
Notifications
You must be signed in to change notification settings - Fork 18
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
feat: introduce eslint plugin #121
base: main
Are you sure you want to change the base?
feat: introduce eslint plugin #121
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.
Thanks so much for raising this PR mate, this is awesome stuff!!
Just have a few questions to be sure I fully understand 😄
"name": "eslint-plugin-codemod", | ||
"version": "0.0.1", | ||
"dependencies": { | ||
"eslint-codemod-utils": "latest" |
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.
Was latest
intentional? Would probably be better to specify the version here unless there's a reason that i'm missing 🤔
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 mean it was a bit meh. I'll add a caret range.
}, | ||
}); | ||
|
||
ruleTester.run('jsx/update-prop-name', rule, { |
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.
How do you see jsx/update-prop-name
being used? Is this something someone would configure in their eslintrc, run and then remove from the config?
Or maybe would they have multiple configurations setup, one for modal-dialog, one for button etc then they remain in the eslintfile and can be updated as the version changes?
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 yeah it could run alongside / with / in place of / any codemod approach. Maybe a codemod could even be used to update the eslint config around releases. The flexibility of the current config is that it can be used with lots of configs and thus different modules.
The difficult part to figure out is when to turn it off or how to manage ratcheting it.
code: [ | ||
// This has an invalid header so is ignored | ||
`/* integrity: codemod-hash-1399692252 */`, | ||
`// TODO codemod-generated-comment signed: codemod-hash-1399692252`, |
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.
Could you explain how the integrity check works?
So if I was to imagine a codemod run on a repo and the diffs raised in a PR, would these be presented as an error? Or can they be merged and subsequent changes to the file would trigger an error?
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.
@danieldelcore I should add a README for these rules sorry mate, will amend.
In essence the idea is that a codemod would add a header comment and generate hashes off the comments it introduces to code. Each of these comments are validated against the header. So it's clear that this were generated by a script.
I thought of multiple different approaches here tho for example:
- Using a hash of the whole file from the time that the codemod ran and storing it in a header, then recalculating the hash off the whole file minus the hash. Idea here would be as soon as you make a change in this file it will error. IE don't leave the codemod header / make a change without validating that you've acknowledged the codemod ran.
- Alternatively just erroring or warning off comments generated by codemod.
Or some combination of the above.
facba25
to
5248c0e
Compare
Hi @danieldelcore this is mk 2!