Skip to content

Commit 2d654f1

Browse files
nmattianzakas
andauthoredSep 29, 2021
Docs: add example .eslintrc.json (#15087)
* Docs: add example .eslintrc.json This adds a `.eslintrc.json` that shows how to set rules config (among others). * Update docs/user-guide/configuring/configuration-files.md Co-authored-by: Nicholas C. Zakas <nicholas@humanwhocodes.com> * Update docs/user-guide/configuring/configuration-files.md Co-authored-by: Nicholas C. Zakas <nicholas@humanwhocodes.com> * Update docs/user-guide/configuring/configuration-files.md Co-authored-by: Nicholas C. Zakas <nicholas@humanwhocodes.com> Co-authored-by: Nicholas C. Zakas <nicholas@humanwhocodes.com>
1 parent 16034f0 commit 2d654f1

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
 

‎docs/user-guide/configuring/configuration-files.md

+27
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,33 @@ The second way to use configuration files is to save the file wherever you would
3939

4040
If you are using one configuration file and want ESLint to ignore any `.eslintrc.*` files, make sure to use [`--no-eslintrc`](https://eslint.org/docs/user-guide/command-line-interface#--no-eslintrc) along with the [`-c`](https://eslint.org/docs/user-guide/command-line-interface#-c---config) flag.
4141

42+
Here's an example JSON configuration file that uses the `typescript-eslint` parser to support TypeScript syntax:
43+
44+
```json
45+
{
46+
"root": true,
47+
"extends": [
48+
"eslint:recommended",
49+
"plugin:@typescript-eslint/recommended"
50+
],
51+
"parser": "@typescript-eslint/parser",
52+
"parserOptions": { "project": ["./tsconfig.json"] },
53+
"plugins": [
54+
"@typescript-eslint"
55+
],
56+
"rules": {
57+
"@typescript-eslint/strict-boolean-expressions": [
58+
2,
59+
{
60+
"allowString" : false,
61+
"allowNumber" : false
62+
}
63+
]
64+
},
65+
"ignorePatterns": ["src/**/*.test.ts", "src/frontend/generated/*"]
66+
}
67+
```
68+
4269
### Comments in configuration files
4370

4471
Both the JSON and YAML configuration file formats support comments (package.json files should not include them). You can use JavaScript-style comments for JSON files and YAML-style comments for YAML files. ESLint safely ignores comments in configuration files. This allows your configuration files to be more human-friendly.

0 commit comments

Comments
 (0)
Please sign in to comment.