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
prefer-ternary
: Refactor to use ESLint recommended way to extend fix range
#857
Conversation
@mdjermanovic After I tried the way you recommended, I figure I can simplify the logic to this 404860c function * extendFixRange(range = []) {
const [start = 0, end = Infinity] = range;
yield {range: [start, start], text: ''};
yield {range: [end, end], text: ''};
} So, I don't need pass |
I don't think it's good. |
It isn't official yet. The applying fixes spec was intentionally not too specific in order to allow for future internal optimizations. It's arguable whether eslint/eslint#13748 documents too many internal details and thus adds some implementation constraints that may not reach consensus. Nevertheless, I'd say it's pretty safe to use this pattern, unlike requiring the FixTracker module which almost certainly won't make it into the public API when we add the |
Thanks for the quick reply. I'd say your suggestted implementation in eslint/eslint#13748 is very good, just two lines in But I'm going to add this as a utility function, and I think most cases we need in our codebase is extend the range to the whole file, so @futpib Do you insist to use public |
This reverts commit 404860c.
@mdjermanovic Thank you very much, I restored the changes. |
What's left for this to be mergable? |
I don't think there is anything to do, unless you have a better idea to make it easier to use. We may need check other rules. when generating a new variable, should use this function to avoid conflicts with other rules(ours and other plugins). |
ESLint recommended a new way to extend fix range.