Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I tell Prettier to ignore a package.json file?

I am using prettier-standard because the project uses the standard for linting.

Following the prettier pre-commit hook example I am running prettier on commits. However I would like to ignore the package.json file. I tried adding package.json to a .prettierignore file but this did not work.

Code from the prettier pre-commit hook example that I am using in my package.json

{
  "scripts": {
    "precommit": "lint-staged"
  },
  "lint-staged": {
     "*.{js,json,css}": [
       "prettier --write",
       "git add"
     ]
  }
}

```

like image 686
Mdd Avatar asked Sep 25 '17 16:09

Mdd


People also ask

How do you ignore prettier on one line?

Enable “Only format if prettier is found in your project's dependencies” or “Only format if a Prettier config is found” Disable format on save, save the file, then re-enable it again. Disable format on save and manually run format each time you want to format a file as desired from the command pallette.

Does prettier ignore files in Gitignore?

Prettier should process all files with relevant file extensions, but it should ignore the patterns from . gitignore . In other words, ignore the build outputs.

How do I create a prettier ignore file?

Ignoring Files or Folders To exclude files from formatting, add entries to a . prettierignore file in the project root or set the --ignore-path CLI option. . prettierignore uses gitignore syntax.

How do I tell prettier to ignore a file?

Use . prettierignore to ignore (i.e. not reformat) certain files and folders completely. Use “prettier-ignore” comments to ignore parts of files.


1 Answers

you can also use a .prettierignore file.

See the prettier project itself for a reference.

like image 132
xiphe Avatar answered Oct 13 '22 22:10

xiphe