From: Wouter Admiraal Date: Mon, 25 Mar 2019 10:29:23 +0000 (+0100) Subject: Introduce new T.Dict type constructor X-Git-Tag: 7.8~491 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=10cb25f0f8634d392a029a54f23ebb5e48b96e36;p=sonarqube.git Introduce new T.Dict type constructor --- diff --git a/server/sonar-web/src/main/js/api/quality-profiles.ts b/server/sonar-web/src/main/js/api/quality-profiles.ts index 2002c06c65a..a7c6b3f1f2a 100644 --- a/server/sonar-web/src/main/js/api/quality-profiles.ts +++ b/server/sonar-web/src/main/js/api/quality-profiles.ts @@ -169,8 +169,8 @@ export interface CompareResponse { modified: Array<{ key: string; name: string; - left: { params: { [p: string]: string }; severity: string }; - right: { params: { [p: string]: string }; severity: string }; + left: { params: T.Dict; severity: string }; + right: { params: T.Dict; severity: string }; }>; } @@ -284,7 +284,7 @@ export function bulkDeactivateRules(data: BulkActivateParameters) { export function activateRule(data: { key: string; organization: string | undefined; - params?: { [key: string]: string }; + params?: T.Dict; reset?: boolean; rule: string; severity?: string; diff --git a/server/sonar-web/src/main/js/api/rules.ts b/server/sonar-web/src/main/js/api/rules.ts index 8ea8821b574..60b45746e32 100644 --- a/server/sonar-web/src/main/js/api/rules.ts +++ b/server/sonar-web/src/main/js/api/rules.ts @@ -32,7 +32,7 @@ export function getRulesApp(data: { } export interface SearchRulesResponse { - actives?: { [rule: string]: T.RuleActivation[] }; + actives?: T.Dict; facets?: { property: string; values: { count: number; val: string }[] }[]; p: number; ps: number; diff --git a/server/sonar-web/src/main/js/app/components/embed-docs-modal/SuggestionsProvider.tsx b/server/sonar-web/src/main/js/app/components/embed-docs-modal/SuggestionsProvider.tsx index 61610c62902..4e119d95eac 100644 --- a/server/sonar-web/src/main/js/app/components/embed-docs-modal/SuggestionsProvider.tsx +++ b/server/sonar-web/src/main/js/app/components/embed-docs-modal/SuggestionsProvider.tsx @@ -22,9 +22,7 @@ import suggestionsJson from 'Docs/EmbedDocsSuggestions.json'; import { SuggestionsContext } from './SuggestionsContext'; import { isSonarCloud } from '../../../helpers/system'; -interface SuggestionsJson { - [key: string]: T.SuggestionLink[]; -} +type SuggestionsJson = T.Dict; interface State { suggestions: T.SuggestionLink[]; diff --git a/server/sonar-web/src/main/js/app/components/search/Search.tsx b/server/sonar-web/src/main/js/app/components/search/Search.tsx index 8fa9aa71747..9d358998335 100644 --- a/server/sonar-web/src/main/js/app/components/search/Search.tsx +++ b/server/sonar-web/src/main/js/app/components/search/Search.tsx @@ -51,8 +51,8 @@ interface State { loadingMore?: string; more: More; open: boolean; - organizations: { [key: string]: { name: string } }; - projects: { [key: string]: { name: string } }; + organizations: T.Dict<{ name: string }>; + projects: T.Dict<{ name: string }>; query: string; results: Results; selected?: string; @@ -62,7 +62,7 @@ interface State { export class Search extends React.PureComponent { input?: HTMLInputElement | null; node?: HTMLElement | null; - nodes: { [x: string]: HTMLElement }; + nodes: T.Dict; mounted = false; constructor(props: Props) { diff --git a/server/sonar-web/src/main/js/app/components/search/SearchResult.tsx b/server/sonar-web/src/main/js/app/components/search/SearchResult.tsx index b68ebdceeb4..5ffab5ec6a4 100644 --- a/server/sonar-web/src/main/js/app/components/search/SearchResult.tsx +++ b/server/sonar-web/src/main/js/app/components/search/SearchResult.tsx @@ -32,8 +32,8 @@ interface Props { innerRef: (componentKey: string, node: HTMLElement | null) => void; onClose: () => void; onSelect: (componentKey: string) => void; - organizations: { [key: string]: { name: string } }; - projects: { [key: string]: { name: string } }; + organizations: T.Dict<{ name: string }>; + projects: T.Dict<{ name: string }>; selected: boolean; } diff --git a/server/sonar-web/src/main/js/app/types.d.ts b/server/sonar-web/src/main/js/app/types.d.ts index 24d81014308..16d74f126c0 100644 --- a/server/sonar-web/src/main/js/app/types.d.ts +++ b/server/sonar-web/src/main/js/app/types.d.ts @@ -18,6 +18,8 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ declare namespace T { + export type Dict = { [key: string]: T }; + export type Omit = Pick>; // Type ordered alphabetically to prevent merge conflicts @@ -97,7 +99,7 @@ declare namespace T { organizationsEnabled?: boolean; productionDatabase: boolean; qualifiers: string[]; - settings: { [key: string]: string }; + settings: T.Dict; standalone?: boolean; version: string; } @@ -400,9 +402,7 @@ declare namespace T { name: string; } - export interface Languages { - [key: string]: Language; - } + export type Languages = T.Dict; export interface LightComponent { key: string; @@ -773,10 +773,10 @@ declare namespace T { } export interface SettingValue { - fieldValues?: Array<{ [key: string]: string }>; + fieldValues?: Array>; inherited?: boolean; key: string; - parentFieldValues?: Array<{ [key: string]: string }>; + parentFieldValues?: Array>; parentValue?: string; parentValues?: string[]; value?: string; diff --git a/server/sonar-web/src/main/js/app/utils/installExtensionsHandler.ts b/server/sonar-web/src/main/js/app/utils/installExtensionsHandler.ts index 21fb3d0c52b..adf94c2d84a 100644 --- a/server/sonar-web/src/main/js/app/utils/installExtensionsHandler.ts +++ b/server/sonar-web/src/main/js/app/utils/installExtensionsHandler.ts @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -const extensions: { [key: string]: Function } = {}; +const extensions: T.Dict = {}; const registerExtension = (key: string, start: Function) => { extensions[key] = start; diff --git a/server/sonar-web/src/main/js/apps/about/components/AboutApp.tsx b/server/sonar-web/src/main/js/apps/about/components/AboutApp.tsx index 4e93eb52bac..7c35f893d3a 100644 --- a/server/sonar-web/src/main/js/apps/about/components/AboutApp.tsx +++ b/server/sonar-web/src/main/js/apps/about/components/AboutApp.tsx @@ -55,7 +55,7 @@ interface Props { } interface State { - issueTypes?: { [key: string]: { count: number } }; + issueTypes?: T.Dict<{ count: number }>; loading: boolean; projectsCount: number; } diff --git a/server/sonar-web/src/main/js/apps/account/notifications/Projects.tsx b/server/sonar-web/src/main/js/apps/account/notifications/Projects.tsx index 56683108cfe..5c116e15665 100644 --- a/server/sonar-web/src/main/js/apps/account/notifications/Projects.tsx +++ b/server/sonar-web/src/main/js/apps/account/notifications/Projects.tsx @@ -29,7 +29,7 @@ import { translate } from '../../../helpers/l10n'; export interface Props { addNotification: (n: T.Notification) => void; channels: string[]; - notificationsByProject: { [project: string]: T.Notification[] }; + notificationsByProject: T.Dict; projects: NotificationProject[]; removeNotification: (n: T.Notification) => void; types: string[]; diff --git a/server/sonar-web/src/main/js/apps/code/bucket.ts b/server/sonar-web/src/main/js/apps/code/bucket.ts index a005027ac35..aba36f31d4a 100644 --- a/server/sonar-web/src/main/js/apps/code/bucket.ts +++ b/server/sonar-web/src/main/js/apps/code/bucket.ts @@ -17,15 +17,13 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -let bucket: { [key: string]: T.ComponentMeasure } = {}; -let childrenBucket: { - [key: string]: { - children: T.ComponentMeasure[]; - page: number; - total: number; - }; -} = {}; -let breadcrumbsBucket: { [key: string]: T.Breadcrumb[] } = {}; +let bucket: T.Dict = {}; +let childrenBucket: T.Dict<{ + children: T.ComponentMeasure[]; + page: number; + total: number; +}> = {}; +let breadcrumbsBucket: T.Dict = {}; export function addComponent(component: T.ComponentMeasure): void { bucket[component.key] = component; diff --git a/server/sonar-web/src/main/js/apps/code/components/App.tsx b/server/sonar-web/src/main/js/apps/code/components/App.tsx index 10b3fc08349..1c030f377a2 100644 --- a/server/sonar-web/src/main/js/apps/code/components/App.tsx +++ b/server/sonar-web/src/main/js/apps/code/components/App.tsx @@ -40,7 +40,7 @@ import { getProjectUrl, getCodeUrl } from '../../../helpers/urls'; import '../code.css'; interface StateToProps { - metrics: { [metric: string]: T.Metric }; + metrics: T.Dict; } interface DispatchToProps { diff --git a/server/sonar-web/src/main/js/apps/code/components/Components.tsx b/server/sonar-web/src/main/js/apps/code/components/Components.tsx index 7fd2c4f50c3..b83e015aae5 100644 --- a/server/sonar-web/src/main/js/apps/code/components/Components.tsx +++ b/server/sonar-web/src/main/js/apps/code/components/Components.tsx @@ -29,7 +29,7 @@ interface Props { baseComponent?: T.ComponentMeasure; branchLike?: T.BranchLike; components: T.ComponentMeasure[]; - metrics: { [metric: string]: T.Metric }; + metrics: T.Dict; rootComponent: T.ComponentMeasure; selected?: T.ComponentMeasure; } diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/ActivationFormModal.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/ActivationFormModal.tsx index 50b5cce4633..d5264e69c5d 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/ActivationFormModal.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/ActivationFormModal.tsx @@ -39,7 +39,7 @@ interface Props { } interface State { - params: { [p: string]: string }; + params: T.Dict; profile: string; severity: string; submitting: boolean; @@ -68,7 +68,7 @@ export default class ActivationFormModal extends React.PureComponent { - const params: { [p: string]: string } = {}; + const params: T.Dict = {}; if (rule && rule.params) { for (const param of rule.params) { params[param.key] = param.defaultValue || ''; diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/App.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/App.tsx index 36230f89c60..0ae3109d4a0 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/App.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/App.tsx @@ -96,8 +96,8 @@ interface State { openRule?: T.Rule; paging?: T.Paging; query: Query; - referencedProfiles: { [profile: string]: Profile }; - referencedRepositories: { [repository: string]: { key: string; language: string; name: string } }; + referencedProfiles: T.Dict; + referencedRepositories: T.Dict<{ key: string; language: string; name: string }>; rules: T.Rule[]; selected?: string; } @@ -615,7 +615,7 @@ export class App extends React.PureComponent { } } -function parseActives(rawActives: { [rule: string]: T.RuleActivation[] }) { +function parseActives(rawActives: T.Dict) { const actives: Actives = {}; for (const [rule, activations] of Object.entries(rawActives)) { actives[rule] = {}; @@ -629,7 +629,7 @@ function parseActives(rawActives: { [rule: string]: T.RuleActivation[] }) { function parseFacets(rawFacets: { property: string; values: { count: number; val: string }[] }[]) { const facets: Facets = {}; for (const rawFacet of rawFacets) { - const values: { [value: string]: number } = {}; + const values: T.Dict = {}; for (const rawValue of rawFacet.values) { values[rawValue.val] = rawValue.count; } diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/BulkChange.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/BulkChange.tsx index ca6a67e2345..508c9bfc621 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/BulkChange.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/BulkChange.tsx @@ -29,7 +29,7 @@ interface Props { languages: T.Languages; organization: string | undefined; query: Query; - referencedProfiles: { [profile: string]: Profile }; + referencedProfiles: T.Dict; total: number; } diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/BulkChangeModal.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/BulkChangeModal.tsx index b6bf6c9d4ec..a7df07d3130 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/BulkChangeModal.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/BulkChangeModal.tsx @@ -34,7 +34,7 @@ interface Props { organization: string | undefined; profile?: Profile; query: Query; - referencedProfiles: { [profile: string]: Profile }; + referencedProfiles: T.Dict; total: number; } diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/CustomRuleFormModal.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/CustomRuleFormModal.tsx index c97036fd75a..0ce7a3cab59 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/CustomRuleFormModal.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/CustomRuleFormModal.tsx @@ -44,7 +44,7 @@ interface State { key: string; keyModifiedByUser: boolean; name: string; - params: { [p: string]: string }; + params: T.Dict; reactivating: boolean; severity: string; status: string; @@ -57,7 +57,7 @@ export default class CustomRuleFormModal extends React.PureComponent = {}; if (props.customRule && props.customRule.params) { for (const param of props.customRule.params) { params[param.key] = param.defaultValue || ''; diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/Facet.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/Facet.tsx index fb0386b422d..a39e77d2398 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/Facet.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/Facet.tsx @@ -30,10 +30,10 @@ import { translate } from '../../../helpers/l10n'; import { formatMeasure } from '../../../helpers/measures'; export interface BasicProps { - onChange: (changes: { [x: string]: string | string[] | undefined }) => void; + onChange: (changes: T.Dict) => void; onToggle: (facet: FacetKey) => void; open: boolean; - stats?: { [x: string]: number }; + stats?: T.Dict; values: string[]; } diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/FacetsList.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/FacetsList.tsx index 7d92e5133bc..b934ab4a1f7 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/FacetsList.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/FacetsList.tsx @@ -41,8 +41,8 @@ interface Props { organization: string | undefined; organizationsEnabled?: boolean; query: Query; - referencedProfiles: { [profile: string]: Profile }; - referencedRepositories: { [repository: string]: { key: string; language: string; name: string } }; + referencedProfiles: T.Dict; + referencedRepositories: T.Dict<{ key: string; language: string; name: string }>; selectedProfile?: Profile; } diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/ProfileFacet.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/ProfileFacet.tsx index afc1f06cfbc..2e15cea1b9c 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/ProfileFacet.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/ProfileFacet.tsx @@ -36,7 +36,7 @@ interface Props { onChange: (changes: Partial) => void; onToggle: (facet: FacetKey) => void; open: boolean; - referencedProfiles: { [profile: string]: Profile }; + referencedProfiles: T.Dict; value: string | undefined; } diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/RepositoryFacet.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/RepositoryFacet.tsx index 5a51cedf82c..e3f82deade2 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/RepositoryFacet.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/RepositoryFacet.tsx @@ -23,11 +23,11 @@ import Facet, { BasicProps } from './Facet'; import { getLanguages, Store } from '../../../store/rootReducer'; interface StateProps { - referencedLanguages: { [language: string]: { key: string; name: string } }; + referencedLanguages: T.Dict<{ key: string; name: string }>; } interface Props extends BasicProps, StateProps { - referencedRepositories: { [repository: string]: { key: string; language: string; name: string } }; + referencedRepositories: T.Dict<{ key: string; language: string; name: string }>; } class RepositoryFacet extends React.PureComponent { diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetails.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetails.tsx index 276be9e6f2c..b56478416fe 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetails.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetails.tsx @@ -43,8 +43,8 @@ interface Props { onDelete: (rule: string) => void; onFilterChange: (changes: Partial) => void; organization: string | undefined; - referencedProfiles: { [profile: string]: Profile }; - referencedRepositories: { [repository: string]: { key: string; language: string; name: string } }; + referencedProfiles: T.Dict; + referencedRepositories: T.Dict<{ key: string; language: string; name: string }>; ruleKey: string; selectedProfile?: Profile; } diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsMeta.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsMeta.tsx index 78ef447f8b7..4e9b534f34c 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsMeta.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsMeta.tsx @@ -42,7 +42,7 @@ interface Props { onFilterChange: (changes: Partial) => void; onTagsChange: (tags: string[]) => void; organization: string | undefined; - referencedRepositories: { [repository: string]: { key: string; language: string; name: string } }; + referencedRepositories: T.Dict<{ key: string; language: string; name: string }>; ruleDetails: T.RuleDetails; } diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsProfiles.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsProfiles.tsx index 29f4de18cba..f112a6edd95 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsProfiles.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsProfiles.tsx @@ -38,7 +38,7 @@ interface Props { onActivate: () => Promise; onDeactivate: () => Promise; organization: string | undefined; - referencedProfiles: { [profile: string]: Profile }; + referencedProfiles: T.Dict; ruleDetails: T.RuleDetails; } diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/App.tsx b/server/sonar-web/src/main/js/apps/component-measures/components/App.tsx index 0603e1a269b..c55fae9ab8c 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/components/App.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/components/App.tsx @@ -74,7 +74,7 @@ interface State { leakPeriod?: T.Period; loading: boolean; measures: T.MeasureEnhanced[]; - metrics: { [metric: string]: T.Metric }; + metrics: T.Dict; } export class App extends React.PureComponent { diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/MeasureContent.tsx b/server/sonar-web/src/main/js/apps/component-measures/components/MeasureContent.tsx index 80920d1895e..e47aaf7ac34 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/components/MeasureContent.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/components/MeasureContent.tsx @@ -42,7 +42,7 @@ interface Props { branchLike?: T.BranchLike; leakPeriod?: T.Period; requestedMetric: Pick; - metrics: { [metric: string]: T.Metric }; + metrics: T.Dict; rootComponent: T.ComponentMeasure; router: InjectedRouter; selected?: string; diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/MeasureOverview.tsx b/server/sonar-web/src/main/js/apps/component-measures/components/MeasureOverview.tsx index 3cd2bbd362c..d8b3a9c5075 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/components/MeasureOverview.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/components/MeasureOverview.tsx @@ -37,9 +37,9 @@ interface Props { domain: string; leakPeriod?: T.Period; loading: boolean; - metrics: { [metric: string]: T.Metric }; + metrics: T.Dict; rootComponent: T.ComponentMeasure; - updateLoading: (param: { [key: string]: boolean }) => void; + updateLoading: (param: T.Dict) => void; updateSelected: (component: string) => void; } diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/MeasureOverviewContainer.tsx b/server/sonar-web/src/main/js/apps/component-measures/components/MeasureOverviewContainer.tsx index af26325e68a..4808cc21741 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/components/MeasureOverviewContainer.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/components/MeasureOverviewContainer.tsx @@ -30,7 +30,7 @@ interface Props { className?: string; domain: string; leakPeriod?: T.Period; - metrics: { [metric: string]: T.Metric }; + metrics: T.Dict; rootComponent: T.ComponentMeasure; router: InjectedRouter; selected?: string; diff --git a/server/sonar-web/src/main/js/apps/component-measures/config/complementary.ts b/server/sonar-web/src/main/js/apps/component-measures/config/complementary.ts index 349638f97eb..3f1795e0b9f 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/config/complementary.ts +++ b/server/sonar-web/src/main/js/apps/component-measures/config/complementary.ts @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -export const complementary: { [metric: string]: string[] } = { +export const complementary: T.Dict = { coverage: ['uncovered_lines', 'uncovered_conditions'], line_coverage: ['uncovered_lines'], branch_coverage: ['uncovered_conditions'], diff --git a/server/sonar-web/src/main/js/apps/component-measures/drilldown/BubbleChart.tsx b/server/sonar-web/src/main/js/apps/component-measures/drilldown/BubbleChart.tsx index 83cd304c288..16ff032dbb4 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/drilldown/BubbleChart.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/drilldown/BubbleChart.tsx @@ -39,7 +39,7 @@ interface Props { component: T.ComponentMeasure; components: T.ComponentMeasureEnhanced[]; domain: string; - metrics: { [metric: string]: T.Metric }; + metrics: T.Dict; updateSelected: (component: string) => void; } diff --git a/server/sonar-web/src/main/js/apps/component-measures/drilldown/ComponentsList.tsx b/server/sonar-web/src/main/js/apps/component-measures/drilldown/ComponentsList.tsx index 21777417bec..877ea41f70e 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/drilldown/ComponentsList.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/drilldown/ComponentsList.tsx @@ -29,7 +29,7 @@ interface Props { components: T.ComponentMeasureEnhanced[]; onClick: (component: string) => void; metric: T.Metric; - metrics: { [metric: string]: T.Metric }; + metrics: T.Dict; rootComponent: T.ComponentMeasure; selectedComponent?: string; view: View; diff --git a/server/sonar-web/src/main/js/apps/component-measures/drilldown/FilesView.tsx b/server/sonar-web/src/main/js/apps/component-measures/drilldown/FilesView.tsx index 3a2f52bd98f..52fc3caa4b1 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/drilldown/FilesView.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/drilldown/FilesView.tsx @@ -38,7 +38,7 @@ interface Props { handleOpen: (component: string) => void; loadingMore: boolean; metric: T.Metric; - metrics: { [metric: string]: T.Metric }; + metrics: T.Dict; paging?: T.Paging; rootComponent: T.ComponentMeasure; selectedKey?: string; diff --git a/server/sonar-web/src/main/js/apps/component-measures/sidebar/Sidebar.tsx b/server/sonar-web/src/main/js/apps/component-measures/sidebar/Sidebar.tsx index ef78ac7809e..f72dd25d0b5 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/sidebar/Sidebar.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/sidebar/Sidebar.tsx @@ -32,7 +32,7 @@ interface Props { } interface State { - openFacets: { [metric: string]: boolean }; + openFacets: T.Dict; } export default class Sidebar extends React.PureComponent { @@ -84,10 +84,7 @@ export default class Sidebar extends React.PureComponent { } } -function getOpenFacets( - openFacets: { [metric: string]: boolean }, - { measures, selectedMetric }: Props -) { +function getOpenFacets(openFacets: T.Dict, { measures, selectedMetric }: Props) { const newOpenFacets = { ...openFacets }; const measure = measures.find(measure => measure.metric.key === selectedMetric); if (measure && measure.metric && measure.metric.domain) { diff --git a/server/sonar-web/src/main/js/apps/component-measures/utils.ts b/server/sonar-web/src/main/js/apps/component-measures/utils.ts index b28a82613cc..8efbde6ded0 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/utils.ts +++ b/server/sonar-web/src/main/js/apps/component-measures/utils.ts @@ -93,7 +93,7 @@ export function addMeasureCategories(domainName: string, measures: T.MeasureEnha export function enhanceComponent( component: T.ComponentMeasure, metric: Pick | undefined, - metrics: { [key: string]: T.Metric } + metrics: T.Dict ): T.ComponentMeasureEnhanced { if (!component.measures) { return { ...component, measures: [] }; @@ -153,10 +153,7 @@ export function hasFullMeasures(branch?: T.BranchLike) { return !branch || isLongLivingBranch(branch) || isMainBranch(branch); } -export function getMeasuresPageMetricKeys( - metrics: { [key: string]: T.Metric }, - branch?: T.BranchLike -) { +export function getMeasuresPageMetricKeys(metrics: T.Dict, branch?: T.BranchLike) { const metricKeys = getDisplayMetrics(Object.values(metrics)).map(metric => metric.key); if (isPullRequest(branch) || isShortLivingBranch(branch)) { @@ -166,7 +163,7 @@ export function getMeasuresPageMetricKeys( } } -export function getBubbleMetrics(domain: string, metrics: { [key: string]: T.Metric }) { +export function getBubbleMetrics(domain: string, metrics: T.Dict) { const conf = bubbles[domain]; return { x: metrics[conf.x], diff --git a/server/sonar-web/src/main/js/apps/create/project/RemoteRepositories.tsx b/server/sonar-web/src/main/js/apps/create/project/RemoteRepositories.tsx index a94edf14f99..6451e98e024 100644 --- a/server/sonar-web/src/main/js/apps/create/project/RemoteRepositories.tsx +++ b/server/sonar-web/src/main/js/apps/create/project/RemoteRepositories.tsx @@ -36,7 +36,7 @@ interface Props { organization: T.Organization; } -type SelectedRepositories = { [key: string]: T.AlmRepository | undefined }; +type SelectedRepositories = T.Dict; interface State { highlight: boolean; diff --git a/server/sonar-web/src/main/js/apps/documentation/components/SearchResultEntry.tsx b/server/sonar-web/src/main/js/apps/documentation/components/SearchResultEntry.tsx index 57083fa5021..613616375b1 100644 --- a/server/sonar-web/src/main/js/apps/documentation/components/SearchResultEntry.tsx +++ b/server/sonar-web/src/main/js/apps/documentation/components/SearchResultEntry.tsx @@ -24,7 +24,7 @@ import { highlightMarks, cutWords, DocumentationEntry } from '../utils'; export interface SearchResult { exactMatch?: boolean; - highlights: { [field: string]: [number, number][] }; + highlights: T.Dict<[number, number][]>; longestTerm: string; page: DocumentationEntry; query: string; diff --git a/server/sonar-web/src/main/js/apps/documentation/components/SearchResults.tsx b/server/sonar-web/src/main/js/apps/documentation/components/SearchResults.tsx index fc70715270b..e2db1c0bf6b 100644 --- a/server/sonar-web/src/main/js/apps/documentation/components/SearchResults.tsx +++ b/server/sonar-web/src/main/js/apps/documentation/components/SearchResults.tsx @@ -60,7 +60,7 @@ export default class SearchResults extends React.PureComponent { ) .map(match => { const page = this.props.pages.find(page => page.relativeName === match.ref); - const highlights: { [field: string]: [number, number][] } = {}; + const highlights: T.Dict<[number, number][]> = {}; let longestTerm = ''; let exactMatch = false; diff --git a/server/sonar-web/src/main/js/apps/issues/components/App.tsx b/server/sonar-web/src/main/js/apps/issues/components/App.tsx index 632211d2af7..8e079deebbe 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/App.tsx +++ b/server/sonar-web/src/main/js/apps/issues/components/App.tsx @@ -115,23 +115,23 @@ export interface State { checkAll?: boolean; checked: string[]; effortTotal?: number; - facets: { [facet: string]: Facet }; + facets: T.Dict; issues: T.Issue[]; loading: boolean; - loadingFacets: { [key: string]: boolean }; + loadingFacets: T.Dict; loadingMore: boolean; locationsNavigator: boolean; myIssues: boolean; - openFacets: { [facet: string]: boolean }; + openFacets: T.Dict; openIssue?: T.Issue; openPopup?: { issue: string; name: string }; paging?: T.Paging; query: Query; - referencedComponentsById: { [id: string]: ReferencedComponent }; - referencedComponentsByKey: { [key: string]: ReferencedComponent }; - referencedLanguages: { [languageKey: string]: ReferencedLanguage }; - referencedRules: { [ruleKey: string]: ReferencedRule }; - referencedUsers: { [login: string]: ReferencedUser }; + referencedComponentsById: T.Dict; + referencedComponentsByKey: T.Dict; + referencedLanguages: T.Dict; + referencedRules: T.Dict; + referencedUsers: T.Dict; selected?: string; selectedFlowIndex?: number; selectedLocationIndex?: number; diff --git a/server/sonar-web/src/main/js/apps/issues/components/BulkChangeModal.tsx b/server/sonar-web/src/main/js/apps/issues/components/BulkChangeModal.tsx index 5082742f980..744a1552a6c 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/BulkChangeModal.tsx +++ b/server/sonar-web/src/main/js/apps/issues/components/BulkChangeModal.tsx @@ -239,7 +239,7 @@ export default class BulkChangeModal extends React.PureComponent { }; getAvailableTransitions(issues: T.Issue[]) { - const transitions: { [x: string]: number } = {}; + const transitions: T.Dict = {}; issues.forEach(issue => { if (issue.transitions) { issue.transitions.forEach(t => { diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/AssigneeFacet.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/AssigneeFacet.tsx index add1d6e1cc8..ba19f5264f8 100644 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/AssigneeFacet.tsx +++ b/server/sonar-web/src/main/js/apps/issues/sidebar/AssigneeFacet.tsx @@ -35,8 +35,8 @@ export interface Props { open: boolean; organization: string | undefined; query: Query; - stats: { [x: string]: number } | undefined; - referencedUsers: { [login: string]: ReferencedUser }; + stats: T.Dict | undefined; + referencedUsers: T.Dict; } export default class AssigneeFacet extends React.PureComponent { diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/AuthorFacet.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/AuthorFacet.tsx index c1576a95fb0..02e0da6331d 100644 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/AuthorFacet.tsx +++ b/server/sonar-web/src/main/js/apps/issues/sidebar/AuthorFacet.tsx @@ -34,7 +34,7 @@ interface Props { open: boolean; organization: string | undefined; query: Query; - stats: { [x: string]: number } | undefined; + stats: T.Dict | undefined; authors: string[]; } diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/CreationDateFacet.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/CreationDateFacet.tsx index 256fafa9afc..ba6b59c2df9 100644 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/CreationDateFacet.tsx +++ b/server/sonar-web/src/main/js/apps/issues/sidebar/CreationDateFacet.tsx @@ -45,7 +45,7 @@ interface Props { onToggle: (property: string) => void; open: boolean; sinceLeakPeriod: boolean; - stats: { [x: string]: number } | undefined; + stats: T.Dict | undefined; } class CreationDateFacet extends React.PureComponent { diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/DirectoryFacet.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/DirectoryFacet.tsx index c210ec54e6e..c605a2bf106 100644 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/DirectoryFacet.tsx +++ b/server/sonar-web/src/main/js/apps/issues/sidebar/DirectoryFacet.tsx @@ -36,7 +36,7 @@ interface Props { onToggle: (property: string) => void; open: boolean; query: Query; - stats: { [x: string]: number } | undefined; + stats: T.Dict | undefined; } export default class DirectoryFacet extends React.PureComponent { diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/FileFacet.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/FileFacet.tsx index b36e6ac47b4..92b10e4399d 100644 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/FileFacet.tsx +++ b/server/sonar-web/src/main/js/apps/issues/sidebar/FileFacet.tsx @@ -36,8 +36,8 @@ interface Props { onToggle: (property: string) => void; open: boolean; query: Query; - referencedComponents: { [componentKey: string]: ReferencedComponent }; - stats: { [x: string]: number } | undefined; + referencedComponents: T.Dict; + stats: T.Dict | undefined; } export default class FileFacet extends React.PureComponent { diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/LanguageFacet.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/LanguageFacet.tsx index 0b77a39c980..1fc34ff91be 100644 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/LanguageFacet.tsx +++ b/server/sonar-web/src/main/js/apps/issues/sidebar/LanguageFacet.tsx @@ -40,8 +40,8 @@ interface Props { onToggle: (property: string) => void; open: boolean; query: Query; - referencedLanguages: { [languageKey: string]: ReferencedLanguage }; - stats: { [x: string]: number } | undefined; + referencedLanguages: T.Dict; + stats: T.Dict | undefined; } class LanguageFacet extends React.PureComponent { diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/ProjectFacet.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/ProjectFacet.tsx index f9bb06a221d..5b314670034 100644 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/ProjectFacet.tsx +++ b/server/sonar-web/src/main/js/apps/issues/sidebar/ProjectFacet.tsx @@ -37,8 +37,8 @@ interface Props { organization: { key: string } | undefined; projects: string[]; query: Query; - referencedComponents: { [componentKey: string]: ReferencedComponent }; - stats: { [x: string]: number } | undefined; + referencedComponents: T.Dict; + stats: T.Dict | undefined; } interface SearchedProject { diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/ResolutionFacet.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/ResolutionFacet.tsx index 6dadfe235b3..5e069b27e14 100644 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/ResolutionFacet.tsx +++ b/server/sonar-web/src/main/js/apps/issues/sidebar/ResolutionFacet.tsx @@ -35,7 +35,7 @@ interface Props { open: boolean; resolved: boolean; resolutions: string[]; - stats: { [x: string]: number } | undefined; + stats: T.Dict | undefined; } const RESOLUTIONS = ['', 'FIXED', 'FALSE-POSITIVE', 'WONTFIX', 'REMOVED']; diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/RuleFacet.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/RuleFacet.tsx index 5ab823fe6a7..599b401951a 100644 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/RuleFacet.tsx +++ b/server/sonar-web/src/main/js/apps/issues/sidebar/RuleFacet.tsx @@ -33,9 +33,9 @@ interface Props { open: boolean; organization: string | undefined; query: Query; - referencedRules: { [ruleKey: string]: ReferencedRule }; + referencedRules: T.Dict; rules: string[]; - stats: { [x: string]: number } | undefined; + stats: T.Dict | undefined; } export default class RuleFacet extends React.PureComponent { diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/SeverityFacet.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/SeverityFacet.tsx index b8055caa5ff..4bd9b25755a 100644 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/SeverityFacet.tsx +++ b/server/sonar-web/src/main/js/apps/issues/sidebar/SeverityFacet.tsx @@ -35,7 +35,7 @@ interface Props { onToggle: (property: string) => void; open: boolean; severities: string[]; - stats: { [x: string]: number } | undefined; + stats: T.Dict | undefined; } const SEVERITIES = ['BLOCKER', 'MINOR', 'CRITICAL', 'INFO', 'MAJOR']; diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/Sidebar.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/Sidebar.tsx index f401c1ee99c..c40f1889559 100644 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/Sidebar.tsx +++ b/server/sonar-web/src/main/js/apps/issues/sidebar/Sidebar.tsx @@ -44,21 +44,21 @@ import { export interface Props { component: T.Component | undefined; - facets: { [facet: string]: Facet }; + facets: T.Dict; hideAuthorFacet?: boolean; loadSearchResultCount: (property: string, changes: Partial) => Promise; - loadingFacets: { [key: string]: boolean }; + loadingFacets: T.Dict; myIssues: boolean; onFacetToggle: (property: string) => void; onFilterChange: (changes: Partial) => void; - openFacets: { [facet: string]: boolean }; + openFacets: T.Dict; organization: { key: string } | undefined; query: Query; - referencedComponentsById: { [id: string]: ReferencedComponent }; - referencedComponentsByKey: { [key: string]: ReferencedComponent }; - referencedLanguages: { [languageKey: string]: ReferencedLanguage }; - referencedRules: { [ruleKey: string]: ReferencedRule }; - referencedUsers: { [login: string]: ReferencedUser }; + referencedComponentsById: T.Dict; + referencedComponentsByKey: T.Dict; + referencedLanguages: T.Dict; + referencedRules: T.Dict; + referencedUsers: T.Dict; } export default class Sidebar extends React.PureComponent { diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/StandardFacet.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/StandardFacet.tsx index cee06f90ec2..534482898a9 100644 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/StandardFacet.tsx +++ b/server/sonar-web/src/main/js/apps/issues/sidebar/StandardFacet.tsx @@ -39,7 +39,7 @@ import ListStyleFacet from '../../../components/facet/ListStyleFacet'; export interface Props { cwe: string[]; cweOpen: boolean; - cweStats: { [x: string]: number } | undefined; + cweStats: T.Dict | undefined; fetchingOwaspTop10: boolean; fetchingSansTop25: boolean; fetchingCwe: boolean; @@ -49,11 +49,11 @@ export interface Props { open: boolean; owaspTop10: string[]; owaspTop10Open: boolean; - owaspTop10Stats: { [x: string]: number } | undefined; + owaspTop10Stats: T.Dict | undefined; query: Query; sansTop25: string[]; sansTop25Open: boolean; - sansTop25Stats: { [x: string]: number } | undefined; + sansTop25Stats: T.Dict | undefined; } interface State { diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/StatusFacet.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/StatusFacet.tsx index 07b0087532f..03d6864947a 100644 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/StatusFacet.tsx +++ b/server/sonar-web/src/main/js/apps/issues/sidebar/StatusFacet.tsx @@ -34,7 +34,7 @@ interface Props { onChange: (changes: Partial) => void; onToggle: (property: string) => void; open: boolean; - stats: { [x: string]: number } | undefined; + stats: T.Dict | undefined; statuses: string[]; } diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/TagFacet.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/TagFacet.tsx index 0b0afc552e0..682485997bc 100644 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/TagFacet.tsx +++ b/server/sonar-web/src/main/js/apps/issues/sidebar/TagFacet.tsx @@ -36,7 +36,7 @@ interface Props { open: boolean; organization: string | undefined; query: Query; - stats: { [x: string]: number } | undefined; + stats: T.Dict | undefined; tags: string[]; } diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/TypeFacet.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/TypeFacet.tsx index f20673e9341..f315d310387 100644 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/TypeFacet.tsx +++ b/server/sonar-web/src/main/js/apps/issues/sidebar/TypeFacet.tsx @@ -35,7 +35,7 @@ interface Props { onChange: (changes: Partial) => void; onToggle: (property: string) => void; open: boolean; - stats: { [x: string]: number } | undefined; + stats: T.Dict | undefined; types: string[]; } diff --git a/server/sonar-web/src/main/js/apps/issues/utils.ts b/server/sonar-web/src/main/js/apps/issues/utils.ts index 1f5e3e31e03..528be4778af 100644 --- a/server/sonar-web/src/main/js/apps/issues/utils.ts +++ b/server/sonar-web/src/main/js/apps/issues/utils.ts @@ -149,25 +149,25 @@ export interface Facet { } export function mapFacet(facet: string) { - const propertyMapping: { [x: string]: string } = { + const propertyMapping: T.Dict = { files: 'fileUuids', modules: 'moduleUuids' }; return propertyMapping[facet] || facet; } -export function parseFacets(facets: RawFacet[]): { [x: string]: Facet } { +export function parseFacets(facets: RawFacet[]): T.Dict { if (!facets) { return {}; } // for readability purpose - const propertyMapping: { [x: string]: string } = { + const propertyMapping: T.Dict = { fileUuids: 'files', moduleUuids: 'modules' }; - const result: { [x: string]: Facet } = {}; + const result: T.Dict = {}; facets.forEach(facet => { const values: Facet = {}; facet.values.forEach(value => { diff --git a/server/sonar-web/src/main/js/apps/organizationMembers/ManageMemberGroupsForm.tsx b/server/sonar-web/src/main/js/apps/organizationMembers/ManageMemberGroupsForm.tsx index 1bc300691ad..fbc68ce2d8f 100644 --- a/server/sonar-web/src/main/js/apps/organizationMembers/ManageMemberGroupsForm.tsx +++ b/server/sonar-web/src/main/js/apps/organizationMembers/ManageMemberGroupsForm.tsx @@ -39,7 +39,7 @@ interface Props { } interface State { - userGroups?: { [k: string]: UserGroup & { status?: string } }; + userGroups?: T.Dict; loading?: boolean; } diff --git a/server/sonar-web/src/main/js/apps/organizations/components/OrganizationProjects.tsx b/server/sonar-web/src/main/js/apps/organizations/components/OrganizationProjects.tsx index 431262cd3a9..4eab0d0de2b 100644 --- a/server/sonar-web/src/main/js/apps/organizations/components/OrganizationProjects.tsx +++ b/server/sonar-web/src/main/js/apps/organizations/components/OrganizationProjects.tsx @@ -22,7 +22,7 @@ import AllProjectsContainer from '../../projects/components/AllProjectsContainer import Suggestions from '../../../app/components/embed-docs-modal/Suggestions'; interface Props { - location: { pathname: string; query: { [x: string]: string } }; + location: { pathname: string; query: T.Dict }; organization: T.Organization; } diff --git a/server/sonar-web/src/main/js/apps/overview/badges/BadgeParams.tsx b/server/sonar-web/src/main/js/apps/overview/badges/BadgeParams.tsx index d2ae576f636..d0b351ff799 100644 --- a/server/sonar-web/src/main/js/apps/overview/badges/BadgeParams.tsx +++ b/server/sonar-web/src/main/js/apps/overview/badges/BadgeParams.tsx @@ -26,7 +26,7 @@ import { getLocalizedMetricName, translate } from '../../../helpers/l10n'; interface Props { className?: string; - metrics: { [key: string]: T.Metric }; + metrics: T.Dict; options: BadgeOptions; type: BadgeType; updateOptions: (options: Partial) => void; diff --git a/server/sonar-web/src/main/js/apps/overview/badges/BadgesModal.tsx b/server/sonar-web/src/main/js/apps/overview/badges/BadgesModal.tsx index 214645981c1..3f4bf8d33ce 100644 --- a/server/sonar-web/src/main/js/apps/overview/badges/BadgesModal.tsx +++ b/server/sonar-web/src/main/js/apps/overview/badges/BadgesModal.tsx @@ -31,7 +31,7 @@ import './styles.css'; interface Props { branchLike?: T.BranchLike; - metrics: { [key: string]: T.Metric }; + metrics: T.Dict; project: string; qualifier: string; } diff --git a/server/sonar-web/src/main/js/apps/overview/components/OverviewApp.tsx b/server/sonar-web/src/main/js/apps/overview/components/OverviewApp.tsx index 5969ecc588f..59c6ff4fefd 100644 --- a/server/sonar-web/src/main/js/apps/overview/components/OverviewApp.tsx +++ b/server/sonar-web/src/main/js/apps/overview/components/OverviewApp.tsx @@ -54,7 +54,7 @@ interface Props { component: T.Component; fetchMetrics: () => void; onComponentChange: (changes: {}) => void; - metrics: { [key: string]: T.Metric }; + metrics: T.Dict; } interface State { @@ -119,7 +119,7 @@ export class OverviewApp extends React.PureComponent { metrics: metrics.join() }).then(r => { if (this.mounted) { - const history: { [metric: string]: Array<{ date: Date; value?: string }> } = {}; + const history: T.Dict> = {}; r.measures.forEach(measure => { const measureHistory = measure.history.map(analysis => ({ date: parseDate(analysis.date), diff --git a/server/sonar-web/src/main/js/apps/overview/events/AnalysesList.tsx b/server/sonar-web/src/main/js/apps/overview/events/AnalysesList.tsx index 37ebc13ca01..c21b0dc01b8 100644 --- a/server/sonar-web/src/main/js/apps/overview/events/AnalysesList.tsx +++ b/server/sonar-web/src/main/js/apps/overview/events/AnalysesList.tsx @@ -32,7 +32,7 @@ interface Props { history?: { [metric: string]: Array<{ date: Date; value?: string }>; }; - metrics: { [key: string]: T.Metric }; + metrics: T.Dict; qualifier: string; } diff --git a/server/sonar-web/src/main/js/apps/overview/meta/MetaContainer.tsx b/server/sonar-web/src/main/js/apps/overview/meta/MetaContainer.tsx index bcd1bccf8e5..709754c92b0 100644 --- a/server/sonar-web/src/main/js/apps/overview/meta/MetaContainer.tsx +++ b/server/sonar-web/src/main/js/apps/overview/meta/MetaContainer.tsx @@ -53,7 +53,7 @@ interface OwnProps { [metric: string]: Array<{ date: Date; value?: string }>; }; measures?: T.MeasureEnhanced[]; - metrics?: { [key: string]: T.Metric }; + metrics?: T.Dict; onComponentChange: (changes: {}) => void; } diff --git a/server/sonar-web/src/main/js/apps/overview/meta/MetaQualityProfiles.tsx b/server/sonar-web/src/main/js/apps/overview/meta/MetaQualityProfiles.tsx index 808be87db1d..f5e666d5b87 100644 --- a/server/sonar-web/src/main/js/apps/overview/meta/MetaQualityProfiles.tsx +++ b/server/sonar-web/src/main/js/apps/overview/meta/MetaQualityProfiles.tsx @@ -38,7 +38,7 @@ interface OwnProps { } interface State { - deprecatedByKey: { [key: string]: number }; + deprecatedByKey: T.Dict; } class MetaQualityProfiles extends React.PureComponent { @@ -61,7 +61,7 @@ class MetaQualityProfiles extends React.PureComponent { if (this.mounted) { - const deprecatedByKey: { [key: string]: number } = {}; + const deprecatedByKey: T.Dict = {}; responses.forEach((count, i) => { const profileKey = this.props.profiles[i].key; deprecatedByKey[profileKey] = count; diff --git a/server/sonar-web/src/main/js/apps/overview/qualityGate/ApplicationQualityGate.tsx b/server/sonar-web/src/main/js/apps/overview/qualityGate/ApplicationQualityGate.tsx index a0037f4684a..7af63eba6fb 100644 --- a/server/sonar-web/src/main/js/apps/overview/qualityGate/ApplicationQualityGate.tsx +++ b/server/sonar-web/src/main/js/apps/overview/qualityGate/ApplicationQualityGate.tsx @@ -33,7 +33,7 @@ interface Props { type State = { loading: boolean; - metrics?: { [key: string]: T.Metric }; + metrics?: T.Dict; projects?: ApplicationProject[]; status?: string; }; diff --git a/server/sonar-web/src/main/js/apps/overview/qualityGate/ApplicationQualityGateProject.tsx b/server/sonar-web/src/main/js/apps/overview/qualityGate/ApplicationQualityGateProject.tsx index a865777e0ab..07c44a34741 100644 --- a/server/sonar-web/src/main/js/apps/overview/qualityGate/ApplicationQualityGateProject.tsx +++ b/server/sonar-web/src/main/js/apps/overview/qualityGate/ApplicationQualityGateProject.tsx @@ -27,7 +27,7 @@ import './ApplicationQualityGateProject.css'; import { ApplicationProject, ConditionAnalysis } from '../../../api/quality-gates'; interface Props { - metrics: { [key: string]: T.Metric }; + metrics: T.Dict; project: ApplicationProject; } diff --git a/server/sonar-web/src/main/js/apps/overview/qualityGate/QualityGateCondition.tsx b/server/sonar-web/src/main/js/apps/overview/qualityGate/QualityGateCondition.tsx index 693d5739e1c..c02add35b60 100644 --- a/server/sonar-web/src/main/js/apps/overview/qualityGate/QualityGateCondition.tsx +++ b/server/sonar-web/src/main/js/apps/overview/qualityGate/QualityGateCondition.tsx @@ -45,8 +45,8 @@ export default class QualityGateCondition extends React.PureComponent { } } - getIssuesUrl = (sinceLeakPeriod: boolean, customQuery: { [x: string]: string }) => { - const query: { [x: string]: string | undefined } = { + getIssuesUrl = (sinceLeakPeriod: boolean, customQuery: T.Dict) => { + const query: T.Dict = { resolved: 'false', ...getBranchLikeQuery(this.props.branchLike), ...customQuery @@ -98,7 +98,7 @@ export default class QualityGateCondition extends React.PureComponent { const metricKey = condition.measure.metric.key; - const RATING_METRICS_MAPPING: { [metric: string]: [string, boolean] } = { + const RATING_METRICS_MAPPING: T.Dict<[string, boolean]> = { reliability_rating: ['BUG', false], new_reliability_rating: ['BUG', true], security_rating: ['VULNERABILITY', false], diff --git a/server/sonar-web/src/main/js/apps/permissions/shared/components/HoldersList.tsx b/server/sonar-web/src/main/js/apps/permissions/shared/components/HoldersList.tsx index 05c510aaf58..5ad0b29ba3b 100644 --- a/server/sonar-web/src/main/js/apps/permissions/shared/components/HoldersList.tsx +++ b/server/sonar-web/src/main/js/apps/permissions/shared/components/HoldersList.tsx @@ -40,7 +40,7 @@ interface Props { } interface State { - initialPermissionsCount: { [key: string]: number }; + initialPermissionsCount: T.Dict; } export default class HoldersList extends React.PureComponent { state: State = { initialPermissionsCount: {} }; diff --git a/server/sonar-web/src/main/js/apps/permissions/utils.ts b/server/sonar-web/src/main/js/apps/permissions/utils.ts index d2c1ea6ad75..4f44cdb3f25 100644 --- a/server/sonar-web/src/main/js/apps/permissions/utils.ts +++ b/server/sonar-web/src/main/js/apps/permissions/utils.ts @@ -46,7 +46,7 @@ export const PERMISSIONS_ORDER_FOR_VIEW = ['user', 'admin']; export const PERMISSIONS_ORDER_FOR_DEV = ['user', 'admin']; -export const PERMISSIONS_ORDER_BY_QUALIFIER: { [index: string]: string[] } = { +export const PERMISSIONS_ORDER_BY_QUALIFIER: T.Dict = { TRK: PERMISSIONS_ORDER_FOR_PROJECT_TEMPLATE, VW: PERMISSIONS_ORDER_FOR_VIEW, SVW: PERMISSIONS_ORDER_FOR_VIEW, diff --git a/server/sonar-web/src/main/js/apps/portfolio/components/Activity.tsx b/server/sonar-web/src/main/js/apps/portfolio/components/Activity.tsx index 93a9f377231..4e08fb2e46f 100644 --- a/server/sonar-web/src/main/js/apps/portfolio/components/Activity.tsx +++ b/server/sonar-web/src/main/js/apps/portfolio/components/Activity.tsx @@ -30,7 +30,7 @@ import { translate } from '../../../helpers/l10n'; interface Props { component: string; - metrics: { [key: string]: T.Metric }; + metrics: T.Dict; } interface State { @@ -72,7 +72,7 @@ export default class Activity extends React.PureComponent { return getAllTimeMachineData({ component, metrics: graphMetrics.join() }).then( timeMachine => { if (this.mounted) { - const history: { [metric: string]: Array<{ date: Date; value?: string }> } = {}; + const history: T.Dict> = {}; timeMachine.measures.forEach(measure => { const measureHistory = measure.history.map(analysis => ({ date: parseDate(analysis.date), diff --git a/server/sonar-web/src/main/js/apps/portfolio/components/App.tsx b/server/sonar-web/src/main/js/apps/portfolio/components/App.tsx index e53553217ee..7c18623172a 100644 --- a/server/sonar-web/src/main/js/apps/portfolio/components/App.tsx +++ b/server/sonar-web/src/main/js/apps/portfolio/components/App.tsx @@ -42,7 +42,7 @@ interface OwnProps { } interface StateToProps { - metrics: { [key: string]: T.Metric }; + metrics: T.Dict; } interface DispatchToProps { @@ -53,7 +53,7 @@ type Props = StateToProps & DispatchToProps & OwnProps; interface State { loading: boolean; - measures?: { [key: string]: string | undefined }; + measures?: T.Dict; subComponents?: SubComponent[]; totalSubComponents?: number; } diff --git a/server/sonar-web/src/main/js/apps/portfolio/components/MaintainabilityBox.tsx b/server/sonar-web/src/main/js/apps/portfolio/components/MaintainabilityBox.tsx index 3a16b681676..29c58da3fea 100644 --- a/server/sonar-web/src/main/js/apps/portfolio/components/MaintainabilityBox.tsx +++ b/server/sonar-web/src/main/js/apps/portfolio/components/MaintainabilityBox.tsx @@ -27,7 +27,7 @@ import { translate } from '../../../helpers/l10n'; interface Props { component: string; - measures: { [key: string]: string | undefined }; + measures: T.Dict; } export default function MaintainabilityBox({ component, measures }: Props) { diff --git a/server/sonar-web/src/main/js/apps/portfolio/components/ReleasabilityBox.tsx b/server/sonar-web/src/main/js/apps/portfolio/components/ReleasabilityBox.tsx index 896e030def6..fdffce0d3dc 100644 --- a/server/sonar-web/src/main/js/apps/portfolio/components/ReleasabilityBox.tsx +++ b/server/sonar-web/src/main/js/apps/portfolio/components/ReleasabilityBox.tsx @@ -28,7 +28,7 @@ import { getComponentDrilldownUrl } from '../../../helpers/urls'; interface Props { component: string; - measures: { [key: string]: string | undefined }; + measures: T.Dict; } export default function ReleasabilityBox({ component, measures }: Props) { diff --git a/server/sonar-web/src/main/js/apps/portfolio/components/ReliabilityBox.tsx b/server/sonar-web/src/main/js/apps/portfolio/components/ReliabilityBox.tsx index c1988e2f689..2e2c1893d11 100644 --- a/server/sonar-web/src/main/js/apps/portfolio/components/ReliabilityBox.tsx +++ b/server/sonar-web/src/main/js/apps/portfolio/components/ReliabilityBox.tsx @@ -27,7 +27,7 @@ import { translate } from '../../../helpers/l10n'; interface Props { component: string; - measures: { [key: string]: string | undefined }; + measures: T.Dict; } export default function ReliabilityBox({ component, measures }: Props) { diff --git a/server/sonar-web/src/main/js/apps/portfolio/components/SecurityBox.tsx b/server/sonar-web/src/main/js/apps/portfolio/components/SecurityBox.tsx index e4b9f861d88..b8101d7f8f9 100644 --- a/server/sonar-web/src/main/js/apps/portfolio/components/SecurityBox.tsx +++ b/server/sonar-web/src/main/js/apps/portfolio/components/SecurityBox.tsx @@ -27,7 +27,7 @@ import { translate } from '../../../helpers/l10n'; interface Props { component: string; - measures: { [key: string]: string | undefined }; + measures: T.Dict; } export default function SecurityBox({ component, measures }: Props) { diff --git a/server/sonar-web/src/main/js/apps/portfolio/components/Summary.tsx b/server/sonar-web/src/main/js/apps/portfolio/components/Summary.tsx index 8005fce9b96..b396276a003 100644 --- a/server/sonar-web/src/main/js/apps/portfolio/components/Summary.tsx +++ b/server/sonar-web/src/main/js/apps/portfolio/components/Summary.tsx @@ -26,7 +26,7 @@ import { getComponentDrilldownUrl } from '../../../helpers/urls'; interface Props { component: { description?: string; key: string }; - measures: { [key: string]: string | undefined }; + measures: T.Dict; } export default function Summary({ component, measures }: Props) { diff --git a/server/sonar-web/src/main/js/apps/portfolio/components/WorstProjects.tsx b/server/sonar-web/src/main/js/apps/portfolio/components/WorstProjects.tsx index 96f0daa134b..2d9f11e89df 100644 --- a/server/sonar-web/src/main/js/apps/portfolio/components/WorstProjects.tsx +++ b/server/sonar-web/src/main/js/apps/portfolio/components/WorstProjects.tsx @@ -107,7 +107,7 @@ export default function WorstProjects({ component, subComponents, total }: Props ); } -function renderCell(measures: { [key: string]: string | undefined }, metric: string, type: string) { +function renderCell(measures: T.Dict, metric: string, type: string) { return ( @@ -115,7 +115,7 @@ function renderCell(measures: { [key: string]: string | undefined }, metric: str ); } -function renderNcloc(measures: { [key: string]: string | undefined }, maxLoc: number) { +function renderNcloc(measures: T.Dict, maxLoc: number) { const ncloc = Number(measures['ncloc'] || 0); const barWidth = maxLoc > 0 ? Math.max(1, Math.round((ncloc / maxLoc) * 50)) : 0; return ( diff --git a/server/sonar-web/src/main/js/apps/portfolio/types.ts b/server/sonar-web/src/main/js/apps/portfolio/types.ts index 45de85de01f..496ed85db50 100644 --- a/server/sonar-web/src/main/js/apps/portfolio/types.ts +++ b/server/sonar-web/src/main/js/apps/portfolio/types.ts @@ -19,7 +19,7 @@ */ export interface SubComponent { key: string; - measures: { [key: string]: string | undefined }; + measures: T.Dict; name: string; refKey?: string; qualifier: string; diff --git a/server/sonar-web/src/main/js/apps/portfolio/utils.ts b/server/sonar-web/src/main/js/apps/portfolio/utils.ts index 8d219ac5953..f3d76eeab2e 100644 --- a/server/sonar-web/src/main/js/apps/portfolio/utils.ts +++ b/server/sonar-web/src/main/js/apps/portfolio/utils.ts @@ -24,7 +24,7 @@ export function getNextRating(rating: number): number | undefined { function getWorstSeverity(data: string): { severity: string; count: number } | undefined { const SEVERITY_ORDER = ['BLOCKER', 'CRITICAL', 'MAJOR', 'MINOR', 'INFO']; - const severities: { [key: string]: number } = {}; + const severities: T.Dict = {}; data.split(';').forEach(equality => { const [key, count] = equality.split('='); severities[key] = Number(count); @@ -84,7 +84,7 @@ export const SUB_COMPONENTS_METRICS = [ ]; export function convertMeasures(measures: Array<{ metric: string; value?: string }>) { - const result: { [key: string]: string | undefined } = {}; + const result: T.Dict = {}; measures.forEach(measure => { result[measure.metric] = measure.value; }); diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/GraphsTooltipsContentIssues.tsx b/server/sonar-web/src/main/js/apps/projectActivity/components/GraphsTooltipsContentIssues.tsx index 07a28ff5f70..c99cb179741 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/GraphsTooltipsContentIssues.tsx +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/GraphsTooltipsContentIssues.tsx @@ -31,7 +31,7 @@ interface Props { value: string; } -const METRIC_RATING: { [x: string]: string } = { +const METRIC_RATING: T.Dict = { bugs: 'reliability_rating', vulnerabilities: 'security_rating', code_smells: 'sqale_rating' diff --git a/server/sonar-web/src/main/js/apps/projectActivity/utils.ts b/server/sonar-web/src/main/js/apps/projectActivity/utils.ts index fbb551988d6..85653d2319d 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/utils.ts +++ b/server/sonar-web/src/main/js/apps/projectActivity/utils.ts @@ -70,12 +70,12 @@ export const EVENT_TYPES = ['VERSION', 'QUALITY_GATE', 'QUALITY_PROFILE', 'OTHER export const APPLICATION_EVENT_TYPES = ['QUALITY_GATE', 'DEFINITION_CHANGE', 'OTHER']; export const DEFAULT_GRAPH = 'issues'; export const GRAPH_TYPES = ['issues', 'coverage', 'duplications', 'custom']; -export const GRAPHS_METRICS_DISPLAYED: { [x: string]: string[] } = { +export const GRAPHS_METRICS_DISPLAYED: T.Dict = { issues: ['bugs', 'code_smells', 'vulnerabilities'], coverage: ['lines_to_cover', 'uncovered_lines'], duplications: ['ncloc', 'duplicated_lines'] }; -export const GRAPHS_METRICS: { [x: string]: string[] } = { +export const GRAPHS_METRICS: T.Dict = { issues: GRAPHS_METRICS_DISPLAYED['issues'].concat([ 'reliability_rating', 'security_rating', @@ -142,7 +142,7 @@ export function generateCoveredLinesMetric( }; } -function findMetric(key: string, metrics: T.Metric[] | { [key: string]: T.Metric }) { +function findMetric(key: string, metrics: T.Metric[] | T.Dict) { if (Array.isArray(metrics)) { return metrics.find(metric => metric.key === key); } @@ -152,7 +152,7 @@ function findMetric(key: string, metrics: T.Metric[] | { [key: string]: T.Metric export function generateSeries( measuresHistory: MeasureHistory[], graph: string, - metrics: T.Metric[] | { [key: string]: T.Metric }, + metrics: T.Metric[] | T.Dict, displayedMetrics: string[] ): Serie[] { if (displayedMetrics.length <= 0 || typeof measuresHistory === 'undefined') { @@ -193,7 +193,7 @@ export function getSeriesMetricType(series: Serie[]) { } interface AnalysesByDay { - byDay: { [x: string]: ParsedAnalysis[] }; + byDay: T.Dict; version: string | null; key: string | null; } diff --git a/server/sonar-web/src/main/js/apps/projects/components/ProjectCardLeakMeasures.tsx b/server/sonar-web/src/main/js/apps/projects/components/ProjectCardLeakMeasures.tsx index c91d412a6a4..81fe78f56d6 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/ProjectCardLeakMeasures.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/ProjectCardLeakMeasures.tsx @@ -26,7 +26,7 @@ import VulnerabilityIcon from '../../../components/icons-components/Vulnerabilit import { translate } from '../../../helpers/l10n'; interface Props { - measures: { [key: string]: string }; + measures: T.Dict; } export default function ProjectCardLeakMeasures({ measures }: Props) { diff --git a/server/sonar-web/src/main/js/apps/projects/components/ProjectCardOverallMeasures.tsx b/server/sonar-web/src/main/js/apps/projects/components/ProjectCardOverallMeasures.tsx index c5f201a76d9..821257cb266 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/ProjectCardOverallMeasures.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/ProjectCardOverallMeasures.tsx @@ -30,7 +30,7 @@ import CodeSmellIcon from '../../../components/icons-components/CodeSmellIcon'; import VulnerabilityIcon from '../../../components/icons-components/VulnerabilityIcon'; interface Props { - measures: { [key: string]: string | undefined }; + measures: T.Dict; } export default function ProjectCardOverallMeasures({ measures }: Props) { diff --git a/server/sonar-web/src/main/js/apps/projects/filters/CoverageFilter.tsx b/server/sonar-web/src/main/js/apps/projects/filters/CoverageFilter.tsx index bbaf688eb5f..cc2b9b8683b 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/CoverageFilter.tsx +++ b/server/sonar-web/src/main/js/apps/projects/filters/CoverageFilter.tsx @@ -33,7 +33,7 @@ export interface Props { onQueryChange: (change: RawQuery) => void; organization?: { key: string }; property?: string; - query: { [x: string]: any }; + query: T.Dict; value?: any; } diff --git a/server/sonar-web/src/main/js/apps/projects/filters/DuplicationsFilter.tsx b/server/sonar-web/src/main/js/apps/projects/filters/DuplicationsFilter.tsx index dbb7252ef81..d0d16e754ed 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/DuplicationsFilter.tsx +++ b/server/sonar-web/src/main/js/apps/projects/filters/DuplicationsFilter.tsx @@ -36,7 +36,7 @@ export interface Props { onQueryChange: (change: RawQuery) => void; organization?: { key: string }; property?: string; - query: { [x: string]: any }; + query: T.Dict; value?: any; } diff --git a/server/sonar-web/src/main/js/apps/projects/filters/Filter.tsx b/server/sonar-web/src/main/js/apps/projects/filters/Filter.tsx index a1316915e15..f5d9ddf3a35 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/Filter.tsx +++ b/server/sonar-web/src/main/js/apps/projects/filters/Filter.tsx @@ -31,7 +31,7 @@ interface Props { className?: string; onQueryChange: (change: RawQuery) => void; options: Option[]; - query: { [x: string]: any }; + query: T.Dict; renderOption: (option: Option, isSelected: boolean) => React.ReactNode; value?: Option | Option[]; diff --git a/server/sonar-web/src/main/js/apps/projects/filters/IssuesFilter.tsx b/server/sonar-web/src/main/js/apps/projects/filters/IssuesFilter.tsx index 3aeb23e4e66..71592f4d272 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/IssuesFilter.tsx +++ b/server/sonar-web/src/main/js/apps/projects/filters/IssuesFilter.tsx @@ -34,7 +34,7 @@ interface Props { onQueryChange: (change: RawQuery) => void; organization?: { key: string }; property: string; - query: { [x: string]: any }; + query: T.Dict; value?: any; } diff --git a/server/sonar-web/src/main/js/apps/projects/filters/LanguagesFilter.tsx b/server/sonar-web/src/main/js/apps/projects/filters/LanguagesFilter.tsx index 52be2d5df6b..aeba3067a00 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/LanguagesFilter.tsx +++ b/server/sonar-web/src/main/js/apps/projects/filters/LanguagesFilter.tsx @@ -35,7 +35,7 @@ interface Props { onQueryChange: (change: RawQuery) => void; organization?: { key: string }; property?: string; - query: { [x: string]: any }; + query: T.Dict; value?: string[]; } diff --git a/server/sonar-web/src/main/js/apps/projects/filters/MaintainabilityFilter.tsx b/server/sonar-web/src/main/js/apps/projects/filters/MaintainabilityFilter.tsx index 8ef4a9c93da..39cfebbc357 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/MaintainabilityFilter.tsx +++ b/server/sonar-web/src/main/js/apps/projects/filters/MaintainabilityFilter.tsx @@ -31,7 +31,7 @@ interface Props { maxFacetValue?: number; onQueryChange: (change: RawQuery) => void; organization?: { key: string }; - query: { [x: string]: any }; + query: T.Dict; value?: any; } diff --git a/server/sonar-web/src/main/js/apps/projects/filters/NewLinesFilter.tsx b/server/sonar-web/src/main/js/apps/projects/filters/NewLinesFilter.tsx index e4abe096478..a3550fa8e70 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/NewLinesFilter.tsx +++ b/server/sonar-web/src/main/js/apps/projects/filters/NewLinesFilter.tsx @@ -32,7 +32,7 @@ export interface Props { onQueryChange: (change: RawQuery) => void; organization?: { key: string }; property?: string; - query: { [x: string]: any }; + query: T.Dict; value?: any; } diff --git a/server/sonar-web/src/main/js/apps/projects/filters/NewMaintainabilityFilter.tsx b/server/sonar-web/src/main/js/apps/projects/filters/NewMaintainabilityFilter.tsx index d59f5a75112..fc4a94a38e8 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/NewMaintainabilityFilter.tsx +++ b/server/sonar-web/src/main/js/apps/projects/filters/NewMaintainabilityFilter.tsx @@ -30,7 +30,7 @@ interface Props { maxFacetValue?: number; onQueryChange: (change: RawQuery) => void; organization?: { key: string }; - query: { [x: string]: any }; + query: T.Dict; value?: any; } diff --git a/server/sonar-web/src/main/js/apps/projects/filters/NewReliabilityFilter.tsx b/server/sonar-web/src/main/js/apps/projects/filters/NewReliabilityFilter.tsx index e2e00e1d1dc..5646371d4b5 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/NewReliabilityFilter.tsx +++ b/server/sonar-web/src/main/js/apps/projects/filters/NewReliabilityFilter.tsx @@ -30,7 +30,7 @@ interface Props { maxFacetValue?: number; onQueryChange: (change: RawQuery) => void; organization?: { key: string }; - query: { [x: string]: any }; + query: T.Dict; value?: any; } diff --git a/server/sonar-web/src/main/js/apps/projects/filters/NewSecurityFilter.tsx b/server/sonar-web/src/main/js/apps/projects/filters/NewSecurityFilter.tsx index 527592cd420..a1765c4fee8 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/NewSecurityFilter.tsx +++ b/server/sonar-web/src/main/js/apps/projects/filters/NewSecurityFilter.tsx @@ -30,7 +30,7 @@ interface Props { maxFacetValue?: number; onQueryChange: (change: RawQuery) => void; organization?: { key: string }; - query: { [x: string]: any }; + query: T.Dict; value?: any; } diff --git a/server/sonar-web/src/main/js/apps/projects/filters/QualityGateFilter.tsx b/server/sonar-web/src/main/js/apps/projects/filters/QualityGateFilter.tsx index 3b8f6c5fff8..7fa456cadc3 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/QualityGateFilter.tsx +++ b/server/sonar-web/src/main/js/apps/projects/filters/QualityGateFilter.tsx @@ -32,7 +32,7 @@ export interface Props { maxFacetValue?: number; onQueryChange: (change: RawQuery) => void; organization?: { key: string }; - query: { [x: string]: any }; + query: T.Dict; value?: any; } diff --git a/server/sonar-web/src/main/js/apps/projects/filters/ReliabilityFilter.tsx b/server/sonar-web/src/main/js/apps/projects/filters/ReliabilityFilter.tsx index 9236cdeba84..a8a0c354fc2 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/ReliabilityFilter.tsx +++ b/server/sonar-web/src/main/js/apps/projects/filters/ReliabilityFilter.tsx @@ -31,7 +31,7 @@ interface Props { maxFacetValue?: number; onQueryChange: (change: RawQuery) => void; organization?: { key: string }; - query: { [x: string]: any }; + query: T.Dict; value?: any; } diff --git a/server/sonar-web/src/main/js/apps/projects/filters/SearchableFilterFooter.tsx b/server/sonar-web/src/main/js/apps/projects/filters/SearchableFilterFooter.tsx index 9b748bfe66a..1348341fc7f 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/SearchableFilterFooter.tsx +++ b/server/sonar-web/src/main/js/apps/projects/filters/SearchableFilterFooter.tsx @@ -31,7 +31,7 @@ interface Props { options: Array<{ label: string; value: string }>; organization?: { key: string }; property: string; - query: { [x: string]: any }; + query: T.Dict; } export default class SearchableFilterFooter extends React.PureComponent { diff --git a/server/sonar-web/src/main/js/apps/projects/filters/SecurityFilter.tsx b/server/sonar-web/src/main/js/apps/projects/filters/SecurityFilter.tsx index a0459e9d8e2..5c70922ae34 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/SecurityFilter.tsx +++ b/server/sonar-web/src/main/js/apps/projects/filters/SecurityFilter.tsx @@ -31,7 +31,7 @@ interface Props { maxFacetValue?: number; onQueryChange: (change: RawQuery) => void; organization?: { key: string }; - query: { [x: string]: any }; + query: T.Dict; value?: any; } diff --git a/server/sonar-web/src/main/js/apps/projects/filters/SizeFilter.tsx b/server/sonar-web/src/main/js/apps/projects/filters/SizeFilter.tsx index f3c93b6c251..9b19c58e26a 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/SizeFilter.tsx +++ b/server/sonar-web/src/main/js/apps/projects/filters/SizeFilter.tsx @@ -33,7 +33,7 @@ export interface Props { onQueryChange: (change: RawQuery) => void; organization?: { key: string }; property?: string; - query: { [x: string]: any }; + query: T.Dict; value?: any; } diff --git a/server/sonar-web/src/main/js/apps/projects/filters/TagsFilter.tsx b/server/sonar-web/src/main/js/apps/projects/filters/TagsFilter.tsx index 18032d0c6c4..2b1be5918cc 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/TagsFilter.tsx +++ b/server/sonar-web/src/main/js/apps/projects/filters/TagsFilter.tsx @@ -34,7 +34,7 @@ interface Props { onQueryChange: (change: RawQuery) => void; organization?: { key: string }; property?: string; - query: { [x: string]: any }; + query: T.Dict; value?: string[]; } diff --git a/server/sonar-web/src/main/js/apps/projects/query.ts b/server/sonar-web/src/main/js/apps/projects/query.ts index 68dfdb7a63e..33adc5cd096 100644 --- a/server/sonar-web/src/main/js/apps/projects/query.ts +++ b/server/sonar-web/src/main/js/apps/projects/query.ts @@ -227,7 +227,7 @@ function convertSize(metric: string, size: number): string { } function mapPropertyToMetric(property?: string): string | undefined { - const map: { [property: string]: string } = { + const map: T.Dict = { analysis_date: 'analysisDate', reliability: 'reliability_rating', new_reliability: 'new_reliability_rating', diff --git a/server/sonar-web/src/main/js/apps/projects/types.ts b/server/sonar-web/src/main/js/apps/projects/types.ts index d841caf3c96..183106c84e2 100644 --- a/server/sonar-web/src/main/js/apps/projects/types.ts +++ b/server/sonar-web/src/main/js/apps/projects/types.ts @@ -22,7 +22,7 @@ export interface Project { isFavorite?: boolean; key: string; leakPeriodDate?: string; - measures: { [key: string]: string }; + measures: T.Dict; name: string; organization?: { key: string; name: string }; tags: string[]; diff --git a/server/sonar-web/src/main/js/apps/projects/utils.ts b/server/sonar-web/src/main/js/apps/projects/utils.ts index 256c21ef866..3971132c87f 100644 --- a/server/sonar-web/src/main/js/apps/projects/utils.ts +++ b/server/sonar-web/src/main/js/apps/projects/utils.ts @@ -57,7 +57,7 @@ export const SORTING_LEAK_METRICS: SortingOption[] = [ { value: 'new_lines', class: 'projects-leak-sorting-option' } ]; -export const SORTING_SWITCH: { [x: string]: string } = { +export const SORTING_SWITCH: T.Dict = { analysis_date: 'analysis_date', name: 'name', reliability: 'new_reliability', @@ -115,7 +115,7 @@ const LEAK_METRICS = [ 'new_lines' ]; -const METRICS_BY_VISUALIZATION: { [x: string]: string[] } = { +const METRICS_BY_VISUALIZATION: T.Dict = { risk: ['reliability_rating', 'security_rating', 'coverage', 'ncloc', 'sqale_index'], // x, y, size, color reliability: ['ncloc', 'reliability_remediation_effort', 'bugs', 'reliability_rating'], @@ -186,7 +186,7 @@ export function fetchProjects( facets: getFacetsMap(facets), projects: components .map(component => { - const componentMeasures: { [key: string]: string } = {}; + const componentMeasures: T.Dict = {}; measures.filter(measure => measure.component === component.key).forEach(measure => { const value = isDiffMetric(measure.metric) ? getPeriodValue(measure, 1) @@ -272,7 +272,7 @@ export function fetchProjectOrganizations( } function mapFacetValues(values: Array<{ val: string; count: number }>) { - const map: { [value: string]: number } = {}; + const map: T.Dict = {}; values.forEach(value => { map[value.val] = value.count; }); @@ -280,7 +280,7 @@ function mapFacetValues(values: Array<{ val: string; count: number }>) { } function getFacetsMap(facets: Facet[]) { - const map: { [property: string]: { [value: string]: number } } = {}; + const map: T.Dict> = {}; facets.forEach(facet => { const property = mapMetricToProperty(facet.property); const { values } = facet; @@ -293,7 +293,7 @@ function getFacetsMap(facets: Facet[]) { } function mapPropertyToMetric(property?: string) { - const map: { [property: string]: string } = { + const map: T.Dict = { analysis_date: 'analysisDate', reliability: 'reliability_rating', new_reliability: 'new_reliability_rating', @@ -323,7 +323,7 @@ function convertToSorting({ sort }: Query): { s?: string; asc?: boolean } { } function mapMetricToProperty(metricKey: string) { - const map: { [metric: string]: string } = { + const map: T.Dict = { analysisDate: 'analysis_date', reliability_rating: 'reliability', new_reliability_rating: 'new_reliability', diff --git a/server/sonar-web/src/main/js/apps/projects/visualizations/Visualizations.tsx b/server/sonar-web/src/main/js/apps/projects/visualizations/Visualizations.tsx index 8d3c81f9e34..153c74fd54b 100644 --- a/server/sonar-web/src/main/js/apps/projects/visualizations/Visualizations.tsx +++ b/server/sonar-web/src/main/js/apps/projects/visualizations/Visualizations.tsx @@ -38,7 +38,7 @@ interface Props { export default class Visualizations extends React.PureComponent { renderVisualization(projects: Project[]) { - const visualizationToComponent: { [x: string]: any } = { + const visualizationToComponent: T.Dict = { risk: Risk, reliability: Reliability, security: Security, diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/Conditions.tsx b/server/sonar-web/src/main/js/apps/quality-gates/components/Conditions.tsx index 6dae3053fc3..be63b21b251 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/Conditions.tsx +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/Conditions.tsx @@ -30,7 +30,7 @@ import { Alert } from '../../../components/ui/Alert'; interface Props { canEdit: boolean; conditions: T.Condition[]; - metrics: { [key: string]: T.Metric }; + metrics: T.Dict; onAddCondition: (condition: T.Condition) => void; onSaveCondition: (newCondition: T.Condition, oldCondition: T.Condition) => void; onRemoveCondition: (Condition: T.Condition) => void; diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/Details.tsx b/server/sonar-web/src/main/js/apps/quality-gates/components/Details.tsx index fb9a7580e8c..614f6ddecea 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/Details.tsx +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/Details.tsx @@ -37,7 +37,7 @@ interface OwnProps { } interface StateToProps { - metrics: { [key: string]: T.Metric }; + metrics: T.Dict; } interface DispatchToProps { diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/DetailsContent.tsx b/server/sonar-web/src/main/js/apps/quality-gates/components/DetailsContent.tsx index a6083c473f8..b420ada7a14 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/DetailsContent.tsx +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/DetailsContent.tsx @@ -25,7 +25,7 @@ import { translate } from '../../../helpers/l10n'; interface Props { isDefault?: boolean; - metrics: { [key: string]: T.Metric }; + metrics: T.Dict; organization?: string; onAddCondition: (condition: T.Condition) => void; onRemoveCondition: (Condition: T.Condition) => void; diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/changelog/ChangesList.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/changelog/ChangesList.tsx index acbb45c981d..2f27ed4c65d 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/changelog/ChangesList.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/changelog/ChangesList.tsx @@ -22,7 +22,7 @@ import SeverityChange from './SeverityChange'; import ParameterChange from './ParameterChange'; interface Props { - changes: { [change: string]: string | null }; + changes: T.Dict; } export default function ChangesList({ changes }: Props) { diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonResults.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonResults.tsx index bbb8269caad..34a3e6f7f67 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonResults.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonResults.tsx @@ -28,7 +28,7 @@ import { CompareResponse, Profile } from '../../../api/quality-profiles'; import ChevronRightIcon from '../../../components/icons-components/ChevronRightcon'; import ChevronLeftIcon from '../../../components/icons-components/ChevronLeftIcon'; -type Params = { [p: string]: string }; +type Params = T.Dict; interface Props extends CompareResponse { organization?: string; diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileRules.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileRules.tsx index bb6692db7fe..b9060b042c0 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileRules.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileRules.tsx @@ -46,8 +46,8 @@ interface ByType { interface State { activatedTotal: number | null; - activatedByType: { [type: string]: ByType }; - allByType: { [type: string]: ByType }; + activatedByType: T.Dict; + allByType: T.Dict; compareToSonarWay: { profile: string; profileName: string; missingRuleCount: number } | null; loading: boolean; total: number | null; diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/home/EvolutionRules.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/home/EvolutionRules.tsx index 3bea7a17198..b0c46e36abe 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/home/EvolutionRules.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/home/EvolutionRules.tsx @@ -28,10 +28,7 @@ import { formatMeasure } from '../../../helpers/measures'; const RULES_LIMIT = 10; -function parseRules( - rules: T.Rule[], - actives?: { [rule: string]: T.RuleActivation[] } -): ExtendedRule[] { +function parseRules(rules: T.Rule[], actives?: T.Dict): ExtendedRule[] { return rules.map(rule => { const activations = actives && actives[rule.key]; return { ...rule, activations: activations ? activations.length : 0 }; diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/home/HomeContainer.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/home/HomeContainer.tsx index cb09d54819a..defe270b574 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/home/HomeContainer.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/home/HomeContainer.tsx @@ -27,7 +27,7 @@ import { Actions } from '../../../api/quality-profiles'; interface Props { actions: Actions; languages: Array<{ key: string; name: string }>; - location: { query: { [p: string]: string } }; + location: { query: T.Dict }; organization: string | null; profiles: Profile[]; updateProfiles: () => Promise; diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/home/ProfilesList.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/home/ProfilesList.tsx index ca4b28b4595..9a50bcfca9a 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/home/ProfilesList.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/home/ProfilesList.tsx @@ -28,7 +28,7 @@ import { Alert } from '../../../components/ui/Alert'; interface Props { languages: Array<{ key: string; name: string }>; - location: { query: { [p: string]: string } }; + location: { query: T.Dict }; organization: string | null; profiles: Profile[]; updateProfiles: () => Promise; @@ -92,7 +92,7 @@ export default class ProfilesList extends React.PureComponent { const { profiles, languages } = this.props; const { language } = this.props.location.query; - const profilesIndex: { [language: string]: Profile[] } = groupBy( + const profilesIndex: T.Dict = groupBy( profiles, profile => profile.language ); diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/types.ts b/server/sonar-web/src/main/js/apps/quality-profiles/types.ts index 2fdcdb9d80e..70e522f9bb7 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/types.ts +++ b/server/sonar-web/src/main/js/apps/quality-profiles/types.ts @@ -34,7 +34,7 @@ export interface ProfileChangelogEvent { action: string; authorName: string; date: string; - params?: { [change: string]: string | null }; + params?: T.Dict; ruleKey: string; ruleName: string; } diff --git a/server/sonar-web/src/main/js/apps/securityReports/components/VulnerabilityList.tsx b/server/sonar-web/src/main/js/apps/securityReports/components/VulnerabilityList.tsx index 61571b8a565..95dc4630e29 100755 --- a/server/sonar-web/src/main/js/apps/securityReports/components/VulnerabilityList.tsx +++ b/server/sonar-web/src/main/js/apps/securityReports/components/VulnerabilityList.tsx @@ -122,7 +122,7 @@ export default class VulnerabilityList extends React.PureComponent const languages = this.props.component.qualityProfiles ? this.props.component.qualityProfiles.map(qp => qp.language).join(',') : ''; - const sansTopCategoryTags: { [key: string]: string } = { + const sansTopCategoryTags: T.Dict = { 'insecure-interaction': 'insecure', 'porous-defenses': 'porous', 'risky-resource': 'risky' @@ -168,7 +168,7 @@ export default class VulnerabilityList extends React.PureComponent renderComponentIssuesLink = ( activeRules: number, - query: { [x: string]: string | undefined }, + query: T.Dict, value: number, tooltip?: JSX.Element ) => { @@ -194,7 +194,7 @@ export default class VulnerabilityList extends React.PureComponent parent?: T.SecurityHotspot ): React.ReactFragment { const { branchLike, component, type } = this.props; - const params: { [name: string]: string | undefined } = { + const params: T.Dict = { ...getBranchLikeQuery(branchLike), types: 'SECURITY_HOTSPOT' }; diff --git a/server/sonar-web/src/main/js/apps/securityReports/utils.ts b/server/sonar-web/src/main/js/apps/securityReports/utils.ts index e9394d7edc3..023f7f76dba 100755 --- a/server/sonar-web/src/main/js/apps/securityReports/utils.ts +++ b/server/sonar-web/src/main/js/apps/securityReports/utils.ts @@ -20,9 +20,9 @@ export type StandardType = 'owaspTop10' | 'sansTop25' | 'cwe'; export interface Standards { - owaspTop10: { [x: string]: { title: string; description?: string } }; - sansTop25: { [x: string]: { title: string; description?: string } }; - cwe: { [x: string]: { title: string; description?: string } }; + owaspTop10: T.Dict<{ title: string; description?: string }>; + sansTop25: T.Dict<{ title: string; description?: string }>; + cwe: T.Dict<{ title: string; description?: string }>; } export function renderOwaspTop10Category( diff --git a/server/sonar-web/src/main/js/apps/settings/store/definitions.ts b/server/sonar-web/src/main/js/apps/settings/store/definitions.ts index f0054d4af17..4eccf0d7a9a 100644 --- a/server/sonar-web/src/main/js/apps/settings/store/definitions.ts +++ b/server/sonar-web/src/main/js/apps/settings/store/definitions.ts @@ -27,9 +27,7 @@ const enum Actions { type Action = ActionType; -export interface State { - [key: string]: T.SettingCategoryDefinition; -} +export type State = T.Dict; export function receiveDefinitions(definitions: T.SettingCategoryDefinition[]) { return { type: Actions.ReceiveDefinitions, definitions }; diff --git a/server/sonar-web/src/main/js/apps/settings/store/settingsPage.ts b/server/sonar-web/src/main/js/apps/settings/store/settingsPage.ts index 703da03714a..cc672c28fb6 100644 --- a/server/sonar-web/src/main/js/apps/settings/store/settingsPage.ts +++ b/server/sonar-web/src/main/js/apps/settings/store/settingsPage.ts @@ -39,9 +39,9 @@ type Action = | ActionType; export interface State { - changedValues: { [key: string]: any }; - loading: { [key: string]: boolean }; - validationMessages: { [key: string]: string }; + changedValues: T.Dict; + loading: T.Dict; + validationMessages: T.Dict; } export function cancelChange(key: string) { diff --git a/server/sonar-web/src/main/js/apps/settings/store/values.ts b/server/sonar-web/src/main/js/apps/settings/store/values.ts index d92ae47d739..7dfeb996fc1 100644 --- a/server/sonar-web/src/main/js/apps/settings/store/values.ts +++ b/server/sonar-web/src/main/js/apps/settings/store/values.ts @@ -28,12 +28,10 @@ enum Actions { type Action = ActionType; -interface SettingsState { - [key: string]: T.SettingValue; -} +type SettingsState = T.Dict; export interface State { - components: { [component: string]: SettingsState }; + components: T.Dict; global: SettingsState; } diff --git a/server/sonar-web/src/main/js/apps/settings/utils.ts b/server/sonar-web/src/main/js/apps/settings/utils.ts index e52ce100c21..09484304223 100644 --- a/server/sonar-web/src/main/js/apps/settings/utils.ts +++ b/server/sonar-web/src/main/js/apps/settings/utils.ts @@ -98,7 +98,7 @@ export function getEmptyValue(item: T.SettingDefinition | T.SettingCategoryDefin } if (item.type === 'PROPERTY_SET') { - const value: { [key: string]: string } = {}; + const value: T.Dict = {}; item.fields.forEach(field => (value[field.key] = getEmptyValue(field))); return [value]; } diff --git a/server/sonar-web/src/main/js/apps/tutorials/components/commands/BuildWrapper.tsx b/server/sonar-web/src/main/js/apps/tutorials/components/commands/BuildWrapper.tsx index bc8d5448966..829c09c02d6 100644 --- a/server/sonar-web/src/main/js/apps/tutorials/components/commands/BuildWrapper.tsx +++ b/server/sonar-web/src/main/js/apps/tutorials/components/commands/BuildWrapper.tsx @@ -26,7 +26,7 @@ interface Props { os: string; } -const filenames: { [key: string]: string } = { +const filenames: T.Dict = { win: 'build-wrapper-win-x86.zip', linux: 'build-wrapper-linux-x86.zip', mac: 'build-wrapper-macosx-x86.zip' diff --git a/server/sonar-web/src/main/js/apps/tutorials/components/commands/ClangGCC.tsx b/server/sonar-web/src/main/js/apps/tutorials/components/commands/ClangGCC.tsx index e0b29454704..c36574af7d8 100644 --- a/server/sonar-web/src/main/js/apps/tutorials/components/commands/ClangGCC.tsx +++ b/server/sonar-web/src/main/js/apps/tutorials/components/commands/ClangGCC.tsx @@ -34,7 +34,7 @@ interface Props { token: string; } -const executables: { [key: string]: string } = { +const executables: T.Dict = { linux: 'build-wrapper-linux-x86-64', win: 'build-wrapper-win-x86-64.exe', mac: 'build-wrapper-macosx-x86' diff --git a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerBase.tsx b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerBase.tsx index db24f1d0ceb..071cdbf65e5 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerBase.tsx +++ b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerBase.tsx @@ -87,7 +87,7 @@ export interface Props { interface State { component?: T.SourceViewerFile; displayDuplications: boolean; - duplicatedFiles?: { [ref: string]: T.DuplicatedFile }; + duplicatedFiles?: T.Dict; duplications?: T.Duplication[]; duplicationsByLine: { [line: number]: number[] }; hasSourcesAfter: boolean; diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/DuplicationPopup.tsx b/server/sonar-web/src/main/js/components/SourceViewer/components/DuplicationPopup.tsx index 295ce16edc7..f35ea78319e 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/components/DuplicationPopup.tsx +++ b/server/sonar-web/src/main/js/components/SourceViewer/components/DuplicationPopup.tsx @@ -33,7 +33,7 @@ import { Alert } from '../../ui/Alert'; interface Props { blocks: T.DuplicationBlock[]; branchLike: T.BranchLike | undefined; - duplicatedFiles?: { [ref: string]: T.DuplicatedFile }; + duplicatedFiles?: T.Dict; inRemovedComponent: boolean; onClose: () => void; openComponent: WorkspaceContextShape['openComponent']; diff --git a/server/sonar-web/src/main/js/components/docs/DocMarkdownBlock.tsx b/server/sonar-web/src/main/js/components/docs/DocMarkdownBlock.tsx index 389b799d863..92c34ad59b6 100644 --- a/server/sonar-web/src/main/js/components/docs/DocMarkdownBlock.tsx +++ b/server/sonar-web/src/main/js/components/docs/DocMarkdownBlock.tsx @@ -33,7 +33,7 @@ import { separateFrontMatter, filterContent } from '../../helpers/markdown'; import { scrollToElement } from '../../helpers/scrolling'; interface Props { - childProps?: { [k: string]: string }; + childProps?: T.Dict; className?: string; content: string | undefined; displayH1?: boolean; @@ -108,8 +108,8 @@ export default class DocMarkdownBlock extends React.PureComponent { } function withChildProps

( - WrappedComponent: React.ComponentType

, - childProps?: { [k: string]: any } + WrappedComponent: React.ComponentType

}>, + childProps?: T.Dict ) { return function withChildProps(props: P) { return ; diff --git a/server/sonar-web/src/main/js/components/docs/DocTooltip.tsx b/server/sonar-web/src/main/js/components/docs/DocTooltip.tsx index 42c421c8e72..bc818f68f69 100644 --- a/server/sonar-web/src/main/js/components/docs/DocTooltip.tsx +++ b/server/sonar-web/src/main/js/components/docs/DocTooltip.tsx @@ -28,7 +28,7 @@ interface Props { children?: React.ReactNode; // Use as `import(/* webpackMode: "eager" */ 'Docs/tooltips/foo/bar.md')` doc: Promise<{ default: string }>; - overlayProps?: { [k: string]: string }; + overlayProps?: T.Dict; } interface State { diff --git a/server/sonar-web/src/main/js/components/docs/DocTooltipLink.tsx b/server/sonar-web/src/main/js/components/docs/DocTooltipLink.tsx index 12b3fb9d054..f2ebad3840f 100644 --- a/server/sonar-web/src/main/js/components/docs/DocTooltipLink.tsx +++ b/server/sonar-web/src/main/js/components/docs/DocTooltipLink.tsx @@ -23,7 +23,7 @@ import { forEach } from 'lodash'; import DetachIcon from '../icons-components/DetachIcon'; interface OwnProps { - customProps?: { [k: string]: string }; + customProps?: T.Dict; } type Props = OwnProps & React.AnchorHTMLAttributes; diff --git a/server/sonar-web/src/main/js/components/facet/ListStyleFacet.tsx b/server/sonar-web/src/main/js/components/facet/ListStyleFacet.tsx index f52b6ab10bc..0845c888738 100644 --- a/server/sonar-web/src/main/js/components/facet/ListStyleFacet.tsx +++ b/server/sonar-web/src/main/js/components/facet/ListStyleFacet.tsx @@ -50,11 +50,11 @@ export interface Props { getFacetItemText: (item: string) => string; getSearchResultKey: (result: S) => string; getSearchResultText: (result: S) => string; - loadSearchResultCount?: (result: S[]) => Promise<{ [x: string]: number }>; + loadSearchResultCount?: (result: S[]) => Promise>; maxInitialItems: number; maxItems: number; minSearchLength: number; - onChange: (changes: { [x: string]: string | string[] }) => void; + onChange: (changes: T.Dict) => void; onClear?: () => void; onItemClick?: (itemValue: string, multiple: boolean) => void; onSearch: (query: string, page?: number) => Promise>; @@ -66,7 +66,7 @@ export interface Props { renderSearchResult: (result: S, query: string) => React.ReactNode; searchPlaceholder: string; getSortedItems?: () => string[]; - stats: { [x: string]: number } | undefined; + stats: T.Dict | undefined; values: string[]; } @@ -77,7 +77,7 @@ interface State { searchMaxResults?: boolean; searchPaging?: T.Paging; searchResults?: S[]; - searchResultsCounts: { [key: string]: number }; + searchResultsCounts: T.Dict; showFullList: boolean; } diff --git a/server/sonar-web/src/main/js/components/icons-components/QualifierIcon.tsx b/server/sonar-web/src/main/js/components/icons-components/QualifierIcon.tsx index 5b4fa09cb07..84475054e9b 100644 --- a/server/sonar-web/src/main/js/components/icons-components/QualifierIcon.tsx +++ b/server/sonar-web/src/main/js/components/icons-components/QualifierIcon.tsx @@ -21,7 +21,7 @@ import * as React from 'react'; import Icon, { IconProps } from './Icon'; import * as theme from '../../app/theme'; -const qualifierIcons: { [x: string]: (props: IconProps) => React.ReactElement } = { +const qualifierIcons: T.Dict<(props: IconProps) => React.ReactElement> = { app: ApplicationIcon, brc: SubProjectIcon, dev: DeveloperIcon, diff --git a/server/sonar-web/src/main/js/components/icons-components/SeverityIcon.tsx b/server/sonar-web/src/main/js/components/icons-components/SeverityIcon.tsx index a08be1b0e3e..2fc2a95def7 100644 --- a/server/sonar-web/src/main/js/components/icons-components/SeverityIcon.tsx +++ b/server/sonar-web/src/main/js/components/icons-components/SeverityIcon.tsx @@ -26,7 +26,7 @@ interface Props { severity: string | null | undefined; } -const severityIcons: { [x: string]: (props: IconProps) => React.ReactElement } = { +const severityIcons: T.Dict<(props: IconProps) => React.ReactElement> = { blocker: BlockerSeverityIcon, critical: CriticalSeverityIcon, major: MajorSeverityIcon, diff --git a/server/sonar-web/src/main/js/components/icons-components/StatusIcon.tsx b/server/sonar-web/src/main/js/components/icons-components/StatusIcon.tsx index cf96fe44b3b..a4d0e3bfcb9 100644 --- a/server/sonar-web/src/main/js/components/icons-components/StatusIcon.tsx +++ b/server/sonar-web/src/main/js/components/icons-components/StatusIcon.tsx @@ -26,7 +26,7 @@ interface Props { status: string; } -const statusIcons: { [x: string]: (props: IconProps) => React.ReactElement } = { +const statusIcons: T.Dict<(props: IconProps) => React.ReactElement> = { open: OpenStatusIcon, confirmed: ConfirmedStatusIcon, reopened: ReopenedStatusIcon, diff --git a/server/sonar-web/src/main/js/components/icons-components/TestStatusIcon.tsx b/server/sonar-web/src/main/js/components/icons-components/TestStatusIcon.tsx index 48f7925edbe..eb859471cfb 100644 --- a/server/sonar-web/src/main/js/components/icons-components/TestStatusIcon.tsx +++ b/server/sonar-web/src/main/js/components/icons-components/TestStatusIcon.tsx @@ -26,7 +26,7 @@ interface Props { status: string; } -const statusIcons: { [x: string]: (props: IconProps) => React.ReactElement } = { +const statusIcons: T.Dict<(props: IconProps) => React.ReactElement> = { ok: OkTestStatusIcon, failure: FailureTestStatusIcon, error: ErrorTestStatusIcon, diff --git a/server/sonar-web/src/main/js/components/measure/utils.ts b/server/sonar-web/src/main/js/components/measure/utils.ts index 06be324ca14..d1067cdc40b 100644 --- a/server/sonar-web/src/main/js/components/measure/utils.ts +++ b/server/sonar-web/src/main/js/components/measure/utils.ts @@ -27,10 +27,7 @@ const KNOWN_RATINGS = [ 'security_rating' ]; -export function enhanceMeasure( - measure: T.Measure, - metrics: { [key: string]: T.Metric } -): T.MeasureEnhanced { +export function enhanceMeasure(measure: T.Measure, metrics: T.Dict): T.MeasureEnhanced { return { ...measure, metric: metrics[measure.metric], diff --git a/server/sonar-web/src/main/js/components/preview-graph/PreviewGraph.tsx b/server/sonar-web/src/main/js/components/preview-graph/PreviewGraph.tsx index 2709e650cb9..917bed05128 100644 --- a/server/sonar-web/src/main/js/components/preview-graph/PreviewGraph.tsx +++ b/server/sonar-web/src/main/js/components/preview-graph/PreviewGraph.tsx @@ -43,7 +43,7 @@ interface History { interface Props { branchLike?: T.BranchLike; history?: History; - metrics: { [key: string]: T.Metric }; + metrics: T.Dict; project: string; renderWhenEmpty?: () => React.ReactNode; router: Pick; @@ -110,7 +110,7 @@ class PreviewGraph extends React.PureComponent { history: History | undefined, graph: string, customMetrics: string[], - metrics: { [x: string]: T.Metric } + metrics: T.Dict ) => { const myHistory = history; if (!myHistory) { diff --git a/server/sonar-web/src/main/js/components/shared/DrilldownLink.tsx b/server/sonar-web/src/main/js/components/shared/DrilldownLink.tsx index 0d69d1afa7c..62a52952146 100644 --- a/server/sonar-web/src/main/js/components/shared/DrilldownLink.tsx +++ b/server/sonar-web/src/main/js/components/shared/DrilldownLink.tsx @@ -47,7 +47,7 @@ const ISSUE_MEASURES = [ 'new_vulnerabilities' ]; -const issueParamsPerMetric: { [key: string]: { [key: string]: string } } = { +const issueParamsPerMetric: T.Dict> = { blocker_violations: { resolved: 'false', severities: 'BLOCKER' }, new_blocker_violations: { resolved: 'false', severities: 'BLOCKER' }, critical_violations: { resolved: 'false', severities: 'CRITICAL' }, @@ -85,7 +85,7 @@ export default class DrilldownLink extends React.PureComponent { }; propsToIssueParams = () => { - const params: { [key: string]: string | boolean } = { + const params: T.Dict = { ...(issueParamsPerMetric[this.props.metric] || { resolved: 'false' }) }; diff --git a/server/sonar-web/src/main/js/components/workspace/WorkspaceRuleDetails.tsx b/server/sonar-web/src/main/js/components/workspace/WorkspaceRuleDetails.tsx index 6560908b09a..159424d0b8c 100644 --- a/server/sonar-web/src/main/js/components/workspace/WorkspaceRuleDetails.tsx +++ b/server/sonar-web/src/main/js/components/workspace/WorkspaceRuleDetails.tsx @@ -35,7 +35,7 @@ interface Props { interface State { loading: boolean; - referencedRepositories: { [repository: string]: { key: string; language: string; name: string } }; + referencedRepositories: T.Dict<{ key: string; language: string; name: string }>; ruleDetails?: T.RuleDetails; } diff --git a/server/sonar-web/src/main/js/helpers/cookies.ts b/server/sonar-web/src/main/js/helpers/cookies.ts index 4d767b711b8..f170a2da925 100644 --- a/server/sonar-web/src/main/js/helpers/cookies.ts +++ b/server/sonar-web/src/main/js/helpers/cookies.ts @@ -20,9 +20,9 @@ import { memoize } from 'lodash'; const parseCookies = memoize( - (documentCookie: string): { [key: string]: string } => { + (documentCookie: string): T.Dict => { const rawCookies = documentCookie.split('; '); - const cookies: { [key: string]: string } = {}; + const cookies: T.Dict = {}; rawCookies.forEach(candidate => { const [key, value] = candidate.split('='); cookies[key] = value; diff --git a/server/sonar-web/src/main/js/helpers/issues.ts b/server/sonar-web/src/main/js/helpers/issues.ts index 221480a4302..3a2fe6696a2 100644 --- a/server/sonar-web/src/main/js/helpers/issues.ts +++ b/server/sonar-web/src/main/js/helpers/issues.ts @@ -64,12 +64,12 @@ export function sortBySeverity(issues: T.Issue[]): T.Issue[] { } function injectRelational( - issue: { [x: string]: any }, + issue: T.Dict, source: any[] | undefined, baseField: string, lookupField: string ) { - const newFields: { [x: string]: any } = {}; + const newFields: T.Dict = {}; const baseValue = issue[baseField]; if (baseValue !== undefined && source !== undefined) { const lookupValue = source.find(candidate => candidate[lookupField] === baseValue); diff --git a/server/sonar-web/src/main/js/helpers/measures.ts b/server/sonar-web/src/main/js/helpers/measures.ts index 36bdae7ed38..8f6443bb9be 100644 --- a/server/sonar-web/src/main/js/helpers/measures.ts +++ b/server/sonar-web/src/main/js/helpers/measures.ts @@ -93,7 +93,7 @@ function useFormatter( } function getFormatter(type: string): Formatter { - const FORMATTERS: { [type: string]: Formatter } = { + const FORMATTERS: T.Dict = { INT: intFormatter, SHORT_INT: shortIntFormatter, FLOAT: floatFormatter, diff --git a/server/sonar-web/src/main/js/helpers/request.ts b/server/sonar-web/src/main/js/helpers/request.ts index 29d4bb7aaff..5834fafbe28 100644 --- a/server/sonar-web/src/main/js/helpers/request.ts +++ b/server/sonar-web/src/main/js/helpers/request.ts @@ -41,16 +41,14 @@ export function getCSRFTokenValue(): string { /** * Return an object containing a special http request header used to prevent CSRF attacks. */ -export function getCSRFToken(): { [x: string]: string } { +export function getCSRFToken(): T.Dict { // Fetch API in Edge doesn't work with empty header, // so we ensure non-empty value const value = getCSRFTokenValue(); return value ? { [getCSRFTokenName()]: value } : {}; } -export interface RequestData { - [x: string]: any; -} +export type RequestData = T.Dict; export function omitNil(obj: RequestData): RequestData { return omitBy(obj, isNil); diff --git a/server/sonar-web/src/main/js/helpers/strings.ts b/server/sonar-web/src/main/js/helpers/strings.ts index 22e17c36b7f..27d4222c84d 100644 --- a/server/sonar-web/src/main/js/helpers/strings.ts +++ b/server/sonar-web/src/main/js/helpers/strings.ts @@ -393,7 +393,7 @@ const defaultDiacriticsRemovalap = [ } ]; -const diacriticsMap: { [x: string]: string } = {}; +const diacriticsMap: T.Dict = {}; defaultDiacriticsRemovalap.forEach(defaultDiacritic => defaultDiacritic.letters.split('').forEach(letter => { diacriticsMap[letter] = defaultDiacritic.base; diff --git a/server/sonar-web/src/main/js/store/metrics.ts b/server/sonar-web/src/main/js/store/metrics.ts index 8ba20a84bfe..95e3e96cd43 100644 --- a/server/sonar-web/src/main/js/store/metrics.ts +++ b/server/sonar-web/src/main/js/store/metrics.ts @@ -27,7 +27,7 @@ export function receiveMetrics(metrics: T.Metric[]) { type Action = ActionType; -export type State = { byKey: { [key: string]: T.Metric }; keys: string[] }; +export type State = { byKey: T.Dict; keys: string[] }; const byKey = (state: State['byKey'] = {}, action: Action) => { if (action.type === 'RECEIVE_METRICS') { diff --git a/server/sonar-web/src/main/js/store/organizations.ts b/server/sonar-web/src/main/js/store/organizations.ts index 00709482c26..e1f870d23bd 100644 --- a/server/sonar-web/src/main/js/store/organizations.ts +++ b/server/sonar-web/src/main/js/store/organizations.ts @@ -32,7 +32,7 @@ type Action = | ActionType; export interface State { - byKey: { [key: string]: T.Organization }; + byKey: T.Dict; my: string[]; } diff --git a/server/sonar-web/src/main/js/store/users.ts b/server/sonar-web/src/main/js/store/users.ts index 1a7601256c0..3075ff565bd 100644 --- a/server/sonar-web/src/main/js/store/users.ts +++ b/server/sonar-web/src/main/js/store/users.ts @@ -37,7 +37,7 @@ type Action = | ActionType; export interface State { - usersByLogin: { [login: string]: any }; + usersByLogin: T.Dict; userLogins: string[]; currentUser: T.CurrentUser; }