diff options
Diffstat (limited to 'server/sonar-web/src')
243 files changed, 490 insertions, 470 deletions
diff --git a/server/sonar-web/src/main/js/app/components/StartupModal.tsx b/server/sonar-web/src/main/js/app/components/StartupModal.tsx index c11ac083e29..30c6dd2189f 100644 --- a/server/sonar-web/src/main/js/app/components/StartupModal.tsx +++ b/server/sonar-web/src/main/js/app/components/StartupModal.tsx @@ -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. */ -import * as differenceInDays from 'date-fns/difference_in_days'; +import { differenceInDays } from 'date-fns'; import * as React from 'react'; import { connect } from 'react-redux'; import { showLicense } from '../../api/marketplace'; diff --git a/server/sonar-web/src/main/js/app/components/__tests__/ComponentContainer-test.tsx b/server/sonar-web/src/main/js/app/components/__tests__/ComponentContainer-test.tsx index 6a4590cd08c..89dc7822561 100644 --- a/server/sonar-web/src/main/js/app/components/__tests__/ComponentContainer-test.tsx +++ b/server/sonar-web/src/main/js/app/components/__tests__/ComponentContainer-test.tsx @@ -75,9 +75,7 @@ jest.mock('../../../api/alm-settings', () => ({ })); // mock this, because some of its children are using redux store -jest.mock('../nav/component/ComponentNav', () => ({ - default: () => null -})); +jest.mock('../nav/component/ComponentNav', () => () => null); const Inner = () => <div />; diff --git a/server/sonar-web/src/main/js/app/components/__tests__/GlobalContainer-test.tsx b/server/sonar-web/src/main/js/app/components/__tests__/GlobalContainer-test.tsx index 7c099331ba4..96b6219fcd1 100644 --- a/server/sonar-web/src/main/js/app/components/__tests__/GlobalContainer-test.tsx +++ b/server/sonar-web/src/main/js/app/components/__tests__/GlobalContainer-test.tsx @@ -29,7 +29,7 @@ jest.mock('../embed-docs-modal/SuggestionsProvider', () => { } } - return { default: SuggestionsProvider }; + return SuggestionsProvider; }); it('should render correctly', () => { diff --git a/server/sonar-web/src/main/js/app/components/__tests__/KeyboardShortcutsModal-test.tsx b/server/sonar-web/src/main/js/app/components/__tests__/KeyboardShortcutsModal-test.tsx index 3313ba1c0c4..91a01ff3b5a 100644 --- a/server/sonar-web/src/main/js/app/components/__tests__/KeyboardShortcutsModal-test.tsx +++ b/server/sonar-web/src/main/js/app/components/__tests__/KeyboardShortcutsModal-test.tsx @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { shallow } from 'enzyme'; -import * as React from 'react'; +import React from 'react'; import Modal from '../../../components/controls/Modal'; import { mockEvent } from '../../../helpers/testMocks'; import KeyboardShortcutsModal from '../KeyboardShortcutsModal'; diff --git a/server/sonar-web/src/main/js/app/components/__tests__/ProjectAdminContainer-test.tsx b/server/sonar-web/src/main/js/app/components/__tests__/ProjectAdminContainer-test.tsx index e867f7145ae..e2e9aaa91c9 100644 --- a/server/sonar-web/src/main/js/app/components/__tests__/ProjectAdminContainer-test.tsx +++ b/server/sonar-web/src/main/js/app/components/__tests__/ProjectAdminContainer-test.tsx @@ -24,7 +24,7 @@ import { mockComponent } from '../../../helpers/mocks/component'; import ProjectAdminContainer from '../ProjectAdminContainer'; jest.mock('../../utils/handleRequiredAuthorization', () => { - return { default: jest.fn() }; + return jest.fn(); }); class ChildComponent extends React.Component { diff --git a/server/sonar-web/src/main/js/app/components/__tests__/StartupModal-test.tsx b/server/sonar-web/src/main/js/app/components/__tests__/StartupModal-test.tsx index e527440c46b..79d76ac2f1f 100644 --- a/server/sonar-web/src/main/js/app/components/__tests__/StartupModal-test.tsx +++ b/server/sonar-web/src/main/js/app/components/__tests__/StartupModal-test.tsx @@ -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. */ -import * as differenceInDays from 'date-fns/difference_in_days'; +import { differenceInDays } from 'date-fns'; import { shallow, ShallowWrapper } from 'enzyme'; import * as React from 'react'; import { showLicense } from '../../../api/marketplace'; @@ -46,7 +46,7 @@ jest.mock('../../../helpers/dates', () => ({ toShortNotSoISOString: jest.fn().mockReturnValue('short-not-iso-date') })); -jest.mock('date-fns/difference_in_days', () => jest.fn().mockReturnValue(1)); +jest.mock('date-fns', () => ({ differenceInDays: jest.fn().mockReturnValue(1) })); const LOGGED_IN_USER: T.LoggedInUser = { groups: [], diff --git a/server/sonar-web/src/main/js/app/components/embed-docs-modal/__tests__/SuggestionsProvider-test.tsx b/server/sonar-web/src/main/js/app/components/embed-docs-modal/__tests__/SuggestionsProvider-test.tsx index e1c76a0539b..864b0a1f738 100644 --- a/server/sonar-web/src/main/js/app/components/embed-docs-modal/__tests__/SuggestionsProvider-test.tsx +++ b/server/sonar-web/src/main/js/app/components/embed-docs-modal/__tests__/SuggestionsProvider-test.tsx @@ -25,13 +25,11 @@ import SuggestionsProvider from '../SuggestionsProvider'; jest.mock( 'Docs/EmbedDocsSuggestions.json', () => ({ - default: { - pageA: [ - { link: '/foo', text: 'Foo' }, - { link: '/bar', text: 'Bar', scope: 'sonarcloud' } - ], - pageB: [{ link: '/qux', text: 'Qux' }] - } + pageA: [ + { link: '/foo', text: 'Foo' }, + { link: '/bar', text: 'Bar', scope: 'sonarcloud' } + ], + pageB: [{ link: '/qux', text: 'Qux' }] }), { virtual: true } ); diff --git a/server/sonar-web/src/main/js/app/components/nav/component/ComponentNav.tsx b/server/sonar-web/src/main/js/app/components/nav/component/ComponentNav.tsx index a17b0b003cd..df02475cfcf 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/ComponentNav.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/component/ComponentNav.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import ContextNavBar from '../../../../components/ui/ContextNavBar'; import { diff --git a/server/sonar-web/src/main/js/app/components/nav/component/Menu.tsx b/server/sonar-web/src/main/js/app/components/nav/component/Menu.tsx index 903fc7d885b..b1ac495c980 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/Menu.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/component/Menu.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { Link, LinkProps } from 'react-router'; import Dropdown from '../../../../components/controls/Dropdown'; diff --git a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNav-test.tsx b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNav-test.tsx index c1e4fe0e54e..0da72dea810 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNav-test.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNav-test.tsx @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { shallow } from 'enzyme'; -import * as React from 'react'; +import React from 'react'; import { mockProjectAlmBindingConfigurationErrors } from '../../../../../helpers/mocks/alm-settings'; import { mockComponent } from '../../../../../helpers/mocks/component'; import { mockTask, mockTaskWarning } from '../../../../../helpers/mocks/tasks'; diff --git a/server/sonar-web/src/main/js/app/components/nav/component/branch-like/BranchLikeNavigation.tsx b/server/sonar-web/src/main/js/app/components/nav/component/branch-like/BranchLikeNavigation.tsx index 1f017226c57..5b748818f9b 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/branch-like/BranchLikeNavigation.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/component/branch-like/BranchLikeNavigation.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import Toggler from '../../../../../components/controls/Toggler'; import { withAppState } from '../../../../../components/hoc/withAppState'; diff --git a/server/sonar-web/src/main/js/app/components/nav/component/branch-like/MenuItem.tsx b/server/sonar-web/src/main/js/app/components/nav/component/branch-like/MenuItem.tsx index 7cc0592d4d5..16631eeba2c 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/branch-like/MenuItem.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/component/branch-like/MenuItem.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import BranchStatus from '../../../../../components/common/BranchStatus'; import BranchLikeIcon from '../../../../../components/icons/BranchLikeIcon'; diff --git a/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/InfoDrawer.tsx b/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/InfoDrawer.tsx index 4369bc93b7b..ae8aef6b211 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/InfoDrawer.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/InfoDrawer.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { ClearButton } from '../../../../../components/controls/buttons'; import EscKeydownHandler from '../../../../../components/controls/EscKeydownHandler'; diff --git a/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/InfoDrawerPage.tsx b/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/InfoDrawerPage.tsx index 5ecb1970b25..68ce72f2adf 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/InfoDrawerPage.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/InfoDrawerPage.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import BackIcon from '../../../../../components/icons/BackIcon'; import { translate } from '../../../../../helpers/l10n'; diff --git a/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/badges/BadgeButton.tsx b/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/badges/BadgeButton.tsx index 9bdf960e4aa..c4b66aeb0af 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/badges/BadgeButton.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/badges/BadgeButton.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { Button } from '../../../../../../components/controls/buttons'; import { translate } from '../../../../../../helpers/l10n'; diff --git a/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/badges/BadgeParams.tsx b/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/badges/BadgeParams.tsx index f6406e91ea3..4aa6edc257e 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/badges/BadgeParams.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/badges/BadgeParams.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { fetchWebApi } from '../../../../../../api/web-api'; import Select from '../../../../../../components/controls/Select'; diff --git a/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/badges/utils.ts b/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/badges/utils.ts index cb455dff6f1..f4d4a8a7233 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/badges/utils.ts +++ b/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/badges/utils.ts @@ -17,7 +17,6 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import { stringify } from 'querystring'; import { getLocalizedMetricName } from '../../../../../../helpers/l10n'; import { omitNil } from '../../../../../../helpers/request'; import { getHostUrl, getPathUrlAsString, getProjectUrl } from '../../../../../../helpers/urls'; @@ -80,13 +79,13 @@ export function getBadgeUrl( case BadgeType.marketing: return `${getHostUrl()}/images/project_badges/sonarcloud-${color}.svg`; case BadgeType.qualityGate: - return `${getHostUrl()}/api/project_badges/quality_gate?${stringify( + return `${getHostUrl()}/api/project_badges/quality_gate?${new URLSearchParams( omitNil({ branch, project, pullRequest }) - )}`; + ).toString()}`; case BadgeType.measure: default: - return `${getHostUrl()}/api/project_badges/measure?${stringify( + return `${getHostUrl()}/api/project_badges/measure?${new URLSearchParams( omitNil({ branch, project, metric, pullRequest }) - )}`; + ).toString()}`; } } diff --git a/server/sonar-web/src/main/js/app/components/nav/global/GlobalNavMenu.tsx b/server/sonar-web/src/main/js/app/components/nav/global/GlobalNavMenu.tsx index 7ce047bc85a..c72524bd66e 100644 --- a/server/sonar-web/src/main/js/app/components/nav/global/GlobalNavMenu.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/global/GlobalNavMenu.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { Link } from 'react-router'; import { isMySet } from '../../../../apps/issues/utils'; diff --git a/server/sonar-web/src/main/js/app/components/nav/settings/SettingsNav.tsx b/server/sonar-web/src/main/js/app/components/nav/settings/SettingsNav.tsx index 71bc8cc6b3b..e78a3252499 100644 --- a/server/sonar-web/src/main/js/app/components/nav/settings/SettingsNav.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/settings/SettingsNav.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { IndexLink, Link } from 'react-router'; import Dropdown from '../../../../components/controls/Dropdown'; 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 2804d3b0518..6818bdabe43 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 @@ -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. */ -import * as key from 'keymaster'; +import key from 'keymaster'; import { debounce, keyBy, uniqBy } from 'lodash'; import * as React from 'react'; import { FormattedMessage } from 'react-intl'; diff --git a/server/sonar-web/src/main/js/app/components/search/SearchShowMore.tsx b/server/sonar-web/src/main/js/app/components/search/SearchShowMore.tsx index b1840372b12..fdffd10d304 100644 --- a/server/sonar-web/src/main/js/app/components/search/SearchShowMore.tsx +++ b/server/sonar-web/src/main/js/app/components/search/SearchShowMore.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { FormattedMessage } from 'react-intl'; import DeferredSpinner from '../../../components/ui/DeferredSpinner'; diff --git a/server/sonar-web/src/main/js/app/index.ts b/server/sonar-web/src/main/js/app/index.ts index 8ceaf92f55f..78db9a4e0d5 100644 --- a/server/sonar-web/src/main/js/app/index.ts +++ b/server/sonar-web/src/main/js/app/index.ts @@ -21,7 +21,7 @@ import { installExtensionsHandler, installWebAnalyticsHandler } from '../helpers import { loadL10nBundle } from '../helpers/l10n'; import { parseJSON, request } from '../helpers/request'; import { getBaseUrl, getSystemStatus } from '../helpers/system'; -import './styles/sonar.css'; +import './styles/sonar.ts'; installWebAnalyticsHandler(); diff --git a/server/sonar-web/src/main/js/app/styles/sonar.css b/server/sonar-web/src/main/js/app/styles/sonar.css deleted file mode 100644 index ad6c5842cbe..00000000000 --- a/server/sonar-web/src/main/js/app/styles/sonar.css +++ /dev/null @@ -1,46 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@import './init/base.css'; -@import './init/type.css'; -@import './init/links.css'; -@import './init/tables.css'; -@import './init/lists.css'; -@import './init/forms.css'; -@import './init/icons.css'; -@import './init/misc.css'; - -@import './components/ui.css'; -@import './components/spinner.css'; -@import './components/global-loading.css'; -@import './components/issues.css'; -@import './components/dropdowns.css'; -@import './components/menu.css'; -@import './components/page.css'; -@import './components/component-name.css'; -@import './components/list-groups.css'; -@import './components/panels.css'; -@import './components/badges.css'; -@import './components/columns.css'; -@import './components/boxed-group.css'; - -@import './style.css'; -@import './print.css'; -@import './sonar-colorizer.css'; -@import './mixins.css'; diff --git a/server/sonar-web/src/main/js/app/styles/sonar.ts b/server/sonar-web/src/main/js/app/styles/sonar.ts new file mode 100644 index 00000000000..57934e0e47b --- /dev/null +++ b/server/sonar-web/src/main/js/app/styles/sonar.ts @@ -0,0 +1,47 @@ +/* + * SonarQube + * Copyright (C) 2009-2021 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +/* + * The esbuild postcss plugin fails to handle CSS `@import` + */ +import './components/badges.css'; +import './components/boxed-group.css'; +import './components/columns.css'; +import './components/component-name.css'; +import './components/dropdowns.css'; +import './components/global-loading.css'; +import './components/issues.css'; +import './components/list-groups.css'; +import './components/menu.css'; +import './components/page.css'; +import './components/panels.css'; +import './components/spinner.css'; +import './components/ui.css'; +import './init/base.css'; +import './init/forms.css'; +import './init/icons.css'; +import './init/links.css'; +import './init/lists.css'; +import './init/misc.css'; +import './init/tables.css'; +import './init/type.css'; +import './mixins.css'; +import './print.css'; +import './sonar-colorizer.css'; +import './style.css'; diff --git a/server/sonar-web/src/main/js/app/utils/startReactApp.tsx b/server/sonar-web/src/main/js/app/utils/startReactApp.tsx index 2c90471aa77..c1c7b4fdc37 100644 --- a/server/sonar-web/src/main/js/app/utils/startReactApp.tsx +++ b/server/sonar-web/src/main/js/app/utils/startReactApp.tsx @@ -21,7 +21,7 @@ import { Location } from 'history'; import { pick } from 'lodash'; import * as React from 'react'; -import { render } from 'react-dom'; +import ReactDom, { render } from 'react-dom'; import { HelmetProvider } from 'react-helmet-async'; import { IntlProvider } from 'react-intl'; import { Provider } from 'react-redux'; @@ -69,6 +69,14 @@ import { PageContext } from '../components/indexation/PageUnavailableDueToIndexa import MigrationContainer from '../components/MigrationContainer'; import getStore from './getStore'; +/* + * Expose dependencies to extensions + */ +function attachToGlobal() { + window.React = React; + window.ReactDOM = ReactDom; +} + function handleUpdate(this: { state: { location: Location } }) { const { action } = this.state.location; @@ -249,6 +257,8 @@ export default function startReactApp( currentUser?: T.CurrentUser, appState?: T.AppState ) { + attachToGlobal(); + const el = document.getElementById('content'); const history = getHistory(); diff --git a/server/sonar-web/src/main/js/apps/about/components/__tests__/AboutApp-test.tsx b/server/sonar-web/src/main/js/apps/about/components/__tests__/AboutApp-test.tsx index 56da775ca17..4d814ae0698 100644 --- a/server/sonar-web/src/main/js/apps/about/components/__tests__/AboutApp-test.tsx +++ b/server/sonar-web/src/main/js/apps/about/components/__tests__/AboutApp-test.tsx @@ -47,14 +47,16 @@ jest.mock('../../../../api/issues', () => ({ }) })); -jest.mock('../../../../app/components/GlobalContainer', () => ({ - default: class GlobalContainer extends React.Component { - static displayName = 'GlobalContainer'; - render() { - return this.props.children; +jest.mock( + '../../../../app/components/GlobalContainer', + () => + class GlobalContainer extends React.Component { + static displayName = 'GlobalContainer'; + render() { + return this.props.children; + } } - } -})); +); it('should render correctly', async () => { const wrapper = shallowRender(); diff --git a/server/sonar-web/src/main/js/apps/account/components/__tests__/Account-test.tsx b/server/sonar-web/src/main/js/apps/account/components/__tests__/Account-test.tsx index fc0a840742a..a72ad22e810 100644 --- a/server/sonar-web/src/main/js/apps/account/components/__tests__/Account-test.tsx +++ b/server/sonar-web/src/main/js/apps/account/components/__tests__/Account-test.tsx @@ -23,9 +23,7 @@ import handleRequiredAuthentication from '../../../../helpers/handleRequiredAuth import { mockCurrentUser } from '../../../../helpers/testMocks'; import { Account } from '../Account'; -jest.mock('../../../../helpers/handleRequiredAuthentication', () => ({ - default: jest.fn() -})); +jest.mock('../../../../helpers/handleRequiredAuthentication', () => jest.fn()); it('should render correctly', () => { const wrapper = shallowRender(); diff --git a/server/sonar-web/src/main/js/apps/account/notifications/ProjectModal.tsx b/server/sonar-web/src/main/js/apps/account/notifications/ProjectModal.tsx index e8d335fc3f9..7a0060f4569 100644 --- a/server/sonar-web/src/main/js/apps/account/notifications/ProjectModal.tsx +++ b/server/sonar-web/src/main/js/apps/account/notifications/ProjectModal.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import { debounce } from 'lodash'; import * as React from 'react'; import { getSuggestions } from '../../../api/components'; diff --git a/server/sonar-web/src/main/js/apps/application-console/__tests__/ApplicationConsoleApp-test.tsx b/server/sonar-web/src/main/js/apps/application-console/__tests__/ApplicationConsoleApp-test.tsx index f0e2a1c9bfa..018f68d844c 100644 --- a/server/sonar-web/src/main/js/apps/application-console/__tests__/ApplicationConsoleApp-test.tsx +++ b/server/sonar-web/src/main/js/apps/application-console/__tests__/ApplicationConsoleApp-test.tsx @@ -37,7 +37,7 @@ jest.mock('../../../api/application', () => ({ editApplication: jest.fn().mockResolvedValue({}) })); -jest.mock('../../../app/utils/addGlobalSuccessMessage', () => ({ default: jest.fn() })); +jest.mock('../../../app/utils/addGlobalSuccessMessage', () => jest.fn()); it('Should render correctly', async () => { expect(shallowRender()).toMatchSnapshot('Empty app'); diff --git a/server/sonar-web/src/main/js/apps/application-console/__tests__/ApplicationConsoleRender-test.tsx b/server/sonar-web/src/main/js/apps/application-console/__tests__/ApplicationConsoleRender-test.tsx index da5952a1965..234a6028c50 100644 --- a/server/sonar-web/src/main/js/apps/application-console/__tests__/ApplicationConsoleRender-test.tsx +++ b/server/sonar-web/src/main/js/apps/application-console/__tests__/ApplicationConsoleRender-test.tsx @@ -26,9 +26,7 @@ import ApplicationConsoleAppRenderer, { } from '../ApplicationConsoleAppRenderer'; import EditForm from '../EditForm'; -jest.mock('../../../app/utils/addGlobalSuccessMessage', () => ({ - default: jest.fn() -})); +jest.mock('../../../app/utils/addGlobalSuccessMessage', () => jest.fn()); it('should render correctly', () => { expect(shallowRender()).toMatchSnapshot('default'); diff --git a/server/sonar-web/src/main/js/apps/audit-logs/components/DownloadButton.tsx b/server/sonar-web/src/main/js/apps/audit-logs/components/DownloadButton.tsx index 2b9c748d033..bbe8bf9521b 100644 --- a/server/sonar-web/src/main/js/apps/audit-logs/components/DownloadButton.tsx +++ b/server/sonar-web/src/main/js/apps/audit-logs/components/DownloadButton.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import { endOfDay, startOfDay, subDays } from 'date-fns'; import * as React from 'react'; import { translate } from '../../../helpers/l10n'; diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/TaskDate.tsx b/server/sonar-web/src/main/js/apps/background-tasks/components/TaskDate.tsx index 146f2bbc3ed..fa4e077ab74 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/components/TaskDate.tsx +++ b/server/sonar-web/src/main/js/apps/background-tasks/components/TaskDate.tsx @@ -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. */ -import * as differenceInDays from 'date-fns/difference_in_days'; +import { differenceInDays } from 'date-fns'; import * as React from 'react'; import TimeFormatter from '../../../components/intl/TimeFormatter'; import { isValidDate, parseDate } from '../../../helpers/dates'; diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/TaskDay.tsx b/server/sonar-web/src/main/js/apps/background-tasks/components/TaskDay.tsx index 805c7e108be..242fa22d8d3 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/components/TaskDay.tsx +++ b/server/sonar-web/src/main/js/apps/background-tasks/components/TaskDay.tsx @@ -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. */ -import * as isSameDay from 'date-fns/is_same_day'; +import { isSameDay } from 'date-fns'; import * as React from 'react'; import DateFormatter from '../../../components/intl/DateFormatter'; import { parseDate } from '../../../helpers/dates'; diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/Tasks.tsx b/server/sonar-web/src/main/js/apps/background-tasks/components/Tasks.tsx index bc9d0898b4a..eacac47fb20 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/components/Tasks.tsx +++ b/server/sonar-web/src/main/js/apps/background-tasks/components/Tasks.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { translate } from '../../../helpers/l10n'; import { Task as ITask } from '../../../types/tasks'; diff --git a/server/sonar-web/src/main/js/apps/code/components/CodeApp.tsx b/server/sonar-web/src/main/js/apps/code/components/CodeApp.tsx index 9c8518ea8c4..9bb59ded960 100644 --- a/server/sonar-web/src/main/js/apps/code/components/CodeApp.tsx +++ b/server/sonar-web/src/main/js/apps/code/components/CodeApp.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import { Location } from 'history'; import { debounce } from 'lodash'; import * as React from 'react'; diff --git a/server/sonar-web/src/main/js/apps/code/components/Component.tsx b/server/sonar-web/src/main/js/apps/code/components/Component.tsx index d902d22e2c8..eb96e015ee8 100644 --- a/server/sonar-web/src/main/js/apps/code/components/Component.tsx +++ b/server/sonar-web/src/main/js/apps/code/components/Component.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { withScrollTo } from '../../../components/hoc/withScrollTo'; import { WorkspaceContext } from '../../../components/workspace/context'; diff --git a/server/sonar-web/src/main/js/apps/code/components/ComponentsHeader.tsx b/server/sonar-web/src/main/js/apps/code/components/ComponentsHeader.tsx index 41830122e94..f458cc98484 100644 --- a/server/sonar-web/src/main/js/apps/code/components/ComponentsHeader.tsx +++ b/server/sonar-web/src/main/js/apps/code/components/ComponentsHeader.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { translate } from '../../../helpers/l10n'; 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 e2611f72bb6..7ce6bdf12c6 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 @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { activateRule, Profile } from '../../../api/quality-profiles'; import { ResetButtonLink, SubmitButton } from '../../../components/controls/buttons'; 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 b1326f51341..52157b66998 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 @@ -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. */ -import * as key from 'keymaster'; +import key from 'keymaster'; import { keyBy } from 'lodash'; import * as React from 'react'; import { Helmet } from 'react-helmet-async'; 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 c7bcd333d74..c5af27f619f 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 @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import { orderBy, sortBy, without } from 'lodash'; import * as React from 'react'; import Tooltip from '../../../components/controls/Tooltip'; 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 b518f365076..bd968b073ab 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 @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import { sortBy } from 'lodash'; import * as React from 'react'; import { Profile } from '../../../api/quality-profiles'; diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/RuleListItem.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/RuleListItem.tsx index bc86033feed..8900d75c92b 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/RuleListItem.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/RuleListItem.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { Link } from 'react-router'; import { deactivateRule, Profile } from '../../../api/quality-profiles'; 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 bed13ccc0d4..7d1f7457ba7 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 @@ -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. */ -import * as key from 'keymaster'; +import key from 'keymaster'; import { debounce, keyBy } from 'lodash'; import * as React from 'react'; import { Helmet } from 'react-helmet-async'; diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/Breadcrumbs.tsx b/server/sonar-web/src/main/js/apps/component-measures/components/Breadcrumbs.tsx index 3e721cd65df..bdb3214d5fb 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/components/Breadcrumbs.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/components/Breadcrumbs.tsx @@ -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. */ -import * as key from 'keymaster'; +import key from 'keymaster'; import * as React from 'react'; import { getBreadcrumbs } from '../../../api/components'; import { getBranchLikeQuery, isSameBranchLike } from '../../../helpers/branch-like'; diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/LeakPeriodLegend.tsx b/server/sonar-web/src/main/js/apps/component-measures/components/LeakPeriodLegend.tsx index b221e826bed..6cadbcfe0ca 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/components/LeakPeriodLegend.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/components/LeakPeriodLegend.tsx @@ -17,8 +17,8 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import * as classNames from 'classnames'; -import * as differenceInDays from 'date-fns/difference_in_days'; +import classNames from 'classnames'; +import { differenceInDays } from 'date-fns'; import * as React from 'react'; import { InjectedIntlProps, injectIntl } from 'react-intl'; import Tooltip from '../../../components/controls/Tooltip'; diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/__tests__/LeakPeriodLegend-test.tsx b/server/sonar-web/src/main/js/apps/component-measures/components/__tests__/LeakPeriodLegend-test.tsx index 1978a195fd9..e2adbbcc61d 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/components/__tests__/LeakPeriodLegend-test.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/components/__tests__/LeakPeriodLegend-test.tsx @@ -17,13 +17,16 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import * as differenceInDays from 'date-fns/difference_in_days'; +import { differenceInDays } from 'date-fns'; import { shallow } from 'enzyme'; import * as React from 'react'; import { InjectedIntlProps } from 'react-intl'; import { LeakPeriodLegend } from '../LeakPeriodLegend'; -jest.mock('date-fns/difference_in_days', () => jest.fn().mockReturnValue(10)); +jest.mock('date-fns', () => { + const actual = jest.requireActual('date-fns'); + return { ...actual, differenceInDays: jest.fn().mockReturnValue(10) }; +}); const PROJECT = { key: 'foo', diff --git a/server/sonar-web/src/main/js/apps/component-measures/drilldown/ComponentsListRow.tsx b/server/sonar-web/src/main/js/apps/component-measures/drilldown/ComponentsListRow.tsx index c29be3db951..ea86423dc39 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/drilldown/ComponentsListRow.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/drilldown/ComponentsListRow.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { BranchLike } from '../../../types/branch-like'; import { MeasurePageView } from '../../../types/measures'; 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 8e6271ea845..fb3819160e5 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 @@ -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. */ -import * as key from 'keymaster'; +import key from 'keymaster'; import { throttle } from 'lodash'; import * as React from 'react'; import { Button } from '../../../components/controls/buttons'; diff --git a/server/sonar-web/src/main/js/apps/component-measures/sidebar/FacetMeasureValue.tsx b/server/sonar-web/src/main/js/apps/component-measures/sidebar/FacetMeasureValue.tsx index 38af9388e76..edbfc46005e 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/sidebar/FacetMeasureValue.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/sidebar/FacetMeasureValue.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import Measure from '../../../components/measure/Measure'; import { isDiffMetric } from '../../../helpers/measures'; diff --git a/server/sonar-web/src/main/js/apps/create/project/AzurePersonalAccessTokenForm.tsx b/server/sonar-web/src/main/js/apps/create/project/AzurePersonalAccessTokenForm.tsx index 0c9e026776f..e88968d8e98 100644 --- a/server/sonar-web/src/main/js/apps/create/project/AzurePersonalAccessTokenForm.tsx +++ b/server/sonar-web/src/main/js/apps/create/project/AzurePersonalAccessTokenForm.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { FormattedMessage } from 'react-intl'; import { SubmitButton } from '../../../components/controls/buttons'; diff --git a/server/sonar-web/src/main/js/apps/create/project/AzureProjectAccordion.tsx b/server/sonar-web/src/main/js/apps/create/project/AzureProjectAccordion.tsx index 27fc44d2a5d..72de55edeeb 100644 --- a/server/sonar-web/src/main/js/apps/create/project/AzureProjectAccordion.tsx +++ b/server/sonar-web/src/main/js/apps/create/project/AzureProjectAccordion.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { FormattedMessage } from 'react-intl'; import { Link } from 'react-router'; diff --git a/server/sonar-web/src/main/js/apps/create/project/BitbucketProjectAccordion.tsx b/server/sonar-web/src/main/js/apps/create/project/BitbucketProjectAccordion.tsx index 0d3f65ecdd9..95b34ccfbf9 100644 --- a/server/sonar-web/src/main/js/apps/create/project/BitbucketProjectAccordion.tsx +++ b/server/sonar-web/src/main/js/apps/create/project/BitbucketProjectAccordion.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { FormattedMessage } from 'react-intl'; import { Link } from 'react-router'; diff --git a/server/sonar-web/src/main/js/apps/create/project/CreateProjectModeSelection.tsx b/server/sonar-web/src/main/js/apps/create/project/CreateProjectModeSelection.tsx index 9542a58b5c9..506c1ac489a 100644 --- a/server/sonar-web/src/main/js/apps/create/project/CreateProjectModeSelection.tsx +++ b/server/sonar-web/src/main/js/apps/create/project/CreateProjectModeSelection.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { withAppState } from '../../../components/hoc/withAppState'; import ChevronsIcon from '../../../components/icons/ChevronsIcon'; diff --git a/server/sonar-web/src/main/js/apps/create/project/ManualProjectCreate.tsx b/server/sonar-web/src/main/js/apps/create/project/ManualProjectCreate.tsx index 78197388ac8..6a62ae59d0a 100644 --- a/server/sonar-web/src/main/js/apps/create/project/ManualProjectCreate.tsx +++ b/server/sonar-web/src/main/js/apps/create/project/ManualProjectCreate.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import { debounce } from 'lodash'; import * as React from 'react'; import { createProject, doesComponentExists } from '../../../api/components'; diff --git a/server/sonar-web/src/main/js/apps/create/project/PersonalAccessTokenForm.tsx b/server/sonar-web/src/main/js/apps/create/project/PersonalAccessTokenForm.tsx index a571ab12006..d2438c13638 100644 --- a/server/sonar-web/src/main/js/apps/create/project/PersonalAccessTokenForm.tsx +++ b/server/sonar-web/src/main/js/apps/create/project/PersonalAccessTokenForm.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { FormattedMessage } from 'react-intl'; import { diff --git a/server/sonar-web/src/main/js/apps/create/project/__tests__/AzurePersonalAccessTokenForm-test.tsx b/server/sonar-web/src/main/js/apps/create/project/__tests__/AzurePersonalAccessTokenForm-test.tsx index 430ce61f194..c74953c742f 100644 --- a/server/sonar-web/src/main/js/apps/create/project/__tests__/AzurePersonalAccessTokenForm-test.tsx +++ b/server/sonar-web/src/main/js/apps/create/project/__tests__/AzurePersonalAccessTokenForm-test.tsx @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { shallow } from 'enzyme'; -import * as React from 'react'; +import React from 'react'; import { SubmitButton } from '../../../../components/controls/buttons'; import { mockAlmSettingsInstance } from '../../../../helpers/mocks/alm-settings'; import { change, submit } from '../../../../helpers/testUtils'; diff --git a/server/sonar-web/src/main/js/apps/documentation/__tests__/pages-test.ts b/server/sonar-web/src/main/js/apps/documentation/__tests__/pages-test.ts index 7e61f661cc4..48b136593c8 100644 --- a/server/sonar-web/src/main/js/apps/documentation/__tests__/pages-test.ts +++ b/server/sonar-web/src/main/js/apps/documentation/__tests__/pages-test.ts @@ -21,17 +21,16 @@ import { filterContent, ParsedContent } from '../../../helpers/markdown'; import { mockDocumentationMarkdown } from '../../../helpers/testMocks'; -jest.mock('remark', () => ({ - default: () => ({ - parse: jest.fn().mockReturnValue({}) - }) +jest.mock('remark', () => () => ({ + parse: jest.fn().mockReturnValue({}) })); -jest.mock('unist-util-visit', () => ({ - default: (_: any, cb: (node: { type: string; value: string }) => void) => { +jest.mock( + 'unist-util-visit', + () => (_: any, cb: (node: { type: string; value: string }) => void) => { cb({ type: 'text', value: 'Text content' }); } -})); +); jest.mock('../../../helpers/markdown', () => { const markdown = jest.requireActual('../../../helpers/markdown'); diff --git a/server/sonar-web/src/main/js/apps/documentation/components/MenuBlock.tsx b/server/sonar-web/src/main/js/apps/documentation/components/MenuBlock.tsx index fb51d62654e..4891f947dc3 100644 --- a/server/sonar-web/src/main/js/apps/documentation/components/MenuBlock.tsx +++ b/server/sonar-web/src/main/js/apps/documentation/components/MenuBlock.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import { DocNavigationItem, DocsNavigationBlock } from 'Docs/@types/types'; import * as React from 'react'; import { ButtonLink } from '../../../components/controls/buttons'; diff --git a/server/sonar-web/src/main/js/apps/documentation/components/MenuItem.tsx b/server/sonar-web/src/main/js/apps/documentation/components/MenuItem.tsx index a68d1ba07c8..86ea670c415 100644 --- a/server/sonar-web/src/main/js/apps/documentation/components/MenuItem.tsx +++ b/server/sonar-web/src/main/js/apps/documentation/components/MenuItem.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { Link } from 'react-router'; import { testPathAgainstUrl } from '../navTreeUtils'; 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 22ee12b8cad..ae85ebc33fb 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 @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { Link } from 'react-router'; import { cutWords, DocumentationEntry, highlightMarks } from '../utils'; diff --git a/server/sonar-web/src/main/js/apps/documentation/components/__tests__/App-test.tsx b/server/sonar-web/src/main/js/apps/documentation/components/__tests__/App-test.tsx index 1c18bcb3437..5c2bb59ac31 100644 --- a/server/sonar-web/src/main/js/apps/documentation/components/__tests__/App-test.tsx +++ b/server/sonar-web/src/main/js/apps/documentation/components/__tests__/App-test.tsx @@ -28,28 +28,26 @@ import App from '../App'; jest.mock('../../../../components/common/ScreenPositionHelper'); -jest.mock('Docs/../static/SonarQubeNavigationTree.json', () => ({ - default: [ - { - title: 'SonarQube', - children: [ - '/lorem/ipsum/', - '/analysis/languages/csharp/', - { - title: 'Child category', - children: [ - '/lorem/ipsum/dolor', - { - title: 'Grandchild category', - children: ['/lorem/ipsum/sit'] - }, - '/lorem/ipsum/amet' - ] - } - ] - } - ] -})); +jest.mock('Docs/../static/SonarQubeNavigationTree.json', () => [ + { + title: 'SonarQube', + children: [ + '/lorem/ipsum/', + '/analysis/languages/csharp/', + { + title: 'Child category', + children: [ + '/lorem/ipsum/dolor', + { + title: 'Grandchild category', + children: ['/lorem/ipsum/sit'] + }, + '/lorem/ipsum/amet' + ] + } + ] + } +]); jest.mock('../../../../helpers/pages', () => ({ addSideBarClass: jest.fn(), @@ -70,14 +68,12 @@ jest.mock('../../../../helpers/request', () => { jest.mock('../../pages', () => { const { mockDocumentationEntry } = jest.requireActual('../../../../helpers/testMocks'); - return { - default: jest - .fn() - .mockReturnValue([ - mockDocumentationEntry(), - mockDocumentationEntry({ url: '/analysis/languages/csharp/' }) - ]) - }; + return jest + .fn() + .mockReturnValue([ + mockDocumentationEntry(), + mockDocumentationEntry({ url: '/analysis/languages/csharp/' }) + ]); }); jest.mock('../../../../api/plugins', () => ({ diff --git a/server/sonar-web/src/main/js/apps/documentation/components/__tests__/SearchResults-test.tsx b/server/sonar-web/src/main/js/apps/documentation/components/__tests__/SearchResults-test.tsx index 88d5acffaa3..cb15ab5066d 100644 --- a/server/sonar-web/src/main/js/apps/documentation/components/__tests__/SearchResults-test.tsx +++ b/server/sonar-web/src/main/js/apps/documentation/components/__tests__/SearchResults-test.tsx @@ -22,8 +22,8 @@ import lunr from 'lunr'; import * as React from 'react'; import SearchResults from '../SearchResults'; -jest.mock('lunr', () => ({ - default: jest.fn(() => ({ +jest.mock('lunr', () => + jest.fn(() => ({ search: jest.fn(() => [ { ref: 'lorem/origin', @@ -61,7 +61,7 @@ jest.mock('lunr', () => ({ } ]) })) -})); +); function createPage(title: string, relativeName: string, text = '') { return { relativeName, url: '/' + relativeName, title, navTitle: undefined, text, content: text }; diff --git a/server/sonar-web/src/main/js/apps/documentation/documentation.directory-loader.js b/server/sonar-web/src/main/js/apps/documentation/documentation.directory-loader.js index 77d077b7ff9..1e09ae66170 100644 --- a/server/sonar-web/src/main/js/apps/documentation/documentation.directory-loader.js +++ b/server/sonar-web/src/main/js/apps/documentation/documentation.directory-loader.js @@ -20,5 +20,5 @@ const path = require('path'); module.exports = { - root: path.resolve(__dirname, '../../../../../../sonar-docs/src/pages') + placeholder: true // doesn't matter, this is replaced by esbuild }; diff --git a/server/sonar-web/src/main/js/apps/documentation/pages.ts b/server/sonar-web/src/main/js/apps/documentation/pages.ts index e083f2b3dd9..47a77d52f74 100644 --- a/server/sonar-web/src/main/js/apps/documentation/pages.ts +++ b/server/sonar-web/src/main/js/apps/documentation/pages.ts @@ -20,7 +20,7 @@ import remark from 'remark'; import visit from 'unist-util-visit'; import { filterContent, ParsedContent, separateFrontMatter } from '../../helpers/markdown'; -import * as Docs from './documentation.directory-loader'; +import Docs from './documentation.directory-loader'; import { DocumentationEntry, DocumentationEntryScope } from './utils'; export default function getPages( 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 376072c762a..313a343de73 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 @@ -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. */ -import * as key from 'keymaster'; +import key from 'keymaster'; import { debounce, keyBy, omit, without } from 'lodash'; import * as React from 'react'; import { Helmet } from 'react-helmet-async'; diff --git a/server/sonar-web/src/main/js/apps/issues/components/__tests__/App-test.tsx b/server/sonar-web/src/main/js/apps/issues/components/__tests__/App-test.tsx index a86def001bb..40e99fc0392 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/__tests__/App-test.tsx +++ b/server/sonar-web/src/main/js/apps/issues/components/__tests__/App-test.tsx @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { shallow } from 'enzyme'; -import * as key from 'keymaster'; +import key from 'keymaster'; import * as React from 'react'; import handleRequiredAuthentication from '../../../../helpers/handleRequiredAuthentication'; import { KeyCodes } from '../../../../helpers/keycodes'; @@ -57,9 +57,7 @@ jest.mock('../../../../helpers/pages', () => ({ removeWhitePageClass: jest.fn() })); -jest.mock('../../../../helpers/handleRequiredAuthentication', () => ({ - default: jest.fn() -})); +jest.mock('../../../../helpers/handleRequiredAuthentication', () => jest.fn()); jest.mock('keymaster', () => { const key: any = (bindKey: string, _: string, callback: Function) => { diff --git a/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/ConciseIssueBox.tsx b/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/ConciseIssueBox.tsx index 587c64ca672..a63e8a7f159 100644 --- a/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/ConciseIssueBox.tsx +++ b/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/ConciseIssueBox.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import TypeHelper from '../../../components/shared/TypeHelper'; import ConciseIssueLocations from './ConciseIssueLocations'; 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 a39c65adc52..609f48f5e51 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 @@ -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. */ -import * as isSameDay from 'date-fns/is_same_day'; +import { isSameDay } from 'date-fns'; import { max } from 'lodash'; import * as React from 'react'; import { InjectedIntlProps, injectIntl } from 'react-intl'; 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 f28e8944a2b..e8d4f8baf0f 100644 --- a/server/sonar-web/src/main/js/apps/issues/utils.ts +++ b/server/sonar-web/src/main/js/apps/issues/utils.ts @@ -119,7 +119,7 @@ export function serializeQuery(query: Query): T.RawQuery { const filter = { assigned: query.assigned ? undefined : 'false', assignees: serializeStringArray(query.assignees), - author: query.author, + author: serializeStringArray(query.author), createdAfter: serializeDateShort(query.createdAfter), createdAt: serializeString(query.createdAt), createdBefore: serializeDateShort(query.createdBefore), diff --git a/server/sonar-web/src/main/js/apps/maintenance/components/App.tsx b/server/sonar-web/src/main/js/apps/maintenance/components/App.tsx index a676f7e2b5c..9af30c26cd3 100644 --- a/server/sonar-web/src/main/js/apps/maintenance/components/App.tsx +++ b/server/sonar-web/src/main/js/apps/maintenance/components/App.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { Helmet } from 'react-helmet-async'; import { FormattedMessage } from 'react-intl'; diff --git a/server/sonar-web/src/main/js/apps/marketplace/components/__tests__/__snapshots__/EditionBox-test.tsx.snap b/server/sonar-web/src/main/js/apps/marketplace/components/__tests__/__snapshots__/EditionBox-test.tsx.snap index 538a9f2b9ef..51c52c7ea2a 100644 --- a/server/sonar-web/src/main/js/apps/marketplace/components/__tests__/__snapshots__/EditionBox-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/marketplace/components/__tests__/__snapshots__/EditionBox-test.tsx.snap @@ -4,7 +4,9 @@ exports[`should display the edition 1`] = ` <div className="boxed-group boxed-group-inner marketplace-edition" > - <DocMarkdownBlock /> + <DocMarkdownBlock + content="test-file-stub" + /> <div className="marketplace-edition-action spacer-top" > diff --git a/server/sonar-web/src/main/js/apps/overview/branches/QualityGatePanel.tsx b/server/sonar-web/src/main/js/apps/overview/branches/QualityGatePanel.tsx index 9ca24fceeab..161e1c686eb 100644 --- a/server/sonar-web/src/main/js/apps/overview/branches/QualityGatePanel.tsx +++ b/server/sonar-web/src/main/js/apps/overview/branches/QualityGatePanel.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import HelpTooltip from '../../../components/controls/HelpTooltip'; import { Alert } from '../../../components/ui/Alert'; diff --git a/server/sonar-web/src/main/js/apps/overview/branches/__tests__/ProjectLeakPeriodInfo-test.tsx b/server/sonar-web/src/main/js/apps/overview/branches/__tests__/ProjectLeakPeriodInfo-test.tsx index 6062c7237e3..eb3a9d35711 100644 --- a/server/sonar-web/src/main/js/apps/overview/branches/__tests__/ProjectLeakPeriodInfo-test.tsx +++ b/server/sonar-web/src/main/js/apps/overview/branches/__tests__/ProjectLeakPeriodInfo-test.tsx @@ -23,7 +23,10 @@ import * as React from 'react'; import { mockPeriod } from '../../../../helpers/testMocks'; import { ProjectLeakPeriodInfo } from '../ProjectLeakPeriodInfo'; -jest.mock('date-fns/difference_in_days', () => jest.fn().mockReturnValue(10)); +jest.mock('date-fns', () => { + const actual = jest.requireActual('date-fns'); + return { ...actual, differenceInDays: jest.fn().mockReturnValue(10) }; +}); it('should render correctly for 10 days', () => { expect(shallowRender({ mode: 'days', parameter: '10' })).toMatchSnapshot(); diff --git a/server/sonar-web/src/main/js/apps/overview/components/LeakPeriodLegend.tsx b/server/sonar-web/src/main/js/apps/overview/components/LeakPeriodLegend.tsx index 25cb9953f1e..62b725b5086 100644 --- a/server/sonar-web/src/main/js/apps/overview/components/LeakPeriodLegend.tsx +++ b/server/sonar-web/src/main/js/apps/overview/components/LeakPeriodLegend.tsx @@ -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. */ -import * as differenceInDays from 'date-fns/difference_in_days'; +import { differenceInDays } from 'date-fns'; import * as React from 'react'; import { InjectedIntlProps, injectIntl } from 'react-intl'; import Tooltip from '../../../components/controls/Tooltip'; diff --git a/server/sonar-web/src/main/js/apps/overview/components/QualityGateCondition.tsx b/server/sonar-web/src/main/js/apps/overview/components/QualityGateCondition.tsx index ee795179407..8fc7bd9740a 100644 --- a/server/sonar-web/src/main/js/apps/overview/components/QualityGateCondition.tsx +++ b/server/sonar-web/src/main/js/apps/overview/components/QualityGateCondition.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { Link } from 'react-router'; import IssueTypeIcon from '../../../components/icons/IssueTypeIcon'; diff --git a/server/sonar-web/src/main/js/apps/overview/components/__tests__/LeakPeriodLegend-test.tsx b/server/sonar-web/src/main/js/apps/overview/components/__tests__/LeakPeriodLegend-test.tsx index 995f0027993..b1ee6be8e1e 100644 --- a/server/sonar-web/src/main/js/apps/overview/components/__tests__/LeakPeriodLegend-test.tsx +++ b/server/sonar-web/src/main/js/apps/overview/components/__tests__/LeakPeriodLegend-test.tsx @@ -17,13 +17,16 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import * as differenceInDays from 'date-fns/difference_in_days'; +import { differenceInDays } from 'date-fns'; import { shallow } from 'enzyme'; import * as React from 'react'; import { InjectedIntlProps } from 'react-intl'; import { LeakPeriodLegend } from '../LeakPeriodLegend'; -jest.mock('date-fns/difference_in_days', () => jest.fn().mockReturnValue(10)); +jest.mock('date-fns', () => { + const actual = jest.requireActual('date-fns'); + return { ...actual, differenceInDays: jest.fn().mockReturnValue(10) }; +}); it('10 days', () => { expect(getWrapper({ mode: 'days', parameter: '10' })).toMatchSnapshot(); diff --git a/server/sonar-web/src/main/js/apps/overview/pullRequests/AfterMergeEstimate.tsx b/server/sonar-web/src/main/js/apps/overview/pullRequests/AfterMergeEstimate.tsx index b8700b07878..333f4947b1e 100644 --- a/server/sonar-web/src/main/js/apps/overview/pullRequests/AfterMergeEstimate.tsx +++ b/server/sonar-web/src/main/js/apps/overview/pullRequests/AfterMergeEstimate.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { translate } from '../../../helpers/l10n'; import { findMeasure, formatMeasure } from '../../../helpers/measures'; diff --git a/server/sonar-web/src/main/js/apps/overview/pullRequests/LargeQualityGateBadge.tsx b/server/sonar-web/src/main/js/apps/overview/pullRequests/LargeQualityGateBadge.tsx index 83296254c49..307c163b893 100644 --- a/server/sonar-web/src/main/js/apps/overview/pullRequests/LargeQualityGateBadge.tsx +++ b/server/sonar-web/src/main/js/apps/overview/pullRequests/LargeQualityGateBadge.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { FormattedMessage } from 'react-intl'; import { Link } from 'react-router'; diff --git a/server/sonar-web/src/main/js/apps/overview/pullRequests/PullRequestOverview.tsx b/server/sonar-web/src/main/js/apps/overview/pullRequests/PullRequestOverview.tsx index b009e4eb519..8c542df49e1 100644 --- a/server/sonar-web/src/main/js/apps/overview/pullRequests/PullRequestOverview.tsx +++ b/server/sonar-web/src/main/js/apps/overview/pullRequests/PullRequestOverview.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import { differenceBy, uniq } from 'lodash'; import * as React from 'react'; import { connect } from 'react-redux'; diff --git a/server/sonar-web/src/main/js/apps/permissions/shared/components/PermissionCell.tsx b/server/sonar-web/src/main/js/apps/permissions/shared/components/PermissionCell.tsx index bd685933967..66d667f147b 100644 --- a/server/sonar-web/src/main/js/apps/permissions/shared/components/PermissionCell.tsx +++ b/server/sonar-web/src/main/js/apps/permissions/shared/components/PermissionCell.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import Checkbox from '../../../../components/controls/Checkbox'; import { isPermissionDefinitionGroup } from '../../utils'; diff --git a/server/sonar-web/src/main/js/apps/permissions/shared/components/PermissionHeader.tsx b/server/sonar-web/src/main/js/apps/permissions/shared/components/PermissionHeader.tsx index 4e749d59660..e0012f41af1 100644 --- a/server/sonar-web/src/main/js/apps/permissions/shared/components/PermissionHeader.tsx +++ b/server/sonar-web/src/main/js/apps/permissions/shared/components/PermissionHeader.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import InstanceMessage from '../../../../components/common/InstanceMessage'; import HelpTooltip from '../../../../components/controls/HelpTooltip'; diff --git a/server/sonar-web/src/main/js/apps/portfolio/components/__tests__/App-test.tsx b/server/sonar-web/src/main/js/apps/portfolio/components/__tests__/App-test.tsx index e7b4a98f350..aa314271f72 100644 --- a/server/sonar-web/src/main/js/apps/portfolio/components/__tests__/App-test.tsx +++ b/server/sonar-web/src/main/js/apps/portfolio/components/__tests__/App-test.tsx @@ -34,9 +34,7 @@ import { ComponentQualifier } from '../../../../types/component'; import { App } from '../App'; import UnsubscribeEmailModal from '../UnsubscribeEmailModal'; -jest.mock('../../../../helpers/handleRequiredAuthentication', () => ({ - default: jest.fn() -})); +jest.mock('../../../../helpers/handleRequiredAuthentication', () => jest.fn()); jest.mock('../../../../api/measures', () => ({ getMeasures: jest.fn().mockResolvedValue([]) diff --git a/server/sonar-web/src/main/js/apps/projectActivity/__tests__/utils-test.ts b/server/sonar-web/src/main/js/apps/projectActivity/__tests__/utils-test.ts index 0b2cd01534d..9ca1ed335ef 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/__tests__/utils-test.ts +++ b/server/sonar-web/src/main/js/apps/projectActivity/__tests__/utils-test.ts @@ -22,13 +22,17 @@ import * as dates from '../../../helpers/dates'; import { GraphType } from '../../../types/project-activity'; import * as utils from '../utils'; -jest.mock('date-fns/start_of_day', () => - jest.fn(date => { - const startDay = new Date(date); - startDay.setUTCHours(0, 0, 0, 0); - return startDay; - }) -); +jest.mock('date-fns', () => { + const actual = jest.requireActual('date-fns'); + return { + ...actual, + startOfDay: jest.fn(date => { + const startDay = new Date(date); + startDay.setUTCHours(0, 0, 0, 0); + return startDay; + }) + }; +}); const ANALYSES = [ { diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAnalysesList.tsx b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAnalysesList.tsx index 1fbbb071979..7354797aef6 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAnalysesList.tsx +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAnalysesList.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import { isEqual } from 'date-fns'; import { throttle } from 'lodash'; import * as React from 'react'; diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAnalysis.tsx b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAnalysis.tsx index f6711f19bb0..9c8b6df8e11 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAnalysis.tsx +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAnalysis.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import ActionsDropdown, { ActionsDropdownDivider, diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityPageHeader.tsx b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityPageHeader.tsx index 149d4a4f174..328a5d1de1d 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityPageHeader.tsx +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityPageHeader.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import Select from '../../../components/controls/Select'; import { translate } from '../../../helpers/l10n'; diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/ProjectActivityAnalysesList-test.tsx b/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/ProjectActivityAnalysesList-test.tsx index 097909c9223..885f89c12b7 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/ProjectActivityAnalysesList-test.tsx +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/ProjectActivityAnalysesList-test.tsx @@ -25,10 +25,16 @@ import { mockParsedAnalysis } from '../../../../helpers/testMocks'; import { ComponentQualifier } from '../../../../types/component'; import ProjectActivityAnalysesList from '../ProjectActivityAnalysesList'; -jest.mock('date-fns/start_of_day', () => (date: Date) => { - const startDay = new Date(date); - startDay.setUTCHours(0, 0, 0, 0); - return startDay; +jest.mock('date-fns', () => { + const actual = jest.requireActual('date-fns'); + return { + ...actual, + startOfDay: (date: Date) => { + const startDay = new Date(date); + startDay.setUTCHours(0, 0, 0, 0); + return startDay; + } + }; }); jest.mock('../../../../helpers/dates', () => { 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 d642d7484b6..86dae218145 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/utils.ts +++ b/server/sonar-web/src/main/js/apps/projectActivity/utils.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. */ -import * as startOfDay from 'date-fns/start_of_day'; +import { startOfDay } from 'date-fns'; import { isEqual } from 'lodash'; import { DEFAULT_GRAPH } from '../../components/activity-graph/utils'; import { parseDate } from '../../helpers/dates'; diff --git a/server/sonar-web/src/main/js/apps/projectBaseline/components/App.tsx b/server/sonar-web/src/main/js/apps/projectBaseline/components/App.tsx index a840de4a57e..3a751aecc1f 100644 --- a/server/sonar-web/src/main/js/apps/projectBaseline/components/App.tsx +++ b/server/sonar-web/src/main/js/apps/projectBaseline/components/App.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import { debounce } from 'lodash'; import * as React from 'react'; import { getNewCodePeriod, resetNewCodePeriod, setNewCodePeriod } from '../../../api/newCodePeriod'; diff --git a/server/sonar-web/src/main/js/apps/projectBaseline/components/BranchAnalysisListRenderer.tsx b/server/sonar-web/src/main/js/apps/projectBaseline/components/BranchAnalysisListRenderer.tsx index c22fa3fa8ed..b5b9d4eeb4a 100644 --- a/server/sonar-web/src/main/js/apps/projectBaseline/components/BranchAnalysisListRenderer.tsx +++ b/server/sonar-web/src/main/js/apps/projectBaseline/components/BranchAnalysisListRenderer.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import Radio from '../../../components/controls/Radio'; import Select from '../../../components/controls/Select'; diff --git a/server/sonar-web/src/main/js/apps/projectBaseline/components/ProjectBaselineSelector.tsx b/server/sonar-web/src/main/js/apps/projectBaseline/components/ProjectBaselineSelector.tsx index 6d9e74d3a6f..c001b46f4c1 100644 --- a/server/sonar-web/src/main/js/apps/projectBaseline/components/ProjectBaselineSelector.tsx +++ b/server/sonar-web/src/main/js/apps/projectBaseline/components/ProjectBaselineSelector.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { ResetButtonLink, SubmitButton } from '../../../components/controls/buttons'; import Radio from '../../../components/controls/Radio'; diff --git a/server/sonar-web/src/main/js/apps/projectBaseline/components/__tests__/BranchAnalysisList-test.tsx b/server/sonar-web/src/main/js/apps/projectBaseline/components/__tests__/BranchAnalysisList-test.tsx index 3b9941a5ca4..c5eaa6c6d81 100644 --- a/server/sonar-web/src/main/js/apps/projectBaseline/components/__tests__/BranchAnalysisList-test.tsx +++ b/server/sonar-web/src/main/js/apps/projectBaseline/components/__tests__/BranchAnalysisList-test.tsx @@ -26,11 +26,15 @@ import { mockAnalysis, mockAnalysisEvent } from '../../../../helpers/testMocks'; import { waitAndUpdate } from '../../../../helpers/testUtils'; import BranchAnalysisList from '../BranchAnalysisList'; -jest.mock('date-fns/start_of_day', () => - jest.fn(() => ({ - getTime: () => '1488322800000' // 2017-03-02 - })) -); +jest.mock('date-fns', () => { + const actual = jest.requireActual('date-fns'); + return { + ...actual, + startOfDay: jest.fn(() => ({ + getTime: () => '1488322800000' // 2017-03-02 + })) + }; +}); jest.mock('../../../../helpers/dates', () => ({ parseDate: jest.fn().mockReturnValue('2017-03-02'), diff --git a/server/sonar-web/src/main/js/apps/projectBaseline/components/__tests__/BranchAnalysisListRenderer-test.tsx b/server/sonar-web/src/main/js/apps/projectBaseline/components/__tests__/BranchAnalysisListRenderer-test.tsx index 9250748d74a..4b06483d612 100644 --- a/server/sonar-web/src/main/js/apps/projectBaseline/components/__tests__/BranchAnalysisListRenderer-test.tsx +++ b/server/sonar-web/src/main/js/apps/projectBaseline/components/__tests__/BranchAnalysisListRenderer-test.tsx @@ -24,10 +24,16 @@ import BranchAnalysisListRenderer, { BranchAnalysisListRendererProps } from '../BranchAnalysisListRenderer'; -jest.mock('date-fns/start_of_day', () => (date: Date) => { - const startDay = new Date(date); - startDay.setUTCHours(0, 0, 0, 0); - return startDay; +jest.mock('date-fns', () => { + const actual = jest.requireActual('date-fns'); + return { + ...actual, + startOfDay: (date: Date) => { + const startDay = new Date(date); + startDay.setUTCHours(0, 0, 0, 0); + return startDay; + } + }; }); jest.mock('../../../../helpers/dates', () => { diff --git a/server/sonar-web/src/main/js/apps/projectQualityGate/__tests__/ProjectQualityGateApp-test.tsx b/server/sonar-web/src/main/js/apps/projectQualityGate/__tests__/ProjectQualityGateApp-test.tsx index 7d3b7248ea4..014a50babb7 100644 --- a/server/sonar-web/src/main/js/apps/projectQualityGate/__tests__/ProjectQualityGateApp-test.tsx +++ b/server/sonar-web/src/main/js/apps/projectQualityGate/__tests__/ProjectQualityGateApp-test.tsx @@ -62,13 +62,9 @@ jest.mock('../../../api/quality-gates', () => { }; }); -jest.mock('../../../app/utils/addGlobalSuccessMessage', () => ({ - default: jest.fn() -})); +jest.mock('../../../app/utils/addGlobalSuccessMessage', () => jest.fn()); -jest.mock('../../../app/utils/handleRequiredAuthorization', () => ({ - default: jest.fn() -})); +jest.mock('../../../app/utils/handleRequiredAuthorization', () => jest.fn()); beforeEach(jest.clearAllMocks); diff --git a/server/sonar-web/src/main/js/apps/projectQualityProfiles/__tests__/ProjectQualityProfilesApp-test.tsx b/server/sonar-web/src/main/js/apps/projectQualityProfiles/__tests__/ProjectQualityProfilesApp-test.tsx index 5b0bc461f05..4cabfdd700b 100644 --- a/server/sonar-web/src/main/js/apps/projectQualityProfiles/__tests__/ProjectQualityProfilesApp-test.tsx +++ b/server/sonar-web/src/main/js/apps/projectQualityProfiles/__tests__/ProjectQualityProfilesApp-test.tsx @@ -71,13 +71,9 @@ jest.mock('../../../api/quality-profiles', () => { }; }); -jest.mock('../../../app/utils/addGlobalSuccessMessage', () => ({ - default: jest.fn() -})); +jest.mock('../../../app/utils/addGlobalSuccessMessage', () => jest.fn()); -jest.mock('../../../app/utils/handleRequiredAuthorization', () => ({ - default: jest.fn() -})); +jest.mock('../../../app/utils/handleRequiredAuthorization', () => jest.fn()); beforeEach(jest.clearAllMocks); diff --git a/server/sonar-web/src/main/js/apps/projects/components/PageHeader.tsx b/server/sonar-web/src/main/js/apps/projects/components/PageHeader.tsx index b2980207975..8d9e1fbcbc8 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/PageHeader.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/PageHeader.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import HomePageSelect from '../../../components/controls/HomePageSelect'; import Tooltip from '../../../components/controls/Tooltip'; diff --git a/server/sonar-web/src/main/js/apps/projects/components/ProjectsSortingSelectOption.tsx b/server/sonar-web/src/main/js/apps/projects/components/ProjectsSortingSelectOption.tsx index 95761531015..f7f1615f3c6 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/ProjectsSortingSelectOption.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/ProjectsSortingSelectOption.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; export interface Option { diff --git a/server/sonar-web/src/main/js/apps/projects/components/__tests__/AllProjects-test.tsx b/server/sonar-web/src/main/js/apps/projects/components/__tests__/AllProjects-test.tsx index e149a05897a..6709060a2ff 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/__tests__/AllProjects-test.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/__tests__/AllProjects-test.tsx @@ -28,26 +28,32 @@ import { LS_PROJECTS_VISUALIZATION } from '../AllProjects'; -jest.mock('../ProjectsList', () => ({ - // eslint-disable-next-line - default: function ProjectsList() { - return null; - } -})); - -jest.mock('../PageHeader', () => ({ - // eslint-disable-next-line - default: function PageHeader() { - return null; - } -})); - -jest.mock('../PageSidebar', () => ({ - // eslint-disable-next-line - default: function PageSidebar() { - return null; - } -})); +jest.mock( + '../ProjectsList', + () => + // eslint-disable-next-line + function ProjectsList() { + return null; + } +); + +jest.mock( + '../PageHeader', + () => + // eslint-disable-next-line + function PageHeader() { + return null; + } +); + +jest.mock( + '../PageSidebar', + () => + // eslint-disable-next-line + function PageSidebar() { + return null; + } +); jest.mock('../../utils', () => { const utils = jest.requireActual('../../utils'); diff --git a/server/sonar-web/src/main/js/apps/projects/components/__tests__/DefaultPageSelector-test.tsx b/server/sonar-web/src/main/js/apps/projects/components/__tests__/DefaultPageSelector-test.tsx index e0ac85e5c84..01a5c463cd4 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/__tests__/DefaultPageSelector-test.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/__tests__/DefaultPageSelector-test.tsx @@ -31,12 +31,14 @@ import { waitAndUpdate } from '../../../../helpers/testUtils'; import { hasGlobalPermission } from '../../../../helpers/users'; import { DefaultPageSelector } from '../DefaultPageSelector'; -jest.mock('../AllProjectsContainer', () => ({ - // eslint-disable-next-line - default: function AllProjectsContainer() { - return null; - } -})); +jest.mock( + '../AllProjectsContainer', + () => + // eslint-disable-next-line + function AllProjectsContainer() { + return null; + } +); jest.mock('../../../../helpers/storage', () => ({ get: jest.fn().mockReturnValue(undefined) diff --git a/server/sonar-web/src/main/js/apps/projects/components/project-card/ProjectCard.tsx b/server/sonar-web/src/main/js/apps/projects/components/project-card/ProjectCard.tsx index 7cde29df645..96758862825 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/project-card/ProjectCard.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/project-card/ProjectCard.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { FormattedMessage } from 'react-intl'; import { Link } from 'react-router'; diff --git a/server/sonar-web/src/main/js/apps/projects/components/project-card/ProjectCardMeasure.tsx b/server/sonar-web/src/main/js/apps/projects/components/project-card/ProjectCardMeasure.tsx index d103da690ac..8270a88c314 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/project-card/ProjectCardMeasure.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/project-card/ProjectCardMeasure.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import IssueTypeIcon from '../../../../components/icons/IssueTypeIcon'; diff --git a/server/sonar-web/src/main/js/apps/projects/components/project-card/ProjectCardMeasures.tsx b/server/sonar-web/src/main/js/apps/projects/components/project-card/ProjectCardMeasures.tsx index b9d1c682865..1694baf44b1 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/project-card/ProjectCardMeasures.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/project-card/ProjectCardMeasures.tsx @@ -17,8 +17,8 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import * as classNames from 'classnames'; -import * as difference from 'date-fns/difference_in_milliseconds'; +import classNames from 'classnames'; +import { differenceInMilliseconds } from 'date-fns'; import * as React from 'react'; import DateTimeFormatter from '../../../../components/intl/DateTimeFormatter'; import Measure from '../../../../components/measure/Measure'; @@ -164,7 +164,9 @@ export default function ProjectCardMeasures(props: ProjectCardMeasuresProps) { ); } - const newCodeTimespan = newCodeStartingDate ? difference(Date.now(), newCodeStartingDate) : 0; + const newCodeTimespan = newCodeStartingDate + ? differenceInMilliseconds(Date.now(), newCodeStartingDate) + : 0; const measureList = [ ...renderRatings(props), diff --git a/server/sonar-web/src/main/js/apps/projects/components/project-card/__tests__/ProjectCardMeasures-test.tsx b/server/sonar-web/src/main/js/apps/projects/components/project-card/__tests__/ProjectCardMeasures-test.tsx index b66a8d67aab..788f567050f 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/project-card/__tests__/ProjectCardMeasures-test.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/project-card/__tests__/ProjectCardMeasures-test.tsx @@ -24,10 +24,9 @@ import { ComponentQualifier } from '../../../../../types/component'; import { MetricKey } from '../../../../../types/metrics'; import ProjectCardMeasures, { ProjectCardMeasuresProps } from '../ProjectCardMeasures'; -jest.mock( - 'date-fns/difference_in_milliseconds', - () => () => 1000 * 60 * 60 * 24 * 30 * 8 // ~ 8 months -); +jest.mock('date-fns', () => ({ + differenceInMilliseconds: () => 1000 * 60 * 60 * 24 * 30 * 8 // ~ 8 months +})); describe('Overall measures', () => { it('should be rendered properly', () => { 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 150a78d6cb8..85a15f0e7b5 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 @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { translate } from '../../../helpers/l10n'; import { formatMeasure } from '../../../helpers/measures'; diff --git a/server/sonar-web/src/main/js/apps/projectsManagement/CreateProjectForm.tsx b/server/sonar-web/src/main/js/apps/projectsManagement/CreateProjectForm.tsx index eeb7e424efe..b9b7f1aa40c 100644 --- a/server/sonar-web/src/main/js/apps/projectsManagement/CreateProjectForm.tsx +++ b/server/sonar-web/src/main/js/apps/projectsManagement/CreateProjectForm.tsx @@ -65,12 +65,12 @@ export default class CreateProjectForm extends React.PureComponent<Props, State> } componentDidUpdate() { - // wrap with `setImmediate` because of https://github.com/reactjs/react-modal/issues/338 - setImmediate(() => { + // wrap with `setTimeout` because of https://github.com/reactjs/react-modal/issues/338 + setTimeout(() => { if (this.closeButton) { this.closeButton.focus(); } - }); + }, 0); } componentWillUnmount() { diff --git a/server/sonar-web/src/main/js/apps/projectsManagement/Projects.tsx b/server/sonar-web/src/main/js/apps/projectsManagement/Projects.tsx index 60a2ed2f579..a5b575c8bae 100644 --- a/server/sonar-web/src/main/js/apps/projectsManagement/Projects.tsx +++ b/server/sonar-web/src/main/js/apps/projectsManagement/Projects.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { Project } from '../../api/components'; import { translate } from '../../helpers/l10n'; diff --git a/server/sonar-web/src/main/js/apps/quality-gates/__tests__/utils-test.ts b/server/sonar-web/src/main/js/apps/quality-gates/__tests__/utils-test.ts index b2aa80c52cf..e55e77c1866 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/__tests__/utils-test.ts +++ b/server/sonar-web/src/main/js/apps/quality-gates/__tests__/utils-test.ts @@ -24,14 +24,12 @@ jest.mock('../../../store/rootReducer', () => ({ getMetricByKey: (store: any, key: string) => store[key] })); -jest.mock('../../../app/utils/getStore', () => ({ - default: () => ({ - getState: () => ({ - bugs: mockMetric({ key: 'bugs', name: 'Bugs' }), - existing_metric: mockMetric(), - new_maintainability_rating: mockMetric(), - sqale_rating: mockMetric({ key: 'sqale_rating', name: 'Maintainability Rating' }) - }) +jest.mock('../../../app/utils/getStore', () => () => ({ + getState: () => ({ + bugs: mockMetric({ key: 'bugs', name: 'Bugs' }), + existing_metric: mockMetric(), + new_maintainability_rating: mockMetric(), + sqale_rating: mockMetric({ key: 'sqale_rating', name: 'Maintainability Rating' }) }) })); diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/BuiltInQualityGateBadge.tsx b/server/sonar-web/src/main/js/apps/quality-gates/components/BuiltInQualityGateBadge.tsx index 948c81a73f6..ca42dbaeb9e 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/BuiltInQualityGateBadge.tsx +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/BuiltInQualityGateBadge.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import Tooltip from '../../../components/controls/Tooltip'; import { translate } from '../../../helpers/l10n'; diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/Condition.tsx b/server/sonar-web/src/main/js/apps/quality-gates/components/Condition.tsx index 313ff3af985..c03a1bc871f 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/Condition.tsx +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/Condition.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { deleteCondition } from '../../../api/quality-gates'; import { DeleteButton, EditButton } from '../../../components/controls/buttons'; diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/changelog/Changelog.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/changelog/Changelog.tsx index 4805da105c8..e51182702bc 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/changelog/Changelog.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/changelog/Changelog.tsx @@ -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. */ -import * as isSameMinute from 'date-fns/is_same_minute'; +import { isSameMinute } from 'date-fns'; import { sortBy } from 'lodash'; import * as React from 'react'; import { Link } from 'react-router'; diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/components/BuiltInQualityProfileBadge.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/components/BuiltInQualityProfileBadge.tsx index 0654a37825a..d8252cee89d 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/components/BuiltInQualityProfileBadge.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/components/BuiltInQualityProfileBadge.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import Tooltip from '../../../components/controls/Tooltip'; import { translate } from '../../../helpers/l10n'; diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileInheritance.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileInheritance.tsx index ad15bdf407e..1ff81921b64 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileInheritance.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileInheritance.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { getProfileInheritance } from '../../../api/quality-profiles'; import { Button } from '../../../components/controls/buttons'; diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileInheritanceBox.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileInheritanceBox.tsx index 341904871ae..d3fad78f1d1 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileInheritanceBox.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileInheritanceBox.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import HelpTooltip from '../../../components/controls/HelpTooltip'; import { translate, translateWithParameters } from '../../../helpers/l10n'; diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/utils.ts b/server/sonar-web/src/main/js/apps/quality-profiles/utils.ts index cc8ddea8634..5f0e2e02679 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/utils.ts +++ b/server/sonar-web/src/main/js/apps/quality-profiles/utils.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. */ -import * as differenceInYears from 'date-fns/difference_in_years'; +import { differenceInYears } from 'date-fns'; import { sortBy } from 'lodash'; import { Profile as BaseProfile } from '../../api/quality-profiles'; import { isValidDate, parseDate } from '../../helpers/dates'; diff --git a/server/sonar-web/src/main/js/apps/security-hotspots/SecurityHotspotsApp.tsx b/server/sonar-web/src/main/js/apps/security-hotspots/SecurityHotspotsApp.tsx index 1a91178d9b5..12a879b338e 100644 --- a/server/sonar-web/src/main/js/apps/security-hotspots/SecurityHotspotsApp.tsx +++ b/server/sonar-web/src/main/js/apps/security-hotspots/SecurityHotspotsApp.tsx @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { Location } from 'history'; -import * as key from 'keymaster'; +import key from 'keymaster'; import { flatMap, range } from 'lodash'; import * as React from 'react'; import { connect } from 'react-redux'; diff --git a/server/sonar-web/src/main/js/apps/security-hotspots/__tests__/SecurityHotspotsAppRenderer-test.tsx b/server/sonar-web/src/main/js/apps/security-hotspots/__tests__/SecurityHotspotsAppRenderer-test.tsx index 1eea18597c5..0886b8c486f 100644 --- a/server/sonar-web/src/main/js/apps/security-hotspots/__tests__/SecurityHotspotsAppRenderer-test.tsx +++ b/server/sonar-web/src/main/js/apps/security-hotspots/__tests__/SecurityHotspotsAppRenderer-test.tsx @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { shallow } from 'enzyme'; -import * as React from 'react'; +import React from 'react'; import ScreenPositionHelper from '../../../components/common/ScreenPositionHelper'; import { mockComponent } from '../../../helpers/mocks/component'; import { mockRawHotspot, mockStandards } from '../../../helpers/mocks/security-hotspots'; diff --git a/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotCategory.tsx b/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotCategory.tsx index 2d08d7d9a04..92c1ff1fe2e 100644 --- a/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotCategory.tsx +++ b/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotCategory.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import ChevronDownIcon from '../../../components/icons/ChevronDownIcon'; import ChevronUpIcon from '../../../components/icons/ChevronUpIcon'; diff --git a/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotList.tsx b/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotList.tsx index f4631ea1018..3f73800926e 100644 --- a/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotList.tsx +++ b/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotList.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import { groupBy } from 'lodash'; import * as React from 'react'; import ListFooter from '../../../components/controls/ListFooter'; diff --git a/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotListItem.tsx b/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotListItem.tsx index 1ca23f4a7f2..329d2c3895e 100644 --- a/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotListItem.tsx +++ b/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotListItem.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { translate } from '../../../helpers/l10n'; import { RawHotspot } from '../../../types/security-hotspots'; diff --git a/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotReviewHistory.tsx b/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotReviewHistory.tsx index e3cf11a8a23..0002ab9bc60 100644 --- a/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotReviewHistory.tsx +++ b/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotReviewHistory.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { Button, ButtonLink, DeleteButton, EditButton } from '../../../components/controls/buttons'; import Dropdown, { DropdownOverlay } from '../../../components/controls/Dropdown'; diff --git a/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotViewerRenderer.tsx b/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotViewerRenderer.tsx index 35231c6a120..8b0e0a1bf3c 100644 --- a/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotViewerRenderer.tsx +++ b/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotViewerRenderer.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { Link } from 'react-router'; import { Button } from '../../../components/controls/buttons'; diff --git a/server/sonar-web/src/main/js/apps/security-hotspots/components/StatusUpdateSuccessModal.tsx b/server/sonar-web/src/main/js/apps/security-hotspots/components/StatusUpdateSuccessModal.tsx index 5af63885f06..4eb13b07bba 100644 --- a/server/sonar-web/src/main/js/apps/security-hotspots/components/StatusUpdateSuccessModal.tsx +++ b/server/sonar-web/src/main/js/apps/security-hotspots/components/StatusUpdateSuccessModal.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { FormattedMessage } from 'react-intl'; import { Button, ButtonLink } from '../../../components/controls/buttons'; diff --git a/server/sonar-web/src/main/js/apps/security-hotspots/components/__tests__/HotspotReviewHistory-test.tsx b/server/sonar-web/src/main/js/apps/security-hotspots/components/__tests__/HotspotReviewHistory-test.tsx index 8eda5958c98..0402ce40803 100644 --- a/server/sonar-web/src/main/js/apps/security-hotspots/components/__tests__/HotspotReviewHistory-test.tsx +++ b/server/sonar-web/src/main/js/apps/security-hotspots/components/__tests__/HotspotReviewHistory-test.tsx @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { shallow } from 'enzyme'; -import * as React from 'react'; +import React from 'react'; import { Button, EditButton } from '../../../../components/controls/buttons'; import Dropdown, { DropdownOverlay } from '../../../../components/controls/Dropdown'; import Toggler from '../../../../components/controls/Toggler'; diff --git a/server/sonar-web/src/main/js/apps/security-hotspots/components/assignee/AssigneeSelectionRenderer.tsx b/server/sonar-web/src/main/js/apps/security-hotspots/components/assignee/AssigneeSelectionRenderer.tsx index 51f06bf170a..a7add0ef13e 100644 --- a/server/sonar-web/src/main/js/apps/security-hotspots/components/assignee/AssigneeSelectionRenderer.tsx +++ b/server/sonar-web/src/main/js/apps/security-hotspots/components/assignee/AssigneeSelectionRenderer.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { DropdownOverlay } from '../../../../components/controls/Dropdown'; import SearchBox from '../../../../components/controls/SearchBox'; diff --git a/server/sonar-web/src/main/js/apps/security-hotspots/components/assignee/__tests__/Assignee-test.tsx b/server/sonar-web/src/main/js/apps/security-hotspots/components/assignee/__tests__/Assignee-test.tsx index 1228c2457c3..ce18db2a847 100644 --- a/server/sonar-web/src/main/js/apps/security-hotspots/components/assignee/__tests__/Assignee-test.tsx +++ b/server/sonar-web/src/main/js/apps/security-hotspots/components/assignee/__tests__/Assignee-test.tsx @@ -32,9 +32,7 @@ jest.mock('../../../../../api/security-hotspots', () => ({ assignSecurityHotspot: jest.fn() })); -jest.mock('../../../../../app/utils/addGlobalSuccessMessage', () => ({ - default: jest.fn() -})); +jest.mock('../../../../../app/utils/addGlobalSuccessMessage', () => jest.fn()); it('should render correctly', () => { expect(shallowRender()).toMatchSnapshot(); diff --git a/server/sonar-web/src/main/js/apps/security-hotspots/components/status/Status.tsx b/server/sonar-web/src/main/js/apps/security-hotspots/components/status/Status.tsx index a174ee4943b..689eb93c302 100644 --- a/server/sonar-web/src/main/js/apps/security-hotspots/components/status/Status.tsx +++ b/server/sonar-web/src/main/js/apps/security-hotspots/components/status/Status.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { Button } from '../../../../components/controls/buttons'; import { DropdownOverlay } from '../../../../components/controls/Dropdown'; diff --git a/server/sonar-web/src/main/js/apps/sessions/components/OAuthProviders.tsx b/server/sonar-web/src/main/js/apps/sessions/components/OAuthProviders.tsx index 8e8ee8f8303..4b773abb37d 100644 --- a/server/sonar-web/src/main/js/apps/sessions/components/OAuthProviders.tsx +++ b/server/sonar-web/src/main/js/apps/sessions/components/OAuthProviders.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import HelpTooltip from '../../../components/controls/HelpTooltip'; import IdentityProviderLink from '../../../components/controls/IdentityProviderLink'; diff --git a/server/sonar-web/src/main/js/apps/settings/components/AllCategoriesList.tsx b/server/sonar-web/src/main/js/apps/settings/components/AllCategoriesList.tsx index 00d96a02c90..70d39c40770 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/AllCategoriesList.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/AllCategoriesList.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import { sortBy } from 'lodash'; import * as React from 'react'; import { connect } from 'react-redux'; diff --git a/server/sonar-web/src/main/js/apps/settings/components/PageHeader.tsx b/server/sonar-web/src/main/js/apps/settings/components/PageHeader.tsx index 75234993ac1..b6052ab4c85 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/PageHeader.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/PageHeader.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import InstanceMessage from '../../../components/common/InstanceMessage'; import { translate } from '../../../helpers/l10n'; diff --git a/server/sonar-web/src/main/js/apps/settings/components/SettingsSearchRenderer.tsx b/server/sonar-web/src/main/js/apps/settings/components/SettingsSearchRenderer.tsx index c52febbcb5c..38d72710fbc 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/SettingsSearchRenderer.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/SettingsSearchRenderer.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { Link } from 'react-router'; import { DropdownOverlay } from '../../../components/controls/Dropdown'; diff --git a/server/sonar-web/src/main/js/apps/settings/components/__tests__/SettingsSearch-test.tsx b/server/sonar-web/src/main/js/apps/settings/components/__tests__/SettingsSearch-test.tsx index 7ad7a845d6f..a29b3db703e 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/__tests__/SettingsSearch-test.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/__tests__/SettingsSearch-test.tsx @@ -24,8 +24,8 @@ import { mockRouter } from '../../../../helpers/testMocks'; import { mockEvent, waitAndUpdate } from '../../../../helpers/testUtils'; import { SettingsSearch } from '../SettingsSearch'; -jest.mock('lunr', () => ({ - default: jest.fn(() => ({ +jest.mock('lunr', () => + jest.fn(() => ({ search: jest.fn(() => [ { ref: 'foo' @@ -35,7 +35,7 @@ jest.mock('lunr', () => ({ } ]) })) -})); +); describe('instance', () => { const router = mockRouter(); diff --git a/server/sonar-web/src/main/js/apps/settings/components/__tests__/SettingsSearchRenderer-test.tsx b/server/sonar-web/src/main/js/apps/settings/components/__tests__/SettingsSearchRenderer-test.tsx index 9864135ab3f..af73a6e8720 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/__tests__/SettingsSearchRenderer-test.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/__tests__/SettingsSearchRenderer-test.tsx @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { shallow } from 'enzyme'; -import * as React from 'react'; +import React from 'react'; import { mockDefinition } from '../../../../helpers/mocks/settings'; import { scrollToElement } from '../../../../helpers/scrolling'; import SettingsSearchRenderer, { SettingsSearchRendererProps } from '../SettingsSearchRenderer'; diff --git a/server/sonar-web/src/main/js/apps/settings/components/inputs/SimpleInput.tsx b/server/sonar-web/src/main/js/apps/settings/components/inputs/SimpleInput.tsx index 2c5df6a506f..31ad1d08118 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/inputs/SimpleInput.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/inputs/SimpleInput.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { DefaultSpecializedInputProps } from '../../utils'; diff --git a/server/sonar-web/src/main/js/apps/settings/encryption/__tests__/EncryptionForm-test.tsx b/server/sonar-web/src/main/js/apps/settings/encryption/__tests__/EncryptionForm-test.tsx index 1c6dabfbbe9..204f73812de 100644 --- a/server/sonar-web/src/main/js/apps/settings/encryption/__tests__/EncryptionForm-test.tsx +++ b/server/sonar-web/src/main/js/apps/settings/encryption/__tests__/EncryptionForm-test.tsx @@ -17,8 +17,8 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import * as React from 'react'; import { shallow } from 'enzyme'; +import * as React from 'react'; import EncryptionForm from '../EncryptionForm'; it('should render correctly', () => { diff --git a/server/sonar-web/src/main/js/apps/settings/encryption/__tests__/GenerateSecretKeyForm-test.tsx b/server/sonar-web/src/main/js/apps/settings/encryption/__tests__/GenerateSecretKeyForm-test.tsx index a9f5110905c..21ef36f8051 100644 --- a/server/sonar-web/src/main/js/apps/settings/encryption/__tests__/GenerateSecretKeyForm-test.tsx +++ b/server/sonar-web/src/main/js/apps/settings/encryption/__tests__/GenerateSecretKeyForm-test.tsx @@ -17,8 +17,8 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import * as React from 'react'; import { shallow } from 'enzyme'; +import * as React from 'react'; import GenerateSecretKeyForm from '../GenerateSecretKeyForm'; it('should render correctly', () => { diff --git a/server/sonar-web/src/main/js/apps/system/components/info-items/HealthCauseItem.tsx b/server/sonar-web/src/main/js/apps/system/components/info-items/HealthCauseItem.tsx index 49cd480e91d..f6022748fb5 100644 --- a/server/sonar-web/src/main/js/apps/system/components/info-items/HealthCauseItem.tsx +++ b/server/sonar-web/src/main/js/apps/system/components/info-items/HealthCauseItem.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { Alert } from '../../../../components/ui/Alert'; diff --git a/server/sonar-web/src/main/js/apps/system/components/info-items/HealthItem.tsx b/server/sonar-web/src/main/js/apps/system/components/info-items/HealthItem.tsx index f445caf6d0a..3c9fa6acebd 100644 --- a/server/sonar-web/src/main/js/apps/system/components/info-items/HealthItem.tsx +++ b/server/sonar-web/src/main/js/apps/system/components/info-items/HealthItem.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import StatusIndicator from '../../../../components/common/StatusIndicator'; import Tooltip from '../../../../components/controls/Tooltip'; diff --git a/server/sonar-web/src/main/js/apps/tutorials/components/__tests__/TutorialsApp-test.tsx b/server/sonar-web/src/main/js/apps/tutorials/components/__tests__/TutorialsApp-test.tsx index 39c7745f313..1471f4982d1 100644 --- a/server/sonar-web/src/main/js/apps/tutorials/components/__tests__/TutorialsApp-test.tsx +++ b/server/sonar-web/src/main/js/apps/tutorials/components/__tests__/TutorialsApp-test.tsx @@ -25,9 +25,7 @@ import { mockComponent } from '../../../../helpers/mocks/component'; import { mockCurrentUser, mockLoggedInUser } from '../../../../helpers/testMocks'; import { TutorialsApp, TutorialsAppProps } from '../TutorialsApp'; -jest.mock('../../../../helpers/handleRequiredAuthentication', () => ({ - default: jest.fn() -})); +jest.mock('../../../../helpers/handleRequiredAuthentication', () => jest.fn()); it('should render correctly', () => { expect(shallowRender()).toMatchSnapshot(); diff --git a/server/sonar-web/src/main/js/apps/users/components/__tests__/PasswordForm-test.tsx b/server/sonar-web/src/main/js/apps/users/components/__tests__/PasswordForm-test.tsx index 302f706a361..a0341732919 100644 --- a/server/sonar-web/src/main/js/apps/users/components/__tests__/PasswordForm-test.tsx +++ b/server/sonar-web/src/main/js/apps/users/components/__tests__/PasswordForm-test.tsx @@ -19,9 +19,9 @@ */ import { shallow } from 'enzyme'; import * as React from 'react'; +import { changePassword } from '../../../../api/users'; import { mockUser } from '../../../../helpers/testMocks'; import PasswordForm from '../PasswordForm'; -import { changePassword } from '../../../../api/users'; const password = 'new password asdf'; diff --git a/server/sonar-web/src/main/js/apps/web-api/components/Action.tsx b/server/sonar-web/src/main/js/apps/web-api/components/Action.tsx index 5bcc98ade25..cda482e9f61 100644 --- a/server/sonar-web/src/main/js/apps/web-api/components/Action.tsx +++ b/server/sonar-web/src/main/js/apps/web-api/components/Action.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { Link } from 'react-router'; import LinkIcon from '../../../components/icons/LinkIcon'; diff --git a/server/sonar-web/src/main/js/apps/web-api/components/Menu.tsx b/server/sonar-web/src/main/js/apps/web-api/components/Menu.tsx index 80675908844..c39bf9b2eb1 100644 --- a/server/sonar-web/src/main/js/apps/web-api/components/Menu.tsx +++ b/server/sonar-web/src/main/js/apps/web-api/components/Menu.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { Link } from 'react-router'; import { actionsFilter, isDomainPathActive, Query, serializeQuery } from '../utils'; diff --git a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeader.tsx b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeader.tsx index 95172b76ee5..2ea560e1937 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeader.tsx +++ b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeader.tsx @@ -17,7 +17,6 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import { stringify } from 'querystring'; import * as React from 'react'; import { Link } from 'react-router'; import { ButtonIcon } from '../../components/controls/buttons'; @@ -126,10 +125,10 @@ export default class SourceViewerHeader extends React.PureComponent<Props, State } = this.props.sourceViewerFile; const unitTestsOrLines = q === ComponentQualifier.TestFile ? 'tests' : 'lines'; const workspace = false; - const rawSourcesLink = - getBaseUrl() + - '/api/sources/raw?' + - stringify(omitNil({ key, ...getBranchLikeQuery(this.props.branchLike) })); + const query = new URLSearchParams( + omitNil({ key, ...getBranchLikeQuery(this.props.branchLike) }) + ).toString(); + const rawSourcesLink = `${getBaseUrl()}/api/sources/raw?${query}`; // TODO favorite return ( diff --git a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeaderSlim.tsx b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeaderSlim.tsx index 917cc49f1a7..f0c70947618 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeaderSlim.tsx +++ b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeaderSlim.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { Link } from 'react-router'; import { ButtonIcon } from '../../components/controls/buttons'; diff --git a/server/sonar-web/src/main/js/components/SourceViewer/__tests__/SourceViewerBase-test.tsx b/server/sonar-web/src/main/js/components/SourceViewer/__tests__/SourceViewerBase-test.tsx index 3fd9556de43..f21e3ed8a20 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/__tests__/SourceViewerBase-test.tsx +++ b/server/sonar-web/src/main/js/components/SourceViewer/__tests__/SourceViewerBase-test.tsx @@ -26,9 +26,7 @@ import { waitAndUpdate } from '../../../helpers/testUtils'; import defaultLoadIssues from '../helpers/loadIssues'; import SourceViewerBase from '../SourceViewerBase'; -jest.mock('../helpers/loadIssues', () => ({ - default: jest.fn().mockRejectedValue({}) -})); +jest.mock('../helpers/loadIssues', () => jest.fn().mockRejectedValue({})); jest.mock('../../../api/components', () => ({ getComponentForSourceViewer: jest.fn().mockRejectedValue(''), diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/Line.tsx b/server/sonar-web/src/main/js/components/SourceViewer/components/Line.tsx index 8d7deed7708..58b835d88c8 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/components/Line.tsx +++ b/server/sonar-web/src/main/js/components/SourceViewer/components/Line.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import { times } from 'lodash'; import * as React from 'react'; import { BranchLike } from '../../../types/branch-like'; diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/LineCode.tsx b/server/sonar-web/src/main/js/components/SourceViewer/components/LineCode.tsx index 2ddac8a3c7e..bcf53776df9 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/components/LineCode.tsx +++ b/server/sonar-web/src/main/js/components/SourceViewer/components/LineCode.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { BranchLike } from '../../../types/branch-like'; import LocationIndex from '../../common/LocationIndex'; diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/LineDuplicationBlock.tsx b/server/sonar-web/src/main/js/components/SourceViewer/components/LineDuplicationBlock.tsx index abaeff59dc9..225edce276a 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/components/LineDuplicationBlock.tsx +++ b/server/sonar-web/src/main/js/components/SourceViewer/components/LineDuplicationBlock.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { DropdownOverlay } from '../../../components/controls/Dropdown'; import Toggler from '../../../components/controls/Toggler'; diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/LineIssuesIndicator.tsx b/server/sonar-web/src/main/js/components/SourceViewer/components/LineIssuesIndicator.tsx index 63424aa667b..91e1191eedb 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/components/LineIssuesIndicator.tsx +++ b/server/sonar-web/src/main/js/components/SourceViewer/components/LineIssuesIndicator.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import { uniq } from 'lodash'; import * as React from 'react'; import Tooltip from '../../../components/controls/Tooltip'; diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/SCMPopup.tsx b/server/sonar-web/src/main/js/components/SourceViewer/components/SCMPopup.tsx index 08b523df621..b9a23093708 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/components/SCMPopup.tsx +++ b/server/sonar-web/src/main/js/components/SourceViewer/components/SCMPopup.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { translate } from '../../../helpers/l10n'; import DateFormatter from '../../intl/DateFormatter'; diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/LineCoverage-test.tsx b/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/LineCoverage-test.tsx index b1868569b91..b9294b57629 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/LineCoverage-test.tsx +++ b/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/LineCoverage-test.tsx @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { shallow } from 'enzyme'; -import * as React from 'react'; +import React from 'react'; import { LineCoverage, LineCoverageProps } from '../LineCoverage'; it('should render correctly', () => { diff --git a/server/sonar-web/src/main/js/components/activity-graph/GraphsLegendItem.tsx b/server/sonar-web/src/main/js/components/activity-graph/GraphsLegendItem.tsx index 90a3c46c77f..0f18fb4daad 100644 --- a/server/sonar-web/src/main/js/components/activity-graph/GraphsLegendItem.tsx +++ b/server/sonar-web/src/main/js/components/activity-graph/GraphsLegendItem.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { ClearButton } from '../../components/controls/buttons'; import AlertWarnIcon from '../../components/icons/AlertWarnIcon'; diff --git a/server/sonar-web/src/main/js/components/activity-graph/__tests__/utils-test.ts b/server/sonar-web/src/main/js/components/activity-graph/__tests__/utils-test.ts index 2b1eeca21b6..9c4ee25246c 100644 --- a/server/sonar-web/src/main/js/components/activity-graph/__tests__/utils-test.ts +++ b/server/sonar-web/src/main/js/components/activity-graph/__tests__/utils-test.ts @@ -23,13 +23,17 @@ import { MetricKey } from '../../../types/metrics'; import { GraphType, Serie } from '../../../types/project-activity'; import * as utils from '../utils'; -jest.mock('date-fns/start_of_day', () => - jest.fn(date => { - const startDay = new Date(date); - startDay.setUTCHours(0, 0, 0, 0); - return startDay; - }) -); +jest.mock('date-fns', () => { + const actual = jest.requireActual('date-fns'); + return { + ...actual, + startOfDay: jest.fn(date => { + const startDay = new Date(date); + startDay.setUTCHours(0, 0, 0, 0); + return startDay; + }) + }; +}); const HISTORY = [ { diff --git a/server/sonar-web/src/main/js/components/charts/AdvancedTimeline.tsx b/server/sonar-web/src/main/js/components/charts/AdvancedTimeline.tsx index 31430bf4599..86afbce4763 100644 --- a/server/sonar-web/src/main/js/components/charts/AdvancedTimeline.tsx +++ b/server/sonar-web/src/main/js/components/charts/AdvancedTimeline.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import { bisector, extent, max } from 'd3-array'; import { scaleLinear, scalePoint, scaleTime, ScaleTime } from 'd3-scale'; import { area, curveBasis, line as d3Line } from 'd3-shape'; diff --git a/server/sonar-web/src/main/js/components/charts/BubbleChart.tsx b/server/sonar-web/src/main/js/components/charts/BubbleChart.tsx index f71f476a50a..dd500169f06 100644 --- a/server/sonar-web/src/main/js/components/charts/BubbleChart.tsx +++ b/server/sonar-web/src/main/js/components/charts/BubbleChart.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import { max, min } from 'd3-array'; import { scaleLinear, ScaleLinear } from 'd3-scale'; import { event, select } from 'd3-selection'; diff --git a/server/sonar-web/src/main/js/components/charts/ColorBoxLegend.tsx b/server/sonar-web/src/main/js/components/charts/ColorBoxLegend.tsx index 8dc53e8e0dd..bb21c0d0728 100644 --- a/server/sonar-web/src/main/js/components/charts/ColorBoxLegend.tsx +++ b/server/sonar-web/src/main/js/components/charts/ColorBoxLegend.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import { ScaleLinear, ScaleOrdinal } from 'd3-scale'; import * as React from 'react'; import { formatMeasure } from '../../helpers/measures'; diff --git a/server/sonar-web/src/main/js/components/charts/ColorRatingsLegend.tsx b/server/sonar-web/src/main/js/components/charts/ColorRatingsLegend.tsx index b51b8b3e9b0..cf68a608af5 100644 --- a/server/sonar-web/src/main/js/components/charts/ColorRatingsLegend.tsx +++ b/server/sonar-web/src/main/js/components/charts/ColorRatingsLegend.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { ButtonLink } from '../../components/controls/buttons'; import Tooltip from '../../components/controls/Tooltip'; diff --git a/server/sonar-web/src/main/js/components/charts/TreeMapRect.tsx b/server/sonar-web/src/main/js/components/charts/TreeMapRect.tsx index 9a2f86e7af9..6b446dc2655 100644 --- a/server/sonar-web/src/main/js/components/charts/TreeMapRect.tsx +++ b/server/sonar-web/src/main/js/components/charts/TreeMapRect.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import { scaleLinear } from 'd3-scale'; import * as React from 'react'; import { Link } from 'react-router'; diff --git a/server/sonar-web/src/main/js/components/charts/ZoomTimeLine.tsx b/server/sonar-web/src/main/js/components/charts/ZoomTimeLine.tsx index 7caee5b3aec..41542eda4bf 100644 --- a/server/sonar-web/src/main/js/components/charts/ZoomTimeLine.tsx +++ b/server/sonar-web/src/main/js/components/charts/ZoomTimeLine.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import { extent, max } from 'd3-array'; import { scaleLinear, scalePoint, scaleTime, ScaleTime } from 'd3-scale'; import { area, curveBasis, line as d3Line } from 'd3-shape'; diff --git a/server/sonar-web/src/main/js/components/common/CodeSnippet.tsx b/server/sonar-web/src/main/js/components/common/CodeSnippet.tsx index 7a48b5929c2..910cbbd877a 100644 --- a/server/sonar-web/src/main/js/components/common/CodeSnippet.tsx +++ b/server/sonar-web/src/main/js/components/common/CodeSnippet.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { ClipboardButton } from '../../components/controls/clipboard'; import { isDefined } from '../../helpers/types'; diff --git a/server/sonar-web/src/main/js/components/common/FormattingTips.tsx b/server/sonar-web/src/main/js/components/common/FormattingTips.tsx index 6753e640435..17bd9460f31 100644 --- a/server/sonar-web/src/main/js/components/common/FormattingTips.tsx +++ b/server/sonar-web/src/main/js/components/common/FormattingTips.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { translate } from '../../helpers/l10n'; import { getFormattingHelpUrl } from '../../helpers/urls'; diff --git a/server/sonar-web/src/main/js/components/common/LocationIndex.tsx b/server/sonar-web/src/main/js/components/common/LocationIndex.tsx index 76ac1c19786..7e106cc3307 100644 --- a/server/sonar-web/src/main/js/components/common/LocationIndex.tsx +++ b/server/sonar-web/src/main/js/components/common/LocationIndex.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import './LocationIndex.css'; diff --git a/server/sonar-web/src/main/js/components/common/LocationMessage.tsx b/server/sonar-web/src/main/js/components/common/LocationMessage.tsx index 162cab3d973..918e5ad53be 100644 --- a/server/sonar-web/src/main/js/components/common/LocationMessage.tsx +++ b/server/sonar-web/src/main/js/components/common/LocationMessage.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import './LocationMessage.css'; diff --git a/server/sonar-web/src/main/js/components/common/MeasuresLink.tsx b/server/sonar-web/src/main/js/components/common/MeasuresLink.tsx index 6b5cba0ba25..5ac47122d41 100644 --- a/server/sonar-web/src/main/js/components/common/MeasuresLink.tsx +++ b/server/sonar-web/src/main/js/components/common/MeasuresLink.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { Link } from 'react-router'; import MeasuresIcon from '../../components/icons/MeasuresIcon'; diff --git a/server/sonar-web/src/main/js/components/common/MultiSelect.tsx b/server/sonar-web/src/main/js/components/common/MultiSelect.tsx index b5f7e396bab..6f0aab023c8 100644 --- a/server/sonar-web/src/main/js/components/common/MultiSelect.tsx +++ b/server/sonar-web/src/main/js/components/common/MultiSelect.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import { difference } from 'lodash'; import * as React from 'react'; import SearchBox from '../../components/controls/SearchBox'; diff --git a/server/sonar-web/src/main/js/components/common/MultiSelectOption.tsx b/server/sonar-web/src/main/js/components/common/MultiSelectOption.tsx index 03b55c64491..7a6ff9802ee 100644 --- a/server/sonar-web/src/main/js/components/common/MultiSelectOption.tsx +++ b/server/sonar-web/src/main/js/components/common/MultiSelectOption.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import Checkbox from '../../components/controls/Checkbox'; import { translate } from '../../helpers/l10n'; diff --git a/server/sonar-web/src/main/js/components/common/PageCounter.tsx b/server/sonar-web/src/main/js/components/common/PageCounter.tsx index 9eef4e4c03e..f09b9cf2296 100644 --- a/server/sonar-web/src/main/js/components/common/PageCounter.tsx +++ b/server/sonar-web/src/main/js/components/common/PageCounter.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { formatMeasure } from '../../helpers/measures'; diff --git a/server/sonar-web/src/main/js/components/common/PrivacyBadgeContainer.tsx b/server/sonar-web/src/main/js/components/common/PrivacyBadgeContainer.tsx index 1b8d1113d09..9515fc39afe 100644 --- a/server/sonar-web/src/main/js/components/common/PrivacyBadgeContainer.tsx +++ b/server/sonar-web/src/main/js/components/common/PrivacyBadgeContainer.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import Tooltip from '../../components/controls/Tooltip'; import { translate } from '../../helpers/l10n'; diff --git a/server/sonar-web/src/main/js/components/common/ProjectKeyInput.tsx b/server/sonar-web/src/main/js/components/common/ProjectKeyInput.tsx index 0218d9d1086..c4c41e062bd 100644 --- a/server/sonar-web/src/main/js/components/common/ProjectKeyInput.tsx +++ b/server/sonar-web/src/main/js/components/common/ProjectKeyInput.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import ValidationInput from '../../components/controls/ValidationInput'; import { PROJECT_KEY_MAX_LEN } from '../../helpers/constants'; diff --git a/server/sonar-web/src/main/js/components/common/RestartButton.tsx b/server/sonar-web/src/main/js/components/common/RestartButton.tsx index 74256cb6acf..612d4caf6d5 100644 --- a/server/sonar-web/src/main/js/components/common/RestartButton.tsx +++ b/server/sonar-web/src/main/js/components/common/RestartButton.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { restart } from '../../api/system'; import { Button } from '../../components/controls/buttons'; diff --git a/server/sonar-web/src/main/js/components/common/SelectList.tsx b/server/sonar-web/src/main/js/components/common/SelectList.tsx index b2784e58b2d..e27ce103f2c 100644 --- a/server/sonar-web/src/main/js/components/common/SelectList.tsx +++ b/server/sonar-web/src/main/js/components/common/SelectList.tsx @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import classNames from 'classnames'; -import * as key from 'keymaster'; +import key from 'keymaster'; import { uniqueId } from 'lodash'; import * as React from 'react'; import SelectListItem from './SelectListItem'; @@ -71,11 +71,14 @@ export default class SelectList extends React.PureComponent<Props, State> { // sometimes there is a *focused* search field next to the SelectList component // we need to allow shortcuts in this case, but only for the used keys - (key as any).filter = (event: KeyboardEvent & { target: HTMLElement }) => { - const { tagName } = event.target || event.srcElement; - const isInput = tagName === 'INPUT' || tagName === 'SELECT' || tagName === 'TEXTAREA'; - return [13, 38, 40].includes(event.keyCode) || !isInput; - }; + + Object.assign(key, { + filter: (event: KeyboardEvent & { target: HTMLElement }) => { + const { tagName } = event.target || event.srcElement; + const isInput = tagName === 'INPUT' || tagName === 'SELECT' || tagName === 'TEXTAREA'; + return [13, 38, 40].includes(event.keyCode) || !isInput; + } + }); key('down', this.currentKeyScope, () => { this.setState(this.selectNextElement); @@ -102,7 +105,7 @@ export default class SelectList extends React.PureComponent<Props, State> { if (this.currentKeyScope) { key.deleteScope(this.currentKeyScope); } - (key as any).filter = this.previousFilter; + Object.assign(key, { filter: this.previousFilter }); }; handleSelect = (item: string) => { diff --git a/server/sonar-web/src/main/js/components/common/StatusIndicator.tsx b/server/sonar-web/src/main/js/components/common/StatusIndicator.tsx index 34d90f14fc2..ee31b8c49a8 100644 --- a/server/sonar-web/src/main/js/components/common/StatusIndicator.tsx +++ b/server/sonar-web/src/main/js/components/common/StatusIndicator.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { translate } from '../../helpers/l10n'; import './StatusIndicator.css'; diff --git a/server/sonar-web/src/main/js/components/common/VisibilitySelector.tsx b/server/sonar-web/src/main/js/components/common/VisibilitySelector.tsx index 2597eff618b..1432f8df59e 100644 --- a/server/sonar-web/src/main/js/components/common/VisibilitySelector.tsx +++ b/server/sonar-web/src/main/js/components/common/VisibilitySelector.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import Radio from '../../components/controls/Radio'; import { translate } from '../../helpers/l10n'; diff --git a/server/sonar-web/src/main/js/components/controls/ActionsDropdown.tsx b/server/sonar-web/src/main/js/components/controls/ActionsDropdown.tsx index 0f161597a07..f61c87eef7a 100644 --- a/server/sonar-web/src/main/js/components/controls/ActionsDropdown.tsx +++ b/server/sonar-web/src/main/js/components/controls/ActionsDropdown.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import { LocationDescriptor } from 'history'; import * as React from 'react'; import { Link } from 'react-router'; diff --git a/server/sonar-web/src/main/js/components/controls/BackButton.tsx b/server/sonar-web/src/main/js/components/controls/BackButton.tsx index 3a20870d89d..34d0bec4092 100644 --- a/server/sonar-web/src/main/js/components/controls/BackButton.tsx +++ b/server/sonar-web/src/main/js/components/controls/BackButton.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { colors } from '../../app/theme'; import { translate } from '../../helpers/l10n'; diff --git a/server/sonar-web/src/main/js/components/controls/BoxedGroupAccordion.tsx b/server/sonar-web/src/main/js/components/controls/BoxedGroupAccordion.tsx index 619b59ca330..b450d1a0598 100644 --- a/server/sonar-web/src/main/js/components/controls/BoxedGroupAccordion.tsx +++ b/server/sonar-web/src/main/js/components/controls/BoxedGroupAccordion.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import OpenCloseIcon from '../icons/OpenCloseIcon'; diff --git a/server/sonar-web/src/main/js/components/controls/Checkbox.tsx b/server/sonar-web/src/main/js/components/controls/Checkbox.tsx index 5fb87ddbf03..ecae3dd9e66 100644 --- a/server/sonar-web/src/main/js/components/controls/Checkbox.tsx +++ b/server/sonar-web/src/main/js/components/controls/Checkbox.tsx @@ -21,7 +21,7 @@ /* eslint-disable jsx-a11y/anchor-has-content */ /* eslint-disable jsx-a11y/control-has-associated-label */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import DeferredSpinner from '../ui/DeferredSpinner'; import './Checkbox.css'; diff --git a/server/sonar-web/src/main/js/components/controls/DateInput.tsx b/server/sonar-web/src/main/js/components/controls/DateInput.tsx index 0c5dc5421f4..b484e952e47 100644 --- a/server/sonar-web/src/main/js/components/controls/DateInput.tsx +++ b/server/sonar-web/src/main/js/components/controls/DateInput.tsx @@ -17,11 +17,8 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import * as classNames from 'classnames'; -import * as addMonths from 'date-fns/add_months'; -import * as setMonth from 'date-fns/set_month'; -import * as setYear from 'date-fns/set_year'; -import * as subMonths from 'date-fns/sub_months'; +import classNames from 'classnames'; +import { addMonths, setMonth, setYear, subMonths } from 'date-fns'; import { range } from 'lodash'; import * as React from 'react'; import { DayModifiers, Modifier, Modifiers } from 'react-day-picker'; diff --git a/server/sonar-web/src/main/js/components/controls/DateRangeInput.tsx b/server/sonar-web/src/main/js/components/controls/DateRangeInput.tsx index fae75f672ce..8dcd5c22a27 100644 --- a/server/sonar-web/src/main/js/components/controls/DateRangeInput.tsx +++ b/server/sonar-web/src/main/js/components/controls/DateRangeInput.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import { max, min } from 'date-fns'; import * as React from 'react'; import { translate } from '../../helpers/l10n'; diff --git a/server/sonar-web/src/main/js/components/controls/Dropdown.tsx b/server/sonar-web/src/main/js/components/controls/Dropdown.tsx index 04f2b3c8208..d39c98dcf03 100644 --- a/server/sonar-web/src/main/js/components/controls/Dropdown.tsx +++ b/server/sonar-web/src/main/js/components/controls/Dropdown.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { Popup, PopupPlacement } from '../ui/popups'; import './Dropdown.css'; diff --git a/server/sonar-web/src/main/js/components/controls/FavoriteButton.tsx b/server/sonar-web/src/main/js/components/controls/FavoriteButton.tsx index e3727dd338a..a989c816f23 100644 --- a/server/sonar-web/src/main/js/components/controls/FavoriteButton.tsx +++ b/server/sonar-web/src/main/js/components/controls/FavoriteButton.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { translate } from '../../helpers/l10n'; import FavoriteIcon from '../icons/FavoriteIcon'; diff --git a/server/sonar-web/src/main/js/components/controls/HelpTooltip.tsx b/server/sonar-web/src/main/js/components/controls/HelpTooltip.tsx index cc927c4075c..c3d51950625 100644 --- a/server/sonar-web/src/main/js/components/controls/HelpTooltip.tsx +++ b/server/sonar-web/src/main/js/components/controls/HelpTooltip.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { colors } from '../../app/theme'; import HelpIcon from '../icons/HelpIcon'; diff --git a/server/sonar-web/src/main/js/components/controls/HomePageSelect.tsx b/server/sonar-web/src/main/js/components/controls/HomePageSelect.tsx index a0aa83571d2..02b8f33ef44 100644 --- a/server/sonar-web/src/main/js/components/controls/HomePageSelect.tsx +++ b/server/sonar-web/src/main/js/components/controls/HomePageSelect.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { connect } from 'react-redux'; import { ButtonLink } from '../../components/controls/buttons'; diff --git a/server/sonar-web/src/main/js/components/controls/IdentityProviderLink.tsx b/server/sonar-web/src/main/js/components/controls/IdentityProviderLink.tsx index 383a344b6ce..2eb1be5c366 100644 --- a/server/sonar-web/src/main/js/components/controls/IdentityProviderLink.tsx +++ b/server/sonar-web/src/main/js/components/controls/IdentityProviderLink.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { isDarkColor } from '../../helpers/colors'; import { getBaseUrl } from '../../helpers/system'; diff --git a/server/sonar-web/src/main/js/components/controls/InputValidationField.tsx b/server/sonar-web/src/main/js/components/controls/InputValidationField.tsx index 0e844b113d2..e9327ec7990 100644 --- a/server/sonar-web/src/main/js/components/controls/InputValidationField.tsx +++ b/server/sonar-web/src/main/js/components/controls/InputValidationField.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import ModalValidationField from './ModalValidationField'; diff --git a/server/sonar-web/src/main/js/components/controls/ListFooter.tsx b/server/sonar-web/src/main/js/components/controls/ListFooter.tsx index 8617c126d65..f0099201389 100644 --- a/server/sonar-web/src/main/js/components/controls/ListFooter.tsx +++ b/server/sonar-web/src/main/js/components/controls/ListFooter.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { translate, translateWithParameters } from '../../helpers/l10n'; import { formatMeasure } from '../../helpers/measures'; diff --git a/server/sonar-web/src/main/js/components/controls/Modal.tsx b/server/sonar-web/src/main/js/components/controls/Modal.tsx index b7181e25e1f..d16c8d3d26e 100644 --- a/server/sonar-web/src/main/js/components/controls/Modal.tsx +++ b/server/sonar-web/src/main/js/components/controls/Modal.tsx @@ -17,9 +17,9 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; -import * as ReactModal from 'react-modal'; +import ReactModal from 'react-modal'; import { getReactDomContainerSelector } from '../../helpers/system'; import './Modal.css'; diff --git a/server/sonar-web/src/main/js/components/controls/ModalValidationField.tsx b/server/sonar-web/src/main/js/components/controls/ModalValidationField.tsx index 2aa649de238..ce4d45806e6 100644 --- a/server/sonar-web/src/main/js/components/controls/ModalValidationField.tsx +++ b/server/sonar-web/src/main/js/components/controls/ModalValidationField.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import AlertErrorIcon from '../icons/AlertErrorIcon'; import AlertSuccessIcon from '../icons/AlertSuccessIcon'; diff --git a/server/sonar-web/src/main/js/components/controls/Radio.tsx b/server/sonar-web/src/main/js/components/controls/Radio.tsx index c664c6f2499..94960c9ce1f 100644 --- a/server/sonar-web/src/main/js/components/controls/Radio.tsx +++ b/server/sonar-web/src/main/js/components/controls/Radio.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import './Radio.css'; diff --git a/server/sonar-web/src/main/js/components/controls/RadioCard.tsx b/server/sonar-web/src/main/js/components/controls/RadioCard.tsx index 223e597e6d9..2ce29ec211b 100644 --- a/server/sonar-web/src/main/js/components/controls/RadioCard.tsx +++ b/server/sonar-web/src/main/js/components/controls/RadioCard.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { FormattedMessage } from 'react-intl'; import { translate } from '../../helpers/l10n'; diff --git a/server/sonar-web/src/main/js/components/controls/RadioToggle.tsx b/server/sonar-web/src/main/js/components/controls/RadioToggle.tsx index 0af42bbca83..348f3582509 100644 --- a/server/sonar-web/src/main/js/components/controls/RadioToggle.tsx +++ b/server/sonar-web/src/main/js/components/controls/RadioToggle.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import './RadioToggle.css'; import Tooltip from './Tooltip'; diff --git a/server/sonar-web/src/main/js/components/controls/ReloadButton.tsx b/server/sonar-web/src/main/js/components/controls/ReloadButton.tsx index 134f43303dc..5df0a90dd5c 100644 --- a/server/sonar-web/src/main/js/components/controls/ReloadButton.tsx +++ b/server/sonar-web/src/main/js/components/controls/ReloadButton.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { colors } from '../../app/theme'; import { translate } from '../../helpers/l10n'; diff --git a/server/sonar-web/src/main/js/components/controls/SearchBox.tsx b/server/sonar-web/src/main/js/components/controls/SearchBox.tsx index 476b8f93b7e..70c97cb3b12 100644 --- a/server/sonar-web/src/main/js/components/controls/SearchBox.tsx +++ b/server/sonar-web/src/main/js/components/controls/SearchBox.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import { Cancelable, debounce } from 'lodash'; import * as React from 'react'; import { translate, translateWithParameters } from '../../helpers/l10n'; diff --git a/server/sonar-web/src/main/js/components/controls/SelectListListContainer.tsx b/server/sonar-web/src/main/js/components/controls/SelectListListContainer.tsx index 160317b1951..288f23d5d9d 100644 --- a/server/sonar-web/src/main/js/components/controls/SelectListListContainer.tsx +++ b/server/sonar-web/src/main/js/components/controls/SelectListListContainer.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { translate } from '../../helpers/l10n'; import DeferredSpinner from '../ui/DeferredSpinner'; diff --git a/server/sonar-web/src/main/js/components/controls/SelectListListElement.tsx b/server/sonar-web/src/main/js/components/controls/SelectListListElement.tsx index defd493f344..d3a0912c1c2 100644 --- a/server/sonar-web/src/main/js/components/controls/SelectListListElement.tsx +++ b/server/sonar-web/src/main/js/components/controls/SelectListListElement.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import Checkbox from './Checkbox'; diff --git a/server/sonar-web/src/main/js/components/controls/Tabs.tsx b/server/sonar-web/src/main/js/components/controls/Tabs.tsx index 6c25ae0c21f..5ee905af806 100644 --- a/server/sonar-web/src/main/js/components/controls/Tabs.tsx +++ b/server/sonar-web/src/main/js/components/controls/Tabs.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import './Tabs.css'; diff --git a/server/sonar-web/src/main/js/components/controls/Toggle.tsx b/server/sonar-web/src/main/js/components/controls/Toggle.tsx index 52448e8b074..db8b46fef5a 100644 --- a/server/sonar-web/src/main/js/components/controls/Toggle.tsx +++ b/server/sonar-web/src/main/js/components/controls/Toggle.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { translate } from '../../helpers/l10n'; import CheckIcon from '../icons/CheckIcon'; diff --git a/server/sonar-web/src/main/js/components/controls/__tests__/ComponentReportActions-test.tsx b/server/sonar-web/src/main/js/components/controls/__tests__/ComponentReportActions-test.tsx index 748f5e649be..c30b3707224 100644 --- a/server/sonar-web/src/main/js/components/controls/__tests__/ComponentReportActions-test.tsx +++ b/server/sonar-web/src/main/js/components/controls/__tests__/ComponentReportActions-test.tsx @@ -50,7 +50,7 @@ jest.mock('../../../helpers/system', () => ({ getBaseUrl: jest.fn().mockReturnValue('baseUrl') })); -jest.mock('../../../app/utils/addGlobalSuccessMessage', () => ({ default: jest.fn() })); +jest.mock('../../../app/utils/addGlobalSuccessMessage', () => jest.fn()); beforeEach(jest.clearAllMocks); diff --git a/server/sonar-web/src/main/js/components/controls/__tests__/DateInput-test.tsx b/server/sonar-web/src/main/js/components/controls/__tests__/DateInput-test.tsx index 6cab7176e1c..7e6a29afdf0 100644 --- a/server/sonar-web/src/main/js/components/controls/__tests__/DateInput-test.tsx +++ b/server/sonar-web/src/main/js/components/controls/__tests__/DateInput-test.tsx @@ -17,11 +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. */ -import * as addDays from 'date-fns/add_days'; -import * as setMonth from 'date-fns/set_month'; -import * as setYear from 'date-fns/set_year'; -import * as subDays from 'date-fns/sub_days'; -import * as subMonths from 'date-fns/sub_months'; +import { addDays, setMonth, setYear, subDays, subMonths } from 'date-fns'; import { shallow } from 'enzyme'; import * as React from 'react'; import { parseDate } from '../../../helpers/dates'; diff --git a/server/sonar-web/src/main/js/components/controls/buttons.tsx b/server/sonar-web/src/main/js/components/controls/buttons.tsx index ff4bd8acdc0..d2f39a0a7fd 100644 --- a/server/sonar-web/src/main/js/components/controls/buttons.tsx +++ b/server/sonar-web/src/main/js/components/controls/buttons.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { colors } from '../../app/theme'; import ChevronRightIcon from '../icons/ChevronRightIcon'; diff --git a/server/sonar-web/src/main/js/components/controls/clipboard.tsx b/server/sonar-web/src/main/js/components/controls/clipboard.tsx index 6d91192275c..a0ff7475ed2 100644 --- a/server/sonar-web/src/main/js/components/controls/clipboard.tsx +++ b/server/sonar-web/src/main/js/components/controls/clipboard.tsx @@ -17,8 +17,8 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import * as classNames from 'classnames'; -import * as Clipboard from 'clipboard'; +import classNames from 'classnames'; +import Clipboard from 'clipboard'; import * as React from 'react'; import { translate } from '../../helpers/l10n'; import CopyIcon from '../icons/CopyIcon'; 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 1fe7220a0e8..9d98c570e30 100644 --- a/server/sonar-web/src/main/js/components/docs/DocMarkdownBlock.tsx +++ b/server/sonar-web/src/main/js/components/docs/DocMarkdownBlock.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import rehypeRaw from 'rehype-raw'; import rehypeReact from 'rehype-react'; diff --git a/server/sonar-web/src/main/js/components/docs/DocToc.tsx b/server/sonar-web/src/main/js/components/docs/DocToc.tsx index edcc71da2ef..a807931c06b 100644 --- a/server/sonar-web/src/main/js/components/docs/DocToc.tsx +++ b/server/sonar-web/src/main/js/components/docs/DocToc.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import { debounce, memoize } from 'lodash'; import * as React from 'react'; import { findDOMNode } from 'react-dom'; diff --git a/server/sonar-web/src/main/js/components/docs/__tests__/DocMarkdownBlock-test.tsx b/server/sonar-web/src/main/js/components/docs/__tests__/DocMarkdownBlock-test.tsx index eb1c3e0208a..8e1e9f9ffaa 100644 --- a/server/sonar-web/src/main/js/components/docs/__tests__/DocMarkdownBlock-test.tsx +++ b/server/sonar-web/src/main/js/components/docs/__tests__/DocMarkdownBlock-test.tsx @@ -44,11 +44,11 @@ Risus placerat, efficitur enim ut, pellentesque sem. Mauris non lorem auctor, co `; // mock `remark` & co to work around the issue with cjs imports -jest.mock('remark', () => ({ default: jest.requireActual('remark') })); -jest.mock('remark-rehype', () => ({ default: jest.requireActual('remark-rehype') })); -jest.mock('rehype-raw', () => ({ default: jest.requireActual('rehype-raw') })); -jest.mock('rehype-react', () => ({ default: jest.requireActual('rehype-react') })); -jest.mock('rehype-slug', () => ({ default: jest.requireActual('rehype-slug') })); +jest.mock('remark', () => jest.requireActual('remark')); +jest.mock('remark-rehype', () => jest.requireActual('remark-rehype')); +jest.mock('rehype-raw', () => jest.requireActual('rehype-raw')); +jest.mock('rehype-react', () => jest.requireActual('rehype-react')); +jest.mock('rehype-slug', () => jest.requireActual('rehype-slug')); jest.mock('../../../helpers/scrolling', () => ({ scrollToElement: jest.fn() diff --git a/server/sonar-web/src/main/js/components/docs/__tests__/DocToc-test.tsx b/server/sonar-web/src/main/js/components/docs/__tests__/DocToc-test.tsx index 78838e2d971..3f68a39d23a 100644 --- a/server/sonar-web/src/main/js/components/docs/__tests__/DocToc-test.tsx +++ b/server/sonar-web/src/main/js/components/docs/__tests__/DocToc-test.tsx @@ -46,12 +46,12 @@ Risus placerat, efficitur enim ut, pellentesque sem. Mauris non lorem auctor, co jest.mock('remark', () => { const remark = jest.requireActual('remark'); - return { default: remark }; + return remark; }); jest.mock('remark-react', () => { const remarkReact = jest.requireActual('remark-react'); - return { default: remarkReact }; + return remarkReact; }); jest.mock('lodash', () => { diff --git a/server/sonar-web/src/main/js/components/facet/FacetBox.tsx b/server/sonar-web/src/main/js/components/facet/FacetBox.tsx index 381fac3d3fc..5d8189af4a1 100644 --- a/server/sonar-web/src/main/js/components/facet/FacetBox.tsx +++ b/server/sonar-web/src/main/js/components/facet/FacetBox.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; interface Props { diff --git a/server/sonar-web/src/main/js/components/facet/FacetItem.tsx b/server/sonar-web/src/main/js/components/facet/FacetItem.tsx index 3429ffb1f18..cd67d180e03 100644 --- a/server/sonar-web/src/main/js/components/facet/FacetItem.tsx +++ b/server/sonar-web/src/main/js/components/facet/FacetItem.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; export interface Props { 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 822e5964faa..bd4933f3ab6 100644 --- a/server/sonar-web/src/main/js/components/facet/ListStyleFacet.tsx +++ b/server/sonar-web/src/main/js/components/facet/ListStyleFacet.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import { sortBy, without } from 'lodash'; import * as React from 'react'; import ListFooter from '../../components/controls/ListFooter'; diff --git a/server/sonar-web/src/main/js/components/hoc/__tests__/whenLoggedIn-test.tsx b/server/sonar-web/src/main/js/components/hoc/__tests__/whenLoggedIn-test.tsx index cdf4910523f..051f4a4932d 100644 --- a/server/sonar-web/src/main/js/components/hoc/__tests__/whenLoggedIn-test.tsx +++ b/server/sonar-web/src/main/js/components/hoc/__tests__/whenLoggedIn-test.tsx @@ -23,9 +23,7 @@ import handleRequiredAuthentication from '../../../helpers/handleRequiredAuthent import { mockStore } from '../../../helpers/testMocks'; import { whenLoggedIn } from '../whenLoggedIn'; -jest.mock('../../../helpers/handleRequiredAuthentication', () => ({ - default: jest.fn() -})); +jest.mock('../../../helpers/handleRequiredAuthentication', () => jest.fn()); class X extends React.Component { render() { diff --git a/server/sonar-web/src/main/js/components/hoc/withKeyboardNavigation.tsx b/server/sonar-web/src/main/js/components/hoc/withKeyboardNavigation.tsx index 531ea3a5962..9288e336bbb 100644 --- a/server/sonar-web/src/main/js/components/hoc/withKeyboardNavigation.tsx +++ b/server/sonar-web/src/main/js/components/hoc/withKeyboardNavigation.tsx @@ -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. */ -import * as key from 'keymaster'; +import key from 'keymaster'; import * as React from 'react'; import PageActions from '../../components/ui/PageActions'; import { getWrappedDisplayName } from './utils'; diff --git a/server/sonar-web/src/main/js/components/icons/ClockIcon.tsx b/server/sonar-web/src/main/js/components/icons/ClockIcon.tsx index c777a4a8e60..c569021f3b6 100644 --- a/server/sonar-web/src/main/js/components/icons/ClockIcon.tsx +++ b/server/sonar-web/src/main/js/components/icons/ClockIcon.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import Icon, { IconProps } from './Icon'; diff --git a/server/sonar-web/src/main/js/components/icons/FavoriteIcon.tsx b/server/sonar-web/src/main/js/components/icons/FavoriteIcon.tsx index 217601d5cb7..6a62dc226f1 100644 --- a/server/sonar-web/src/main/js/components/icons/FavoriteIcon.tsx +++ b/server/sonar-web/src/main/js/components/icons/FavoriteIcon.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { colors } from '../../app/theme'; import Icon, { IconProps } from './Icon'; diff --git a/server/sonar-web/src/main/js/components/icons/HomeIcon.tsx b/server/sonar-web/src/main/js/components/icons/HomeIcon.tsx index 47a91692e76..6ff7ccbc173 100644 --- a/server/sonar-web/src/main/js/components/icons/HomeIcon.tsx +++ b/server/sonar-web/src/main/js/components/icons/HomeIcon.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { colors } from '../../app/theme'; import Icon, { IconProps } from './Icon'; diff --git a/server/sonar-web/src/main/js/components/issue/Issue.tsx b/server/sonar-web/src/main/js/components/issue/Issue.tsx index 654583a578f..0b965122f28 100644 --- a/server/sonar-web/src/main/js/components/issue/Issue.tsx +++ b/server/sonar-web/src/main/js/components/issue/Issue.tsx @@ -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. */ -import * as key from 'keymaster'; +import key from 'keymaster'; import * as React from 'react'; import { setIssueAssignee } from '../../api/issues'; import { BranchLike } from '../../types/branch-like'; diff --git a/server/sonar-web/src/main/js/components/issue/__tests__/actions-test.ts b/server/sonar-web/src/main/js/components/issue/__tests__/actions-test.ts index 371fd2c35fd..05b97a32c9c 100644 --- a/server/sonar-web/src/main/js/components/issue/__tests__/actions-test.ts +++ b/server/sonar-web/src/main/js/components/issue/__tests__/actions-test.ts @@ -23,9 +23,7 @@ import { mockComponent } from '../../../helpers/mocks/component'; import { mockIssue } from '../../../helpers/testMocks'; import { updateIssue } from '../actions'; -jest.mock('../../../app/utils/throwGlobalError', () => ({ - default: jest.fn() -})); +jest.mock('../../../app/utils/throwGlobalError', () => jest.fn()); jest.mock('../../../helpers/issues', () => ({ parseIssueFromResponse: jest.fn() diff --git a/server/sonar-web/src/main/js/components/tags/TagsList.tsx b/server/sonar-web/src/main/js/components/tags/TagsList.tsx index e6d80810f39..5e43af29f56 100644 --- a/server/sonar-web/src/main/js/components/tags/TagsList.tsx +++ b/server/sonar-web/src/main/js/components/tags/TagsList.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import DropdownIcon from '../../components/icons/DropdownIcon'; import TagsIcon from '../../components/icons/TagsIcon'; diff --git a/server/sonar-web/src/main/js/components/tutorials/components/Step.tsx b/server/sonar-web/src/main/js/components/tutorials/components/Step.tsx index af75e5bd92e..bb8c0d3bb53 100644 --- a/server/sonar-web/src/main/js/components/tutorials/components/Step.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/components/Step.tsx @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /* eslint-disable jsx-a11y/no-static-element-interactions, jsx-a11y/no-noninteractive-tabindex */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import './Step.css'; diff --git a/server/sonar-web/src/main/js/components/ui/Alert.tsx b/server/sonar-web/src/main/js/components/ui/Alert.tsx index 0a86b415a9c..0c7f2435632 100644 --- a/server/sonar-web/src/main/js/components/ui/Alert.tsx +++ b/server/sonar-web/src/main/js/components/ui/Alert.tsx @@ -19,7 +19,7 @@ */ import { css } from '@emotion/core'; import styled from '@emotion/styled'; -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { colors, sizes } from '../../app/theme'; import { translate } from '../../helpers/l10n'; diff --git a/server/sonar-web/src/main/js/components/ui/Avatar.tsx b/server/sonar-web/src/main/js/components/ui/Avatar.tsx index 274b99892c1..a97b1e1d353 100644 --- a/server/sonar-web/src/main/js/components/ui/Avatar.tsx +++ b/server/sonar-web/src/main/js/components/ui/Avatar.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { connect } from 'react-redux'; import GenericAvatar from '../../components/ui/GenericAvatar'; diff --git a/server/sonar-web/src/main/js/components/ui/ContextNavBar.tsx b/server/sonar-web/src/main/js/components/ui/ContextNavBar.tsx index e81fbf8bbce..aed94b24f76 100644 --- a/server/sonar-web/src/main/js/components/ui/ContextNavBar.tsx +++ b/server/sonar-web/src/main/js/components/ui/ContextNavBar.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import './ContextNavBar.css'; import NavBar, { NavBarProps } from './NavBar'; diff --git a/server/sonar-web/src/main/js/components/ui/DeferredSpinner.tsx b/server/sonar-web/src/main/js/components/ui/DeferredSpinner.tsx index 7021917c0bc..83d5f9c2a41 100644 --- a/server/sonar-web/src/main/js/components/ui/DeferredSpinner.tsx +++ b/server/sonar-web/src/main/js/components/ui/DeferredSpinner.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import './DeferredSpinner.css'; diff --git a/server/sonar-web/src/main/js/components/ui/DismissableAlert.tsx b/server/sonar-web/src/main/js/components/ui/DismissableAlert.tsx index 2f99e376f51..b6f5e08fb33 100644 --- a/server/sonar-web/src/main/js/components/ui/DismissableAlert.tsx +++ b/server/sonar-web/src/main/js/components/ui/DismissableAlert.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { ButtonIcon } from '../../components/controls/buttons'; import ClearIcon from '../../components/icons/ClearIcon'; diff --git a/server/sonar-web/src/main/js/components/ui/DuplicationsRating.tsx b/server/sonar-web/src/main/js/components/ui/DuplicationsRating.tsx index 1c1d2595e32..ff6943f5636 100644 --- a/server/sonar-web/src/main/js/components/ui/DuplicationsRating.tsx +++ b/server/sonar-web/src/main/js/components/ui/DuplicationsRating.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import { inRange } from 'lodash'; import * as React from 'react'; import './DuplicationsRating.css'; diff --git a/server/sonar-web/src/main/js/components/ui/GenericAvatar.tsx b/server/sonar-web/src/main/js/components/ui/GenericAvatar.tsx index d9c78da675d..dc27eb68594 100644 --- a/server/sonar-web/src/main/js/components/ui/GenericAvatar.tsx +++ b/server/sonar-web/src/main/js/components/ui/GenericAvatar.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { getTextColor, stringToColor } from '../../helpers/colors'; diff --git a/server/sonar-web/src/main/js/components/ui/Level.tsx b/server/sonar-web/src/main/js/components/ui/Level.tsx index 5b5174470cc..2231bd2c221 100644 --- a/server/sonar-web/src/main/js/components/ui/Level.tsx +++ b/server/sonar-web/src/main/js/components/ui/Level.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { formatMeasure } from '../../helpers/measures'; import './Level.css'; diff --git a/server/sonar-web/src/main/js/components/ui/MandatoryFieldMarker.tsx b/server/sonar-web/src/main/js/components/ui/MandatoryFieldMarker.tsx index bedf016d2a6..db2c76c6cc6 100644 --- a/server/sonar-web/src/main/js/components/ui/MandatoryFieldMarker.tsx +++ b/server/sonar-web/src/main/js/components/ui/MandatoryFieldMarker.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { translate } from '../../helpers/l10n'; diff --git a/server/sonar-web/src/main/js/components/ui/MandatoryFieldsExplanation.tsx b/server/sonar-web/src/main/js/components/ui/MandatoryFieldsExplanation.tsx index 67ef7370bca..093073c0e71 100644 --- a/server/sonar-web/src/main/js/components/ui/MandatoryFieldsExplanation.tsx +++ b/server/sonar-web/src/main/js/components/ui/MandatoryFieldsExplanation.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { FormattedMessage } from 'react-intl'; import { translate } from '../../helpers/l10n'; diff --git a/server/sonar-web/src/main/js/components/ui/NavBar.tsx b/server/sonar-web/src/main/js/components/ui/NavBar.tsx index 5f6de14ffaa..82f2ad47539 100644 --- a/server/sonar-web/src/main/js/components/ui/NavBar.tsx +++ b/server/sonar-web/src/main/js/components/ui/NavBar.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import { throttle } from 'lodash'; import * as React from 'react'; import './NavBar.css'; diff --git a/server/sonar-web/src/main/js/components/ui/NavBarTabs.tsx b/server/sonar-web/src/main/js/components/ui/NavBarTabs.tsx index d10bb7b4446..2d61c1ab42b 100644 --- a/server/sonar-web/src/main/js/components/ui/NavBarTabs.tsx +++ b/server/sonar-web/src/main/js/components/ui/NavBarTabs.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import './NavBarTabs.css'; diff --git a/server/sonar-web/src/main/js/components/ui/NewsBox.tsx b/server/sonar-web/src/main/js/components/ui/NewsBox.tsx index 27626765848..d93194bdaff 100644 --- a/server/sonar-web/src/main/js/components/ui/NewsBox.tsx +++ b/server/sonar-web/src/main/js/components/ui/NewsBox.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { translate } from '../../helpers/l10n'; import { ClearButton } from '../controls/buttons'; diff --git a/server/sonar-web/src/main/js/components/ui/PageShortcutsTooltip.tsx b/server/sonar-web/src/main/js/components/ui/PageShortcutsTooltip.tsx index 00cffc0f4bf..9a3a38b80a4 100644 --- a/server/sonar-web/src/main/js/components/ui/PageShortcutsTooltip.tsx +++ b/server/sonar-web/src/main/js/components/ui/PageShortcutsTooltip.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import Tooltip from '../../components/controls/Tooltip'; import { translate, translateWithParameters } from '../../helpers/l10n'; diff --git a/server/sonar-web/src/main/js/components/ui/Rating.tsx b/server/sonar-web/src/main/js/components/ui/Rating.tsx index 91c661ffc97..4fe2b295f93 100644 --- a/server/sonar-web/src/main/js/components/ui/Rating.tsx +++ b/server/sonar-web/src/main/js/components/ui/Rating.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { translate, translateWithParameters } from '../../helpers/l10n'; import { formatMeasure } from '../../helpers/measures'; diff --git a/server/sonar-web/src/main/js/components/ui/SizeRating.tsx b/server/sonar-web/src/main/js/components/ui/SizeRating.tsx index c6c71072fdb..614f9e7af7a 100644 --- a/server/sonar-web/src/main/js/components/ui/SizeRating.tsx +++ b/server/sonar-web/src/main/js/components/ui/SizeRating.tsx @@ -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. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import { inRange } from 'lodash'; import * as React from 'react'; import './SizeRating.css'; diff --git a/server/sonar-web/src/main/js/components/ui/__tests__/DismissableAlert-test.tsx b/server/sonar-web/src/main/js/components/ui/__tests__/DismissableAlert-test.tsx index 2dced3bd8b9..f7a77ebb46f 100644 --- a/server/sonar-web/src/main/js/components/ui/__tests__/DismissableAlert-test.tsx +++ b/server/sonar-web/src/main/js/components/ui/__tests__/DismissableAlert-test.tsx @@ -19,7 +19,7 @@ */ import { shallow } from 'enzyme'; -import * as React from 'react'; +import React from 'react'; import { ButtonIcon } from '../../../components/controls/buttons'; import { save } from '../../../helpers/storage'; import { click } from '../../../helpers/testUtils'; diff --git a/server/sonar-web/src/main/js/components/ui/popups.tsx b/server/sonar-web/src/main/js/components/ui/popups.tsx index 5873d0f658f..881cc2a2469 100644 --- a/server/sonar-web/src/main/js/components/ui/popups.tsx +++ b/server/sonar-web/src/main/js/components/ui/popups.tsx @@ -20,7 +20,7 @@ /* eslint-disable prefer-destructuring */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import { throttle } from 'lodash'; import * as React from 'react'; import { createPortal, findDOMNode } from 'react-dom'; diff --git a/server/sonar-web/src/main/js/components/ui/update-center/MetaData.tsx b/server/sonar-web/src/main/js/components/ui/update-center/MetaData.tsx index b6918749d99..79e5759071d 100644 --- a/server/sonar-web/src/main/js/components/ui/update-center/MetaData.tsx +++ b/server/sonar-web/src/main/js/components/ui/update-center/MetaData.tsx @@ -18,10 +18,10 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; +import { isSuccessStatus } from '../../../helpers/request'; import './MetaData.css'; import MetaDataVersions from './MetaDataVersions'; import { MetaDataInformation } from './update-center-metadata'; -import { isSuccessStatus } from '../../../helpers/request'; interface Props { updateCenterKey?: string; diff --git a/server/sonar-web/src/main/js/components/ui/update-center/__tests__/MetaData-test.tsx b/server/sonar-web/src/main/js/components/ui/update-center/__tests__/MetaData-test.tsx index e89307b350a..3f40982899c 100644 --- a/server/sonar-web/src/main/js/components/ui/update-center/__tests__/MetaData-test.tsx +++ b/server/sonar-web/src/main/js/components/ui/update-center/__tests__/MetaData-test.tsx @@ -19,11 +19,11 @@ */ import { shallow } from 'enzyme'; import * as React from 'react'; +import { HttpStatus } from '../../../../helpers/request'; import { waitAndUpdate } from '../../../../helpers/testUtils'; import MetaData from '../MetaData'; import { mockMetaDataInformation } from '../mocks/update-center-metadata'; import { MetaDataInformation } from '../update-center-metadata'; -import { HttpStatus } from '../../../../helpers/request'; beforeAll(() => { window.fetch = jest.fn(); diff --git a/server/sonar-web/src/main/js/helpers/__tests__/extensions-test.ts b/server/sonar-web/src/main/js/helpers/__tests__/extensions-test.ts index fe842cae95d..20df8a7491e 100644 --- a/server/sonar-web/src/main/js/helpers/__tests__/extensions-test.ts +++ b/server/sonar-web/src/main/js/helpers/__tests__/extensions-test.ts @@ -21,9 +21,7 @@ import exposeLibraries from '../../app/components/extensions/exposeLibraries'; import { getExtensionStart, installScript } from '../extensions'; import { installExtensionsHandler } from '../extensionsHandler'; -jest.mock('../../app/components/extensions/exposeLibraries', () => ({ - default: jest.fn() -})); +jest.mock('../../app/components/extensions/exposeLibraries', () => jest.fn()); beforeEach(() => { jest.clearAllMocks(); diff --git a/server/sonar-web/src/main/js/helpers/__tests__/getHistory-test.ts b/server/sonar-web/src/main/js/helpers/__tests__/getHistory-test.ts index b5a66227d57..839ed9eca4d 100644 --- a/server/sonar-web/src/main/js/helpers/__tests__/getHistory-test.ts +++ b/server/sonar-web/src/main/js/helpers/__tests__/getHistory-test.ts @@ -17,13 +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. */ -import * as Router from 'react-router'; +import { browserHistory } from 'react-router'; import getHistory from '../getHistory'; it('should get browser history properly', () => { expect(getHistory()).not.toBeUndefined(); expect(getHistory().getCurrentLocation().pathname).toBe('/'); const pathname = '/foo/bar'; - Router.browserHistory.push(pathname); + browserHistory.push(pathname); expect(getHistory().getCurrentLocation().pathname).toBe(pathname); }); diff --git a/server/sonar-web/src/main/js/helpers/__tests__/handleRequiredAuthentication-test.ts b/server/sonar-web/src/main/js/helpers/__tests__/handleRequiredAuthentication-test.ts index dfb377e6a7a..0f5b0b49664 100644 --- a/server/sonar-web/src/main/js/helpers/__tests__/handleRequiredAuthentication-test.ts +++ b/server/sonar-web/src/main/js/helpers/__tests__/handleRequiredAuthentication-test.ts @@ -20,9 +20,7 @@ import getHistory from '../getHistory'; import handleRequiredAuthentication from '../handleRequiredAuthentication'; -jest.mock('../getHistory', () => ({ - default: jest.fn() -})); +jest.mock('../getHistory', () => jest.fn()); it('should not render for anonymous user', () => { const replace = jest.fn(); diff --git a/server/sonar-web/src/main/js/helpers/__tests__/request-test.ts b/server/sonar-web/src/main/js/helpers/__tests__/request-test.ts index f4729185ef4..55818d0e7d9 100644 --- a/server/sonar-web/src/main/js/helpers/__tests__/request-test.ts +++ b/server/sonar-web/src/main/js/helpers/__tests__/request-test.ts @@ -36,7 +36,7 @@ import { requestTryAndRepeatUntil } from '../request'; -jest.mock('../handleRequiredAuthentication', () => ({ default: jest.fn() })); +jest.mock('../handleRequiredAuthentication', () => jest.fn()); const url = '/my-url'; @@ -187,6 +187,18 @@ describe('post', () => { expect(response.json).not.toBeCalled(); expect(response.text).not.toBeCalled(); }); + + it('should handle array values', async () => { + const response = mockResponse(); + window.fetch = jest.fn().mockResolvedValue(response); + post(url, { dataArray: ['1', '2'] }); + await new Promise(setImmediate); + + expect(window.fetch).toBeCalledWith( + url, + expect.objectContaining({ body: 'dataArray=1&dataArray=2', method: 'POST' }) + ); + }); }); describe('requestTryAndRepeatUntil', () => { diff --git a/server/sonar-web/src/main/js/helpers/dates.ts b/server/sonar-web/src/main/js/helpers/dates.ts index daa25a7b603..f7944f3955a 100644 --- a/server/sonar-web/src/main/js/helpers/dates.ts +++ b/server/sonar-web/src/main/js/helpers/dates.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. */ -import * as parse from 'date-fns/parse'; +import { parse } from 'date-fns'; function pad(number: number) { if (number < 10) { diff --git a/server/sonar-web/src/main/js/helpers/editions.ts b/server/sonar-web/src/main/js/helpers/editions.ts index f57cfbfd2dc..20a9d626c15 100644 --- a/server/sonar-web/src/main/js/helpers/editions.ts +++ b/server/sonar-web/src/main/js/helpers/editions.ts @@ -17,7 +17,6 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import { stringify } from 'querystring'; import { omitNil } from '../helpers/request'; import { Edition, EditionKey } from '../types/editions'; import { SystemUpgrade } from '../types/system'; @@ -64,7 +63,7 @@ export function getEditionUrl( data: { serverId?: string; ncloc?: number; sourceEdition?: EditionKey } ) { let url = edition.homeUrl; - const query = stringify(omitNil(data)); + const query = new URLSearchParams(omitNil(data)).toString(); if (query) { url += '?' + query; } diff --git a/server/sonar-web/src/main/js/helpers/urls.ts b/server/sonar-web/src/main/js/helpers/urls.ts index 879d809e080..9a21a7ce814 100644 --- a/server/sonar-web/src/main/js/helpers/urls.ts +++ b/server/sonar-web/src/main/js/helpers/urls.ts @@ -18,7 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { isNil, omitBy, pick } from 'lodash'; -import { stringify } from 'querystring'; import { getProfilePath } from '../apps/quality-profiles/utils'; import { BranchLike, BranchParameters } from '../types/branch-like'; import { ComponentQualifier, isApplication, isPortfolioLike } from '../types/component'; @@ -333,9 +332,9 @@ export function getHostUrl(): string { } export function getPathUrlAsString(path: Location, internal = true): string { - return `${internal ? getBaseUrl() : getHostUrl()}${path.pathname}?${stringify( + return `${internal ? getBaseUrl() : getHostUrl()}${path.pathname}?${new URLSearchParams( omitBy(path.query, isNil) - )}`; + ).toString()}`; } export function getReturnUrl(location: { hash?: string; query?: { return_to?: string } }) { |