From: Stas Vilchik Date: Tue, 6 Sep 2016 15:44:55 +0000 (+0200) Subject: improve code quality X-Git-Tag: 6.1-RC1~194 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=c1e3840edf6c7fd36a3149b280a3d276ebce03a5;p=sonarqube.git improve code quality --- diff --git a/server/sonar-web/.eslintrc b/server/sonar-web/.eslintrc index 06d77b7ab50..d0a6a17a2ea 100644 --- a/server/sonar-web/.eslintrc +++ b/server/sonar-web/.eslintrc @@ -1,6 +1,7 @@ { "extends": [ "eslint:recommended", + "plugin:react/recommended", "plugin:import/errors", "plugin:import/warnings" ], @@ -53,23 +54,9 @@ "semi": [2, "always"], "keyword-spacing": 2, - "react/jsx-closing-bracket-location": [2, "after-props"], - "react/jsx-handler-names": 0, - "react/jsx-max-props-per-line": [2, { "maximum": 3 }], - "react/jsx-no-duplicate-props": 2, - "react/jsx-no-undef": 2, - "react/jsx-pascal-case": 2, - "react/jsx-uses-react": 2, - "react/jsx-uses-vars": 2, - "react/no-did-mount-set-state": [2, "allow-in-func"], - "react/no-did-update-set-state": [2, "allow-in-func"], - "react/no-direct-mutation-state": 2, - "react/no-multi-comp": 0, - "react/no-unknown-property": 2, - "react/prop-types": 0, - "react/react-in-jsx-scope": 2, - "react/self-closing-comp": 2, - "react/sort-comp": 2 + "react/display-name": 0, + "react/no-find-dom-node": 0, + "react/prop-types": 0 }, "settings": { diff --git a/server/sonar-web/package.json b/server/sonar-web/package.json index 25aa6b38c18..efc4aaea629 100644 --- a/server/sonar-web/package.json +++ b/server/sonar-web/package.json @@ -29,9 +29,9 @@ "css-loader": "0.23.1", "d3": "3.5.6", "enzyme": "2.2.0", - "eslint": "^2.13.1", - "eslint-plugin-import": "^1.9.2", - "eslint-plugin-react": "^5.2.2", + "eslint": "^3.4.0", + "eslint-plugin-import": "^1.14.0", + "eslint-plugin-react": "^6.2.0", "expose-loader": "0.7.1", "express": "4.13.4", "express-http-proxy": "0.6.0", diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/TaskId.js b/server/sonar-web/src/main/js/apps/background-tasks/components/TaskId.js index 1cf24890c16..719f7517d02 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/components/TaskId.js +++ b/server/sonar-web/src/main/js/apps/background-tasks/components/TaskId.js @@ -19,8 +19,6 @@ */ import React from 'react'; -import { translate } from '../../../helpers/l10n'; - const TaskId = ({ task }) => { return ( diff --git a/server/sonar-web/src/main/js/apps/overview/main/enhance.js b/server/sonar-web/src/main/js/apps/overview/main/enhance.js index 26e57e1afa7..00a6df79e93 100644 --- a/server/sonar-web/src/main/js/apps/overview/main/enhance.js +++ b/server/sonar-web/src/main/js/apps/overview/main/enhance.js @@ -25,16 +25,16 @@ import { DonutChart } from '../../../components/charts/donut-chart'; import Rating from './../../../components/ui/Rating'; import Timeline from '../components/Timeline'; import { - formatMeasure, - formatMeasureVariation, - isDiffMetric, - getPeriodValue, - getShortType + formatMeasure, + formatMeasureVariation, + isDiffMetric, + getPeriodValue, + getShortType, + getRatingTooltip } from '../../../helpers/measures'; -import { translateWithParameters, translate } from '../../../helpers/l10n'; +import { translateWithParameters } from '../../../helpers/l10n'; import { getPeriodDate } from '../../../helpers/periods'; import { getComponentIssuesUrl } from '../../../helpers/urls'; -import { getRatingTooltip } from '../../../helpers/measures'; export default function enhance (ComposedComponent) { return class extends React.Component { diff --git a/server/sonar-web/src/main/js/apps/permission-templates/components/Header.js b/server/sonar-web/src/main/js/apps/permission-templates/components/Header.js index 97590dc0ce3..578e42822c8 100644 --- a/server/sonar-web/src/main/js/apps/permission-templates/components/Header.js +++ b/server/sonar-web/src/main/js/apps/permission-templates/components/Header.js @@ -45,7 +45,7 @@ export default class Header extends React.Component { this.context.router.push({ pathname: '/', query: { id: r.permissionTemplate.id } - }) + }); }); }) .render(); diff --git a/server/sonar-web/src/main/js/apps/project-admin/key/views/UpdateKeyConfirmation.js b/server/sonar-web/src/main/js/apps/project-admin/key/views/UpdateKeyConfirmation.js index 4ece410093b..5a8d14417f4 100644 --- a/server/sonar-web/src/main/js/apps/project-admin/key/views/UpdateKeyConfirmation.js +++ b/server/sonar-web/src/main/js/apps/project-admin/key/views/UpdateKeyConfirmation.js @@ -19,7 +19,6 @@ */ import ModalForm from '../../../../components/common/modal-form'; import Template from './UpdateKeyConfirmation.hbs'; -import { parseError } from '../../../code/utils'; export default ModalForm.extend({ template: Template, diff --git a/server/sonar-web/src/main/js/apps/project-admin/store/actions.js b/server/sonar-web/src/main/js/apps/project-admin/store/actions.js index ca20001b763..18eb9917862 100644 --- a/server/sonar-web/src/main/js/apps/project-admin/store/actions.js +++ b/server/sonar-web/src/main/js/apps/project-admin/store/actions.js @@ -17,21 +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 { - getQualityProfiles, - associateProject, - dissociateProject -} from '../../../api/quality-profiles'; +import { getQualityProfiles, associateProject, dissociateProject } from '../../../api/quality-profiles'; import { getProfileByKey } from './rootReducer'; import { - fetchQualityGates, - getGateForProject, - associateGateWithProject, - dissociateGateWithProject + fetchQualityGates, + getGateForProject, + associateGateWithProject, + dissociateGateWithProject } from '../../../api/quality-gates'; import { getProjectLinks, createLink } from '../../../api/projectLinks'; -import { getTree } from '../../../api/components'; -import { changeKey as changeKeyApi } from '../../../api/components'; +import { getTree, changeKey as changeKeyApi } from '../../../api/components'; import { addGlobalSuccessMessage } from '../../../components/store/globalMessages'; import { translate, translateWithParameters } from '../../../helpers/l10n'; diff --git a/server/sonar-web/src/main/js/apps/project-admin/store/links.js b/server/sonar-web/src/main/js/apps/project-admin/store/links.js index 9a79d3d7905..b1e4dea7f65 100644 --- a/server/sonar-web/src/main/js/apps/project-admin/store/links.js +++ b/server/sonar-web/src/main/js/apps/project-admin/store/links.js @@ -19,8 +19,7 @@ */ import keyBy from 'lodash/keyBy'; import omit from 'lodash/omit'; -import { RECEIVE_PROJECT_LINKS, DELETE_PROJECT_LINK } from './actions'; -import { ADD_PROJECT_LINK } from './actions'; +import { RECEIVE_PROJECT_LINKS, DELETE_PROJECT_LINK, ADD_PROJECT_LINK } from './actions'; const links = (state = {}, action = {}) => { if (action.type === RECEIVE_PROJECT_LINKS) { diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/changelog/ParameterChange.js b/server/sonar-web/src/main/js/apps/quality-profiles/changelog/ParameterChange.js index d3ea5ecedb0..6a79f5c2723 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/changelog/ParameterChange.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/changelog/ParameterChange.js @@ -31,7 +31,7 @@ export default class ParameterChange extends React.Component { if (value == null) { return ( -
+
{translateWithParameters( 'quality_profiles.changelog.parameter_reset_to_default_value', name @@ -41,7 +41,7 @@ export default class ParameterChange extends React.Component { } return ( -
+
{translateWithParameters( 'quality_profiles.parameter_set_to', name, diff --git a/server/sonar-web/src/main/js/main/nav/component/component-nav-menu.js b/server/sonar-web/src/main/js/main/nav/component/component-nav-menu.js index 24a8d5f0a25..50525635834 100644 --- a/server/sonar-web/src/main/js/main/nav/component/component-nav-menu.js +++ b/server/sonar-web/src/main/js/main/nav/component/component-nav-menu.js @@ -18,7 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import qs from 'querystring'; -import _ from 'underscore'; import classNames from 'classnames'; import React from 'react'; import LinksMixin from '../links-mixin';