diff --git a/docs/configuration.md b/docs/configuration.md index 5651e690a..894e14565 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -12,6 +12,8 @@ Prettier uses [cosmiconfig](https://github.com/davidtheclark/cosmiconfig) for co 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. +Prettier intentionally doesn't support any kind of global configuration. This is to make sure that when a project is copied to another computer, Prettier's behavior stays the same. Otherwise, Prettier wouldn't be able to guarantee that everybody in a team gets the same consistent results. + The options to the configuration file are the same as the [API options](options.md). ## Basic Configuration diff --git a/docs/ignore.md b/docs/ignore.md index 9706b8d23..bf95c272e 100644 --- a/docs/ignore.md +++ b/docs/ignore.md @@ -107,6 +107,16 @@ This type of ignore is only allowed to be used in top-level and aimed to disable ``` +## YAML + +To ignore a part of a YAML file, `# prettier-ignore` should be placed on the line immediately above the ignored node: + +```yaml +# prettier-ignore +key : value +hello: world +``` + ## GraphQL ```graphql diff --git a/docs/options.md b/docs/options.md index b8173c0c1..86dd85571 100644 --- a/docs/options.md +++ b/docs/options.md @@ -240,6 +240,8 @@ For example, the following will use the CSS parser: cat foo | prettier --stdin-filepath foo.css ``` +This option is only useful in the CLI and API. It doesn't make sense to use it in a configuration file. + | Default | CLI Override | API Override | | ------- | --------------------------- | ---------------------- | | None | `--stdin-filepath ` | `filepath: ""` | diff --git a/docs/rationale.md b/docs/rationale.md index af9cba2e2..6268693bb 100644 --- a/docs/rationale.md +++ b/docs/rationale.md @@ -262,11 +262,11 @@ Secondly, [the alternate formatting makes it easier to edit the JSX](https://git ### Comments -When it comes to the _contents_ of comments, Prettier can’t do much really. Comments can contain everything from prose to commented out code and ASCII diagrams. Since they can contain anything, Prettier can’t know how to format or wrap them. So they are left as-is. The only exception to this are JSDoc-style comments (block comments where every line starts with a `*`), which Prettier can fix the indentation of. +When it comes to the _content_ of comments, Prettier can’t do much really. Comments can contain everything from prose to commented out code and ASCII diagrams. Since they can contain anything, Prettier can’t know how to format or wrap them. So they are left as-is. The only exception to this are JSDoc-style comments (block comments where every line starts with a `*`), which Prettier can fix the indentation of. Then there’s the question of _where_ to put the comments. Turns out this is a really difficult problem. Prettier tries its best to keep your comments roughly where they were, but it’s no easy task because comments can be placed almost anywhere. -Generally, you get the best results when placing comments **on their own lines,** instead of at the end of lines. Prefer `// eslint-disable-next-line` over `// eslint-disable-line`. +Generally, you get the best results when placing comments **on their own lines**, instead of at the end of lines. Prefer `// eslint-disable-next-line` over `// eslint-disable-line`. Note that “magic comments” such as `eslint-disable-next-line` and `$FlowFixMe` might sometimes need to be manually moved due to Prettier breaking an expression into multiple lines. @@ -293,7 +293,7 @@ const result = safeToEval && settings.allowNativeEval ? eval(input) : fallback(input); ``` -Which means that the `eslint-disable` comment is no longer effective. In this case you need to move the comment: +Which means that the `eslint-disable-next-line` comment is no longer effective. In this case you need to move the comment: ```js const result = @@ -301,6 +301,8 @@ const result = safeToEval && settings.allowNativeEval ? eval(input) : fallback(input); ``` +If possible, prefer comments that operate on line ranges (e.g. `eslint-disable` and `eslint-enable`) or on the statement level (e.g. `/* istanbul ignore next */`), they are even safer. It's possible to disallow using `eslint-disable-line` and `eslint-disable-next-line` comments using [`eslint-plugin-eslint-comments`](https://github.com/mysticatea/eslint-plugin-eslint-comments). + ## What Prettier is _not_ concerned about Prettier only _prints_ code. It does not transform it. This is to limit the scope of Prettier. Let's focus on the printing and do it really well!