From ec1b2a05ddf561fc4e0336e55086e3f1c89f65dc Mon Sep 17 00:00:00 2001 From: Connor Gilbert Date: Fri, 26 May 2023 16:50:01 -0700 Subject: [PATCH 1/3] Configure eslint job to output Code Quality report --- .gitlab/ci/static-analysis.gitlab-ci.yml | 4 ++++ package.json | 3 ++- yarn.lock | 8 ++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/.gitlab/ci/static-analysis.gitlab-ci.yml b/.gitlab/ci/static-analysis.gitlab-ci.yml index 17dc2a55e4eb4f..63878780326d07 100644 --- a/.gitlab/ci/static-analysis.gitlab-ci.yml +++ b/.gitlab/ci/static-analysis.gitlab-ci.yml @@ -71,9 +71,13 @@ eslint: needs: ['generate-apollo-graphql-schema'] variables: USE_BUNDLE_INSTALL: "false" + ESLINT_CODE_QUALITY_REPORT: "gl-code-quality-report.json" script: - yarn_install_script - run_timed_command "yarn run lint:eslint:all" + artifacts: + reports: + codequality: gl-code-quality-report.json eslint-docs: extends: diff --git a/package.json b/package.json index 420b9a674c0949..63927f8667c977 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "dev-server": "NODE_OPTIONS=\"${NODE_OPTIONS:=--max-old-space-size=5120}\" node scripts/frontend/webpack_dev_server.js", "file-coverage": "scripts/frontend/file_test_coverage.js", "lint-docs": "scripts/lint-doc.sh", - "internal:eslint": "eslint --cache --max-warnings 0 --report-unused-disable-directives", + "internal:eslint": "eslint --cache --max-warnings 0 --report-unused-disable-directives --format gitlab", "internal:stylelint": "stylelint -q --rd '{ee/,}app/assets/{stylesheets/**/*.{css,scss},builds/tailwind.css}'", "prejest": "yarn check-dependencies", "build:css": "node scripts/frontend/build_css.mjs", @@ -282,6 +282,7 @@ "crypto": "^1.0.1", "custom-jquery-matchers": "^2.1.0", "eslint": "9.14.0", + "eslint-formatter-gitlab": "^5.1.0", "eslint-import-resolver-jest": "3.0.2", "eslint-import-resolver-webpack": "0.13.9", "eslint-plugin-import": "^2.31.0", diff --git a/yarn.lock b/yarn.lock index 3946d6b278ba96..f95da9e6cc87aa 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7242,6 +7242,14 @@ eslint-config-prettier@^9.1.0: resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-9.1.0.tgz#31af3d94578645966c082fcb71a5846d3c94867f" integrity sha512-NSWl5BFQWEPi1j4TjVNItzYV7dZXZ+wP6I6ZhrBGpChQhZRUaElihE9uRRkcbRnNb76UMKDF3r+WTmNcGPKsqw== +eslint-formatter-gitlab@^5.1.0: + version "5.1.0" + resolved "https://registry.yarnpkg.com/eslint-formatter-gitlab/-/eslint-formatter-gitlab-5.1.0.tgz#33162a17eefba5a44a257af568511d360212e866" + integrity sha512-IxhrjLYzDlbFgPWEnvZlWLwPjMeyymbyo0hDHWntZ3DSAP9AP9huj15KbU+BK3OqeO3OHhbFEh2TA6sR0KZhkA== + dependencies: + chalk "^4.0.0" + yaml "^2.0.0" + eslint-import-resolver-jest@3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/eslint-import-resolver-jest/-/eslint-import-resolver-jest-3.0.2.tgz#b20150f574576b6bd0d432a7ff08b0067141b33e" -- GitLab From aa3792d130fd6cc72bd9d1b96695d22067fcecca Mon Sep 17 00:00:00 2001 From: Connor Gilbert Date: Thu, 14 Nov 2024 09:03:37 -0800 Subject: [PATCH 2/3] Move '--format gitlab' to CI config, out of yarn scripts --- .gitlab/ci/static-analysis.gitlab-ci.yml | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab/ci/static-analysis.gitlab-ci.yml b/.gitlab/ci/static-analysis.gitlab-ci.yml index 63878780326d07..6fa7de26c74f2f 100644 --- a/.gitlab/ci/static-analysis.gitlab-ci.yml +++ b/.gitlab/ci/static-analysis.gitlab-ci.yml @@ -74,7 +74,7 @@ eslint: ESLINT_CODE_QUALITY_REPORT: "gl-code-quality-report.json" script: - yarn_install_script - - run_timed_command "yarn run lint:eslint:all" + - run_timed_command "yarn run lint:eslint:all --format gitlab" artifacts: reports: codequality: gl-code-quality-report.json diff --git a/package.json b/package.json index 63927f8667c977..ee3658be23b9d8 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "dev-server": "NODE_OPTIONS=\"${NODE_OPTIONS:=--max-old-space-size=5120}\" node scripts/frontend/webpack_dev_server.js", "file-coverage": "scripts/frontend/file_test_coverage.js", "lint-docs": "scripts/lint-doc.sh", - "internal:eslint": "eslint --cache --max-warnings 0 --report-unused-disable-directives --format gitlab", + "internal:eslint": "eslint --cache --max-warnings 0 --report-unused-disable-directives", "internal:stylelint": "stylelint -q --rd '{ee/,}app/assets/{stylesheets/**/*.{css,scss},builds/tailwind.css}'", "prejest": "yarn check-dependencies", "build:css": "node scripts/frontend/build_css.mjs", -- GitLab From 02cc7d032ac25226c2475d78e0c3eb353cb01e4d Mon Sep 17 00:00:00 2001 From: Connor Gilbert Date: Tue, 30 May 2023 16:14:45 -0700 Subject: [PATCH 3/3] Do not merge: Re-enable some eslint rules to test --- app/assets/javascripts/diff.js | 1 - eslint.config.mjs | 12 ++++++------ jest.config.js | 1 - 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/app/assets/javascripts/diff.js b/app/assets/javascripts/diff.js index 0c31443e5f7d0b..c5d79368c5db36 100644 --- a/app/assets/javascripts/diff.js +++ b/app/assets/javascripts/diff.js @@ -154,7 +154,6 @@ export default class Diff { } } - // eslint-disable-next-line class-methods-use-this lineNumbers(line) { const children = line.find('.diff-line-num').toArray(); if (children.length !== 2) { diff --git a/eslint.config.mjs b/eslint.config.mjs index 8b2a368cb6874e..5d4d6b47a4e459 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -127,7 +127,7 @@ export default [ rules: { 'import/no-commonjs': 'error', - 'import/no-default-export': 'off', + // 'import/no-default-export': 'off', 'no-underscore-dangle': [ 'error', @@ -147,7 +147,7 @@ export default [ 'no-jquery/no-animate-toggle': 'off', 'no-jquery/no-event-shorthand': 'off', 'no-jquery/no-serialize': 'error', - 'promise/always-return': 'off', + // 'promise/always-return': 'off', 'promise/no-callback-in-promise': 'off', '@gitlab/no-global-event-off': 'error', @@ -168,8 +168,8 @@ export default [ 'error', { props: true, - ignorePropertyModificationsFor: ['acc', 'accumulator', 'el', 'element', 'state'], - ignorePropertyModificationsForRegex: ['^draft'], + ignorePropertyModificationsFor: ['accumulator', 'el', 'element', 'state'], + // ignorePropertyModificationsForRegex: ['^draft'], }, ], @@ -408,8 +408,8 @@ export default [ '@gitlab/no-max-width-media-queries': 'off', '@gitlab/vue-tailwind-no-max-width-media-queries': 'off', 'require-await': 'error', - 'import/no-dynamic-require': 'off', - 'no-import-assign': 'off', + // 'import/no-dynamic-require': 'off', + // 'no-import-assign': 'off', 'no-restricted-syntax': [ 'error', diff --git a/jest.config.js b/jest.config.js index acfaee14fbfc59..5043b607b2042f 100644 --- a/jest.config.js +++ b/jest.config.js @@ -5,7 +5,6 @@ const baseConfig = require('./jest.config.base'); // TODO: Remove existsSync once jh has added jest.config.js if (IS_JH && fs.existsSync('./jh/jest.config.js')) { // We can't be explicit with eslint-disable rules because in JH it'll pass import/no-unresolved - // eslint-disable-next-line module.exports = require('./jh/jest.config'); } else { module.exports = { -- GitLab