From 9106608398a0218611ed26bae6cc2c25cdcbdd17 Mon Sep 17 00:00:00 2001 From: Denys Vuika Date: Fri, 8 Sep 2023 09:00:00 +0100 Subject: [PATCH] ESLint fixes and unified lint targets (#3424) * optimise lint targets * fix eslint config files * fix app coverage settings * tune eslint to warn about optional chains --- .eslintrc.json | 3 ++- app/karma.conf.js | 6 ++++- app/project.json | 14 +---------- e2e/playwright/actions/project.json | 12 +--------- e2e/playwright/authentication/project.json | 12 +--------- e2e/playwright/folder-rules/project.json | 12 +--------- e2e/playwright/navigation/project.json | 12 +--------- e2e/playwright/viewer/project.json | 12 +--------- e2e/protractor/project.json | 14 +---------- nx.json | 15 ++++++++---- projects/aca-content/.eslintrc.js | 28 ++++++++-------------- projects/aca-content/project.json | 14 +---------- projects/aca-shared/.eslintrc.js | 28 ++++++++-------------- projects/aca-shared/project.json | 14 +---------- 14 files changed, 47 insertions(+), 149 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index df79cb686..662af8b63 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -113,6 +113,7 @@ "@angular-eslint/no-outputs-metadata-property": "error", "@angular-eslint/use-lifecycle-interface": "error", "@angular-eslint/use-pipe-transform-interface": "error", + "@typescript-eslint/prefer-optional-chain": "warn", "@typescript-eslint/no-misused-new": "error", "@typescript-eslint/no-non-null-assertion": "error", "@typescript-eslint/prefer-function-type": "error", @@ -328,7 +329,7 @@ "@angular-eslint/template/no-negated-async": "off", "@angular-eslint/template/no-positive-tabindex": "error", "@angular-eslint/template/eqeqeq": "error", - "@angular-eslint/template/no-call-expression": "warn" + "@angular-eslint/template/no-call-expression": "off" } }, { diff --git a/app/karma.conf.js b/app/karma.conf.js index e2838524b..37ad8b4b3 100644 --- a/app/karma.conf.js +++ b/app/karma.conf.js @@ -1,11 +1,15 @@ // Karma configuration file, see link for more information // https://karma-runner.github.io/1.0/config/configuration-file.html +const { join } = require('path'); const getBaseKarmaConfig = require('../karma.conf'); module.exports = function (config) { const baseConfig = getBaseKarmaConfig(); config.set({ ...baseConfig, - coverageReporter: {}, + coverageReporter: { + ...baseConfig.coverageReporter, + dir: join(__dirname, '../coverage/content-ce') + } }); }; diff --git a/app/project.json b/app/project.json index 8509a7042..0775144d0 100644 --- a/app/project.json +++ b/app/project.json @@ -237,19 +237,7 @@ } }, "lint": { - "executor": "@angular-eslint/builder:lint", - "options": { - "lintFilePatterns": [ - "app/**/*.ts", - "app/**/*.html" - ], - "cache": true, - "cacheLocation": ".eslintcache", - "ignorePath": ".eslintignore" - }, - "outputs": [ - "{options.outputFile}" - ] + "executor": "@angular-eslint/builder:lint" } } } diff --git a/e2e/playwright/actions/project.json b/e2e/playwright/actions/project.json index c7228bfa0..a92c78203 100644 --- a/e2e/playwright/actions/project.json +++ b/e2e/playwright/actions/project.json @@ -18,17 +18,7 @@ } }, "lint": { - "executor": "@angular-eslint/builder:lint", - "options": { - "lintFilePatterns": [ - "e2e/**/*.ts", - "e2e/**/*.html" - ], - "cache": true, - "cacheLocation": ".eslintcache", - "ignorePath": ".eslintignore" - }, - "outputs": ["{options.outputFile}"] + "executor": "@angular-eslint/builder:lint" } } } diff --git a/e2e/playwright/authentication/project.json b/e2e/playwright/authentication/project.json index d906f84dd..6307ec492 100644 --- a/e2e/playwright/authentication/project.json +++ b/e2e/playwright/authentication/project.json @@ -18,17 +18,7 @@ } }, "lint": { - "executor": "@angular-eslint/builder:lint", - "options": { - "lintFilePatterns": [ - "e2e/**/*.ts", - "e2e/**/*.html" - ], - "cache": true, - "cacheLocation": ".eslintcache", - "ignorePath": ".eslintignore" - }, - "outputs": ["{options.outputFile}"] + "executor": "@angular-eslint/builder:lint" } } } diff --git a/e2e/playwright/folder-rules/project.json b/e2e/playwright/folder-rules/project.json index f279a4ba6..e2acf54d4 100644 --- a/e2e/playwright/folder-rules/project.json +++ b/e2e/playwright/folder-rules/project.json @@ -18,17 +18,7 @@ } }, "lint": { - "executor": "@angular-eslint/builder:lint", - "options": { - "lintFilePatterns": [ - "e2e/**/*.ts", - "e2e/**/*.html" - ], - "cache": true, - "cacheLocation": ".eslintcache", - "ignorePath": ".eslintignore" - }, - "outputs": ["{options.outputFile}"] + "executor": "@angular-eslint/builder:lint" } } } diff --git a/e2e/playwright/navigation/project.json b/e2e/playwright/navigation/project.json index 8dde0c968..b3c441fcd 100644 --- a/e2e/playwright/navigation/project.json +++ b/e2e/playwright/navigation/project.json @@ -18,17 +18,7 @@ } }, "lint": { - "executor": "@angular-eslint/builder:lint", - "options": { - "lintFilePatterns": [ - "e2e/**/*.ts", - "e2e/**/*.html" - ], - "cache": true, - "cacheLocation": ".eslintcache", - "ignorePath": ".eslintignore" - }, - "outputs": ["{options.outputFile}"] + "executor": "@angular-eslint/builder:lint" } } } diff --git a/e2e/playwright/viewer/project.json b/e2e/playwright/viewer/project.json index bb31d77f5..99acd939c 100644 --- a/e2e/playwright/viewer/project.json +++ b/e2e/playwright/viewer/project.json @@ -18,17 +18,7 @@ } }, "lint": { - "executor": "@angular-eslint/builder:lint", - "options": { - "lintFilePatterns": [ - "e2e/**/*.ts", - "e2e/**/*.html" - ], - "cache": true, - "cacheLocation": ".eslintcache", - "ignorePath": ".eslintignore" - }, - "outputs": ["{options.outputFile}"] + "executor": "@angular-eslint/builder:lint" } } } diff --git a/e2e/protractor/project.json b/e2e/protractor/project.json index ca6a4c653..316ed6295 100644 --- a/e2e/protractor/project.json +++ b/e2e/protractor/project.json @@ -17,19 +17,7 @@ } }, "lint": { - "executor": "@angular-eslint/builder:lint", - "options": { - "lintFilePatterns": [ - "e2e/**/*.ts", - "e2e/**/*.html" - ], - "cache": true, - "cacheLocation": ".eslintcache", - "ignorePath": ".eslintignore" - }, - "outputs": [ - "{options.outputFile}" - ] + "executor": "@angular-eslint/builder:lint" } } } diff --git a/nx.json b/nx.json index 3c5d1c266..1d0c126c6 100644 --- a/nx.json +++ b/nx.json @@ -48,10 +48,17 @@ ] }, "lint": { - "inputs": [ - "default", - "{workspaceRoot}/.eslintrc.json" - ] + "executor": "@angular-eslint/builder:lint", + "outputs": ["{options.outputFile}"], + "options": { + "lintFilePatterns": [ + "{projectRoot}/**/*.ts", + "{projectRoot}/**/*.html" + ], + "cache": true, + "cacheLocation": ".eslintcache", + "ignorePath": ".eslintignore" + } }, "e2e": { "inputs": [ diff --git a/projects/aca-content/.eslintrc.js b/projects/aca-content/.eslintrc.js index 9e780e164..b98ba4eb8 100644 --- a/projects/aca-content/.eslintrc.js +++ b/projects/aca-content/.eslintrc.js @@ -1,23 +1,15 @@ -path = require("path"); +const path = require('path'); module.exports = { - "extends": "../../.eslintrc.json", - "ignorePatterns": [ - "!**/*" - ], - "overrides": [ + extends: '../../.eslintrc.json', + ignorePatterns: ['!**/*'], + overrides: [ { - "files": [ - "*.ts" - ], - "parserOptions": { - "project": [ - path.join(__dirname, "tsconfig.lib.json"), - path.join(__dirname, "tsconfig.spec.json") - ], - "createDefaultProgram": true + files: ['*.ts'], + parserOptions: { + project: [path.join(__dirname, 'tsconfig.lib.json'), path.join(__dirname, 'tsconfig.spec.json')], + createDefaultProgram: true }, - "rules": { - } + rules: {} } ] -} +}; diff --git a/projects/aca-content/project.json b/projects/aca-content/project.json index cdea95c0a..fee878dde 100644 --- a/projects/aca-content/project.json +++ b/projects/aca-content/project.json @@ -41,19 +41,7 @@ } }, "lint": { - "executor": "@angular-eslint/builder:lint", - "options": { - "lintFilePatterns": [ - "projects/aca-content/**/*.ts", - "projects/aca-content/**/*.html" - ], - "cache": true, - "cacheLocation": ".eslintcache", - "ignorePath": ".eslintignore" - }, - "outputs": [ - "{options.outputFile}" - ] + "executor": "@angular-eslint/builder:lint" } } } diff --git a/projects/aca-shared/.eslintrc.js b/projects/aca-shared/.eslintrc.js index 9e780e164..b98ba4eb8 100644 --- a/projects/aca-shared/.eslintrc.js +++ b/projects/aca-shared/.eslintrc.js @@ -1,23 +1,15 @@ -path = require("path"); +const path = require('path'); module.exports = { - "extends": "../../.eslintrc.json", - "ignorePatterns": [ - "!**/*" - ], - "overrides": [ + extends: '../../.eslintrc.json', + ignorePatterns: ['!**/*'], + overrides: [ { - "files": [ - "*.ts" - ], - "parserOptions": { - "project": [ - path.join(__dirname, "tsconfig.lib.json"), - path.join(__dirname, "tsconfig.spec.json") - ], - "createDefaultProgram": true + files: ['*.ts'], + parserOptions: { + project: [path.join(__dirname, 'tsconfig.lib.json'), path.join(__dirname, 'tsconfig.spec.json')], + createDefaultProgram: true }, - "rules": { - } + rules: {} } ] -} +}; diff --git a/projects/aca-shared/project.json b/projects/aca-shared/project.json index d41adc8a1..a5d537b7c 100644 --- a/projects/aca-shared/project.json +++ b/projects/aca-shared/project.json @@ -36,19 +36,7 @@ } }, "lint": { - "executor": "@angular-eslint/builder:lint", - "options": { - "lintFilePatterns": [ - "projects/aca-shared/**/*.ts", - "projects/aca-shared/**/*.html" - ], - "cache": true, - "cacheLocation": ".eslintcache", - "ignorePath": ".eslintignore" - }, - "outputs": [ - "{options.outputFile}" - ] + "executor": "@angular-eslint/builder:lint" } } }