megalinter icon indicating copy to clipboard operation
megalinter copied to clipboard

Run Prettier on CSS, GraphQL, HTML, JSX, Markdown, and TSX Files

Open Kurt-von-Laven opened this issue 2 years ago • 15 comments

Is your feature request related to a problem? Please describe. By default, Mega-Linter only runs Prettier on JavaScript, JSON, TypeScript, and YAML files.

Describe the solution you'd like It would be ideal to run Prettier on all file types that it supports by default. This may lead to the need for more options similar to DEFAULT_JAVASCRIPT_STYLE and DEFAULT_TYPESCRIPT_STYLE where Prettier conflicts with other linters. It would be ideal to offer a single option (e.g., ENABLE_PRETTIER) that sets all appropriate default styles to "prettier".

Describe alternatives you've considered In the meantime, one can either configure Prettier to run on additional extensions or run Prettier separately and disable or compatibly configure any conflicting linters. For the former case, here is an excerpt that can be added to .mega-linter.yml:

JAVASCRIPT_PRETTIER_FILE_EXTENSIONS:
  - .css
  - .graphql
  - .htm
  - .html
  - .saas
  - .scss
  - .js
  - .jsx
  - .tsx

Additional context Prettier may add even more languages and formats in the future, and there are already many community plugins for other languages.

Kurt-von-Laven avatar Sep 27 '21 03:09 Kurt-von-Laven

When there are several formatters for a language, Mega-Linter architecture can work only if they are described in the descriptors, so even if it's not nice, your first proposition "DEFAULT_JAVASCRIPT_STYLE and DEFAULT_TYPESCRIPT_STYLE " is what needs to be implemented

Would you like to make a PR ? ^^

nvuillam avatar Sep 30 '21 21:09 nvuillam

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.

If you think this issue should stay open, please remove the O: stale 🤖 label or comment on the issue.

github-actions[bot] avatar Oct 31 '21 00:10 github-actions[bot]

This is on my backlog for now since the workaround is straightforward.

Kurt-von-Laven avatar Nov 01 '21 02:11 Kurt-von-Laven

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.

If you think this issue should stay open, please remove the O: stale 🤖 label or comment on the issue.

github-actions[bot] avatar Dec 02 '21 00:12 github-actions[bot]

I'd love to see this as well, though it's true that the workaround isn't hard. Maybe for v6 😛

IlanCosman avatar Dec 09 '21 21:12 IlanCosman

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.

If you think this issue should stay open, please remove the O: stale 🤖 label or comment on the issue.

github-actions[bot] avatar Jan 09 '22 00:01 github-actions[bot]

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.

If you think this issue should stay open, please remove the O: stale 🤖 label or comment on the issue.

github-actions[bot] avatar Feb 18 '22 00:02 github-actions[bot]

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.

If you think this issue should stay open, please remove the O: stale 🤖 label or comment on the issue.

github-actions[bot] avatar Mar 23 '22 00:03 github-actions[bot]

This should stay open :)

IlanCosman avatar Apr 07 '22 21:04 IlanCosman

ok but i hope someone will make the PR, because it's too big for my current bandwith ^^

nvuillam avatar Apr 07 '22 21:04 nvuillam

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.

If you think this issue should stay open, please remove the O: stale 🤖 label or comment on the issue.

github-actions[bot] avatar May 16 '22 01:05 github-actions[bot]

I wonder if it would be better overall to do this for v6 and remove linters that conflict with Prettier. The obvious drawbacks I see are that this would force users who have been using the conflicting linters to choose between running those linters outside of MegaLinter and disabling Prettier, not upgrading MegaLinter (not advisable for security reasons), and accepting Prettier as the new world order. There are a few benefits I see to this:

  • simpler implementations lower maintenance burdens and decrease turnaround times for new features.
  • reduced dependency surface area reduces Docker image sizes, runtime, build time, build flakiness, and percentage of maintenance bandwidth dedicated to troubleshooting dependency conflicts and breakages caused by upgrades.
  • reduced configuration surface area reduces the time spent adapting MegaLinter per downstream repository (and debating pros and cons of stylistic considerations rather than whatever they would rather be doing) as well as issues first encountered by users since the combinatorial explosion makes testing all combinations of settings impossible.
  • anecdotally, Prettier works very well for our projects and many others, fits well with MegaLinter’s goal of supporting a vast array of file types, and espouses a similar low-configuration philosophy. There is now even a full port for C# that is vastly faster, slimmer, and in my opinion more powerful than dotnet-format! (For context, running the v5.13.0 dotnet flavor via WSL (Windows Subsystem for Linux) for best performance on Windows tends to frequently knock over a mid-range 2022 laptop with 8 GB of RAM even when running incrementally.)
  • MegaLinter never prevents anyone from running any tool they like externally and configuring them however they like, disabling any linters they don’t wish to run, or creating their own plugins.

Curious how others feel about the trade offs here and what I may have missed. I can compile a list of conflicting linters if that would be helpful.

Kurt-von-Laven avatar May 20 '22 18:05 Kurt-von-Laven

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.

If you think this issue should stay open, please remove the O: stale 🤖 label or comment on the issue.

github-actions[bot] avatar Jun 20 '22 01:06 github-actions[bot]

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.

If you think this issue should stay open, please remove the O: stale 🤖 label or comment on the issue.

github-actions[bot] avatar Jul 25 '22 01:07 github-actions[bot]

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.

If you think this issue should stay open, please remove the O: stale 🤖 label or comment on the issue.

github-actions[bot] avatar Sep 17 '22 01:09 github-actions[bot]