From c9b813b8191fbc952b258ebe465b6b1013601436 Mon Sep 17 00:00:00 2001 From: Alan Orth Date: Thu, 15 Jun 2023 16:31:28 +0300 Subject: [PATCH 1/5] .eslintrc.json: use plugin:jsonc/recommended-with-json5 The eslint-plugin-jsonc has a recommended configuration for json5. See: https://ota-meshi.github.io/eslint-plugin-jsonc/user-guide/#usage --- .eslintrc.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.eslintrc.json b/.eslintrc.json index 5fb4c121717..fe8bc16dcb1 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -301,7 +301,7 @@ "*.json5" ], "extends": [ - "plugin:jsonc/recommended-with-jsonc" + "plugin:jsonc/recommended-with-json5" ], "rules": { "no-irregular-whitespace": "error", From 5d66a14fedd14df6189b57b3375da324c4fe38bf Mon Sep 17 00:00:00 2001 From: Alan Orth Date: Thu, 15 Jun 2023 16:33:06 +0300 Subject: [PATCH 2/5] .eslintrc.json: use jsonc/no-irregular-whitespace The eslint-plugin-jsonc documentation recommends turning ESLint's own no-irregular-whitespace plugin off for JSON files in favor of its own jsonc/no-irregular-whitespace plugin. The idea here is to allow "irregular" whitespace in quoted strings and regular expressions, as that may be deliberate, and to forbid such whitespace in comments and templates (though I'm unsure if we should skip them in templates?). See: https://ota-meshi.github.io/eslint-plugin-jsonc/rules/no-irregular-whitespace.html --- .eslintrc.json | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.eslintrc.json b/.eslintrc.json index fe8bc16dcb1..ee95c7acf78 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -304,7 +304,17 @@ "plugin:jsonc/recommended-with-json5" ], "rules": { - "no-irregular-whitespace": "error", + // ESLint core no-irregular-whitespace rule doesn't work well in JSON + "no-irregular-whitespace": "off", + "jsonc/no-irregular-whitespace": [ + "error", + { + "skipStrings": true, + "skipComments": false, + "skipRegExps": true, + "skipTemplates": false + } + ], "no-trailing-spaces": "error", "jsonc/comma-dangle": [ "error", From 0d8d1559680fb7ac40b804fd1460f40c8a56d497 Mon Sep 17 00:00:00 2001 From: Alan Orth Date: Thu, 15 Jun 2023 16:36:42 +0300 Subject: [PATCH 3/5] .eslintrc.json: enforce limit on empty lines in json5 Only allow one blank line in json5 files as well as a max of one line at the end of the file. See: https://eslint.org/docs/latest/rules/no-multiple-empty-lines --- .eslintrc.json | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.eslintrc.json b/.eslintrc.json index ee95c7acf78..312d8ed1b63 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -316,6 +316,12 @@ } ], "no-trailing-spaces": "error", + "no-multiple-empty-lines": ["error", + { + "max": 1, + "maxEOF": 1 + } + ], "jsonc/comma-dangle": [ "error", "always-multiline" From 55c9ca55d1228fdf65dd7902dee649ac6f9afd18 Mon Sep 17 00:00:00 2001 From: Alan Orth Date: Thu, 15 Jun 2023 16:53:17 +0300 Subject: [PATCH 4/5] .eslintrc.json: enable comma-spacing plugin for json5 files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We want to avoid this: { // "bitstream.download.page.back": "Back" , "bitstream.download.page.back": "AtrĂ¡s" , } There is no need for the space before the comma. Note that we do not need this plugin to check for spaces after the comma because those will be highlighted by the other trailing whitespace checks. See: https://eslint.org/docs/latest/rules/comma-spacing --- .eslintrc.json | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.eslintrc.json b/.eslintrc.json index 312d8ed1b63..2941da956a1 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -322,6 +322,12 @@ "maxEOF": 1 } ], + "comma-spacing": ["error", + { + "before": false, + "after": true + } + ], "jsonc/comma-dangle": [ "error", "always-multiline" From 0e1682532b850698de1d2979fd2b27d2e5d8cf55 Mon Sep 17 00:00:00 2001 From: Alan Orth Date: Sun, 15 Sep 2024 15:11:31 +0300 Subject: [PATCH 5/5] .eslintrc.json: remove second eslint-plugin-jsonc This seems to have been added twice at some point. --- .eslintrc.json | 1 - 1 file changed, 1 deletion(-) diff --git a/.eslintrc.json b/.eslintrc.json index 2941da956a1..043455358d0 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -8,7 +8,6 @@ "eslint-plugin-deprecation", "unused-imports", "eslint-plugin-lodash", - "eslint-plugin-jsonc", "eslint-plugin-rxjs", "eslint-plugin-simple-import-sort", "eslint-plugin-import-newlines",