Pattern: Inconsistent code format
Issue: -
Runs Prettier as an ESLint rule and reports differences.
-
The first option:
-
Objects are passed directly to Prettier as options. Example:
"prettier/prettier": ["error", {"singleQuote": true, "parser": "flow"}]
-
Or the string
"fb"
may be used to set "Facebook style" defaults:"prettier/prettier": ["error", "fb"]
Equivalent to:
"prettier/prettier": ["error", { "singleQuote": true, "trailingComma": "all", "bracketSpacing": false, "jsxBracketSameLine": true, "parser": "flow" }]
-
-
The second option:
-
A string with a pragma that triggers this rule. By default, this rule applies to all files. However, if you set a pragma (this option), only files with that pragma in the heading docblock will be checked. All pragmas must start with
@
. Example:"prettier/prettier": ["error", null, "@prettier"]
Only files with
@prettier
in the heading docblock will be checked:/** @prettier */ console.log(1 + 2 + 3);
Or:
/** * @prettier */ console.log(4 + 5 + 6);
This option is useful if you're migrating a large codebase and already use pragmas like
@flow
.
-