Skip to content
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

Closed
Tsimopak opened this issue Nov 11, 2020 · 6 comments
Closed

Request range formatter for ESLint #13835

Tsimopak opened this issue Nov 11, 2020 · 6 comments
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion auto closed The bot closed this issue core Relates to ESLint's core APIs and features enhancement This change enhances an existing feature of ESLint evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion

Comments

@Tsimopak
Copy link

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.

@Tsimopak Tsimopak added core Relates to ESLint's core APIs and features enhancement This change enhances an existing feature of ESLint triage An ESLint team member will look at this issue soon labels Nov 11, 2020
@mdjermanovic mdjermanovic added evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion and removed triage An ESLint team member will look at this issue soon labels Nov 11, 2020
@mdjermanovic
Copy link
Member

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.

@Tsimopak
Copy link
Author

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

No, ESLint doesn't contribute a range formatter since they have no API to do this.

@dbaeumer
Copy link

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.

@mdjermanovic
Copy link
Member

@dbaeumer thanks for clarifying!

if a fix one depends on a fix two and I only include one of them

Rules shouldn't produce such fixes. For example, no-extra-parens makes a single fix to replace (foo) with foo, not two fixes.

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.

@nzakas
Copy link
Member

nzakas commented Nov 17, 2020

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.

@eslint-deprecated eslint-deprecated bot added the auto closed The bot closed this issue label Dec 18, 2020
@eslint-deprecated
Copy link

Unfortunately, it looks like there wasn't enough interest from the team
or community to implement this change. While we wish we'd be able to
accommodate everyone's requests, we do need to prioritize. We've found
that issues failing to reach accepted status after 21 days tend to
never be accepted, and as such, we close those issues.
This doesn't mean the idea isn't interesting or useful, just that it's
not something the team can commit to.

Thanks for contributing to ESLint and we appreciate your understanding.

mmomtchev added a commit to mmomtchev/node-gdal-async that referenced this issue May 1, 2021
@eslint-github-bot eslint-github-bot bot locked and limited conversation to collaborators Jun 17, 2021
@eslint-github-bot eslint-github-bot bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Jun 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion auto closed The bot closed this issue core Relates to ESLint's core APIs and features enhancement This change enhances an existing feature of ESLint evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion
Projects
None yet
Development

No branches or pull requests

4 participants