You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Now that ESLint supports JSON parsing, it’d be great to achieve the value of sort-package-json via a rule. Conceptually it is similar to sorting imports in JS files, so I believe that it fits the scope. WDYT?
UPD Maybe this should be done elsewhere because the rule would be package.json specific. There is a discussion in keithamus/sort-package-json#322.
The text was updated successfully, but these errors were encountered:
Rule details
The rule would normalize
package.json
keys by following a convention in sort-package-json (or similar).What type of rule is this?
Suggests an alternate way of doing something
Example code
↓
Participation
Additional comments
I am using
sort-package-json
viaprettier-plugin-packagejson
and it works well. Automatic key sorting is especially useful in monorepos with lots ofpackage.json
files and contributors. The problem withprettier-plugin-packagejson
is that it goes outside the scope of Prettier:Now that ESLint supports JSON parsing, it’d be great to achieve the value of
sort-package-json
via a rule. Conceptually it is similar to sorting imports in JS files, so I believe that it fits the scope. WDYT?UPD Maybe this should be done elsewhere because the rule would be
package.json
specific. There is a discussion in keithamus/sort-package-json#322.The text was updated successfully, but these errors were encountered: