question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Separate prettier command eg. "tsdx format"

See original GitHub issue

Current Behavior

Prettier is integrated into eslint and runs in one tsdx lint command. This comes with couple of disadvantages described at https://prettier.io/docs/en/integrating-with-linters.html . It is also not possible to run prettier on non JS/TS files eg. json, css/less/scss, md, yml etc…

Desired Behavior / Suggested Solution

tsdx lint runs only lint without prettier. tsdx format runs prettier and it’s possible to configure all file types we want to format. Default can be ts,tsx.. while the user can decide to also format yml, sass etc.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:3
  • Comments:6

github_iconTop GitHub Comments

5reactions
agilgur5commented, Oct 29, 2020

This comes with couple of disadvantages described at https://prettier.io/docs/en/integrating-with-linters.html

TSDX does use eslint-config-prettier so the main disadvantage doesn’t apply.

It is also not possible to run prettier on non JS/TS files eg. json, css/less/scss, md, yml etc…

I’m not sure if this is actually correct, I feel like there should be a way of doing this and would also like to use that feature of Prettier.

That being said, it’s important to actually lint (not just format) the other types of files too, which might be outside the scope of TSDX and add bloat. I personally run a variety of linters in my IDE etc (and run Policy-as-Code and SAST in CI).

tsdx lint runs only lint without prettier.

This proposal would be a breaking change in it’s current state.

To give an alternative that works today: Prettier is also very much usable in user-land too. Since it’s already in your dependency tree with TSDX, you can add some package.json#scripts like:

{
   "format": "prettier --write './**/*'",
    "// format:check": "for pre-commit and CI usage",
   "format:check": "prettier --check './**/*'"
}
2reactions
agilgur5commented, Oct 29, 2020

It also adds more dependencies to tsdx

eslint-plugin-prettier is only a single dependency out of the gigantic amount of other deps. It can be impacted by majors, yes, but so will eslint-config-prettier, which is necessary. So not a huge burden in that sense.

I personally believe in single-responsibility principle which means lint does linting and format does formatting.

Well eslint --fix and ESLint style rules existed well before Prettier or really “formatter tools” as a category existed – so it already does both and will continue to do both. I’ve personally been a long-time user of Standard, which is entirely built on ESLint. Also there’s a group of people that believe type-checking is a subset of linting too in #352 – there’s opinions on opposite ends of the spectrum here.

But as I wrote there combining tools typically means for more bugs, nuances, and hacks and is well-evidenced in TSDX issues itself (some mentioned there too), so I’m much more inclined to separate them and am in fact planning to separate each command as a separate package and configs as separate presets (#634 ).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Separate prettier command eg. "tsdx format" #917 - GitHub
Current Behavior Prettier is integrated into eslint and runs in one tsdx lint command. This comes with couple of disadvantages described at ...
Read more >
CLI - Prettier
This command formats all files supported by Prettier in the current directory and its subdirectories. It's recommended to always make sure that prettier...
Read more >
TSDX: Introduction
TSDX is a zero-config CLI that helps you develop, test, and publish modern TypeScript packages with ease--so you can focus on your awesome...
Read more >
TSdx - Best of JS
Below is a list of commands you will probably find useful: ... Aside from just bundling your module into different formats, TSDX comes...
Read more >
Build your First Typescript Package in Under 10 Minutes
Let's bootstrap our TSDX project from the command line: ... To keep with React best practices, we'll make a separate file for our...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found