-
-
Notifications
You must be signed in to change notification settings - Fork 162
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
Make most variants of module.exports = { ... } fixable #208
Make most variants of module.exports = { ... } fixable #208
Conversation
Both work and satisfy the linter
Seems like in-between comments are only attached to one of the nodes
@mysticatea, is this something you would consider supporting in the plugin? 🌞 |
@mysticatea, ping? |
I've applied this fixing mode to a code base with 3k+ source files without breaking anything 🤗 |
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 apologize for my late response. Thank you for your work!
Almost LGTM. But I have a concern. If you keep the motivation on this, would you fix a deprecated method?
lib/rules/exports-style.js
Outdated
fixedValue = `async ${fixedValue}` | ||
} | ||
} | ||
const comments = sourceCode.getComments(property) |
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.
sourceCode.getComments()
method has been deprecated since ESLint v4.0.0 (https://github.com/eslint/eslint/blob/caeb223c4f7b0b6fe35e5348ae0df4c6446b5bed/docs/user-guide/migrating-to-4.0.0.md#-ast-nodes-no-longer-have-comment-properties). Would you fix it with the new methods?
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.
Absolutely, fixed in 8d7cec4
I had no idea, I was just playing around with it in the debugger to discover how to get to the comments :)
@mysticatea, does it look OK to you now? 🙏 |
@mysticatea, ping? 🙇 |
@mysticatea, would be really nice to get this merged 🙏 🤗 |
@mysticatea, ping? 🙏 |
@ota-meshi @kevinoid, maybe one of you can help get this landed? 🙏 |
I'd be happy to help. Unfortunately, I'm not sure what I could do. I'm not currently affiliated in this project beyond having created a few issues and a PR in the past. |
@kevinoid, oh, I saw your name on some commits to master and assumed that you were more involved. Sorry! |
c0a41f7
to
8425c80
Compare
* Make the exports style fixable under some circumstances * Handle generators * Preserve comments from inside the object literal * Consistent semicolons in fixed output * Test that we only replace top-level module.exports = {...} * Also replace module.exports.foo references * Split fixing code into two functions to avoid exceeding the complexity budget * Also fix shorthand property occurrences * Make helper functions * Return undefined instead of [] Both work and satisfy the linter * Simplify a bit Seems like in-between comments are only attached to one of the nodes * Don't use SourceCode#getComments (deprecated) mysticatea#208 (comment) * Be more defensive and try to match the patterns that we do want to fix #17 (comment) * Return null instead of undefined #17 (comment) #17 (comment) #17 (comment) * Add a few more test cases #17 (comment)
Landed in Feel free to pick this up if |
I need a codemod-like way to convert
module.exports = { foo: ... }
toexports.foo = ...
statements. Seems like that can be achieved by making theexports-style
rule fixable when inexports
mode.TODO: