]> source.dussan.org Git - sonarqube.git/commitdiff
update typescript and prettier, use shortcut fragment syntax (#2913)
authorStas Vilchik <stas.vilchik@sonarsource.com>
Fri, 15 Dec 2017 14:29:41 +0000 (15:29 +0100)
committerGitHub <noreply@github.com>
Fri, 15 Dec 2017 14:29:41 +0000 (15:29 +0100)
20 files changed:
server/sonar-web/package.json
server/sonar-web/src/main/js/api/plugins.ts
server/sonar-web/src/main/js/app/components/ComponentContainer.tsx
server/sonar-web/src/main/js/app/components/nav/component/ComponentNav.tsx
server/sonar-web/src/main/js/app/utils/startReactApp.js
server/sonar-web/src/main/js/apps/account/organizations/OrganizationsList.js
server/sonar-web/src/main/js/apps/code/components/Component.tsx
server/sonar-web/src/main/js/apps/code/components/ComponentsHeader.tsx
server/sonar-web/src/main/js/apps/marketplace/App.tsx
server/sonar-web/src/main/js/apps/projectActivity/components/Event.js
server/sonar-web/src/main/js/apps/projects/components/PageSidebar.tsx
server/sonar-web/src/main/js/apps/projects/components/ProjectsSortingSelect.tsx
server/sonar-web/src/main/js/apps/quality-profiles/changelog/__tests__/Changelog-test.tsx
server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonResults.tsx
server/sonar-web/src/main/js/apps/quality-profiles/details/ProfilePermissionsForm.tsx
server/sonar-web/src/main/js/apps/sessions/components/LoginFormContainer.tsx
server/sonar-web/src/main/js/apps/users/components/UserActions.tsx
server/sonar-web/src/main/js/helpers/request.ts
server/sonar-web/tsconfig.json
server/sonar-web/yarn.lock

index 1610cd1f0bf9d2362a81c5665f98ff2b92e00dcd..43c73375f6cc9081b68cb8ea8f2bdab44363d379 100644 (file)
     "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"
index a8ea293b1e6ded14bb040184afc6eabf2eabd65a..2579825b9acf40da1c47db38c593dd84a46c697e 100644 (file)
@@ -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[];
 }
 
index f790ab376fef667959db2743690d9a6e46efcc78..eb02ba1d579e48729a054ac7adaf90c1a4b1ade9 100644 (file)
@@ -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([]);
   };
 
index 8f13a285693d71c1d2a3319d67e4c168c4f4d7f4..2dbc6fe9ea480ffaf5fcbf84c7ded8ee8796c2a4 100644 (file)
@@ -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 = () => {
index 0040ae22fa87dec5f8c2070fcf247715a2b8927c..8866517ccab90f5cf3175563219ec7863e7434e3 100644 (file)
@@ -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} />
index 621f1b59117beb398fb28daff1d4a3ce6549cb90..921b636dd3ade01e3552c9809abbdb7e42b85563 100644 (file)
@@ -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>
   );
 }
index 8412774fc27d9d557a0780306bacc0ab026f668c..f4198dcc0600ab4d45ffdf868b1c663d11360cd1 100644 (file)
@@ -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)}>
index a2138a020b4cd5ec020c192080d1a68382f36fd6..69590a84ce5bddc217f61d2cdad5a9ff61527ade 100644 (file)
@@ -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>
index 6ee7fd37bbc2e8711cb3e62a07e864a214b0b481..418681764567d02937c971396e232776365b5266 100644 (file)
@@ -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 = () => {
index 8cec89677170171beef071ef4488922b1db5f478..182fb442459b93f475027598285028de5a165ba9 100644 (file)
@@ -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>
index d22864bc00624edbbbb4437febbc97ef66ccd0ae..d45257e19848fafb83fc6e136097d82d7d93d194 100644 (file)
@@ -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}
index 5fdcec83a09f044eb6e5cb9ef205e33db838dfe3..884e43929e469f3673890f48d6b11c6e630b4307 100644 (file)
@@ -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 = () => {
index 6272bcc2f12683e62b6ccd3cf349795e7c7fb668..66c06ac5e9a2dbf31b1aca6c18b623fb69562374 100644 (file)
@@ -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
   };
 }
index a98f0e91b5fd7860181b81ebcaf690eaf31c8046..1ba6f4fd5eb7919924e604016d7daf2246234b40 100644 (file)
@@ -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>&nbsp;</td>
           </tr>
         ))}
-      </React.Fragment>
+      </>
     );
   }
 
@@ -102,7 +102,7 @@ export default class ComparisonResults extends React.PureComponent<Props> {
       return null;
     }
     return (
-      <React.Fragment>
+      <>
         <tr>
           <td>&nbsp;</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>
+      </>
     );
   }
 
index 0732a1f0783ab9be5e15342cc72a7673a4210f84..ba788305e51e7e645c541f293b92b250182955d4 100644 (file)
@@ -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) => {
index f4096338e9ab2a5bd430c0331322b7674958eb38..71fff3c8330bd5c2fc1dd713046abda5e9a5da84 100644 (file)
@@ -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() {
index 4d3302709f0bf1bd961d8dce1bd000cb0dea9412..ac2710c00d763cdfe0fcf1461250629417470bd8 100644 (file)
@@ -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>
+      </>
     );
   }
 }
index 3aa3a90248c1705eef2ab410f5e800b22af38ee7..0164bb2ed100f986de3f95ab9454d2b226fcfecf 100644 (file)
@@ -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> {
index 427192d12e754db536c580000009eb0adc5ed893..a99673585de902e4615f1455cf1b25da83d2e142 100644 (file)
@@ -6,6 +6,7 @@
     "noUnusedParameters": true,
     "noImplicitAny": true,
     "strict": true,
+    "strictFunctionTypes": false,
     "target": "es5",
     "jsx": "react",
     "lib": ["es2017", "dom"],
index 79a4fa67c813446102e58fa6261bbf95b1c65ca2..86da451ace20a71060afbdd94bd3a373a3335ba2 100644 (file)
@@ -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"