diff options
author | Stas Vilchik <stas.vilchik@sonarsource.com> | 2017-12-15 15:29:41 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-15 15:29:41 +0100 |
commit | 99c250bebeb529e77e6472750b47caee98c0edd3 (patch) | |
tree | be21932c60d73f6454545847c2a2744b041fe0c4 /server/sonar-web | |
parent | f26d933e1ecbd9ca104a6e1e0eb251462056aca8 (diff) | |
download | sonarqube-99c250bebeb529e77e6472750b47caee98c0edd3.tar.gz sonarqube-99c250bebeb529e77e6472750b47caee98c0edd3.zip |
update typescript and prettier, use shortcut fragment syntax (#2913)
Diffstat (limited to 'server/sonar-web')
20 files changed, 105 insertions, 112 deletions
diff --git a/server/sonar-web/package.json b/server/sonar-web/package.json index 1610cd1f0bf..43c73375f6c 100644 --- a/server/sonar-web/package.json +++ b/server/sonar-web/package.json @@ -96,14 +96,14 @@ "postcss-calc": "6.0.1", "postcss-custom-properties": "6.2.0", "postcss-loader": "2.0.8", - "prettier": "1.7.4", + "prettier": "1.9.2", "react-error-overlay": "1.0.7", "react-test-renderer": "16.2.0", "rimraf": "2.6.2", "style-loader": "0.19.0", "ts-jest": "21.1.4", - "typescript": "2.5.3", - "typescript-eslint-parser": "8.0.1", + "typescript": "2.6.2", + "typescript-eslint-parser": "11.0.0", "webpack": "3.8.1", "webpack-bundle-analyzer": "2.9.0", "webpack-dev-server": "2.9.3" diff --git a/server/sonar-web/src/main/js/api/plugins.ts b/server/sonar-web/src/main/js/api/plugins.ts index a8ea293b1e6..2579825b9ac 100644 --- a/server/sonar-web/src/main/js/api/plugins.ts +++ b/server/sonar-web/src/main/js/api/plugins.ts @@ -86,14 +86,12 @@ function getLastUpdates(updates: undefined | Update[]): Update[] { if (!updates) { return []; } - const lastUpdate = [ - 'COMPATIBLE', - 'REQUIRES_SYSTEM_UPGRADE', - 'DEPS_REQUIRE_SYSTEM_UPGRADE' - ].map(status => { - const index = findLastIndex(updates, update => update.status === status); - return index > -1 ? updates[index] : undefined; - }); + const lastUpdate = ['COMPATIBLE', 'REQUIRES_SYSTEM_UPGRADE', 'DEPS_REQUIRE_SYSTEM_UPGRADE'].map( + status => { + const index = findLastIndex(updates, update => update.status === status); + return index > -1 ? updates[index] : undefined; + } + ); return lastUpdate.filter(Boolean) as Update[]; } diff --git a/server/sonar-web/src/main/js/app/components/ComponentContainer.tsx b/server/sonar-web/src/main/js/app/components/ComponentContainer.tsx index f790ab376fe..eb02ba1d579 100644 --- a/server/sonar-web/src/main/js/app/components/ComponentContainer.tsx +++ b/server/sonar-web/src/main/js/app/components/ComponentContainer.tsx @@ -89,26 +89,26 @@ export class ComponentContainer extends React.PureComponent<Props, State> { } }; - Promise.all([ - getComponentNavigation(id, branch), - getComponentData(id, branch) - ]).then(([nav, data]) => { - const component = this.addQualifier({ ...nav, ...data }); - - if (this.props.organizationsEnabled) { - this.props.fetchOrganizations([component.organization]); - } + Promise.all([getComponentNavigation(id, branch), getComponentData(id, branch)]).then( + ([nav, data]) => { + const component = this.addQualifier({ ...nav, ...data }); - this.fetchBranches(component).then(branches => { - if (this.mounted) { - this.setState({ loading: false, branches, component }); + if (this.props.organizationsEnabled) { + this.props.fetchOrganizations([component.organization]); } - }, onError); - }, onError); + + this.fetchBranches(component).then(branches => { + if (this.mounted) { + this.setState({ loading: false, branches, component }); + } + }, onError); + }, + onError + ); } fetchBranches = (component: Component) => { - const project = component.breadcrumbs.find((c: Component) => c.qualifier === 'TRK'); + const project = component.breadcrumbs.find(({ qualifier }) => qualifier === 'TRK'); return project ? getBranches(project.key) : Promise.resolve([]); }; 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 8f13a285693..2dbc6fe9ea4 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 @@ -68,17 +68,17 @@ export default class ComponentNav extends React.PureComponent<Props, State> { } loadStatus = () => { - getTasksForComponent( - this.props.component.key - ).then((r: { queue: PendingTask[]; current: Task }) => { - if (this.mounted) { - this.setState({ - currentTask: r.current, - isInProgress: r.queue.some(task => task.status === STATUSES.IN_PROGRESS), - isPending: r.queue.some(task => task.status === STATUSES.PENDING) - }); + getTasksForComponent(this.props.component.key).then( + (r: { queue: PendingTask[]; current: Task }) => { + if (this.mounted) { + this.setState({ + currentTask: r.current, + isInProgress: r.queue.some(task => task.status === STATUSES.IN_PROGRESS), + isPending: r.queue.some(task => task.status === STATUSES.PENDING) + }); + } } - }); + ); }; populateRecentHistory = () => { diff --git a/server/sonar-web/src/main/js/app/utils/startReactApp.js b/server/sonar-web/src/main/js/app/utils/startReactApp.js index 0040ae22fa8..8866517ccab 100644 --- a/server/sonar-web/src/main/js/app/utils/startReactApp.js +++ b/server/sonar-web/src/main/js/app/utils/startReactApp.js @@ -185,7 +185,8 @@ const startReactApp = () => { <Route getComponent={() => - import('../components/ComponentContainer').then(i => i.default)}> + import('../components/ComponentContainer').then(i => i.default) + }> <Route path="code" childRoutes={codeRoutes} /> <Route path="component_measures" childRoutes={componentMeasuresRoutes} /> <Route path="dashboard" childRoutes={overviewRoutes} /> diff --git a/server/sonar-web/src/main/js/apps/account/organizations/OrganizationsList.js b/server/sonar-web/src/main/js/apps/account/organizations/OrganizationsList.js index 621f1b59117..921b636dd3a 100644 --- a/server/sonar-web/src/main/js/apps/account/organizations/OrganizationsList.js +++ b/server/sonar-web/src/main/js/apps/account/organizations/OrganizationsList.js @@ -32,13 +32,13 @@ type Props = { export default function OrganizationsList(props /*: Props */) { return ( <ul className="account-projects-list"> - {sortBy(props.organizations, organization => - organization.name.toLocaleLowerCase() - ).map(organization => ( - <li key={organization.key}> - <OrganizationCard organization={organization} /> - </li> - ))} + {sortBy(props.organizations, organization => organization.name.toLocaleLowerCase()).map( + organization => ( + <li key={organization.key}> + <OrganizationCard organization={organization} /> + </li> + ) + )} </ul> ); } 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 8412774fc27..f4198dcc060 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 @@ -102,7 +102,7 @@ export default class Component extends React.PureComponent<Props> { { metric: 'sqale_rating', type: 'RATING' }, { metric: 'ncloc', type: 'SHORT_INT' } ] - : [ + : ([ isApplication && { metric: 'alert_status', type: 'LEVEL' }, { metric: 'ncloc', type: 'SHORT_INT' }, { metric: 'bugs', type: 'SHORT_INT' }, @@ -110,7 +110,7 @@ export default class Component extends React.PureComponent<Props> { { metric: 'code_smells', type: 'SHORT_INT' }, { metric: 'coverage', type: 'PERCENT' }, { metric: 'duplicated_lines_density', type: 'PERCENT' } - ].filter(Boolean) as Array<{ metric: string; type: string }>; + ].filter(Boolean) as Array<{ metric: string; type: string }>); return ( <tr className={classNames({ selected })} ref={node => (this.node = node as HTMLElement)}> 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 a2138a020b4..69590a84ce5 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 @@ -38,7 +38,7 @@ export default function ComponentsHeader({ baseComponent, rootComponent }: Props translate('metric_domain.Maintainability'), translate('metric', 'ncloc', 'name') ] - : [ + : ([ isApplication && translate('metric.alert_status.name'), translate('metric', 'ncloc', 'name'), translate('metric', 'bugs', 'name'), @@ -46,7 +46,7 @@ export default function ComponentsHeader({ baseComponent, rootComponent }: Props translate('metric', 'code_smells', 'name'), translate('metric', 'coverage', 'name'), translate('metric', 'duplicated_lines_density', 'short_name') - ].filter(Boolean) as string[]; + ].filter(Boolean) as string[]); return ( <thead> diff --git a/server/sonar-web/src/main/js/apps/marketplace/App.tsx b/server/sonar-web/src/main/js/apps/marketplace/App.tsx index 6ee7fd37bbc..41868176456 100644 --- a/server/sonar-web/src/main/js/apps/marketplace/App.tsx +++ b/server/sonar-web/src/main/js/apps/marketplace/App.tsx @@ -109,17 +109,17 @@ export default class App extends React.PureComponent<Props, State> { fetchAllPlugins = () => { this.setState({ loadingPlugins: true }); - Promise.all([ - getInstalledPluginsWithUpdates(), - getAvailablePlugins() - ]).then(([installed, available]) => { - if (this.mounted) { - this.setState({ - loadingPlugins: false, - plugins: sortBy(uniqBy([...installed, ...available.plugins], 'key'), 'name') - }); - } - }, this.stopLoadingPlugins); + Promise.all([getInstalledPluginsWithUpdates(), getAvailablePlugins()]).then( + ([installed, available]) => { + if (this.mounted) { + this.setState({ + loadingPlugins: false, + plugins: sortBy(uniqBy([...installed, ...available.plugins], 'key'), 'name') + }); + } + }, + this.stopLoadingPlugins + ); }; fetchUpdatesOnly = () => { diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/Event.js b/server/sonar-web/src/main/js/apps/projectActivity/components/Event.js index 8cec8967717..182fb442459 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/Event.js +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/Event.js @@ -122,9 +122,9 @@ export default class Event extends React.PureComponent { removeEventButtonText={ 'project_activity.' + (isVersion ? 'remove_version' : 'remove_custom_event') } - removeEventQuestion={`project_activity.${isVersion - ? 'remove_version' - : 'remove_custom_event'}.question`} + removeEventQuestion={`project_activity.${ + isVersion ? 'remove_version' : 'remove_custom_event' + }.question`} /> )} </div> diff --git a/server/sonar-web/src/main/js/apps/projects/components/PageSidebar.tsx b/server/sonar-web/src/main/js/apps/projects/components/PageSidebar.tsx index d22864bc006..d45257e1984 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/PageSidebar.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/PageSidebar.tsx @@ -82,7 +82,7 @@ export default function PageSidebar(props: Props) { </div> <QualityGateFilter {...facetProps} facet={facets && facets.gate} value={query.gate} /> {!isLeakView && ( - <React.Fragment> + <> <ReliabilityFilter {...facetProps} facet={facets && facets.reliability} @@ -109,10 +109,10 @@ export default function PageSidebar(props: Props) { value={query.duplications} /> <SizeFilter {...facetProps} facet={facets && facets.size} value={query.size} /> - </React.Fragment> + </> )} {isLeakView && ( - <React.Fragment> + <> <NewReliabilityFilter {...facetProps} facet={facets && facets.new_reliability} @@ -143,7 +143,7 @@ export default function PageSidebar(props: Props) { facet={facets && facets.new_lines} value={query.new_lines} /> - </React.Fragment> + </> )} <LanguagesFilterContainer {...facetProps} diff --git a/server/sonar-web/src/main/js/apps/projects/components/ProjectsSortingSelect.tsx b/server/sonar-web/src/main/js/apps/projects/components/ProjectsSortingSelect.tsx index 5fdcec83a09..884e43929e4 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/ProjectsSortingSelect.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/ProjectsSortingSelect.tsx @@ -42,14 +42,13 @@ export default class ProjectsSortingSelect extends React.PureComponent<Props> { getOptions = () => { const sortMetrics = this.props.view === 'leak' ? SORTING_LEAK_METRICS : SORTING_METRICS; - return sortBy( - sortMetrics, - option => (option.value === this.props.defaultOption ? 0 : 1) - ).map(option => ({ - value: option.value, - label: translate('projects.sorting', option.value), - class: option.class - })); + return sortBy(sortMetrics, option => (option.value === this.props.defaultOption ? 0 : 1)).map( + option => ({ + value: option.value, + label: translate('projects.sorting', option.value), + class: option.class + }) + ); }; handleDescToggle = () => { diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/changelog/__tests__/Changelog-test.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/changelog/__tests__/Changelog-test.tsx index 6272bcc2f12..66c06ac5e9a 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/changelog/__tests__/Changelog-test.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/changelog/__tests__/Changelog-test.tsx @@ -23,7 +23,7 @@ import Changelog from '../Changelog'; import ChangesList from '../ChangesList'; import { ProfileChangelogEvent } from '../../types'; -function createEvent(overrides?: { [p: string]: any }): ProfileChangelogEvent { +function createEvent(overrides?: Partial<ProfileChangelogEvent>): ProfileChangelogEvent { return { date: '2016-01-01', authorName: 'John', @@ -31,7 +31,6 @@ function createEvent(overrides?: { [p: string]: any }): ProfileChangelogEvent { ruleKey: 'squid1234', ruleName: 'Do not do this', params: {}, - organization: null, ...overrides }; } diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonResults.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonResults.tsx index a98f0e91b5f..1ba6f4fd5eb 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonResults.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonResults.tsx @@ -74,7 +74,7 @@ export default class ComparisonResults extends React.PureComponent<Props> { return null; } return ( - <React.Fragment> + <> <tr> <td> <h6> @@ -93,7 +93,7 @@ export default class ComparisonResults extends React.PureComponent<Props> { <td> </td> </tr> ))} - </React.Fragment> + </> ); } @@ -102,7 +102,7 @@ export default class ComparisonResults extends React.PureComponent<Props> { return null; } return ( - <React.Fragment> + <> <tr> <td> </td> <td> @@ -121,7 +121,7 @@ export default class ComparisonResults extends React.PureComponent<Props> { <td>{this.renderRule(rule, rule.severity)}</td> </tr> ))} - </React.Fragment> + </> ); } @@ -130,7 +130,7 @@ export default class ComparisonResults extends React.PureComponent<Props> { return null; } return ( - <React.Fragment> + <> <tr> <td colSpan={2} className="text-center"> <h6> @@ -161,7 +161,7 @@ export default class ComparisonResults extends React.PureComponent<Props> { </td> </tr> ))} - </React.Fragment> + </> ); } diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfilePermissionsForm.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfilePermissionsForm.tsx index 0732a1f0783..ba788305e51 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfilePermissionsForm.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfilePermissionsForm.tsx @@ -99,13 +99,9 @@ export default class ProfilePermissionsForm extends React.PureComponent<Props, S qualityProfile: profile.name, selected: 'deselected' }; - return Promise.all([ - searchUsers(parameters), - searchGroups(parameters) - ]).then(([usersResponse, groupsResponse]) => [ - ...usersResponse.users, - ...groupsResponse.groups - ]); + return Promise.all([searchUsers(parameters), searchGroups(parameters)]).then( + ([usersResponse, groupsResponse]) => [...usersResponse.users, ...groupsResponse.groups] + ); }; handleValueChange = (selected: User | Group) => { diff --git a/server/sonar-web/src/main/js/apps/sessions/components/LoginFormContainer.tsx b/server/sonar-web/src/main/js/apps/sessions/components/LoginFormContainer.tsx index f4096338e9a..71fff3c8330 100644 --- a/server/sonar-web/src/main/js/apps/sessions/components/LoginFormContainer.tsx +++ b/server/sonar-web/src/main/js/apps/sessions/components/LoginFormContainer.tsx @@ -41,18 +41,17 @@ class LoginFormContainer extends React.PureComponent<Props, State> { componentDidMount() { this.mounted = true; - Promise.all([ - getIdentityProviders(), - tryGetGlobalNavigation() - ]).then(([identityProvidersResponse, appState]) => { - if (this.mounted) { - this.setState({ - onSonarCloud: - appState.settings && appState.settings['sonar.sonarcloud.enabled'] === 'true', - identityProviders: identityProvidersResponse.identityProviders - }); + Promise.all([getIdentityProviders(), tryGetGlobalNavigation()]).then( + ([identityProvidersResponse, appState]) => { + if (this.mounted) { + this.setState({ + onSonarCloud: + appState.settings && appState.settings['sonar.sonarcloud.enabled'] === 'true', + identityProviders: identityProvidersResponse.identityProviders + }); + } } - }); + ); } componentWillUnmount() { diff --git a/server/sonar-web/src/main/js/apps/users/components/UserActions.tsx b/server/sonar-web/src/main/js/apps/users/components/UserActions.tsx index 4d3302709f0..ac2710c00d7 100644 --- a/server/sonar-web/src/main/js/apps/users/components/UserActions.tsx +++ b/server/sonar-web/src/main/js/apps/users/components/UserActions.tsx @@ -76,7 +76,7 @@ export default class UserActions extends React.PureComponent<Props, State> { const { isCurrentUser, onUpdateUsers, user } = this.props; return ( - <React.Fragment> + <> {this.renderActions()} {openForm === 'deactivate' && ( <DeactivateForm @@ -91,7 +91,7 @@ export default class UserActions extends React.PureComponent<Props, State> { {openForm === 'update' && ( <UserForm onClose={this.handleCloseForm} onUpdateUsers={onUpdateUsers} user={user} /> )} - </React.Fragment> + </> ); } } diff --git a/server/sonar-web/src/main/js/helpers/request.ts b/server/sonar-web/src/main/js/helpers/request.ts index 3aa3a90248c..0164bb2ed10 100644 --- a/server/sonar-web/src/main/js/helpers/request.ts +++ b/server/sonar-web/src/main/js/helpers/request.ts @@ -167,7 +167,7 @@ export function parseJSON(response: Response): Promise<any> { return response.json(); } -/** +/** * Parse response of failed request */ export function parseError(error: { response: Response }): Promise<string> { diff --git a/server/sonar-web/tsconfig.json b/server/sonar-web/tsconfig.json index 427192d12e7..a99673585de 100644 --- a/server/sonar-web/tsconfig.json +++ b/server/sonar-web/tsconfig.json @@ -6,6 +6,7 @@ "noUnusedParameters": true, "noImplicitAny": true, "strict": true, + "strictFunctionTypes": false, "target": "es5", "jsx": "react", "lib": ["es2017", "dom"], diff --git a/server/sonar-web/yarn.lock b/server/sonar-web/yarn.lock index 79a4fa67c81..86da451ace2 100644 --- a/server/sonar-web/yarn.lock +++ b/server/sonar-web/yarn.lock @@ -5837,9 +5837,9 @@ preserve@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b" -prettier@1.7.4: - version "1.7.4" - resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.7.4.tgz#5e8624ae9363c80f95ec644584ecdf55d74f93fa" +prettier@1.9.2: + version "1.9.2" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.9.2.tgz#96bc2132f7a32338e6078aeb29727178c6335827" pretty-error@^2.0.2: version "2.1.1" @@ -7305,16 +7305,16 @@ typedarray@^0.0.6: version "0.0.6" resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" -typescript-eslint-parser@8.0.1: - version "8.0.1" - resolved "https://registry.yarnpkg.com/typescript-eslint-parser/-/typescript-eslint-parser-8.0.1.tgz#e8cac537d996e16c3dbb0d7c4d509799e67afe0c" +typescript-eslint-parser@11.0.0: + version "11.0.0" + resolved "https://registry.yarnpkg.com/typescript-eslint-parser/-/typescript-eslint-parser-11.0.0.tgz#37dba6a0130dd307504aa4b4b21b0d3dc7d4e9f2" dependencies: lodash.unescape "4.0.1" semver "5.4.1" -typescript@2.5.3: - version "2.5.3" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.5.3.tgz#df3dcdc38f3beb800d4bc322646b04a3f6ca7f0d" +typescript@2.6.2: + version "2.6.2" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.6.2.tgz#3c5b6fd7f6de0914269027f03c0946758f7673a4" ua-parser-js@^0.7.9: version "0.7.17" |