Skip to content

Commit c843df0

Browse files
committed
docs: document compatibility with Prettier
1 parent e18c9a3 commit c843df0

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Canonical consists of 1,000+ rules, some of which are [custom written](https://g
99

1010
* [Usage](#usage)
1111
* [Example configuration](#example-configuration)
12+
* [Compatibility with Prettier](#compatibility-prettier)
1213
* [Compatibility with other style guides](#compatibility-with-other-style-guides)
1314
* [Integrations](#integrations)
1415
* [Visual Studio Code](#visual-studio-code)
@@ -96,6 +97,24 @@ This is an example configuration of a React project using TypeScript and Jest:
9697
}
9798
```
9899

100+
### Compatibility with Prettier
101+
102+
For the most part, Prettier and Canonical are already compatible. There are only a few transformations that are incompatible, e.g. Prettier enforces line-length and Canonical does not. As such, there is no good reason to use both. However, if you just want to disable conflicting rules, you can use [`eslint-config-prettier`](https://github.com/prettier/eslint-config-prettier) to do that. Just add it as the last config in your `extends` configuration, e.g.
103+
104+
```json
105+
{
106+
"extends": [
107+
"canonical",
108+
"canonical/react",
109+
"canonical/typescript",
110+
"canonical/jest",
111+
"prettier"
112+
]
113+
}
114+
```
115+
116+
This configuration disables all Canonical rules that conflict with Prettier.
117+
99118
### Compatibility with other style guides
100119

101120
Since Canonical style guide includes more rules than any other style guide, you can have your codebase compatible with a specific style guide (e.g. [airbnb](https://www.npmjs.com/package/eslint-config-airbnb)) and benefit from Canonical for rules that are not covered by the other guide. All you have to do is extend from Canonical before extending from the desired style guide, e.g.

0 commit comments

Comments
 (0)