Prettier-vscode: Support Prettier config from prettierrc and package.json

Created on 12 Jul 2017  路  4Comments  路  Source: prettier/prettier-vscode

Recently, Prettier added support for storing the configuration in a project file.

https://github.com/prettier/prettier#configuration-file

Prettier uses cosmiconfig for configuration file support. This means you can configure prettier via:

  • A .prettierrc file, written in YAML or JSON.
  • A prettier.config.js file that exports an object.
  • A "prettier" key in your package.json file.

The configuration file will be resolved starting from the location of the file being formatted, and searching up the file tree until a config file is (or isn't) found.

AFAICT, the VSCode extension ignores this config now.

It would be great if the extension could load the config the same way how Prettier CLI does it, and then applying any VSCode-specific configuration as an override on top of that base configuration.

locked

Most helpful comment

The use case I have in mind is to keep Prettier configuration in a single place and use it by several tools:

  • use Prettier via VSCode extension
  • allow people using different IDE to run Prettier manually via CLI, or perhaps use their IDE's plugin instead
  • have npm/package.json script to auto-format all files, or perhaps a pre-commit hook
  • have CI step verifying that all files are following our Prettier config (e.g. via https://www.npmjs.com/package/prettier-check)

All 4 comments

The use case I have in mind is to keep Prettier configuration in a single place and use it by several tools:

  • use Prettier via VSCode extension
  • allow people using different IDE to run Prettier manually via CLI, or perhaps use their IDE's plugin instead
  • have npm/package.json script to auto-format all files, or perhaps a pre-commit hook
  • have CI step verifying that all files are following our Prettier config (e.g. via https://www.npmjs.com/package/prettier-check)

Not yet released. See #124

Lovely, let's close my issue as a duplicate then.

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings