From 8da22ed3250e4fe061986d4cd36cf9e3aedff5a4 Mon Sep 17 00:00:00 2001 From: Nicolas Mattia Date: Tue, 21 Sep 2021 10:43:14 +0200 Subject: [PATCH 1/4] Docs: add example .eslintrc.json This adds a `.eslintrc.json` that shows how to set rules config (among others). --- .../configuring/configuration-files.md | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/docs/user-guide/configuring/configuration-files.md b/docs/user-guide/configuring/configuration-files.md index f4feb2fe25b..39eff7e061d 100644 --- a/docs/user-guide/configuring/configuration-files.md +++ b/docs/user-guide/configuring/configuration-files.md @@ -39,6 +39,32 @@ 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. +Example configuration file: + +```js +{ + "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. From 4dd3a06261ddf131ac4189aec74ef8532b915c44 Mon Sep 17 00:00:00 2001 From: Nicolas Mattia Date: Mon, 27 Sep 2021 10:06:05 +0200 Subject: [PATCH 2/4] Update docs/user-guide/configuring/configuration-files.md Co-authored-by: Nicholas C. Zakas --- docs/user-guide/configuring/configuration-files.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/user-guide/configuring/configuration-files.md b/docs/user-guide/configuring/configuration-files.md index 39eff7e061d..ca8046d6a68 100644 --- a/docs/user-guide/configuring/configuration-files.md +++ b/docs/user-guide/configuring/configuration-files.md @@ -39,7 +39,7 @@ 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. -Example configuration file: +Here's an example JSON configuration file that uses the `typescript-eslint` parser to support TypeScript syntax: ```js { From 0f620c9f077419572a967bb26758c3786e1f00af Mon Sep 17 00:00:00 2001 From: Nicolas Mattia Date: Mon, 27 Sep 2021 10:06:12 +0200 Subject: [PATCH 3/4] Update docs/user-guide/configuring/configuration-files.md Co-authored-by: Nicholas C. Zakas --- docs/user-guide/configuring/configuration-files.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/user-guide/configuring/configuration-files.md b/docs/user-guide/configuring/configuration-files.md index ca8046d6a68..d39be839bcc 100644 --- a/docs/user-guide/configuring/configuration-files.md +++ b/docs/user-guide/configuring/configuration-files.md @@ -56,7 +56,8 @@ Here's an example JSON configuration file that uses the `typescript-eslint` pars "rules": { "@typescript-eslint/strict-boolean-expressions": [ 2, - { "allowString" : false, + { + "allowString" : false, "allowNumber" : false } ] From b8d6f11db370aab05b00cc8ef9fe875d5977b7a6 Mon Sep 17 00:00:00 2001 From: Nicolas Mattia Date: Mon, 27 Sep 2021 10:06:18 +0200 Subject: [PATCH 4/4] Update docs/user-guide/configuring/configuration-files.md Co-authored-by: Nicholas C. Zakas --- docs/user-guide/configuring/configuration-files.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/user-guide/configuring/configuration-files.md b/docs/user-guide/configuring/configuration-files.md index d39be839bcc..e900f4e7d75 100644 --- a/docs/user-guide/configuring/configuration-files.md +++ b/docs/user-guide/configuring/configuration-files.md @@ -41,7 +41,7 @@ If you are using one configuration file and want ESLint to ignore any `.eslintrc Here's an example JSON configuration file that uses the `typescript-eslint` parser to support TypeScript syntax: -```js +```json { "root": true, "extends": [