From 56a7fe87d45463af326c4be6c5b319ecbc085e12 Mon Sep 17 00:00:00 2001 From: MariaAga Date: Thu, 29 Jun 2023 18:23:18 +0200 Subject: [PATCH] Fixes #36471 - Add eslint rule to alert missing ouia-ids --- .eslintrc | 9 +++++++-- .github/workflows/js_tests.yml | 4 ++-- package-exclude.json | 1 + package.json | 3 ++- .../BreadcrumbBar/components/Breadcrumb.js | 4 +++- .../react_app/components/Layout/Navigation.js | 6 +++++- .../components/Layout/components/Toolbar/Header.js | 2 +- .../Layout/components/Toolbar/HeaderToolbar.js | 2 +- .../__snapshots__/HeaderToolbar.test.js.snap | 1 + .../PersonalAccessTokenModal.js | 14 +++++++++++++- .../RegistrationCommandsPage/index.js | 2 ++ .../routes/common/PageLayout/PageLayout.js | 4 +++- 12 files changed, 41 insertions(+), 11 deletions(-) diff --git a/.eslintrc b/.eslintrc index d2b5d09efc8..d6d85e90c27 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,5 +1,9 @@ { - "plugins": ["@theforeman/foreman", "spellcheck"], + "plugins": [ + "@theforeman/foreman", + "spellcheck", + "@theforeman/rules" + ], "extends": "plugin:@theforeman/foreman/core", "rules": { "spellcheck/spell-checker": [ @@ -184,6 +188,7 @@ ], "minLength": 3 } - ] + ], + "@theforeman/rules/require-ouiaid": ["error"] } } diff --git a/.github/workflows/js_tests.yml b/.github/workflows/js_tests.yml index 9d681f17342..a6b66d5818a 100644 --- a/.github/workflows/js_tests.yml +++ b/.github/workflows/js_tests.yml @@ -40,8 +40,8 @@ jobs: run: npm ci --no-audit - name: Run linter run: npm run lint - - name: Run Spellcheck (only warnings) - run: npm run lint:spelling + - name: Run custom eslint rules Spellcheck (only warnings) and missing ouia-ids + run: npm run lint:custom - name: Run tests run: npm run test - name: Publish Coveralls (node v14) diff --git a/package-exclude.json b/package-exclude.json index 818dc95a830..1f37c76cf80 100644 --- a/package-exclude.json +++ b/package-exclude.json @@ -3,6 +3,7 @@ "@sheerun/mutationobserver-shim", "@theforeman/env", "@theforeman/eslint-plugin-foreman", + "@theforeman/eslint-plugin-rules", "@theforeman/stories", "@theforeman/test", "@theforeman/vendor-dev", diff --git a/package.json b/package.json index 84e8b4b21a9..faf29ffebe6 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ }, "scripts": { "lint": "tfm-lint", - "lint:spelling": "eslint ./webpack", + "lint:custom": "eslint ./webpack", "foreman-js:link": "./script/npm_link_foreman_js.sh", "postlint": "./script/npm_lint_plugins.js", "test": "tfm-test", @@ -30,6 +30,7 @@ "@babel/core": "^7.7.0", "@theforeman/builder": "^12.0.1", "@theforeman/eslint-plugin-foreman": "^12.0.1", + "@theforeman/eslint-plugin-rules": "^12.0.2", "@theforeman/test": "^12.0.1", "@theforeman/vendor-dev": "^12.0.1", "@types/jest": "<27.0.0", diff --git a/webpack/assets/javascripts/react_app/components/BreadcrumbBar/components/Breadcrumb.js b/webpack/assets/javascripts/react_app/components/BreadcrumbBar/components/Breadcrumb.js index a88b2091bd4..228d02bf701 100644 --- a/webpack/assets/javascripts/react_app/components/BreadcrumbBar/components/Breadcrumb.js +++ b/webpack/assets/javascripts/react_app/components/BreadcrumbBar/components/Breadcrumb.js @@ -20,7 +20,9 @@ const Breadcrumb = ({ if (isTitle) { return ( - {items[0].caption} + + {items[0].caption} + ); } diff --git a/webpack/assets/javascripts/react_app/components/Layout/Navigation.js b/webpack/assets/javascripts/react_app/components/Layout/Navigation.js index 46c9e0d0ad1..5a92239fd88 100644 --- a/webpack/assets/javascripts/react_app/components/Layout/Navigation.js +++ b/webpack/assets/javascripts/react_app/components/Layout/Navigation.js @@ -91,11 +91,12 @@ const Navigation = ({ setCurrentPath(href); }; return ( -