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
Request range formatter for ESLint #13835
Comments
Hi @Tsimopak, thanks for the issue! Can you please provide more details on what exactly should be implemented in ESLint? ESLint provides a list of all fixes for the given source code, and integrations can already filter that list to get only those in the selected range. |
I Honestly not sure what should be implemented, but it's not possible at the moment to format selected range in Visual Studio Code, at first I thought it's a bug, but when I asked at VSCode's repository they said it's not available since there isn't an API. According to @dbaeumer from this link: microsoft/vscode#108808
|
Just to clarify: me filtering the fixes will IMO be problematic if a fix one depends on a fix two and I only include one of them. This has the potential of breaking code. IMO to make that work correctly ESLint would need to offer API that ensures that the fixes reported for a range don't cause any problems to the source code. |
@dbaeumer thanks for clarifying!
Rules shouldn't produce such fixes. For example, However, it's true that there are some plugins where fixes depend on each other in the actual version (prettier/eslint-plugin-prettier#65). We could maybe add an API to check if a single fix or a list of fixes produces parsing error, but that would affect performance and it seems better to fix problematic rules instead. |
I think we are bumping up against a limitation of how ESLint handles fixes here. ESLint was never intended to be used for intricate source code formatting, and that just kind of happened while no one was looking. I don't think it makes sense to make any changes for this at this point. |
Unfortunately, it looks like there wasn't enough interest from the team Thanks for contributing to ESLint and we appreciate your understanding. |
The version of ESLint you are using.
7.13.0
The problem you want to solve.
I made an issue on vscode that I can't reformat selected range:
microsoft/vscode#108808
And they answered that ESLint doesn't provide an API to do so, so I request to make one since it can be very useful.
The text was updated successfully, but these errors were encountered: