Skip to content

Commit 509d483

Browse files
committed
docs: add Example configuration
1 parent 092a2dc commit 509d483

File tree

1 file changed

+58
-18
lines changed

1 file changed

+58
-18
lines changed

README.md

Lines changed: 58 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Canonical is the most comprehensive code style guide. It consists 1,000+ rules,
88
Canonical goal is to reduce noise in code version control and promote use of the latest ES features.
99

1010
* [Usage](#usage)
11+
* [Example configuration](#example-configuration)
1112
* [Compatibility with other style guides](#compatibility-with-other-style-guides)
1213
* [Integrations](#integrations)
1314
* [Visual Studio Code](#visual-studio-code)
@@ -37,27 +38,66 @@ This package includes the following configurations:
3738
* [`canonical/typescript`](./configurations/typescript.json) – for projects that use [TypeScript](http://typescriptlang.org/).
3839
* [`canonical/yaml`](./configurations/yaml.json) – for projects that use YAML.
3940

40-
Example:
41+
### Example configuration
42+
43+
For maximum efficiency, use [overrides](https://eslint.org/docs/user-guide/configuring/configuration-files#how-do-overrides-work) to only apply relevant style guides. This reduces the linting time and the number of false-positives.
44+
45+
This is an example configuration of a React project using TypeScript and Jest:
4146

4247
```json
4348
{
44-
"extends": [
45-
"canonical",
46-
"canonical/ava",
47-
"canonical/browser",
48-
"canonical/cypress",
49-
"canonical/flowtype",
50-
"canonical/jest",
51-
"canonical/json",
52-
"canonical/jsx-a11y",
53-
"canonical/lodash",
54-
"canonical/mocha",
55-
"canonical/module",
56-
"canonical/node",
57-
"canonical/react",
58-
"canonical/typescript",
59-
"canonical/yaml"
60-
]
49+
"overrides": [
50+
{
51+
"extends": [
52+
"canonical",
53+
"canonical/typescript"
54+
],
55+
"files": "*.ts",
56+
"parserOptions": {
57+
"project": "./tsconfig.json",
58+
},
59+
},
60+
{
61+
"extends": [
62+
"canonical",
63+
"canonical/react",
64+
"canonical/jsx-a11y",
65+
"canonical/typescript"
66+
],
67+
"files": "*.tsx",
68+
"parserOptions": {
69+
"project": "./tsconfig.json"
70+
},
71+
},
72+
{
73+
"extends": [
74+
"canonical/jest"
75+
],
76+
"files": "*.test.{ts,tsx}",
77+
"parserOptions": {
78+
"project": "./tsconfig.json"
79+
},
80+
},
81+
{
82+
"extends": [
83+
"canonical"
84+
],
85+
"files": "*.js"
86+
},
87+
{
88+
"extends": [
89+
"canonical/json"
90+
],
91+
"files": "*.json"
92+
},
93+
{
94+
"extends": [
95+
"canonical/yaml"
96+
],
97+
"files": "*.yaml"
98+
},
99+
],
100+
"root": true
61101
}
62102
```
63103

0 commit comments

Comments
 (0)