From 2d654f115f6e05b59c85434e75cf68204b976f22 Mon Sep 17 00:00:00 2001 From: Nicolas Mattia Date: Wed, 29 Sep 2021 02:34:56 +0200 Subject: [PATCH] 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 * Update docs/user-guide/configuring/configuration-files.md Co-authored-by: Nicholas C. Zakas * Update docs/user-guide/configuring/configuration-files.md Co-authored-by: Nicholas C. Zakas Co-authored-by: Nicholas C. Zakas --- .../configuring/configuration-files.md | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/docs/user-guide/configuring/configuration-files.md b/docs/user-guide/configuring/configuration-files.md index f4feb2fe25b..e900f4e7d75 100644 --- a/docs/user-guide/configuring/configuration-files.md +++ b/docs/user-guide/configuring/configuration-files.md @@ -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.