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
Change Request: Deprecate formatting rules and recommend using a source code formatter #17522
Comments
I'm fully in favour of this! We on typescript-eslint have been big proponents of this for a long time and we have the same policy as ESLint around formatting rules - no brand new rules; no new options. We also mostly leave them in the community-maintained domain (as in the maintainers don't normally action bug reports for them). We've been in this weird state for a while because there's a few formatting rules in core that break on TS syntax - so we need to have extension rules in our project to support the syntax. Around half of our extension rules are formatting rules! So I think that ESLint core taking a hard stance will be a boon for the community at large, and will help us simplify things immensely ourselves 🎉 However I do know that a lot of people don't like formatters for various reasons. Whilst I clearly disagree with their reasons I think having the option out there is okay. This was actually something that @JoshuaKGoldberg and I had talked about in the past to try and "get rid of" formatting rules from @typescript-eslint given we never used them and were sick of the load from bug reports and PR reviews around them. |
In the short-term, the rules won't be removed from the core, we just won't keep updating them. In the long term, repackaging them into a separate plugin makes sense. My overall goal is to not move these over during the rewrite, so the final ruleset after the rewrite doesn't contain any formatting rules. |
I generally support this proposal, we just need to define a concrete list of rules we'd like to deprecate.
Would we keep non-whitespace rules that might classify as "formatting"? For example, |
For reference here is a list of rules that people disable when using prettier https://github.com/prettier/eslint-config-prettier/blob/main/index.js |
I was envisioning only rules that relate to whitespace, so we would keep things like |
Initial list of rules:
|
|
|
I agree with deprecating only rules related to whitespace. While there are a few others also handled by prettier (and I believe dprint), there's probably no universal definition of what a JS source code formatter should be responsible for, but it's safe to say that any formatter should be responsible for whitespace. |
Few more whitespace-related rules that I think should be included:
|
|
As someone who has been proactively advocating using ESLint for formatting: I am happy to see formatting rules being deprecated in the core if they can help save the maintenance efforts, as I stated in eslint/eslint.org#435 (comment). To me, neither Prettier nor dprint is good enough to replace what we have right now in ESLint. So I think it's still hard for me to recommend them as alternatives. Instead of feeling bad about recommending ESLint to format and increasing the maintenance burden to the ESLint and If that ends up happening, I'd be happy to initiate an org/community to fork and maintain those stylistic rules. So those efforts can be left to contributors we care about formatting and reducing the burden on the core teams 👍 Thanks a lot for what you have done for the community. ESLint really helped me a lot with maintaining clean and efficient codebases. 💚 |
With https://github.com/prettier/eslint-plugin-prettier we can also already use eslint to check if the style satisfies the repo's need. Deprecating, removing and forking these stylistic rules into a community driven repo is a very good idea, because it makes the core smaller and the rules are specifically maintained by people who care. I can just support this decision ❤️ |
@antfu There are multiple reasons why linters shouldn't care about formatting. Few already mentoyed here:
But I agree that Prettier is not good formatter (even tho I use it). What is difference in those is that, ESLint care about syntax and semantics (and parses the code to meaningful chunks), processing with rules that checks about WHAT code is EXECUTED, not about HOW code LOOKS. Formatters doesn't parse the code, doesn't care about syntax and semantics (excluding exceptions), it cares about white-spaces. Actually ESLint could also include formatter, but that would need to run after Linting phase. Making it two separate things running in sequence. Pretty much what doing I guess we need alternative to Prettier that:
For that I would propose to get rid of ESLint formatting rules, and instead implement API that allows formatters to simply "co-work" with ESLint. Giving high quality results. |
@Mlocik97 I appreciate your input, but I am not sure if here is the right place to discuss what's in the scope of linter or formatter (as I probably can't convince you, either the other way around). I see ESLint more like a general AST-transformer/fixer with a very good rule/API design, despite there being a "Lint" in its name. Solely for the reason of maintenance efforts, I would agree to deprecate them from the core to leave them to the community. In that case, I think we are on the same page :) |
Thanks for the input -- indeed, this isn't the right place to discuss linter vs. formatter. We're using this issue to track how we're moving forward with deprecating issues, so I'm locking it to ensure that we can focus on that. Please feel free to open a discussion if you'd like to free-form discuss things at a higher level. |
I was talking with @antfu on Discord more about the plans for the So, I'm unlocking this thread to continue that conversation. @bradzacher you've recommended against using certain rules in typescript-eslint, are there others besides |
Thanks for unlocking the issue and being so supportive of the stylistic plugin, Nicholas! To add a bit of context here for people who are reading. To address the topic I mentioned in #17522 (comment), we created a GitHub organization https://github.com/eslint-stylistic/eslint-stylistic and started the work of porting stylistic/formatting-related rules from ESLint core and We are waiting for the final list of rules in order to ship the first v0.1 and start the maintenance work. We will work together with both teams to ensure the userland migration is straightforward. If you have any ideas/suggestions for the project or rules, feel free to open issues at https://github.com/eslint-stylistic/eslint-stylistic, and avoid bloating this thread if possible. Thanks! |
@nzakas our stance is pretty well "if it can conflict with prettier then ditch it".
Notes on (new) rules
One final note: the prettier config disables both
|
@bradzacher thanks for this exhaustive list and details! I agree about Similarly, All of the others labeled as "(new)" I'm open to also deprecating, pending consensus from the team. |
So, bottom line: As a (somewhat) newbie user who has so far used stylistic rules:
(Perhaps a wiki page about this would be appropriate.) |
For some parts I'm with you. |
Following up on rules such as
Should the discussion for whether to additionally move not-quite-covered-by-Prettier stylistic rules over be in this issue or a new one? Edit: moved to #17681 per 👇 |
We've already finalized the list to deprecate above (and drafted the announcement: eslint/eslint.org#482). If you'd like to discuss deprecating other rules, then let's start a new issue. |
Working on this |
Following #17692, what about |
@pubmikeb your question was answered on the discussion. If you'd like to suggest other rules to deprecate, please open a separate issue. |
* feat: Deprecate formatting rules Fixes #17522 * Add deprecation notice to rule files * Fix tests * Update eslint:all test * Add deprecation notice to docs * Clarify error message for rule check * Update eslint:all test
This comment was marked as off-topic.
This comment was marked as off-topic.
@Alhadis 8.53.0 does not disable these rules. It just mark them as deprecated Finally if you wanna keep using them without deprecation warning just use Antfu's port https://eslint.style/ |
ESLint version
HEAD
What problem do you want to solve?
ESLint has a lot of core rules that simply move whitespace around. After years of maintaining these rules, I personally believe two things:
What do you think is the correct solution?
I'd like to deprecate all formatting rules (anything that is adjusting whitespace) in v9 and recommend that people use a source code formatter instead. Both Prettier and dprint are viable options that solve the same problems in different ways.
This would free us up from maintaining a large number of core rules and make it easy for us to drop these rules during the rewrite.
Participation
Additional comments
No response
The text was updated successfully, but these errors were encountered: