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

Convert to ESLint plugin/ Provide an ESLint plugin? #322

Open
fisker opened this issue Aug 9, 2024 · 3 comments
Open

Convert to ESLint plugin/ Provide an ESLint plugin? #322

fisker opened this issue Aug 9, 2024 · 3 comments

Comments

@fisker
Copy link
Collaborator

fisker commented Aug 9, 2024

ESLint starting to support other languages. Should we consider?

@fisker fisker changed the title Convert to ESLint plugin/ Provide a ESLint plugin? Convert to ESLint plugin/ Provide an ESLint plugin? Aug 22, 2024
@Zamiell
Copy link

Zamiell commented Sep 21, 2024

The ESLint ecosystem has mostly agreed that formatting should be left to dedicated formatting tools like Prettier. Thus, I think package.json sorting is best done as a Prettier plugin, which is exactly what prettier-plugin-packagejson does. (It simply calls sort-package-json under the hood.)

@kachkaev
Copy link
Contributor

kachkaev commented Oct 6, 2024

I opened eslint/json#37 but maybe this should be done outside @eslint/json plugin. Sorting keys via prettier-plugin-packagejson has been working well for me for a few years. The problem with this plugin is that it goes outside of the scope of Prettier:

What Prettier is not concerned about
Prettier only prints code. It does not transform it. This is to limit the scope of Prettier. Let’s focus on the printing and do it really well!
Here are a few examples of things that are out of scope for Prettier:

  • ...
  • Sorting/moving imports, object keys, class members, JSX keys, CSS properties or anything else. Apart from being a transform rather than just printing (as mentioned above), sorting is potentially unsafe because of side effects (for imports, as an example) and makes it difficult to verify the most important correctness goal.

Sorting package.json keys is similar to sorting imports. It’s not just formatting so it’s a concern of ESLint. The question is whether to sort as part of @eslint/json or as a separate sort-package-json plugin.

@mrmckeb
Copy link

mrmckeb commented Oct 10, 2024

We also use the Prettier plugin. I agree that this should not go into ESLint, as people have been moving away from using ESLint for formatting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants