Skip to content

Commit

Permalink
Docs: add example .eslintrc.json (#15087)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
nmattia and nzakas committed Sep 29, 2021
1 parent 16034f0 commit 2d654f1
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions docs/user-guide/configuring/configuration-files.md
Expand Up @@ -39,6 +39,33 @@ The second way to use configuration files is to save the file wherever you would

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.

Here's an example JSON configuration file that uses the `typescript-eslint` parser to support TypeScript syntax:

```json
{
"root": true,
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": { "project": ["./tsconfig.json"] },
"plugins": [
"@typescript-eslint"
],
"rules": {
"@typescript-eslint/strict-boolean-expressions": [
2,
{
"allowString" : false,
"allowNumber" : false
}
]
},
"ignorePatterns": ["src/**/*.test.ts", "src/frontend/generated/*"]
}
```

### Comments in configuration files

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.
Expand Down

0 comments on commit 2d654f1

Please sign in to comment.