diff --git a/its/ruling/src/test/expected/jsts/Joust/typescript-S1082.json b/its/ruling/src/test/expected/jsts/Joust/typescript-S1082.json new file mode 100644 index 00000000000..a7eab67a2f4 --- /dev/null +++ b/its/ruling/src/test/expected/jsts/Joust/typescript-S1082.json @@ -0,0 +1,13 @@ +{ +"Joust:ts/components/Settings.tsx": [ +22 +], +"Joust:ts/components/Tooltipper.tsx": [ +62, +62 +], +"Joust:ts/components/game/EntityInPlay.tsx": [ +134, +134 +] +} diff --git a/its/ruling/src/test/expected/jsts/ant-design/javascript-S1082.json b/its/ruling/src/test/expected/jsts/ant-design/javascript-S1082.json new file mode 100644 index 00000000000..0950e9a4d1c --- /dev/null +++ b/its/ruling/src/test/expected/jsts/ant-design/javascript-S1082.json @@ -0,0 +1,45 @@ +{ +"ant-design:components/_util/__tests__/useSyncState.test.js": [ +11 +], +"ant-design:components/breadcrumb/__tests__/router.test.js": [ +56, +57 +], +"ant-design:components/calendar/__tests__/index.test.js": [ +421 +], +"ant-design:components/drawer/__tests__/DrawerEvent.test.js": [ +119 +], +"ant-design:components/locale-provider/__tests__/config.test.js": [ +31, +34 +], +"ant-design:components/space/__tests__/index.test.js": [ +123, +142 +], +"ant-design:components/table/__tests__/Table.filter.test.js": [ +184, +187, +190, +193, +2242, +2251 +], +"ant-design:components/upload/__tests__/uploadlist.test.js": [ +630, +1311, +1314, +1317 +], +"ant-design:site/theme/template/Content/Demo/index.jsx": [ +379, +396, +416, +436, +464, +474 +] +} diff --git a/its/ruling/src/test/expected/jsts/ant-design/typescript-S1082.json b/its/ruling/src/test/expected/jsts/ant-design/typescript-S1082.json new file mode 100644 index 00000000000..70559e6462b --- /dev/null +++ b/its/ruling/src/test/expected/jsts/ant-design/typescript-S1082.json @@ -0,0 +1,59 @@ +{ +"ant-design:components/alert/index.tsx": [ +177 +], +"ant-design:components/back-top/index.tsx": [ +127 +], +"ant-design:components/button/button.tsx": [ +284 +], +"ant-design:components/layout/Sider.tsx": [ +162, +182 +], +"ant-design:components/modal/__tests__/Modal.test.tsx": [ +80 +], +"ant-design:components/modal/__tests__/hook.test.tsx": [ +121, +156, +185 +], +"ant-design:components/table/hooks/useFilter/FilterDropdown.tsx": [ +466 +], +"ant-design:components/table/hooks/useFilter/FilterWrapper.tsx": [ +9 +], +"ant-design:components/tag/CheckableTag.tsx": [ +45 +], +"ant-design:components/tag/index.tsx": [ +99 +], +"ant-design:components/typography/Base/index.tsx": [ +371 +], +"ant-design:components/typography/__tests__/copy.test.tsx": [ +214 +], +"ant-design:components/upload/UploadList/ListItem.tsx": [ +189 +], +"ant-design:components/upload/__tests__/type.test.tsx": [ +166, +167, +168 +], +"ant-design:site/theme/template/Color/ColorPicker.tsx": [ +99, +105 +], +"ant-design:site/theme/template/Content/Article.tsx": [ +113 +], +"ant-design:site/theme/template/Layout/Header/SearchBar.tsx": [ +158 +] +} diff --git a/its/ruling/src/test/expected/jsts/console/typescript-S1082.json b/its/ruling/src/test/expected/jsts/console/typescript-S1082.json new file mode 100644 index 00000000000..472a8e7500e --- /dev/null +++ b/its/ruling/src/test/expected/jsts/console/typescript-S1082.json @@ -0,0 +1,483 @@ +{ +"console:src/components/Checkbox.tsx": [ +13 +], +"console:src/components/Datepicker/Datepicker.tsx": [ +80 +], +"console:src/components/Form/Checkbox.tsx": [ +82 +], +"console:src/components/Help/Alert.tsx": [ +27 +], +"console:src/components/Help/Help.tsx": [ +27 +], +"console:src/components/Links.tsx": [ +28 +], +"console:src/components/ModalDocs/ModalDocs.tsx": [ +117, +126 +], +"console:src/components/Popup.tsx": [ +40 +], +"console:src/components/PopupFooter.tsx": [ +92, +97, +103, +124, +146 +], +"console:src/components/PopupHeader.tsx": [ +90, +118 +], +"console:src/components/ProjectSelection/ProjectSelection.tsx": [ +185, +272 +], +"console:src/components/QueryHistory/QueryHistory.tsx": [ +55, +75 +], +"console:src/components/ResizableBox.tsx": [ +93 +], +"console:src/components/Tether/Tether.tsx": [ +141 +], +"console:src/components/ToggleButton/ToggleButton.tsx": [ +62, +70 +], +"console:src/components/Window/Alert.tsx": [ +103, +106 +], +"console:src/components/onboarding/OnboardingPopup/OnboardingPopup.tsx": [ +40, +46 +], +"console:src/views/ActionsView/ActionBoxes.tsx": [ +328 +], +"console:src/views/ActionsView/ActionHandlerBox.tsx": [ +30 +], +"console:src/views/ActionsView/ActionRow.tsx": [ +67, +100 +], +"console:src/views/ActionsView/ActionTriggerBox.tsx": [ +58 +], +"console:src/views/ActionsView/ActionsView.tsx": [ +57 +], +"console:src/views/AfterSignUpView/AfterSignUpView.tsx": [ +185 +], +"console:src/views/FunctionsView/FunctionLogs/Log.tsx": [ +28 +], +"console:src/views/FunctionsView/FunctionPopup/FunctionPopup.tsx": [ +307 +], +"console:src/views/FunctionsView/FunctionPopup/RequestPipeline.tsx": [ +66, +82, +107, +166 +], +"console:src/views/FunctionsView/FunctionPopup/TestPopup.tsx": [ +206, +236 +], +"console:src/views/FunctionsView/FunctionPopup/Toggle.tsx": [ +31 +], +"console:src/views/FunctionsView/FunctionPopup/WebhookEditor.tsx": [ +111, +117, +139 +], +"console:src/views/Integrations/Algolia/AlgoliaHeader.tsx": [ +45, +48 +], +"console:src/views/Integrations/Algolia/AlgoliaIndexes.tsx": [ +23 +], +"console:src/views/Integrations/Algolia/AlgoliaModal.tsx": [ +99, +157, +158 +], +"console:src/views/Integrations/Algolia/AlgoliaQueryEditor.tsx": [ +91, +93, +94 +], +"console:src/views/Integrations/Algolia/ConfirmOperationsPopup.tsx": [ +102, +110, +116 +], +"console:src/views/Integrations/Algolia/CreateAlgoliaIndex.tsx": [ +180 +], +"console:src/views/Integrations/AlgoliaPopup/AlgoliaIndexPopup/AlgoliaIndexPopupHeader.tsx": [ +37, +42, +47, +54 +], +"console:src/views/Integrations/AlgoliaPopup/AlgoliaIndexPopup/AlgoliaIndexPopupModels.tsx": [ +71 +], +"console:src/views/Integrations/AlgoliaPopup/AlgoliaPopupFooter.tsx": [ +26 +], +"console:src/views/Integrations/AlgoliaPopup/AlgoliaPopupHeader.tsx": [ +53 +], +"console:src/views/PermissionsView/PermissionPopup/AffectedFields.tsx": [ +73, +122, +123 +], +"console:src/views/PermissionsView/PermissionPopup/OldPermissionPopupFooter.tsx": [ +30, +35 +], +"console:src/views/PermissionsView/PermissionPopup/OperationChooser.tsx": [ +101 +], +"console:src/views/PermissionsView/PermissionPopup/PermissionConditions.tsx": [ +232, +366, +422 +], +"console:src/views/PermissionsView/PermissionPopup/PermissionPopupFooter.tsx": [ +90, +95, +101, +122, +143 +], +"console:src/views/PermissionsView/PermissionPopup/PermissionPopupHeader.tsx": [ +94, +122 +], +"console:src/views/PermissionsView/PermissionPopup/VariableTag.tsx": [ +16 +], +"console:src/views/PermissionsView/PermissionsList/ModelPermissions/PermissionField.tsx": [ +18 +], +"console:src/views/PermissionsView/RelationPermissionPopup/RelationPermissionPopupHeader.tsx": [ +90, +118 +], +"console:src/views/PermissionsView/RelationPermissionsList/RelationPermissions/RelationPermissionLabel.tsx": [ +45 +], +"console:src/views/ProjectRootView/AddProjectPopup.tsx": [ +201, +202 +], +"console:src/views/ProjectRootView/EndpointPopup.tsx": [ +183 +], +"console:src/views/ProjectRootView/OnboardSideNav.tsx": [ +33, +83, +111 +], +"console:src/views/ProjectRootView/Onboarding/ExampleChooser.tsx": [ +51 +], +"console:src/views/ProjectRootView/Onboarding/IntroPopup.tsx": [ +69 +], +"console:src/views/ProjectRootView/Onboarding/OnboardingFinale.tsx": [ +126 +], +"console:src/views/ProjectRootView/Onboarding/SelectExample.tsx": [ +120 +], +"console:src/views/ProjectRootView/RootRedirectView.tsx": [ +42 +], +"console:src/views/ProjectSettingsView/CreateRelationHeaderTab.tsx": [ +34 +], +"console:src/views/ProjectSettingsView/ProjectSettingsView.tsx": [ +68, +82, +112, +118, +124 +], +"console:src/views/RelationsPopup/CardinalitySelection.tsx": [ +35, +45, +56, +68 +], +"console:src/views/RelationsPopup/ConfirmPopup.tsx": [ +113, +159, +165, +171 +], +"console:src/views/RelationsPopup/FieldNameInput.tsx": [ +39, +124 +], +"console:src/views/RelationsPopup/HorizontalSelect.tsx": [ +34 +], +"console:src/views/RelationsPopup/RelationFooter.tsx": [ +76, +110, +123, +161, +170, +185 +], +"console:src/views/RelationsPopup/RelationHeader.tsx": [ +86 +], +"console:src/views/RelationsPopup/RelationInfo.tsx": [ +28 +], +"console:src/views/RelationsPopup/SetMutation.tsx": [ +88, +132, +150 +], +"console:src/views/SchemaView/EnumsOverview/AddEnum.tsx": [ +209, +212, +216, +240 +], +"console:src/views/SchemaView/EnumsOverview/ConfirmEnum.tsx": [ +123, +134, +171, +177, +183 +], +"console:src/views/SchemaView/EnumsOverview/EnumBox.tsx": [ +208 +], +"console:src/views/SchemaView/EnumsOverview/EnumEditor.tsx": [ +58, +72 +], +"console:src/views/SchemaView/EnumsOverview/EnumsOverviewHeader.tsx": [ +54 +], +"console:src/views/SchemaView/SchemaEditor.tsx": [ +241, +242, +250 +], +"console:src/views/SchemaView/SchemaOverview/AddType.tsx": [ +200, +241, +244, +248, +272 +], +"console:src/views/SchemaView/SchemaOverview/ConfirmModel.tsx": [ +123, +134, +171, +177, +183 +], +"console:src/views/SchemaView/SchemaOverview/SchemaOverviewHeader.tsx": [ +59 +], +"console:src/views/SchemaView/SchemaOverview/TypeBox.tsx": [ +198, +314 +], +"console:src/views/SchemaView/SchemaOverview/TypeBoxSettings.tsx": [ +46, +51 +], +"console:src/views/SchemaView/SchemaViewer.tsx": [ +81 +], +"console:src/views/Settings/Authentication/Tokens.tsx": [ +108 +], +"console:src/views/Settings/Billing/ChangePricingPlan.tsx": [ +36 +], +"console:src/views/Settings/Billing/ConfirmPricingPlan.tsx": [ +71 +], +"console:src/views/Settings/Billing/CreditCardFront.tsx": [ +55, +89, +99 +], +"console:src/views/Settings/Billing/CreditCardInputSection.tsx": [ +122, +272, +276, +304, +318 +], +"console:src/views/Settings/Billing/EditCreditCard.tsx": [ +82, +203, +217 +], +"console:src/views/Settings/Export/Export.tsx": [ +79, +94 +], +"console:src/views/Settings/General/DangerZone.tsx": [ +107, +130, +153 +], +"console:src/views/Settings/General/ProjectInfo.tsx": [ +123, +143, +157, +226, +248, +267 +], +"console:src/views/Settings/PricingColumn.tsx": [ +189 +], +"console:src/views/Settings/Team/EmptyRow.tsx": [ +113 +], +"console:src/views/Settings/Team/MemberRow.tsx": [ +98 +], +"console:src/views/Tooltip/Tooltip.tsx": [ +52 +], +"console:src/views/account/AccountView/SettingsTab.tsx": [ +61 +], +"console:src/views/models/AuthProviderPopup/AuthProviderPopup.tsx": [ +60, +71, +98, +124, +141 +], +"console:src/views/models/AuthProviderPopup/AuthProviderSidePanel.tsx": [ +173, +302, +313, +318 +], +"console:src/views/models/DatabrowserView/Cell.tsx": [ +104 +], +"console:src/views/models/DatabrowserView/Cell/NullableCell.tsx": [ +29 +], +"console:src/views/models/DatabrowserView/Cell/ScalarListCell.tsx": [ +212 +], +"console:src/views/models/DatabrowserView/Cell/SelectNodesCell/SelectNodesCellFooter.tsx": [ +43, +47, +49 +], +"console:src/views/models/DatabrowserView/Cell/SelectNodesCell/Tabs.tsx": [ +28 +], +"console:src/views/models/DatabrowserView/CheckboxCell.tsx": [ +20 +], +"console:src/views/models/DatabrowserView/DataActionRow/DeleteNodeRow.tsx": [ +47, +50 +], +"console:src/views/models/DatabrowserView/DatabrowserView.tsx": [ +295 +], +"console:src/views/models/DatabrowserView/HeaderCell.tsx": [ +59 +], +"console:src/views/models/DatabrowserView/LightCell.tsx": [ +24 +], +"console:src/views/models/DatabrowserView/NewRowInactive.tsx": [ +64 +], +"console:src/views/models/DatabrowserView/RelationsPopup.tsx": [ +112, +118, +124, +134, +156 +], +"console:src/views/models/FieldPopup/AdvancedSettings.tsx": [ +192 +], +"console:src/views/models/FieldPopup/BaseSettings.tsx": [ +165, +300 +], +"console:src/views/models/FieldPopup/ConfirmFieldPopup.tsx": [ +200, +250, +256, +262 +], +"console:src/views/models/FieldPopup/EditValueInput.tsx": [ +72, +89 +], +"console:src/views/models/FieldPopup/FieldHorizontalSelect.tsx": [ +130 +], +"console:src/views/models/FieldPopup/FieldLabel.tsx": [ +132, +145 +], +"console:src/views/models/FieldPopup/FieldPopupFooter.tsx": [ +122, +127, +141, +172, +230 +], +"console:src/views/models/FieldPopup/FieldPopupHeader.tsx": [ +62, +90 +], +"console:src/views/models/FieldPopup/HorizontalSelect.tsx": [ +40 +], +"console:src/views/models/FieldPopup/OptionInput.tsx": [ +12 +], +"console:src/views/models/ModelDescription.tsx": [ +56 +], +"console:src/views/playground/PlaygroundView/CodeGenerationPopup/CodeGenerationPopupClientChooser.tsx": [ +47 +], +"console:src/views/playground/PlaygroundView/CodeGenerationPopup/CodeGenerationPopupEnvironmentChooser.tsx": [ +45 +] +} diff --git a/its/ruling/src/test/expected/jsts/desktop/typescript-S1082.json b/its/ruling/src/test/expected/jsts/desktop/typescript-S1082.json new file mode 100644 index 00000000000..fd77ffd6879 --- /dev/null +++ b/its/ruling/src/test/expected/jsts/desktop/typescript-S1082.json @@ -0,0 +1,54 @@ +{ +"desktop:app/src/ui/banners/banner.tsx": [ +32 +], +"desktop:app/src/ui/branches/pull-request-badge.tsx": [ +81 +], +"desktop:app/src/ui/changes/commit-message-avatar.tsx": [ +74 +], +"desktop:app/src/ui/check-runs/ci-check-run-actions-job-step-item.tsx": [ +62 +], +"desktop:app/src/ui/check-runs/ci-check-run-list-item.tsx": [ +152, +191, +214 +], +"desktop:app/src/ui/dialog/header.tsx": [ +67 +], +"desktop:app/src/ui/diff/side-by-side-diff-row.tsx": [ +388, +429 +], +"desktop:app/src/ui/dropdown-select-button.tsx": [ +161 +], +"desktop:app/src/ui/history/commit-summary.tsx": [ +222 +], +"desktop:app/src/ui/lib/list/list-row.tsx": [ +96 +], +"desktop:app/src/ui/lib/vertical-segmented-control/segmented-item.tsx": [ +67 +], +"desktop:app/src/ui/lib/vertical-segmented-control/vertical-segmented-control.tsx": [ +197 +], +"desktop:app/src/ui/preferences/custom-theme-selector.tsx": [ +157 +], +"desktop:app/src/ui/thank-you/thank-you.tsx": [ +110 +], +"desktop:app/src/ui/toolbar/dropdown.tsx": [ +337 +], +"desktop:app/src/ui/tutorial/tutorial-step-instruction.tsx": [ +34, +35 +] +} diff --git a/its/ruling/src/test/expected/jsts/moose/typescript-S1082.json b/its/ruling/src/test/expected/jsts/moose/typescript-S1082.json new file mode 100644 index 00000000000..c31b75ec562 --- /dev/null +++ b/its/ruling/src/test/expected/jsts/moose/typescript-S1082.json @@ -0,0 +1,9 @@ +{ +"moose:renderer/components/Cast/Cast.tsx": [ +51 +], +"moose:renderer/components/Settings/Settings.tsx": [ +60, +78 +] +} diff --git a/its/ruling/src/test/expected/jsts/react-cloud-music/javascript-S1082.json b/its/ruling/src/test/expected/jsts/react-cloud-music/javascript-S1082.json new file mode 100644 index 00000000000..2e19f59feb7 --- /dev/null +++ b/its/ruling/src/test/expected/jsts/react-cloud-music/javascript-S1082.json @@ -0,0 +1,69 @@ +{ +"react-cloud-music:src/application/Home/index.jsx": [ +17, +19 +], +"react-cloud-music:src/application/Player/mini-player/index.jsx": [ +47, +49, +53 +], +"react-cloud-music:src/application/Player/normal-player/index.jsx": [ +180, +276, +282, +286, +294, +297 +], +"react-cloud-music:src/application/Player/play-list/index.jsx": [ +155, +156, +201, +212, +225, +231 +], +"react-cloud-music:src/application/Search/index.jsx": [ +54, +152 +], +"react-cloud-music:src/application/SongList/index.jsx": [ +41, +69 +], +"react-cloud-music:src/application/User/Login/LoginForm/index.jsx": [ +40, +41, +46, +51, +56 +], +"react-cloud-music:src/application/User/Login/PhoneForm/index.jsx": [ +42 +], +"react-cloud-music:src/application/User/Login/PhoneForm/step-one/index.jsx": [ +22 +], +"react-cloud-music:src/application/User/Login/PhoneForm/step-two/index.jsx": [ +57 +], +"react-cloud-music:src/baseUI/confirm/index.jsx": [ +97, +98 +], +"react-cloud-music:src/baseUI/header/index.jsx": [ +32 +], +"react-cloud-music:src/baseUI/progress-bar/index.jsx": [ +104 +], +"react-cloud-music:src/baseUI/search-box/index.jsx": [ +84, +86 +], +"react-cloud-music:src/layouts/HomeLayout.jsx": [ +13, +20 +] +} diff --git a/its/ruling/src/test/expected/jsts/react-cloud-music/typescript-S1082.json b/its/ruling/src/test/expected/jsts/react-cloud-music/typescript-S1082.json new file mode 100644 index 00000000000..5fbe17230fa --- /dev/null +++ b/its/ruling/src/test/expected/jsts/react-cloud-music/typescript-S1082.json @@ -0,0 +1,6 @@ +{ +"react-cloud-music:ts-music/src/layouts/HomeLayout/index.tsx": [ +13, +20 +] +} diff --git a/its/ruling/src/test/expected/jsts/redux/javascript-S1082.json b/its/ruling/src/test/expected/jsts/redux/javascript-S1082.json new file mode 100644 index 00000000000..7203b0c0968 --- /dev/null +++ b/its/ruling/src/test/expected/jsts/redux/javascript-S1082.json @@ -0,0 +1,8 @@ +{ +"redux:examples/todomvc/components/Footer.js": [ +28 +], +"redux:examples/todos-with-undo/components/Todo.js": [ +6 +] +} diff --git a/packages/jsts/src/rules/S1082/cb.test.ts b/packages/jsts/src/rules/S1082/cb.test.ts new file mode 100644 index 00000000000..e6f8f7cbf08 --- /dev/null +++ b/packages/jsts/src/rules/S1082/cb.test.ts @@ -0,0 +1,28 @@ +/* + * SonarQube JavaScript Plugin + * Copyright (C) 2011-2023 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +import { check } from '../tools'; +import { rule } from '.'; +import path from 'path'; + +const sonarId = path.basename(__dirname); + +describe(`Rule ${sonarId}`, () => { + check(sonarId, rule, __dirname); +}); diff --git a/packages/jsts/src/rules/S1082/clickevents.fixture.jsx b/packages/jsts/src/rules/S1082/clickevents.fixture.jsx new file mode 100644 index 00000000000..0fd14d99d4a --- /dev/null +++ b/packages/jsts/src/rules/S1082/clickevents.fixture.jsx @@ -0,0 +1,8 @@ +