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.

Is there a way to tell specify the files to format (not the ones to ignore!)

See original GitHub issue

I know of prettier.ignorePath, prettier.disableLanguages and the .prettierignore file. But they all exclude some files.

I want to be able to tell the Prettier extension to only format .ts and .json files. Is this possible?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:5
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
CiGitcommented, Feb 9, 2018

["javascript","javascriptreact","typescript","typescriptreact","json","jsonc","css","postcss","less","scss","graphql","markdown","vue"] these are all supported languages.

You will have to add every languages you don’t want in prettier.disableLanguages

In @electrotype 's example: prettier.disableLanguages: ["javascript","javascriptreact","typescriptreact","css","postcss","less","scss","graphql","markdown","vue"] ie everything but the ones you want : "typescript","json","jsonc"

It’s not possible to add a language. HTML is not supported by prettier yet

1reaction
Cianticcommented, Mar 11, 2019

You can also do this in workspace settings.json:

{
    "editor.formatOnPaste": true,
    "editor.formatOnSave": true,
    "editor.formatOnType": true,
    "[markdown]": {
        "editor.formatOnPaste": false,
        "editor.formatOnSave": false,
        "editor.formatOnType": false
    }
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Ignoring Code - Prettier
Use .prettierignore to ignore (i.e. not reformat) certain files and folders completely. Use “prettier-ignore” comments to ignore parts of files.
Read more >
.gitignore file - ignoring files in Git | Atlassian Git Tutorial
There is no explicit git ignore command: instead the .gitignore file must be edited and committed by hand when you have new files...
Read more >
gitignore Documentation - Git
DESCRIPTION. A gitignore file specifies intentionally untracked files that Git should ignore. Files already tracked by Git are not affected; see the NOTES ......
Read more >
Turning off eslint rule for a specific file - Stack Overflow
There are 3 ways you can do this: You can go with 1.2 and add /* eslint-disable */ on top of the files,...
Read more >
How to Use a .gitignore File - Pluralsight
When you make commits in a git repository, you choose which files to stage ... It lets Git know that it should ignore...
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