diff options
author | Stas Vilchik <vilchiks@gmail.com> | 2016-12-22 17:11:21 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-22 17:11:21 +0100 |
commit | bc07b29494abd5dff7875175df91df38d0b908ac (patch) | |
tree | 05f82f8ca3787011e2a0810e7d85c9d81e4b222f | |
parent | e52ca10a4a1b07d05c894e0d8564ffa1b5af3e47 (diff) | |
download | sonarqube-bc07b29494abd5dff7875175df91df38d0b908ac.tar.gz sonarqube-bc07b29494abd5dff7875175df91df38d0b908ac.zip |
upgrade eslint and its plugins, tune rules (#1481)
345 files changed, 1419 insertions, 1544 deletions
diff --git a/server/sonar-web/.eslintrc b/server/sonar-web/.eslintrc index 2eede2ccbee..df5d5291501 100644 --- a/server/sonar-web/.eslintrc +++ b/server/sonar-web/.eslintrc @@ -1,9 +1,6 @@ { "extends": [ - "eslint:recommended", - "plugin:react/recommended", - "plugin:import/errors", - "plugin:import/warnings" + "eslint:recommended" ], "env": { @@ -22,42 +19,151 @@ "parser": "babel-eslint", "plugins": [ - "react", - "import" + "import", + "jsx-a11y", + "flowtype", + "react" ], "rules": { + "array-bracket-spacing": 2, + "array-callback-return": 2, + "arrow-parens": [2, "as-needed"], "arrow-spacing": 2, + "block-scoped-var": 2, + "block-spacing": 2, + "brace-style": 2, "comma-dangle": 2, "comma-spacing": 2, + "comma-style": 2, + "computed-property-spacing": 2, + "consistent-this": [2, "that"], "curly": 2, + "dot-location": [2, "property"], "eol-last": 2, "eqeqeq": [2, "smart"], + "func-call-spacing": 2, + "func-name-matching": 2, + "func-names": [2, "never"], + "generator-star-spacing": 2, "indent": [2, 2, { "SwitchCase": 1, "VariableDeclarator": 2 }], "jsx-quotes": 2, "key-spacing": 2, + "keyword-spacing": 2, + "max-len": [2, 120], + "new-parens": 2, + "no-lonely-if": 2, "no-multi-spaces": 2, + "no-multiple-empty-lines": [2, { "max": 2 }], "no-self-compare": 2, - "no-unexpected-multiline": 2, - "max-len": [2, 120], - "no-const-assign": 2, - "no-multiple-empty-lines": [2, { "max": 3 }], - "no-spaced-func": 2, - "no-this-before-super": 2, + "no-template-curly-in-string": 2, "no-trailing-spaces": 2, "no-unneeded-ternary": 2, - "object-curly-spacing": [2, "always"], + "no-unsafe-negation": 2, + "no-useless-computed-key": 2, + "no-useless-rename": 2, "no-var": 2, + "no-whitespace-before-property": 2, + "object-curly-spacing": [2, "always"], "object-shorthand": 2, - "one-var": [2, { "let": "never", "const": "never" }], - "quotes": [2, "single", "avoid-escape"], + "one-var": [2, "never"], + "operator-assignment": 2, + "padded-blocks": [2, "never"], + "prefer-arrow-callback": 2, "prefer-const": 2, + "prefer-spread": 2, + "quote-props": [2, "consistent"], + "quotes": [2, "single"], + "rest-spread-spacing": 2, "semi": [2, "always"], - "keyword-spacing": 2, + "semi-spacing": 2, + "space-before-blocks": 2, + "space-before-function-paren": 2, + "space-in-parens": 2, + "space-unary-ops": 2, + "template-curly-spacing": 2, + "yield-star-spacing": 2, + + "flowtype/boolean-style": 2, + "flowtype/generic-spacing": 2, + "flowtype/no-dupe-keys": 2, + "flowtype/no-primitive-constructor-types": 2, + "flowtype/no-weak-types": [2, { + "any": true, + "Object": false, + "Function": false + }], + "flowtype/object-type-delimiter": 2, + "flowtype/semi": 2, + "flowtype/space-after-type-colon": 2, + "flowtype/space-before-generic-bracket": 2, + "flowtype/space-before-type-colon": 2, + "flowtype/union-intersection-spacing": 2, + + "import/no-unresolved": 2, + "import/named": 2, + "import/default": 2, + "import/namespace": 2, + "import/no-named-as-default": 2, + "import/no-named-as-default-member": 2, + "import/no-amd": 2, + "import/first": 2, + "import/no-duplicates": 2, + "import/extensions": 2, + "import/order": [2, { + "groups": ["builtin", "external"], + "newlines-between": "never" + }], + "import/newline-after-import": 2, + "import/no-named-default": 2, + + "jsx-a11y/aria-props": 2, + "jsx-a11y/aria-proptypes": 2, + "jsx-a11y/aria-role": 2, + "jsx-a11y/aria-unsupported-elements": 2, + "jsx-a11y/heading-has-content": 2, + "jsx-a11y/html-has-lang": 2, + "jsx-a11y/img-has-alt": 2, + "jsx-a11y/img-redundant-alt": 2, + "jsx-a11y/lang": 2, + "jsx-a11y/mouse-events-have-key-events": 2, + "jsx-a11y/no-access-key": 2, + "jsx-a11y/no-marquee": 2, + "jsx-a11y/onclick-has-focus": 2, + "jsx-a11y/onclick-has-role": 2, + "jsx-a11y/role-has-required-aria-props": 2, + "jsx-a11y/role-supports-aria-props": 2, + "jsx-a11y/tabindex-no-positive": 2, - "react/display-name": 0, - "react/no-find-dom-node": 0, - "react/prop-types": 0 + "react/jsx-boolean-value": [2, "always"], + "react/jsx-closing-bracket-location": [2, "after-props"], + "react/jsx-curly-spacing": [2, "never"], + "react/jsx-equals-spacing": [2, "never"], + "react/jsx-key": 2, + "react/jsx-no-duplicate-props": 2, + "react/jsx-no-undef": 2, + "react/jsx-pascal-case": 2, + "react/jsx-space-before-closing": [2, "never"], + "react/jsx-tag-spacing": [2, { + "closingSlash": "never", + "beforeSelfClosing": "never", + "afterOpening": "never" + }], + "react/jsx-uses-react": 2, + "react/jsx-uses-vars": 2, + "react/jsx-wrap-multilines": 2, + "react/no-children-prop": 2, + "react/no-danger-with-children": 2, + "react/no-deprecated": 2, + "react/no-direct-mutation-state": 2, + "react/no-is-mounted": 2, + "react/no-render-return-value": 2, + "react/no-unescaped-entities": 2, + "react/no-unknown-property": 2, + "react/no-unused-prop-types": 2, + "react/react-in-jsx-scope": 2, + "react/require-render-return": 2, + "react/self-closing-comp": 2 }, "settings": { diff --git a/server/sonar-web/package.json b/server/sonar-web/package.json index c3306d9f68a..c4b9e3b7006 100644 --- a/server/sonar-web/package.json +++ b/server/sonar-web/package.json @@ -51,13 +51,12 @@ "dotenv": "2.0.0", "enzyme": "^2.6.0", "enzyme-to-json": "^1.4.5", - "eslint": "3.5.0", - "eslint-config-react-app": "0.2.1", + "eslint": "^3.12.2", "eslint-loader": "1.5.0", - "eslint-plugin-flowtype": "2.18.1", - "eslint-plugin-import": "1.12.0", - "eslint-plugin-jsx-a11y": "2.2.2", - "eslint-plugin-react": "6.3.0", + "eslint-plugin-flowtype": "^2.29.1", + "eslint-plugin-import": "^2.2.0", + "eslint-plugin-jsx-a11y": "^3.0.2", + "eslint-plugin-react": "^6.8.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/api/components.js b/server/sonar-web/src/main/js/api/components.js index 8c422a1c9ba..fa6ce518734 100644 --- a/server/sonar-web/src/main/js/api/components.js +++ b/server/sonar-web/src/main/js/api/components.js @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ // @flow -import { getJSON, postJSON, post } from '../helpers/request.js'; +import { getJSON, postJSON, post } from '../helpers/request'; export function getComponents (data?: Object) { const url = '/api/components/search'; diff --git a/server/sonar-web/src/main/js/api/issue-filters.js b/server/sonar-web/src/main/js/api/issue-filters.js index f2bd4226eab..0bb0e7c8c24 100644 --- a/server/sonar-web/src/main/js/api/issue-filters.js +++ b/server/sonar-web/src/main/js/api/issue-filters.js @@ -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 { post } from '../helpers/request.js'; +import { post } from '../helpers/request'; export function toggleIssueFilter (id) { const url = '/issues/toggle_fav'; diff --git a/server/sonar-web/src/main/js/api/issues.js b/server/sonar-web/src/main/js/api/issues.js index 21146b1bea9..d658aed91c3 100644 --- a/server/sonar-web/src/main/js/api/issues.js +++ b/server/sonar-web/src/main/js/api/issues.js @@ -18,8 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import _ from 'underscore'; - -import { getJSON } from '../helpers/request.js'; +import { getJSON } from '../helpers/request'; export function getFacets (query, facets) { const url = '/api/issues/search'; diff --git a/server/sonar-web/src/main/js/api/languages.js b/server/sonar-web/src/main/js/api/languages.js index 4b3a00b764d..f596da1f76e 100644 --- a/server/sonar-web/src/main/js/api/languages.js +++ b/server/sonar-web/src/main/js/api/languages.js @@ -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 { getJSON } from '../helpers/request.js'; +import { getJSON } from '../helpers/request'; export function getLanguages () { const url = '/api/languages/list'; diff --git a/server/sonar-web/src/main/js/api/measure-filters.js b/server/sonar-web/src/main/js/api/measure-filters.js index ed64ba09db7..5530a6c30a1 100644 --- a/server/sonar-web/src/main/js/api/measure-filters.js +++ b/server/sonar-web/src/main/js/api/measure-filters.js @@ -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 { post } from '../helpers/request.js'; +import { post } from '../helpers/request'; export function toggleMeasureFilter (id) { const url = '/measures/toggle_fav'; diff --git a/server/sonar-web/src/main/js/api/measures.js b/server/sonar-web/src/main/js/api/measures.js index b9ccc591132..c130bfb6ee3 100644 --- a/server/sonar-web/src/main/js/api/measures.js +++ b/server/sonar-web/src/main/js/api/measures.js @@ -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 { getJSON } from '../helpers/request.js'; +import { getJSON } from '../helpers/request'; export function getMeasures (componentKey, metrics) { const url = '/api/measures/component'; diff --git a/server/sonar-web/src/main/js/api/metrics.js b/server/sonar-web/src/main/js/api/metrics.js index 45f2500288c..d08b65f945a 100644 --- a/server/sonar-web/src/main/js/api/metrics.js +++ b/server/sonar-web/src/main/js/api/metrics.js @@ -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 { getJSON } from '../helpers/request.js'; +import { getJSON } from '../helpers/request'; export function getMetrics () { const url = '/api/metrics/search'; diff --git a/server/sonar-web/src/main/js/api/nav.js b/server/sonar-web/src/main/js/api/nav.js index 424c0a68536..6f53ec289b0 100644 --- a/server/sonar-web/src/main/js/api/nav.js +++ b/server/sonar-web/src/main/js/api/nav.js @@ -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 { getJSON } from '../helpers/request.js'; +import { getJSON } from '../helpers/request'; export function getGlobalNavigation () { const url = '/api/navigation/global'; diff --git a/server/sonar-web/src/main/js/api/quality-gates.js b/server/sonar-web/src/main/js/api/quality-gates.js index edab4f545ea..af6e09b3fb6 100644 --- a/server/sonar-web/src/main/js/api/quality-gates.js +++ b/server/sonar-web/src/main/js/api/quality-gates.js @@ -92,13 +92,13 @@ export function getGateForProject (projectKey) { return getJSON(url, data).then(r => r.qualityGate); } -export function associateGateWithProject(gateId, projectKey) { +export function associateGateWithProject (gateId, projectKey) { const url = '/api/qualitygates/select'; const data = { gateId, projectKey }; return post(url, data); } -export function dissociateGateWithProject(gateId, projectKey) { +export function dissociateGateWithProject (gateId, projectKey) { const url = '/api/qualitygates/deselect'; const data = { gateId, projectKey }; return post(url, data); diff --git a/server/sonar-web/src/main/js/api/time-machine.js b/server/sonar-web/src/main/js/api/time-machine.js index adf44fdbcac..25d65c43c71 100644 --- a/server/sonar-web/src/main/js/api/time-machine.js +++ b/server/sonar-web/src/main/js/api/time-machine.js @@ -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 { getJSON } from '../helpers/request.js'; +import { getJSON } from '../helpers/request'; export function getTimeMachineData (componentKey, metrics) { const url = '/api/timemachine/index'; diff --git a/server/sonar-web/src/main/js/api/user-tokens.js b/server/sonar-web/src/main/js/api/user-tokens.js index 493b0cb065e..3d93320f373 100644 --- a/server/sonar-web/src/main/js/api/user-tokens.js +++ b/server/sonar-web/src/main/js/api/user-tokens.js @@ -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 { getJSON, postJSON, post } from '../helpers/request.js'; +import { getJSON, postJSON, post } from '../helpers/request'; /** * List tokens for given user login diff --git a/server/sonar-web/src/main/js/api/users.js b/server/sonar-web/src/main/js/api/users.js index e5d5d15f7bc..9573d2c2131 100644 --- a/server/sonar-web/src/main/js/api/users.js +++ b/server/sonar-web/src/main/js/api/users.js @@ -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 { getJSON, post } from '../helpers/request.js'; +import { getJSON, post } from '../helpers/request'; export function getCurrentUser () { const url = '/api/users/current'; diff --git a/server/sonar-web/src/main/js/app/components/App.js b/server/sonar-web/src/main/js/app/components/App.js index 6ddad08119e..359d26a0acf 100644 --- a/server/sonar-web/src/main/js/app/components/App.js +++ b/server/sonar-web/src/main/js/app/components/App.js @@ -25,7 +25,7 @@ import { fetchCurrentUser } from '../../store/users/actions'; import { fetchLanguages, fetchAppState } from '../../store/rootActions'; class App extends React.Component { - mounted: bool; + mounted: boolean; static propTypes = { fetchAppState: React.PropTypes.func.isRequired, diff --git a/server/sonar-web/src/main/js/app/components/LocalizationContainer.js b/server/sonar-web/src/main/js/app/components/LocalizationContainer.js index 1241ac8f20c..1a542bb88ad 100644 --- a/server/sonar-web/src/main/js/app/components/LocalizationContainer.js +++ b/server/sonar-web/src/main/js/app/components/LocalizationContainer.js @@ -22,7 +22,7 @@ import React from 'react'; import { requestMessages } from '../../helpers/l10n'; export default class LocalizationContainer extends React.Component { - mounted: bool; + mounted: boolean; state = { loading: true diff --git a/server/sonar-web/src/main/js/app/components/MarkdownHelp.js b/server/sonar-web/src/main/js/app/components/MarkdownHelp.js index 835b8e0cd72..92c6b3a0894 100644 --- a/server/sonar-web/src/main/js/app/components/MarkdownHelp.js +++ b/server/sonar-web/src/main/js/app/components/MarkdownHelp.js @@ -114,8 +114,8 @@ export default class MarkdownHelp extends React.Component { <tr> <td className="text-top"> Standard text<br/> - > Blockquoted text<br/> - > that spans multiple lines<br/> + > Blockquoted text<br/> + > that spans multiple lines<br/> </td> <td className="markdown text-top"> <p>Standard text</p> diff --git a/server/sonar-web/src/main/js/app/components/SimpleContainer.js b/server/sonar-web/src/main/js/app/components/SimpleContainer.js index 342bffa2bc3..31ad5252ae4 100644 --- a/server/sonar-web/src/main/js/app/components/SimpleContainer.js +++ b/server/sonar-web/src/main/js/app/components/SimpleContainer.js @@ -42,7 +42,7 @@ export default class SimpleContainer extends React.Component { <div className="global-container"> <div className="page-wrapper page-wrapper-global" id="container"> <nav className="navbar navbar-global page-container" id="global-navigation"> - <div className="navbar-header"></div> + <div className="navbar-header"/> </nav> <div id="bd" className="page-wrapper-simple"> diff --git a/server/sonar-web/src/main/js/app/components/nav/component/ComponentNav.js b/server/sonar-web/src/main/js/app/components/nav/component/ComponentNav.js index c56eaa49078..c2dfa20660c 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/ComponentNav.js +++ b/server/sonar-web/src/main/js/app/components/nav/component/ComponentNav.js @@ -29,12 +29,12 @@ import { STATUSES } from '../../../../apps/background-tasks/constants'; import './ComponentNav.css'; export default React.createClass({ - componentDidMount() { + componentDidMount () { this.loadStatus(); this.populateRecentHistory(); }, - loadStatus() { + loadStatus () { getTasksForComponent(this.props.component.id).then(r => { this.setState({ isPending: r.queue.some(task => task.status === STATUSES.PENDING), @@ -44,7 +44,7 @@ export default React.createClass({ }); }, - populateRecentHistory() { + populateRecentHistory () { const { breadcrumbs } = this.props.component; const { qualifier } = breadcrumbs[breadcrumbs.length - 1]; if (['TRK', 'VW', 'DEV'].indexOf(qualifier) !== -1) { @@ -52,7 +52,7 @@ export default React.createClass({ } }, - render() { + render () { return ( <nav className="navbar navbar-context page-container" id="context-navigation"> <div className="navbar-context-inner"> diff --git a/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavMeta.js b/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavMeta.js index 393564cd8a3..feddf98a6d7 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavMeta.js +++ b/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavMeta.js @@ -23,7 +23,7 @@ import PendingIcon from '../../../../components/shared/pending-icon'; import { translate, translateWithParameters } from '../../../../helpers/l10n'; export default React.createClass({ - render() { + render () { const metaList = []; const canSeeBackgroundTasks = this.props.conf.showBackgroundTasks; const backgroundTasksUrl = diff --git a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNavBreadcrumbs-test.js b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNavBreadcrumbs-test.js index 4790e90ca41..00683ab73e0 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNavBreadcrumbs-test.js +++ b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNavBreadcrumbs-test.js @@ -21,7 +21,7 @@ import React from 'react'; import { shallow } from 'enzyme'; import ComponentNavBreadcrumbs from '../ComponentNavBreadcrumbs'; -it('should not render breadcrumbs with one element', function () { +it('should not render breadcrumbs with one element', () => { const breadcrumbs = [{ key: 'my-project', name: 'My Project', qualifier: 'TRK' }]; const result = shallow(<ComponentNavBreadcrumbs breadcrumbs={breadcrumbs}/>); expect(result.find('li').length).toBe(1); diff --git a/server/sonar-web/src/main/js/app/components/nav/global/GlobalNavSearch.js b/server/sonar-web/src/main/js/app/components/nav/global/GlobalNavSearch.js index a0af8c4acd3..df674130000 100644 --- a/server/sonar-web/src/main/js/app/components/nav/global/GlobalNavSearch.js +++ b/server/sonar-web/src/main/js/app/components/nav/global/GlobalNavSearch.js @@ -99,7 +99,7 @@ class GlobalNavSearch extends React.Component { <a className="navbar-search-dropdown" href="#" onClick={this.onClick}> <i className="icon-search navbar-icon"/> <i className="icon-dropdown"/> </a> - <div ref="container" className="dropdown-menu dropdown-menu-right global-navbar-search-dropdown"></div> + <div ref="container" className="dropdown-menu dropdown-menu-right global-navbar-search-dropdown"/> </li> ); } diff --git a/server/sonar-web/src/main/js/app/components/nav/global/SearchView.js b/server/sonar-web/src/main/js/app/components/nav/global/SearchView.js index 014f55216ef..801a4d95664 100644 --- a/server/sonar-web/src/main/js/app/components/nav/global/SearchView.js +++ b/server/sonar-web/src/main/js/app/components/nav/global/SearchView.js @@ -121,7 +121,7 @@ export default Marionette.LayoutView.extend({ onRender () { const that = this; this.resultsRegion.show(this.resultsView); - setTimeout(function () { + setTimeout(() => { that.$('.js-search-input').focus(); }, 0); }, @@ -174,7 +174,7 @@ export default Marionette.LayoutView.extend({ resetResultsToDefault () { const recentHistory = RecentHistory.get(); - const history = recentHistory.map(function (historyItem, index) { + const history = recentHistory.map((historyItem, index) => { const url = window.baseUrl + '/dashboard/index?id=' + encodeURIComponent(historyItem.key) + window.dashboardParameters(true); return { @@ -184,7 +184,7 @@ export default Marionette.LayoutView.extend({ extra: index === 0 ? translate('browsed_recently') : null }; }); - const favorite = this.favorite.slice(0, 6).map(function (f, index) { + const favorite = this.favorite.slice(0, 6).map((f, index) => { return { ...f, extra: index === 0 ? translate('favorite') : null }; }); this.results.reset([].concat(history, favorite)); @@ -235,7 +235,7 @@ export default Marionette.LayoutView.extend({ if (isUserAdmin(this.model.get('currentUser'))) { customItems.push({ name: translate('layout.settings'), url: window.baseUrl + '/settings' }); } - const findings = [].concat(DEFAULT_ITEMS, customItems).filter(function (f) { + const findings = [].concat(DEFAULT_ITEMS, customItems).filter(f => { return f.name.match(new RegExp(q, 'i')); }); if (findings.length > 0) { @@ -246,10 +246,10 @@ export default Marionette.LayoutView.extend({ getGlobalDashboardFindings (q) { const dashboards = this.model.get('globalDashboards') || []; - const items = dashboards.map(function (d) { + const items = dashboards.map(d => { return { name: d.name, url: window.baseUrl + '/dashboard/index?did=' + encodeURIComponent(d.key) }; }); - const findings = items.filter(function (f) { + const findings = items.filter(f => { return f.name.match(new RegExp(q, 'i')); }); if (findings.length > 0) { @@ -259,7 +259,7 @@ export default Marionette.LayoutView.extend({ }, getFavoriteFindings (q) { - const findings = this.favorite.filter(function (f) { + const findings = this.favorite.filter(f => { return f.name.match(new RegExp(q, 'i')); }); if (findings.length > 0) { diff --git a/server/sonar-web/src/main/js/app/utils/startAjaxMonitoring.js b/server/sonar-web/src/main/js/app/utils/startAjaxMonitoring.js index 94525d04434..e10c847f6cf 100644 --- a/server/sonar-web/src/main/js/app/utils/startAjaxMonitoring.js +++ b/server/sonar-web/src/main/js/app/utils/startAjaxMonitoring.js @@ -64,7 +64,7 @@ const Process = Backbone.Model.extend({ message: msg }); this.set('state', 'failed'); - setTimeout(function () { + setTimeout(() => { that.finish({ force: true }); }, 5000); } @@ -93,7 +93,7 @@ const ProcessesView = Marionette.ItemView.extend({ .addClass('process-spinner process-spinner-failed shown'); const close = $('<button></button>').html('<i class="icon-close"></i>').addClass('process-spinner-close'); close.appendTo(el); - close.on('click', function () { + close.on('click', () => { failed.finish({ force: true }); }); el.appendTo(this.$el); @@ -120,7 +120,7 @@ function addBackgroundProcess () { const uid = _.uniqueId('process'); const process = new Process({ id: uid, - timer: setTimeout(function () { + timer: setTimeout(() => { process.timeout(); }, defaults.timeout) }); diff --git a/server/sonar-web/src/main/js/apps/about/components/LoginForm.js b/server/sonar-web/src/main/js/apps/about/components/LoginForm.js index 631959f8ec0..c9f022a3d94 100644 --- a/server/sonar-web/src/main/js/apps/about/components/LoginForm.js +++ b/server/sonar-web/src/main/js/apps/about/components/LoginForm.js @@ -57,7 +57,7 @@ export default class LoginForm extends React.Component { <div className="big-spacer-bottom"> <label htmlFor="login" className="login-label">{translate('login')}</label> - <input type="text" id="login" name="login" className="login-input" maxLength="255" required + <input type="text" id="login" name="login" className="login-input" maxLength="255" required={true} placeholder={translate('login')} value={this.state.login} onChange={e => this.setState({ login: e.target.value })}/> @@ -65,7 +65,7 @@ export default class LoginForm extends React.Component { <div className="big-spacer-bottom"> <label htmlFor="password" className="login-label">{translate('password')}</label> - <input type="password" id="password" name="password" className="login-input" required + <input type="password" id="password" name="password" className="login-input" required={true} placeholder={translate('password')} value={this.state.password} onChange={e => this.setState({ password: e.target.value })}/> diff --git a/server/sonar-web/src/main/js/apps/account/components/Password.js b/server/sonar-web/src/main/js/apps/account/components/Password.js index fb3641d676b..05060c6d968 100644 --- a/server/sonar-web/src/main/js/apps/account/components/Password.js +++ b/server/sonar-web/src/main/js/apps/account/components/Password.js @@ -18,7 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React, { Component } from 'react'; - import { changePassword } from '../../../api/users'; import { translate } from '../../../helpers/l10n'; diff --git a/server/sonar-web/src/main/js/apps/account/components/Tokens.js b/server/sonar-web/src/main/js/apps/account/components/Tokens.js index 8c3170380ef..c0043abf678 100644 --- a/server/sonar-web/src/main/js/apps/account/components/Tokens.js +++ b/server/sonar-web/src/main/js/apps/account/components/Tokens.js @@ -19,7 +19,6 @@ */ import Backbone from 'backbone'; import React, { Component } from 'react'; - import TokensView from '../tokens-view'; export default class Tokens extends Component { @@ -49,6 +48,6 @@ export default class Tokens extends Component { } render () { - return <div ref="container"></div>; + return <div ref="container"/>; } } diff --git a/server/sonar-web/src/main/js/apps/account/notifications/GlobalNotifications.js b/server/sonar-web/src/main/js/apps/account/notifications/GlobalNotifications.js index 180f22468f8..469dfe26312 100644 --- a/server/sonar-web/src/main/js/apps/account/notifications/GlobalNotifications.js +++ b/server/sonar-web/src/main/js/apps/account/notifications/GlobalNotifications.js @@ -18,7 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; - import NotificationsList from './NotificationsList'; import { translate } from '../../../helpers/l10n'; @@ -32,7 +31,7 @@ export default function GlobalNotifications ({ notifications, channels }) { <table className="form"> <thead> <tr> - <th></th> + <th/> {channels.map(channel => ( <th key={channel} className="text-center"> <h4>{translate('notification.channel', channel)}</h4> diff --git a/server/sonar-web/src/main/js/apps/account/notifications/Notifications.js b/server/sonar-web/src/main/js/apps/account/notifications/Notifications.js index 96eb2b21109..27b96e5b2a0 100644 --- a/server/sonar-web/src/main/js/apps/account/notifications/Notifications.js +++ b/server/sonar-web/src/main/js/apps/account/notifications/Notifications.js @@ -18,7 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; - import GlobalNotifications from './GlobalNotifications'; import ProjectNotifications from './ProjectNotifications'; import { translate } from '../../../helpers/l10n'; diff --git a/server/sonar-web/src/main/js/apps/account/notifications/NotificationsList.js b/server/sonar-web/src/main/js/apps/account/notifications/NotificationsList.js index a8044b4b142..cc7476e9686 100644 --- a/server/sonar-web/src/main/js/apps/account/notifications/NotificationsList.js +++ b/server/sonar-web/src/main/js/apps/account/notifications/NotificationsList.js @@ -18,7 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; - import { translate } from '../../../helpers/l10n'; export default function NotificationsList ({ notifications, checkboxName, checkboxId }) { diff --git a/server/sonar-web/src/main/js/apps/account/notifications/ProjectNotification.js b/server/sonar-web/src/main/js/apps/account/notifications/ProjectNotification.js index 95fb143d8de..325cca54e1c 100644 --- a/server/sonar-web/src/main/js/apps/account/notifications/ProjectNotification.js +++ b/server/sonar-web/src/main/js/apps/account/notifications/ProjectNotification.js @@ -19,7 +19,6 @@ */ import classNames from 'classnames'; import React, { Component } from 'react'; - import NotificationsList from './NotificationsList'; import { translate } from '../../../helpers/l10n'; diff --git a/server/sonar-web/src/main/js/apps/account/notifications/ProjectNotifications.js b/server/sonar-web/src/main/js/apps/account/notifications/ProjectNotifications.js index 08c5956cd81..cddb8f9149b 100644 --- a/server/sonar-web/src/main/js/apps/account/notifications/ProjectNotifications.js +++ b/server/sonar-web/src/main/js/apps/account/notifications/ProjectNotifications.js @@ -19,13 +19,12 @@ */ import React from 'react'; import Select from 'react-select'; - import ProjectNotification from './ProjectNotification'; import { translate } from '../../../helpers/l10n'; import { getProjectsWithInternalId } from '../../../api/components'; export default function ProjectNotifications ({ notifications, channels, onAddProject, onRemoveProject }) { - const loadOptions = (query) => { + const loadOptions = query => { return getProjectsWithInternalId(query) .then(results => results.map(r => { return { @@ -38,7 +37,7 @@ export default function ProjectNotifications ({ notifications, channels, onAddPr }); }; - const handleAddProject = (selected) => { + const handleAddProject = selected => { const project = { internalId: selected.value, name: selected.label diff --git a/server/sonar-web/src/main/js/apps/account/profile/UserExternalIdentity.js b/server/sonar-web/src/main/js/apps/account/profile/UserExternalIdentity.js index 5fa90240cef..232d2dc639c 100644 --- a/server/sonar-web/src/main/js/apps/account/profile/UserExternalIdentity.js +++ b/server/sonar-web/src/main/js/apps/account/profile/UserExternalIdentity.js @@ -18,7 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; - import { getIdentityProviders } from '../../../api/users'; export default class UserExternalIdentity extends React.Component { @@ -78,7 +77,7 @@ export default class UserExternalIdentity extends React.Component { return ( <div className="identity-provider" style={{ backgroundColor: identityProvider.backgroundColor }}> - <img src={window.baseUrl + identityProvider.iconPath} width="14" height="14"/> + <img src={window.baseUrl + identityProvider.iconPath} width="14" height="14" alt={identityProvider.name}/> {' '} {user.externalIdentity} </div> diff --git a/server/sonar-web/src/main/js/apps/account/projects/Projects.js b/server/sonar-web/src/main/js/apps/account/projects/Projects.js index 30c56708215..8667fd9f0a0 100644 --- a/server/sonar-web/src/main/js/apps/account/projects/Projects.js +++ b/server/sonar-web/src/main/js/apps/account/projects/Projects.js @@ -28,7 +28,6 @@ export default class Projects extends React.Component { projects: projectsListType.isRequired, total: React.PropTypes.number.isRequired, loading: React.PropTypes.bool.isRequired, - search: React.PropTypes.func.isRequired, loadMore: React.PropTypes.func.isRequired }; diff --git a/server/sonar-web/src/main/js/apps/account/tokens-view.js b/server/sonar-web/src/main/js/apps/account/tokens-view.js index 1429bd31d5a..5ba74f49104 100644 --- a/server/sonar-web/src/main/js/apps/account/tokens-view.js +++ b/server/sonar-web/src/main/js/apps/account/tokens-view.js @@ -21,7 +21,6 @@ import $ from 'jquery'; import _ from 'underscore'; import Marionette from 'backbone.marionette'; import Clipboard from 'clipboard'; - import Template from './templates/account-tokens.hbs'; import { getTokens, generateToken, revokeToken } from '../../api/user-tokens'; @@ -67,7 +66,7 @@ export default Marionette.ItemView.extend({ }); }, - onRevokeTokenFormSubmit(e) { + onRevokeTokenFormSubmit (e) { e.preventDefault(); const tokenName = $(e.currentTarget).data('token'); const token = _.findWhere(this.tokens, { name: `${tokenName}` }); @@ -93,7 +92,7 @@ export default Marionette.ItemView.extend({ this.newToken = null; }, - serializeData() { + serializeData () { return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), { tokens: this.tokens, newToken: this.newToken, diff --git a/server/sonar-web/src/main/js/apps/background-tasks/__tests__/background-tasks-test.js b/server/sonar-web/src/main/js/apps/background-tasks/__tests__/background-tasks-test.js index 9c882e0ce88..8c0b458208b 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/__tests__/background-tasks-test.js +++ b/server/sonar-web/src/main/js/apps/background-tasks/__tests__/background-tasks-test.js @@ -56,7 +56,7 @@ describe('Search', () => { expect(component.find('.js-search').length).toBe(0); }); - it('should search', (done) => { + it('should search', done => { const searchSpy = jest.fn(); const component = shallow(<Search {...defaultProps} onFilterUpdate={searchSpy}/>); const searchInput = component.find('.js-search'); diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/BackgroundTasksApp.js b/server/sonar-web/src/main/js/apps/background-tasks/components/BackgroundTasksApp.js index d94951e32c7..45be61d8a9c 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/components/BackgroundTasksApp.js +++ b/server/sonar-web/src/main/js/apps/background-tasks/components/BackgroundTasksApp.js @@ -34,17 +34,30 @@ import { Task } from '../types'; import { getComponent } from '../../../store/rootReducer'; import '../background-tasks.css'; +type Props = { + component: Object, + location: Object +}; + +type State = { + loading: boolean, + tasks: Array<*>, + types?: Array<*>, + query: string, + pendingCount: number, + failingCount: number, +}; + class BackgroundTasksApp extends React.Component { + loadTasksDebounced: Function; + mounted: boolean; + props: Props; + static contextTypes = { router: React.PropTypes.object.isRequired }; - static propTypes = { - component: React.PropTypes.object, - location: React.PropTypes.object - }; - - state: any = { + state: State = { loading: true, tasks: [], @@ -69,11 +82,11 @@ class BackgroundTasksApp extends React.Component { }); } - shouldComponentUpdate (nextProps: any, nextState: any) { + shouldComponentUpdate (nextProps: Props, nextState: State) { return shallowCompare(this, nextProps, nextState); } - componentDidUpdate (prevProps: any) { + componentDidUpdate (prevProps: Props) { if (prevProps.component !== this.props.component || prevProps.location !== this.props.location) { this.loadTasksDebounced(); @@ -84,9 +97,6 @@ class BackgroundTasksApp extends React.Component { this.mounted = false; } - loadTasksDebounced: any; - mounted: boolean; - loadTasks () { this.setState({ loading: true }); @@ -98,7 +108,7 @@ class BackgroundTasksApp extends React.Component { const query = this.props.location.query.query || DEFAULT_FILTERS.query; const filters = { status, taskType, currents, minSubmittedAt, maxExecutedAt, query }; - const parameters: any = mapFiltersToParameters(filters); + const parameters: Object = mapFiltersToParameters(filters); if (this.props.component) { parameters.componentId = this.props.component.id; @@ -125,7 +135,7 @@ class BackgroundTasksApp extends React.Component { }); } - handleFilterUpdate (nextState: any) { + handleFilterUpdate (nextState: Object) { const nextQuery = { ...this.props.location.query, ...nextState }; // remove defaults diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/CurrentsFilter.js b/server/sonar-web/src/main/js/apps/background-tasks/components/CurrentsFilter.js index f6cdd97a28b..41394a5a6b2 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/components/CurrentsFilter.js +++ b/server/sonar-web/src/main/js/apps/background-tasks/components/CurrentsFilter.js @@ -17,13 +17,12 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ - /* @flow */ +/* @flow */ import React from 'react'; - import Checkbox from '../../../components/controls/Checkbox'; import { CURRENTS } from '../constants'; -const CurrentsFilter = ({ value, onChange } : { value: ?string, onChange: any }) => { +const CurrentsFilter = ({ value, onChange }: { value: ?string, onChange: (string) => void }) => { function handleChange (value) { const newValue = value ? CURRENTS.ONLY_CURRENTS : CURRENTS.ALL; onChange(newValue); @@ -40,13 +39,16 @@ const CurrentsFilter = ({ value, onChange } : { value: ?string, onChange: any }) return ( <div className="bt-search-form-field"> - <Checkbox - checked={checked} - onCheck={handleChange}/> + <Checkbox checked={checked} onCheck={handleChange}/> <label - onClick={handleLabelClick} - style={{ cursor: 'pointer' }}>Yes</label> + style={{ cursor: 'pointer' }} + role="checkbox" + tabIndex="0" + aria-checked={checked ? 'true' : 'false'} + onClick={handleLabelClick}> + Yes + </label> </div> ); }; diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/DateFilter.js b/server/sonar-web/src/main/js/apps/background-tasks/components/DateFilter.js index bdebed1fcaf..3cfa4a42028 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/components/DateFilter.js +++ b/server/sonar-web/src/main/js/apps/background-tasks/components/DateFilter.js @@ -21,7 +21,6 @@ import $ from 'jquery'; import moment from 'moment'; import React, { Component } from 'react'; - import { DATE_FORMAT } from '../constants'; export default class DateFilter extends Component { diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/Header.js b/server/sonar-web/src/main/js/apps/background-tasks/components/Header.js index a8dc2607fde..2867a89970b 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/components/Header.js +++ b/server/sonar-web/src/main/js/apps/background-tasks/components/Header.js @@ -19,7 +19,6 @@ */ /* @flow */ import React from 'react'; - import { translate } from '../../../helpers/l10n'; const Header = () => { diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/Search.js b/server/sonar-web/src/main/js/apps/background-tasks/components/Search.js index 1b03a3bbead..d048f3e09e9 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/components/Search.js +++ b/server/sonar-web/src/main/js/apps/background-tasks/components/Search.js @@ -19,7 +19,6 @@ */ /* @flow */ import React from 'react'; - import StatusFilter from './StatusFilter'; import TypesFilter from './TypesFilter'; import CurrentsFilter from './CurrentsFilter'; @@ -58,12 +57,12 @@ export default class Search extends React.Component { this.props.onFilterUpdate({ query }); } - handleReload (e: any) { + handleReload (e: Object) { e.target.blur(); this.props.onReload(); } - handleReset (e: any) { + handleReset (e: Object) { e.preventDefault(); e.target.blur(); this.props.onFilterUpdate(DEFAULT_FILTERS); diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/Stats.js b/server/sonar-web/src/main/js/apps/background-tasks/components/Stats.js index a7f6ffe3e29..4d3e87bf424 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/components/Stats.js +++ b/server/sonar-web/src/main/js/apps/background-tasks/components/Stats.js @@ -20,28 +20,32 @@ /* @flow */ import React from 'react'; import shallowCompare from 'react-addons-shallow-compare'; - import { translate } from '../../../helpers/l10n'; +type Props = { + failingCount: number, + pendingCount: number, + onShowFailing: () => void, + onCancelAllPending: () => void +}; + +type State = Object; + export default class Stats extends React.Component { - static propTypes = { - failingCount: React.PropTypes.number, - pendingCount: React.PropTypes.number, - onShowFailing: React.PropTypes.func.isRequired, - onCancelAllPending: React.PropTypes.func.isRequired - }; + props: Props; + state: State; - shouldComponentUpdate (nextProps: any, nextState: any) { + shouldComponentUpdate (nextProps: Props, nextState: State) { return shallowCompare(this, nextProps, nextState); } - handleCancelAllPending (e: any) { + handleCancelAllPending (e: Object) { e.preventDefault(); e.target.blur(); this.props.onCancelAllPending(); } - handleShowFailing (e: any) { + handleShowFailing (e: Object) { e.preventDefault(); e.target.blur(); this.props.onShowFailing(); diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/StatusFilter.js b/server/sonar-web/src/main/js/apps/background-tasks/components/StatusFilter.js index f0693466bd6..a7663ac0940 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/components/StatusFilter.js +++ b/server/sonar-web/src/main/js/apps/background-tasks/components/StatusFilter.js @@ -20,11 +20,10 @@ /* @flow */ import React from 'react'; import Select from 'react-select'; - import { STATUSES } from '../constants'; import { translate } from '../../../helpers/l10n'; -const StatusFilter = ({ value, onChange }: { value: ?string, onChange: any }) => { +const StatusFilter = ({ value, onChange }: { value: ?string, onChange: Function }) => { const options = [ { value: STATUSES.ALL, label: translate('background_task.status.ALL') }, { value: STATUSES.ALL_EXCEPT_PENDING, label: translate('background_task.status.ALL_EXCEPT_PENDING') }, diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/TaskDay.js b/server/sonar-web/src/main/js/apps/background-tasks/components/TaskDay.js index c7275f1668e..55cba79ec3e 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/components/TaskDay.js +++ b/server/sonar-web/src/main/js/apps/background-tasks/components/TaskDay.js @@ -26,7 +26,7 @@ function isAnotherDay (a, b) { return !moment(a).isSame(moment(b), 'day'); } -const TaskDay = ({ task, prevTask } : { task: Task, prevTask: ?Task }) => { +const TaskDay = ({ task, prevTask }: { task: Task, prevTask: ?Task }) => { const shouldDisplay = !prevTask || isAnotherDay(task.submittedAt, prevTask.submittedAt); return ( diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/TaskExecutionTime.js b/server/sonar-web/src/main/js/apps/background-tasks/components/TaskExecutionTime.js index e0d12d09b7a..7fda5c4304a 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/components/TaskExecutionTime.js +++ b/server/sonar-web/src/main/js/apps/background-tasks/components/TaskExecutionTime.js @@ -22,7 +22,7 @@ import React from 'react'; import { formatDuration } from '../utils'; import { Task } from '../types'; -const TaskExecutionTime = ({ task } : { task: Task }) => { +const TaskExecutionTime = ({ task }: { task: Task }) => { return ( <td className="thin nowrap text-right"> {formatDuration(task.executionTimeMs)} diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/TaskStatus.js b/server/sonar-web/src/main/js/apps/background-tasks/components/TaskStatus.js index 89e925590fe..dceb2c8f61f 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/components/TaskStatus.js +++ b/server/sonar-web/src/main/js/apps/background-tasks/components/TaskStatus.js @@ -19,7 +19,6 @@ */ /* @flow */ import React from 'react'; - import { STATUSES } from './../constants'; import PendingIcon from '../../../components/shared/pending-icon'; import { translate } from '../../../helpers/l10n'; diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/Tasks.js b/server/sonar-web/src/main/js/apps/background-tasks/components/Tasks.js index d696d47f9a2..b81e7818849 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/components/Tasks.js +++ b/server/sonar-web/src/main/js/apps/background-tasks/components/Tasks.js @@ -21,21 +21,25 @@ import React from 'react'; import shallowCompare from 'react-addons-shallow-compare'; import classNames from 'classnames'; - import Task from './Task'; import { translate } from '../../../helpers/l10n'; +type Props = { + tasks: Array<*>, + component: Object, + types: Array<*>, + loading: boolean, + onCancelTask: Function, + onFilterTask: Function +}; + +type State = Object; + export default class Tasks extends React.Component { - static propTypes = { - tasks: React.PropTypes.array.isRequired, - component: React.PropTypes.object, - types: React.PropTypes.array.isRequired, - loading: React.PropTypes.bool.isRequired, - onCancelTask: React.PropTypes.func.isRequired, - onFilterTask: React.PropTypes.func.isRequired - }; + props: Props; + state: State; - shouldComponentUpdate (nextProps: any, nextState: any) { + shouldComponentUpdate (nextProps: Props, nextState: State) { return shallowCompare(this, nextProps, nextState); } diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/TypesFilter.js b/server/sonar-web/src/main/js/apps/background-tasks/components/TypesFilter.js index d167e23a0f6..61d0f3b369b 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/components/TypesFilter.js +++ b/server/sonar-web/src/main/js/apps/background-tasks/components/TypesFilter.js @@ -20,11 +20,10 @@ /* @flow */ import React from 'react'; import Select from 'react-select'; - import { ALL_TYPES } from '../constants'; import { translate } from '../../../helpers/l10n'; -const TypesFilter = ({ value, onChange, types }: { value: string, onChange: any, types: string[] }) => { +const TypesFilter = ({ value, onChange, types }: { value: string, onChange: Function, types: string[] }) => { const options = types.map(t => { return { value: t, diff --git a/server/sonar-web/src/main/js/apps/background-tasks/types.js b/server/sonar-web/src/main/js/apps/background-tasks/types.js index 00c000fd0c8..42ab8b6294b 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/types.js +++ b/server/sonar-web/src/main/js/apps/background-tasks/types.js @@ -18,5 +18,5 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ export type Task = { - id: string; + id: string }; diff --git a/server/sonar-web/src/main/js/apps/background-tasks/utils.js b/server/sonar-web/src/main/js/apps/background-tasks/utils.js index cf0c4c89b8b..6801335faad 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/utils.js +++ b/server/sonar-web/src/main/js/apps/background-tasks/utils.js @@ -25,7 +25,7 @@ export function updateTask (tasks: Task[], newTask: Task) { return tasks.map(task => task.id === newTask.id ? newTask : task); } -export function mapFiltersToParameters (filters: any = {}) { +export function mapFiltersToParameters (filters: Object = {}) { const parameters = {}; if (filters.status === STATUSES.ALL) { diff --git a/server/sonar-web/src/main/js/apps/background-tasks/views/ScannerContextView.js b/server/sonar-web/src/main/js/apps/background-tasks/views/ScannerContextView.js index 21da975c6bb..67d557e3517 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/views/ScannerContextView.js +++ b/server/sonar-web/src/main/js/apps/background-tasks/views/ScannerContextView.js @@ -30,14 +30,14 @@ export default Modal.extend({ this.loadScannerContext(); }, - loadScannerContext() { + loadScannerContext () { getTask(this.options.task.id, ['scannerContext']).then(task => { this.scannerContext = task.scannerContext; this.render(); }); }, - serializeData() { + serializeData () { return { task: this.options.task, scannerContext: this.scannerContext diff --git a/server/sonar-web/src/main/js/apps/background-tasks/views/StacktraceView.js b/server/sonar-web/src/main/js/apps/background-tasks/views/StacktraceView.js index 809467dff01..12e0e4b1eb2 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/views/StacktraceView.js +++ b/server/sonar-web/src/main/js/apps/background-tasks/views/StacktraceView.js @@ -31,7 +31,7 @@ export default Modal.extend({ this.loadStacktrace(); }, - loadStacktrace() { + loadStacktrace () { getTask(this.options.task.id, ['stacktrace']).then(task => { this.loaded = true; this.stacktrace = task.errorStacktrace; @@ -39,7 +39,7 @@ export default Modal.extend({ }); }, - serializeData() { + serializeData () { return { task: this.options.task, stacktrace: this.stacktrace, diff --git a/server/sonar-web/src/main/js/apps/code/components/Breadcrumb.js b/server/sonar-web/src/main/js/apps/code/components/Breadcrumb.js index 1280e2289b4..016de7c2475 100644 --- a/server/sonar-web/src/main/js/apps/code/components/Breadcrumb.js +++ b/server/sonar-web/src/main/js/apps/code/components/Breadcrumb.js @@ -18,7 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; - import ComponentName from './ComponentName'; const Breadcrumb = ({ rootComponent, component, canBrowse }) => ( diff --git a/server/sonar-web/src/main/js/apps/code/components/Breadcrumbs.js b/server/sonar-web/src/main/js/apps/code/components/Breadcrumbs.js index 611b98b1b5d..c4cdc3a2f15 100644 --- a/server/sonar-web/src/main/js/apps/code/components/Breadcrumbs.js +++ b/server/sonar-web/src/main/js/apps/code/components/Breadcrumbs.js @@ -18,7 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; - import Breadcrumb from './Breadcrumb'; const Breadcrumbs = ({ rootComponent, breadcrumbs }) => ( diff --git a/server/sonar-web/src/main/js/apps/code/components/Component.js b/server/sonar-web/src/main/js/apps/code/components/Component.js index 7a772566d7f..26980087887 100644 --- a/server/sonar-web/src/main/js/apps/code/components/Component.js +++ b/server/sonar-web/src/main/js/apps/code/components/Component.js @@ -21,7 +21,6 @@ import classNames from 'classnames'; import React from 'react'; import ReactDOM from 'react-dom'; import shallowCompare from 'react-addons-shallow-compare'; - import ComponentName from './ComponentName'; import ComponentMeasure from './ComponentMeasure'; import ComponentDetach from './ComponentDetach'; diff --git a/server/sonar-web/src/main/js/apps/code/components/ComponentName.js b/server/sonar-web/src/main/js/apps/code/components/ComponentName.js index 3ac38eff1b5..9a11b7e103f 100644 --- a/server/sonar-web/src/main/js/apps/code/components/ComponentName.js +++ b/server/sonar-web/src/main/js/apps/code/components/ComponentName.js @@ -66,28 +66,26 @@ const ComponentName = ({ component, rootComponent, previous, canBrowse }) => { <span>{name}</span> </Link> ); - } else { - if (canBrowse) { - const query = { id: rootComponent.key }; - if (component.key !== rootComponent.key) { - Object.assign(query, { selected: component.key }); - } - inner = ( - <Link to={{ pathname: '/code', query }} className="link-with-icon"> - <QualifierIcon qualifier={component.qualifier}/> - {' '} - <span>{name}</span> - </Link> - ); - } else { - inner = ( - <span> - <QualifierIcon qualifier={component.qualifier}/> - {' '} - {name} - </span> - ); + } else if (canBrowse) { + const query = { id: rootComponent.key }; + if (component.key !== rootComponent.key) { + Object.assign(query, { selected: component.key }); } + inner = ( + <Link to={{ pathname: '/code', query }} className="link-with-icon"> + <QualifierIcon qualifier={component.qualifier}/> + {' '} + <span>{name}</span> + </Link> + ); + } else { + inner = ( + <span> + <QualifierIcon qualifier={component.qualifier}/> + {' '} + {name} + </span> + ); } return ( diff --git a/server/sonar-web/src/main/js/apps/code/components/ComponentPin.js b/server/sonar-web/src/main/js/apps/code/components/ComponentPin.js index b22c078aa07..058004de0c1 100644 --- a/server/sonar-web/src/main/js/apps/code/components/ComponentPin.js +++ b/server/sonar-web/src/main/js/apps/code/components/ComponentPin.js @@ -18,13 +18,12 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; - import Workspace from '../../../components/workspace/main'; import PinIcon from '../../../components/shared/pin-icon'; import { translate } from '../../../helpers/l10n'; const ComponentPin = ({ component }) => { - const handleClick = (e) => { + const handleClick = e => { e.preventDefault(); Workspace.openComponent({ uuid: component.id }); }; diff --git a/server/sonar-web/src/main/js/apps/code/components/Components.js b/server/sonar-web/src/main/js/apps/code/components/Components.js index 902ccccd345..d2b86fcd7a5 100644 --- a/server/sonar-web/src/main/js/apps/code/components/Components.js +++ b/server/sonar-web/src/main/js/apps/code/components/Components.js @@ -18,7 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; - import Component from './Component'; import ComponentsEmpty from './ComponentsEmpty'; import ComponentsHeader from './ComponentsHeader'; diff --git a/server/sonar-web/src/main/js/apps/code/components/Search.js b/server/sonar-web/src/main/js/apps/code/components/Search.js index 659b397074c..91b527710ae 100644 --- a/server/sonar-web/src/main/js/apps/code/components/Search.js +++ b/server/sonar-web/src/main/js/apps/code/components/Search.js @@ -21,7 +21,6 @@ import React from 'react'; import shallowCompare from 'react-addons-shallow-compare'; import classNames from 'classnames'; import debounce from 'lodash/debounce'; - import Components from './Components'; import { getTree } from '../../../api/components'; import { translate, translateWithParameters } from '../../../helpers/l10n'; @@ -192,7 +191,7 @@ export default class Search extends React.Component { <div id="code-search" className={containerClassName}> <form className="search-box" onSubmit={this.handleSubmit.bind(this)}> <button className="search-box-submit button-clean"> - <i className="icon-search"></i> + <i className="icon-search"/> </button> <input diff --git a/server/sonar-web/src/main/js/apps/code/utils.js b/server/sonar-web/src/main/js/apps/code/utils.js index 72c1f58425d..a4b74f38e33 100644 --- a/server/sonar-web/src/main/js/apps/code/utils.js +++ b/server/sonar-web/src/main/js/apps/code/utils.js @@ -18,7 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import without from 'lodash/without'; - import { addComponent, getComponent as getComponentFromBucket, diff --git a/server/sonar-web/src/main/js/apps/coding-rules/bulk-change-modal-view.js b/server/sonar-web/src/main/js/apps/coding-rules/bulk-change-modal-view.js index 773106b4056..f58aff2b8ce 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/bulk-change-modal-view.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/bulk-change-modal-view.js @@ -68,10 +68,10 @@ export default ModalFormView.extend({ const that = this; let looper = $.Deferred().resolve(); this.disableForm(); - profiles.forEach(function (profile) { + profiles.forEach(profile => { const opts = _.extend({}, options, { profile_key: profile }); - looper = looper.then(function () { - return $.post(url, opts).done(function (r) { + looper = looper.then(() => { + return $.post(url, opts).done(r => { if (!that.isDestroyed) { if (r.failed) { that.showWarnMessage(profile, r.succeeded, r.failed); @@ -82,7 +82,7 @@ export default ModalFormView.extend({ }); }); }); - looper.done(function () { + looper.done(() => { that.options.app.controller.fetchList(); if (!that.isDestroyed) { that.$(that.ui.codingRulesSubmitBulkChange.selector).hide(); @@ -98,9 +98,7 @@ export default ModalFormView.extend({ const languages = queryLanguages && queryLanguages.length > 0 ? queryLanguages.split(',') : []; let profiles = this.options.app.qualityProfiles; if (languages.length > 0) { - profiles = _.filter(profiles, function (profile) { - return languages.indexOf(profile.lang) !== -1; - }); + profiles = _.filter(profiles, profile => languages.indexOf(profile.lang) !== -1); } return profiles; }, diff --git a/server/sonar-web/src/main/js/apps/coding-rules/confirm-dialog.js b/server/sonar-web/src/main/js/apps/coding-rules/confirm-dialog.js index 3325e156b5a..10f1902018d 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/confirm-dialog.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/confirm-dialog.js @@ -42,13 +42,13 @@ export default function (options) { settings.html + '</div><div class="modal-foot"><button data-confirm="yes">' + settings.yesLabel + '</button> <a data-confirm="no" class="action">' + settings.noLabel + '</a></div></div>'); - $('[data-confirm=yes]', dialog).on('click', function () { + $('[data-confirm=yes]', dialog).on('click', () => { dialog.dialog('close'); settings.yesHandler(); return settings.always(); }); - $('[data-confirm=no]', dialog).on('click', function () { + $('[data-confirm=no]', dialog).on('click', () => { dialog.dialog('close'); settings.noHandler(); return settings.always(); diff --git a/server/sonar-web/src/main/js/apps/coding-rules/controller.js b/server/sonar-web/src/main/js/apps/coding-rules/controller.js index 27d6a475da4..f22cfbb19a3 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/controller.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/controller.js @@ -61,7 +61,7 @@ export default Controller.extend({ const that = this; const url = window.baseUrl + '/api/rules/search'; const options = _.extend(this._searchParameters(), this.app.state.get('query')); - return $.get(url, options).done(function (r) { + return $.get(url, options).done(r => { const rules = that.app.list.parseRules(r); if (firstPage) { that.app.list.reset(rules); @@ -94,7 +94,7 @@ export default Controller.extend({ const url = window.baseUrl + '/api/rules/search'; const facet = this.app.facets.get(id); const options = _.extend({ facets: id, ps: 1 }, this.app.state.get('query')); - return $.get(url, options).done(function (r) { + return $.get(url, options).done(r => { const facetData = _.findWhere(r.facets, { property: id }); if (facetData) { facet.set(facetData); @@ -116,7 +116,7 @@ export default Controller.extend({ key: rule.id, actives: true }; - return $.get(url, options).done(function (data) { + return $.get(url, options).done(data => { rule.set(data.rule); rule.addExtraAttributes(that.app.repositories); }); @@ -126,7 +126,7 @@ export default Controller.extend({ const that = this; const ruleModel = typeof rule === 'string' ? new Rule({ key: rule }) : rule; this.app.layout.workspaceDetailsRegion.reset(); - this.getRuleDetails(ruleModel).done(function (data) { + this.getRuleDetails(ruleModel).done(data => { key.setScope('details'); that.app.workspaceListView.unbindScrollEvents(); that.app.state.set({ rule: ruleModel }); diff --git a/server/sonar-web/src/main/js/apps/coding-rules/facets/active-severity-facet.js b/server/sonar-web/src/main/js/apps/coding-rules/facets/active-severity-facet.js index 598f09c3a58..9d43e62bde9 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/facets/active-severity-facet.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/facets/active-severity-facet.js @@ -56,8 +56,6 @@ export default BaseFacet.extend({ sortValues (values) { const order = this.severities; - return _.sortBy(values, function (v) { - return order.indexOf(v.val); - }); + return _.sortBy(values, v => order.indexOf(v.val)); } }); diff --git a/server/sonar-web/src/main/js/apps/coding-rules/facets/custom-labels-facet.js b/server/sonar-web/src/main/js/apps/coding-rules/facets/custom-labels-facet.js index 3cd599acaf8..908d59307b2 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/facets/custom-labels-facet.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/facets/custom-labels-facet.js @@ -29,7 +29,7 @@ export default BaseFacet.extend({ getValues () { const that = this; const labels = that.getLabelsSource(); - return this.model.getValues().map(function (item) { + return this.model.getValues().map(item => { return _.extend(item, { label: labels[item.val] }); diff --git a/server/sonar-web/src/main/js/apps/coding-rules/facets/inheritance-facet.js b/server/sonar-web/src/main/js/apps/coding-rules/facets/inheritance-facet.js index bd7a3bba91c..438209740db 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/facets/inheritance-facet.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/facets/inheritance-facet.js @@ -60,7 +60,7 @@ export default BaseFacet.extend({ getValues () { const values = ['NONE', 'INHERITED', 'OVERRIDES']; - return values.map(function (key) { + return values.map(key => { return { label: translate('coding_rules.filters.inheritance', key.toLowerCase()), val: key diff --git a/server/sonar-web/src/main/js/apps/coding-rules/facets/key-facet.js b/server/sonar-web/src/main/js/apps/coding-rules/facets/key-facet.js index 62613aabed5..ac2373659b0 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/facets/key-facet.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/facets/key-facet.js @@ -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 BaseFacet from './base-facet'; import _ from 'underscore'; +import BaseFacet from './base-facet'; import Template from '../templates/facets/coding-rules-key-facet.hbs'; export default BaseFacet.extend({ diff --git a/server/sonar-web/src/main/js/apps/coding-rules/facets/language-facet.js b/server/sonar-web/src/main/js/apps/coding-rules/facets/language-facet.js index 9af9562fff7..f9bb3674191 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/facets/language-facet.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/facets/language-facet.js @@ -36,7 +36,7 @@ export default CustomValuesFacet.extend({ results (data) { return { more: false, - results: data.languages.map(function (lang) { + results: data.languages.map(lang => { return { id: lang.key, text: lang.name }; }) }; @@ -51,7 +51,7 @@ export default CustomValuesFacet.extend({ getValues () { const that = this; const labels = that.getLabelsSource(); - return this.model.getValues().map(function (item) { + return this.model.getValues().map(item => { return _.extend(item, { label: labels[item.val] }); diff --git a/server/sonar-web/src/main/js/apps/coding-rules/facets/quality-profile-facet.js b/server/sonar-web/src/main/js/apps/coding-rules/facets/quality-profile-facet.js index b50c8bd7481..338f088bc62 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/facets/quality-profile-facet.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/facets/quality-profile-facet.js @@ -38,16 +38,14 @@ export default BaseFacet.extend({ const languages = languagesQuery != null ? languagesQuery.split(',') : []; const lang = languages.length === 1 ? languages[0] : null; const values = this.options.app.qualityProfiles - .filter(function (profile) { - return lang != null ? profile.lang === lang : true; - }) - .map(function (profile) { - return { - label: profile.name, - extra: that.options.app.languages[profile.lang], - val: profile.key - }; - }); + .filter(profile => ( + lang != null ? profile.lang === lang : true + )) + .map(profile => ({ + label: profile.name, + extra: that.options.app.languages[profile.lang], + val: profile.key + })); return _.sortBy(values, 'label'); }, diff --git a/server/sonar-web/src/main/js/apps/coding-rules/facets/repository-facet.js b/server/sonar-web/src/main/js/apps/coding-rules/facets/repository-facet.js index 76067f5b24c..5c0c0b6c28f 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/facets/repository-facet.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/facets/repository-facet.js @@ -36,7 +36,7 @@ export default CustomValuesFacet.extend({ results (data) { return { more: false, - results: data.repositories.map(function (repo) { + results: data.repositories.map(repo => { return { id: repo.key, text: repo.name + ' (' + repo.language + ')' }; }) }; @@ -52,7 +52,7 @@ export default CustomValuesFacet.extend({ getValues () { const that = this; const labels = that.getLabelsSource(); - return this.model.getValues().map(function (value) { + return this.model.getValues().map(value => { const repo = _.findWhere(that.options.app.repositories, { key: value.val }); if (repo != null) { const langName = that.options.app.languages[repo.language]; diff --git a/server/sonar-web/src/main/js/apps/coding-rules/facets/severity-facet.js b/server/sonar-web/src/main/js/apps/coding-rules/facets/severity-facet.js index 970722c318c..44f61bd04c4 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/facets/severity-facet.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/facets/severity-facet.js @@ -27,8 +27,6 @@ export default BaseFacet.extend({ sortValues (values) { const order = this.severities; - return _.sortBy(values, function (v) { - return order.indexOf(v.val); - }); + return _.sortBy(values, v => order.indexOf(v.val)); } }); diff --git a/server/sonar-web/src/main/js/apps/coding-rules/facets/status-facet.js b/server/sonar-web/src/main/js/apps/coding-rules/facets/status-facet.js index eab8055cfe2..7bc588e2ead 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/facets/status-facet.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/facets/status-facet.js @@ -26,17 +26,15 @@ export default BaseFacet.extend({ getValues () { const values = this.model.getValues(); - const x = values.map(function (value) { - return _.extend(value, { label: translate('rules.status', value.val.toLowerCase()) }); - }); + const x = values.map(value => ( + _.extend(value, { label: translate('rules.status', value.val.toLowerCase()) }) + )); return x; }, sortValues (values) { const order = this.statuses; - return _.sortBy(values, function (v) { - return order.indexOf(v.val); - }); + return _.sortBy(values, v => order.indexOf(v.val)); }, serializeData () { diff --git a/server/sonar-web/src/main/js/apps/coding-rules/facets/tag-facet.js b/server/sonar-web/src/main/js/apps/coding-rules/facets/tag-facet.js index b672b3af9ba..747b4f93cfb 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/facets/tag-facet.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/facets/tag-facet.js @@ -35,7 +35,7 @@ export default CustomValuesFacet.extend({ results (data) { return { more: false, - results: data.tags.map(function (tag) { + results: data.tags.map(tag => { return { id: tag, text: tag }; }) }; diff --git a/server/sonar-web/src/main/js/apps/coding-rules/facets/type-facet.js b/server/sonar-web/src/main/js/apps/coding-rules/facets/type-facet.js index af8b47c9248..021070ee8e5 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/facets/type-facet.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/facets/type-facet.js @@ -26,9 +26,7 @@ export default BaseFacet.extend({ sortValues (values) { const order = ['BUG', 'VULNERABILITY', 'CODE_SMELL']; - return _.sortBy(values, function (v) { - return order.indexOf(v.val); - }); + return _.sortBy(values, v => order.indexOf(v.val)); } }); diff --git a/server/sonar-web/src/main/js/apps/coding-rules/init.js b/server/sonar-web/src/main/js/apps/coding-rules/init.js index 37470e65465..b3513a01abf 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/init.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/init.js @@ -35,13 +35,13 @@ import FiltersView from './filters-view'; const App = new Marionette.Application(); App.on('start', function (el) { - $.get(window.baseUrl + '/api/rules/app').done(function (r) { + $.get(window.baseUrl + '/api/rules/app').done(r => { App.canWrite = r.canWrite; App.qualityProfiles = _.sortBy(r.qualityprofiles, ['name', 'lang']); App.languages = _.extend(r.languages, { none: 'None' }); - _.map(App.qualityProfiles, function (profile) { + _.map(App.qualityProfiles, profile => { profile.language = App.languages[profile.lang]; }); App.repositories = r.repositories; diff --git a/server/sonar-web/src/main/js/apps/coding-rules/models/rule.js b/server/sonar-web/src/main/js/apps/coding-rules/models/rule.js index 8ceb2ec3dc8..17129610b17 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/models/rule.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/models/rule.js @@ -36,7 +36,7 @@ export default Backbone.Model.extend({ }, getInactiveProfiles (actives, profiles) { - return actives.map(function (profile) { + return actives.map(profile => { const profileBase = _.findWhere(profiles, { key: profile.qProfile }); if (profileBase != null) { _.extend(profile, profileBase); diff --git a/server/sonar-web/src/main/js/apps/coding-rules/models/rules.js b/server/sonar-web/src/main/js/apps/coding-rules/models/rules.js index 57906ae9c7f..4766dd0e17b 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/models/rules.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/models/rules.js @@ -29,8 +29,8 @@ export default Backbone.Collection.extend({ const profiles = r.qProfiles || []; if (r.actives != null) { - rules = rules.map(function (rule) { - const activations = (r.actives[rule.key] || []).map(function (activation) { + rules = rules.map(rule => { + const activations = (r.actives[rule.key] || []).map(activation => { const profile = profiles[activation.qProfile]; if (profile != null) { _.extend(activation, { profile }); @@ -47,13 +47,13 @@ export default Backbone.Collection.extend({ }, setIndex () { - this.forEach(function (rule, index) { + this.forEach((rule, index) => { rule.set({ index }); }); }, addExtraAttributes (repositories) { - this.models.forEach(function (model) { + this.models.forEach(model => { model.addExtraAttributes(repositories); }); } diff --git a/server/sonar-web/src/main/js/apps/coding-rules/rule-details-view.js b/server/sonar-web/src/main/js/apps/coding-rules/rule-details-view.js index 5566f70945d..638722e77fb 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/rule-details-view.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/rule-details-view.js @@ -100,7 +100,7 @@ export default Marionette.LayoutView.extend({ template_key: this.model.get('key'), f: 'name,severity,params' }; - return $.get(url, options).done(function (data) { + return $.get(url, options).done(data => { that.customRules.reset(data.rules); }); }, @@ -111,15 +111,15 @@ export default Marionette.LayoutView.extend({ bindShortcuts () { const that = this; - key('up', 'details', function () { + key('up', 'details', () => { that.options.app.controller.selectPrev(); return false; }); - key('down', 'details', function () { + key('down', 'details', () => { that.options.app.controller.selectNext(); return false; }); - key('left, backspace', 'details', function () { + key('left, backspace', 'details', () => { that.options.app.controller.hideDetails(); return false; }); diff --git a/server/sonar-web/src/main/js/apps/coding-rules/rule/custom-rule-creation-view.js b/server/sonar-web/src/main/js/apps/coding-rules/rule/custom-rule-creation-view.js index b9ebae4d1a2..6e41407104d 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/rule/custom-rule-creation-view.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/rule/custom-rule-creation-view.js @@ -128,9 +128,7 @@ export default ModalFormView.extend({ value }; }).get(); - options.params = params.map(function (param) { - return param.key + '=' + csvEscape(param.value); - }).join(';'); + options.params = params.map(param => param.key + '=' + csvEscape(param.value)).join(';'); this.sendRequest(action, options); }, @@ -145,9 +143,7 @@ export default ModalFormView.extend({ prevent_reactivation: false }; const params = this.existingRule.params; - options.params = params.map(function (param) { - return param.key + '=' + param.defaultValue; - }).join(';'); + options.params = params.map(param => param.key + '=' + param.defaultValue).join(';'); this.sendRequest('create', options); }, @@ -163,14 +159,14 @@ export default ModalFormView.extend({ // do not show global error 400: null } - }).done(function () { + }).done(() => { if (that.options.templateRule) { that.options.app.controller.showDetails(that.options.templateRule); } else { that.options.app.controller.showDetails(that.model); } that.destroy(); - }).fail(function (jqXHR) { + }).fail(jqXHR => { if (jqXHR.status === 409) { that.existingRule = jqXHR.responseJSON.rule; that.showErrors([], [{ msg: translate('coding_rules.reactivate.help') }]); @@ -187,12 +183,10 @@ export default ModalFormView.extend({ if (this.options.templateRule) { params = this.options.templateRule.get('params'); } else if (this.model && this.model.has('params')) { - params = this.model.get('params').map(function (p) { - return _.extend(p, { value: p.defaultValue }); - }); + params = this.model.get('params').map(p => _.extend(p, { value: p.defaultValue })); } - const statuses = ['READY', 'BETA', 'DEPRECATED'].map(function (status) { + const statuses = ['READY', 'BETA', 'DEPRECATED'].map(status => { return { id: status, text: translate('rules.status', status.toLowerCase()) diff --git a/server/sonar-web/src/main/js/apps/coding-rules/rule/delete-rule-view.js b/server/sonar-web/src/main/js/apps/coding-rules/rule/delete-rule-view.js index b0d344118f0..f3f543991b2 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/rule/delete-rule-view.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/rule/delete-rule-view.js @@ -18,14 +18,13 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import $ from 'jquery'; - import ModalFormView from '../../../components/common/modal-form'; import Template from '../templates/rule/coding-rules-delete-rule.hbs'; export default ModalFormView.extend({ template: Template, - onFormSubmit() { + onFormSubmit () { ModalFormView.prototype.onFormSubmit.apply(this, arguments); const url = window.baseUrl + '/api/rules/delete'; diff --git a/server/sonar-web/src/main/js/apps/coding-rules/rule/profile-activation-view.js b/server/sonar-web/src/main/js/apps/coding-rules/rule/profile-activation-view.js index dce27670e4d..62840df8ee0 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/rule/profile-activation-view.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/rule/profile-activation-view.js @@ -66,7 +66,7 @@ export default ModalForm.extend({ formatResult: format, formatSelection: format }); - setTimeout(function () { + setTimeout(() => { that.$('a').first().focus(); }, 0); }, @@ -81,9 +81,7 @@ export default ModalForm.extend({ value: $(this).val() || $(this).prop('placeholder') || '' }; }).get(); - const paramsHash = (params.map(function (param) { - return param.key + '=' + csvEscape(param.value); - })).join(';'); + const paramsHash = (params.map(param => param.key + '=' + csvEscape(param.value))).join(';'); if (this.model) { profileKey = this.model.get('qProfile'); @@ -110,10 +108,10 @@ export default ModalForm.extend({ // do not show global error 400: null } - }).done(function () { + }).done(() => { that.destroy(); that.trigger('profileActivated', severity, params, profileKey); - }).fail(function (jqXHR) { + }).fail(jqXHR => { that.enableForm(); that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings); }); @@ -121,12 +119,10 @@ export default ModalForm.extend({ getAvailableQualityProfiles (lang) { const activeQualityProfiles = this.collection || new Backbone.Collection(); - const inactiveProfiles = _.reject(this.options.app.qualityProfiles, function (profile) { - return activeQualityProfiles.findWhere({ key: profile.key }); - }); - return _.filter(inactiveProfiles, function (profile) { - return profile.lang === lang; - }); + const inactiveProfiles = _.reject(this.options.app.qualityProfiles, profile => ( + activeQualityProfiles.findWhere({ key: profile.key }) + )); + return _.filter(inactiveProfiles, profile => profile.lang === lang); }, serializeData () { @@ -134,7 +130,7 @@ export default ModalForm.extend({ if (this.model != null) { const modelParams = this.model.get('params'); if (_.isArray(modelParams)) { - params = params.map(function (p) { + params = params.map(p => { const parentParam = _.findWhere(modelParams, { key: p.key }); if (parentParam != null) { _.extend(p, { value: parentParam.value }); diff --git a/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-description-view.js b/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-description-view.js index 49486712db8..ae3ca70b0fa 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-description-view.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-description-view.js @@ -70,13 +70,13 @@ export default Marionette.ItemView.extend({ key: this.model.get('key'), markdown_note: this.ui.extendDescriptionText.val() } - }).done(function (r) { + }).done(r => { that.model.set({ htmlNote: r.rule.htmlNote, mdNote: r.rule.mdNote }); that.render(); - }).fail(function () { + }).fail(() => { that.render(); }); }, diff --git a/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-filter-mixin.js b/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-filter-mixin.js index 4bc6a1ef131..f990e39cf48 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-filter-mixin.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-filter-mixin.js @@ -31,7 +31,7 @@ export default { bottomRight: true, model: this.model }); - popup.on('select', function (property, value) { + popup.on('select', (property, value) => { const obj = {}; obj[property] = '' + value; that.options.app.state.updateFilter(obj); diff --git a/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-issues-view.js b/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-issues-view.js index 97c5499ae3b..be53536adfb 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-issues-view.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-issues-view.js @@ -29,7 +29,7 @@ export default Marionette.ItemView.extend({ const that = this; this.total = null; this.projects = []; - this.requestIssues().done(function () { + this.requestIssues().done(() => { that.render(); }); }, @@ -43,10 +43,10 @@ export default Marionette.ItemView.extend({ ps: 1, facets: 'projectUuids' }; - return $.get(url, options).done(function (r) { + return $.get(url, options).done(r => { const projectsFacet = _.findWhere(r.facets, { property: 'projectUuids' }); let projects = projectsFacet != null ? projectsFacet.values : []; - projects = projects.map(function (project) { + projects = projects.map(project => { const projectBase = _.findWhere(r.components, { uuid: project.val }); return _.extend(project, { name: projectBase != null ? projectBase.longName : '' diff --git a/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-meta-view.js b/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-meta-view.js index dc67ad6c39f..9d01de1ec4e 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-meta-view.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-meta-view.js @@ -63,7 +63,7 @@ export default Marionette.ItemView.extend(RuleFilterMixin).extend({ changeTags () { const that = this; - this.requestTags().done(function (r) { + this.requestTags().done(r => { that.ui.tagInput.select2({ tags: _.difference(_.difference(r.tags, that.model.get('tags')), that.model.get('sysTags')), width: '300px' @@ -95,10 +95,10 @@ export default Marionette.ItemView.extend(RuleFilterMixin).extend({ key: this.model.get('key'), tags } - }).done(function (r) { + }).done(r => { that.model.set('tags', r.rule.tags); that.cancelEdit(); - }).always(function () { + }).always(() => { that.cancelEdit(); }); }, diff --git a/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-profile-view.js b/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-profile-view.js index a2dcd979655..d6786752061 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-profile-view.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-profile-view.js @@ -60,7 +60,7 @@ export default Marionette.ItemView.extend({ rule: this.options.rule, app: this.options.app }); - activationView.on('profileActivated', function () { + activationView.on('profileActivated', () => { that.options.refreshActives(); }); activationView.render(); @@ -81,7 +81,7 @@ export default Marionette.ItemView.extend({ rule_key: ruleKey, reset: true } - }).done(function () { + }).done(() => { that.options.refreshActives(); }); } @@ -102,7 +102,7 @@ export default Marionette.ItemView.extend({ profile_key: that.model.get('qProfile'), rule_key: ruleKey } - }).done(function () { + }).done(() => { that.options.refreshActives(); }); } @@ -135,7 +135,7 @@ export default Marionette.ItemView.extend({ if (!parent) { return params; } - return params.map(function (p) { + return params.map(p => { const parentParam = _.findWhere(parent.params, { key: p.key }); if (parentParam != null) { return _.extend(p, { diff --git a/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-profiles-view.js b/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-profiles-view.js index e3abef640bf..625dd58fcb2 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-profiles-view.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-profiles-view.js @@ -61,7 +61,7 @@ export default Marionette.CompositeView.extend({ collection: this.collection, app: this.options.app }); - activationView.on('profileActivated', function (severity, params, profile) { + activationView.on('profileActivated', (severity, params, profile) => { if (that.options.app.state.get('query').qprofile === profile) { const activation = { severity, @@ -78,7 +78,7 @@ export default Marionette.CompositeView.extend({ refreshActives () { const that = this; - this.options.app.controller.getRuleDetails(this.model).done(function (data) { + this.options.app.controller.getRuleDetails(this.model).done(data => { that.collection.reset(that.model.getInactiveProfiles(data.actives, that.options.app.qualityProfiles)); }); }, diff --git a/server/sonar-web/src/main/js/apps/coding-rules/workspace-list-item-view.js b/server/sonar-web/src/main/js/apps/coding-rules/workspace-list-item-view.js index a965be731e3..c96b5e42af9 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/workspace-list-item-view.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/workspace-list-item-view.js @@ -69,15 +69,16 @@ export default WorkspaceListItemView.extend(RuleFilterMixin).extend({ activate () { const that = this; const selectedProfile = this.options.app.state.get('query').qprofile; - const othersQualityProfiles = _.reject(this.options.app.qualityProfiles, function (profile) { - return profile.key === selectedProfile; - }); + const othersQualityProfiles = _.reject( + this.options.app.qualityProfiles, + profile => profile.key === selectedProfile + ); const activationView = new ProfileActivationView({ rule: this.model, collection: new Backbone.Collection(othersQualityProfiles), app: this.options.app }); - activationView.on('profileActivated', function (severity, params, profile) { + activationView.on('profileActivated', (severity, params, profile) => { const activation = { severity, params, @@ -104,7 +105,7 @@ export default WorkspaceListItemView.extend(RuleFilterMixin).extend({ profile_key: activation.qProfile, rule_key: ruleKey } - }).done(function () { + }).done(() => { that.model.unset('activation'); }); } diff --git a/server/sonar-web/src/main/js/apps/coding-rules/workspace-list-view.js b/server/sonar-web/src/main/js/apps/coding-rules/workspace-list-view.js index eda62e135e3..0027d77be23 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/workspace-list-view.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/workspace-list-view.js @@ -31,15 +31,15 @@ export default WorkspaceListView.extend({ bindShortcuts () { WorkspaceListView.prototype.bindShortcuts.apply(this, arguments); const that = this; - key('right', 'list', function () { + key('right', 'list', () => { that.options.app.controller.showDetailsForSelected(); return false; }); - key('a', function () { + key('a', () => { that.options.app.controller.activateCurrent(); return false; }); - key('d', function () { + key('d', () => { that.options.app.controller.deactivateCurrent(); return false; }); diff --git a/server/sonar-web/src/main/js/apps/component-issues/components/ComponentIssuesAppContainer.js b/server/sonar-web/src/main/js/apps/component-issues/components/ComponentIssuesAppContainer.js index 3c08036cb91..cd350778a4a 100644 --- a/server/sonar-web/src/main/js/apps/component-issues/components/ComponentIssuesAppContainer.js +++ b/server/sonar-web/src/main/js/apps/component-issues/components/ComponentIssuesAppContainer.js @@ -18,8 +18,8 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; -import init from '../init'; import { connect } from 'react-redux'; +import init from '../init'; import { getComponent, getCurrentUser } from '../../../store/rootReducer'; class ComponentIssuesAppContainer extends React.Component { diff --git a/server/sonar-web/src/main/js/apps/component-issues/init.js b/server/sonar-web/src/main/js/apps/component-issues/init.js index 3727a08c044..fc3ed9e8464 100644 --- a/server/sonar-web/src/main/js/apps/component-issues/init.js +++ b/server/sonar-web/src/main/js/apps/component-issues/init.js @@ -111,7 +111,7 @@ App.updateContextFacets = function () { }); }; -App.on('start', function (options) { +App.on('start', options => { init.call(App, options); }); diff --git a/server/sonar-web/src/main/js/apps/component-measures/app/App.js b/server/sonar-web/src/main/js/apps/component-measures/app/App.js index 75fa2d320a4..80d365c932b 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/app/App.js +++ b/server/sonar-web/src/main/js/apps/component-measures/app/App.js @@ -18,7 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; - import Spinner from './../components/Spinner'; export default class App extends React.Component { diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/LeakPeriodLegend.js b/server/sonar-web/src/main/js/apps/component-measures/components/LeakPeriodLegend.js index ae760d3a0a5..7ccd892e8f2 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/components/LeakPeriodLegend.js +++ b/server/sonar-web/src/main/js/apps/component-measures/components/LeakPeriodLegend.js @@ -19,7 +19,6 @@ */ import React from 'react'; import moment from 'moment'; - import { TooltipsContainer } from '../../../components/mixins/tooltips-mixin'; import { getPeriodLabel, getPeriodDate } from '../../../helpers/periods'; import { translateWithParameters } from '../../../helpers/l10n'; diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/bubbleChart/BubbleChart.js b/server/sonar-web/src/main/js/apps/component-measures/components/bubbleChart/BubbleChart.js index bb5e925bc73..d96e9f42bb0 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/components/bubbleChart/BubbleChart.js +++ b/server/sonar-web/src/main/js/apps/component-measures/components/bubbleChart/BubbleChart.js @@ -18,7 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; - import Spinner from './../Spinner'; import { BubbleChart as OriginalBubbleChart } from '../../../../components/charts/bubble-chart'; import bubbles from '../../config/bubbles'; @@ -136,8 +135,8 @@ export default class BubbleChart extends React.Component { }; }); - const formatXTick = (tick) => formatMeasure(tick, this.xMetric.type); - const formatYTick = (tick) => formatMeasure(tick, this.yMetric.type); + const formatXTick = tick => formatMeasure(tick, this.xMetric.type); + const formatYTick = tick => formatMeasure(tick, this.yMetric.type); return ( <OriginalBubbleChart diff --git a/server/sonar-web/src/main/js/apps/component-measures/details/MeasureDetails.js b/server/sonar-web/src/main/js/apps/component-measures/details/MeasureDetails.js index 125b9c72897..15ef60cad3d 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/details/MeasureDetails.js +++ b/server/sonar-web/src/main/js/apps/component-measures/details/MeasureDetails.js @@ -19,7 +19,6 @@ */ import React from 'react'; import { Link, IndexLink } from 'react-router'; - import Spinner from './../components/Spinner'; import MeasureDetailsHeader from './MeasureDetailsHeader'; import MeasureDrilldown from './drilldown/MeasureDrilldown'; diff --git a/server/sonar-web/src/main/js/apps/component-measures/details/MeasureDetailsContainer.js b/server/sonar-web/src/main/js/apps/component-measures/details/MeasureDetailsContainer.js index b569c01636b..833a01abf67 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/details/MeasureDetailsContainer.js +++ b/server/sonar-web/src/main/js/apps/component-measures/details/MeasureDetailsContainer.js @@ -25,8 +25,8 @@ import { getMeasuresAppDetailsMetric, getMeasuresAppDetailsMeasure, getMeasuresAppDetailsSecondaryMeasure, - getMeasuresAppDetailsPeriods - , getMeasuresAppComponent + getMeasuresAppDetailsPeriods, + getMeasuresAppComponent } from '../../../store/rootReducer'; const mapStateToProps = state => { diff --git a/server/sonar-web/src/main/js/apps/component-measures/details/MeasureDetailsHeader.js b/server/sonar-web/src/main/js/apps/component-measures/details/MeasureDetailsHeader.js index dfa4e81a60b..c3769f4b5d0 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/details/MeasureDetailsHeader.js +++ b/server/sonar-web/src/main/js/apps/component-measures/details/MeasureDetailsHeader.js @@ -18,7 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; - import Measure from './../components/Measure'; import LanguageDistribution from '../../../components/charts/LanguageDistribution'; import LeakPeriodLegend from '../components/LeakPeriodLegend'; diff --git a/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/Breadcrumb.js b/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/Breadcrumb.js index 15a44e30452..10e9578f6d2 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/Breadcrumb.js +++ b/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/Breadcrumb.js @@ -23,7 +23,7 @@ import { isDiffMetric, formatLeak } from '../../utils'; import { formatMeasure } from '../../../../helpers/measures'; const Breadcrumb = ({ component, metric, onBrowse }) => { - const handleClick = (e) => { + const handleClick = e => { e.preventDefault(); e.target.blur(); onBrowse(component); diff --git a/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/Breadcrumbs.js b/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/Breadcrumbs.js index dfcf88d9bef..eb28c93def5 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/Breadcrumbs.js +++ b/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/Breadcrumbs.js @@ -18,7 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; - import Breadcrumb from './Breadcrumb'; const Breadcrumbs = ({ breadcrumbs, metric, onBrowse }) => ( diff --git a/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/ComponentCell.js b/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/ComponentCell.js index cad8f0d7fb4..13592032907 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/ComponentCell.js +++ b/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/ComponentCell.js @@ -19,7 +19,6 @@ */ import React from 'react'; import classNames from 'classnames'; - import QualifierIcon from '../../../../components/shared/qualifier-icon'; import { splitPath } from '../../../../helpers/path'; import { getComponentUrl } from '../../../../helpers/urls'; diff --git a/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/ComponentsList.js b/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/ComponentsList.js index ff6b063441b..04c0c3a242e 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/ComponentsList.js +++ b/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/ComponentsList.js @@ -18,7 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; - import ComponentsListRow from './ComponentsListRow'; import EmptyComponentsList from './EmptyComponentsList'; import complementary from '../../config/complementary'; diff --git a/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/ComponentsListRow.js b/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/ComponentsListRow.js index d734aca5f75..613ac3b3834 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/ComponentsListRow.js +++ b/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/ComponentsListRow.js @@ -18,7 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; - import ComponentCell from './ComponentCell'; import MeasureCell from './MeasureCell'; diff --git a/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/EmptyComponentsList.js b/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/EmptyComponentsList.js index 7b1a11d5791..fd15d5593ab 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/EmptyComponentsList.js +++ b/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/EmptyComponentsList.js @@ -18,7 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; - import { translate } from '../../../../helpers/l10n'; const EmptyComponentsList = () => { diff --git a/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/ListHeader.js b/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/ListHeader.js index a12be76c7e4..749a633ae07 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/ListHeader.js +++ b/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/ListHeader.js @@ -18,11 +18,10 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; - import Breadcrumbs from './Breadcrumbs'; import { translateWithParameters } from '../../../../helpers/l10n'; -const ListHeader = (props) => { +const ListHeader = props => { const { metric, breadcrumbs, onBrowse } = props; const { selectedIndex, componentsCount, onSelectPrevious, onSelectNext } = props; const hasPrevious = selectedIndex > 0; diff --git a/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/ListView.js b/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/ListView.js index 49a3635cf8d..8897b9df2f9 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/ListView.js +++ b/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/ListView.js @@ -19,7 +19,6 @@ */ import React from 'react'; import classNames from 'classnames'; - import ComponentsList from './ComponentsList'; import ListHeader from './ListHeader'; import Spinner from '../../components/Spinner'; diff --git a/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/ListViewContainer.js b/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/ListViewContainer.js index 57d20b41a46..ee9b1182799 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/ListViewContainer.js +++ b/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/ListViewContainer.js @@ -27,8 +27,8 @@ import { getMeasuresAppListPageIndex, getMeasuresAppAllMetrics, getMeasuresAppDetailsMetric, - isMeasuresAppFetching - , getMeasuresAppComponent + isMeasuresAppFetching, + getMeasuresAppComponent } from '../../../../store/rootReducer'; const mapStateToProps = state => { diff --git a/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/MeasureCell.js b/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/MeasureCell.js index bed973fa11f..1744215ee16 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/MeasureCell.js +++ b/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/MeasureCell.js @@ -18,7 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; - import Measure from '../../components/Measure'; const MeasureCell = ({ component, metric }) => { diff --git a/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/MeasureDrilldown.js b/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/MeasureDrilldown.js index cc7e06546ed..b274c3a4d60 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/MeasureDrilldown.js +++ b/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/MeasureDrilldown.js @@ -19,13 +19,11 @@ */ import React from 'react'; import { Link } from 'react-router'; - import IconList from './../../components/IconList'; import IconTree from './../../components/IconTree'; import IconBubbles from './../../components/IconBubbles'; import IconTreemap from './../../components/IconTreemap'; import IconHistory from './../../components/IconHistory'; - import { hasHistory, hasBubbleChart, hasTreemap } from '../../utils'; import { translate } from '../../../../helpers/l10n'; diff --git a/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/TreeView.js b/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/TreeView.js index e71b35e5e7a..0e6d8923ffa 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/TreeView.js +++ b/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/TreeView.js @@ -18,7 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; - import ComponentsList from './ComponentsList'; import ListHeader from './ListHeader'; import Spinner from '../../components/Spinner'; diff --git a/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/TreeViewContainer.js b/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/TreeViewContainer.js index cb5e2a0e76b..070175f1fe6 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/TreeViewContainer.js +++ b/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/TreeViewContainer.js @@ -36,8 +36,8 @@ import { getMeasuresAppTreePageIndex, getMeasuresAppAllMetrics, getMeasuresAppDetailsMetric, - isMeasuresAppFetching - , getMeasuresAppComponent + isMeasuresAppFetching, + getMeasuresAppComponent } from '../../../../store/rootReducer'; const mapStateToProps = state => { diff --git a/server/sonar-web/src/main/js/apps/component-measures/details/history/MeasureHistory.js b/server/sonar-web/src/main/js/apps/component-measures/details/history/MeasureHistory.js index 3e0f15fec20..71281f261f3 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/details/history/MeasureHistory.js +++ b/server/sonar-web/src/main/js/apps/component-measures/details/history/MeasureHistory.js @@ -20,7 +20,6 @@ import sortBy from 'lodash/sortBy'; import moment from 'moment'; import React from 'react'; - import Spinner from './../../components/Spinner'; import Timeline from '../../../../components/charts/Timeline'; import { getTimeMachineData } from '../../../../api/time-machine'; @@ -117,8 +116,8 @@ export default class MeasureHistory extends React.Component { }; }); - const formatValue = (value) => formatMeasure(value, metric.type); - const formatYTick = (tick) => formatMeasure(tick, getShortType(metric.type)); + const formatValue = value => formatMeasure(value, metric.type); + const formatYTick = tick => formatMeasure(tick, getShortType(metric.type)); return ( <div style={{ height: HEIGHT }}> diff --git a/server/sonar-web/src/main/js/apps/component-measures/details/treemap/MeasureTreemap.js b/server/sonar-web/src/main/js/apps/component-measures/details/treemap/MeasureTreemap.js index 1fe61d36ec9..12060645ba4 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/details/treemap/MeasureTreemap.js +++ b/server/sonar-web/src/main/js/apps/component-measures/details/treemap/MeasureTreemap.js @@ -18,7 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; - import Spinner from './../../components/Spinner'; import { getLeakValue } from '../../utils'; import { Treemap } from '../../../../components/charts/treemap'; diff --git a/server/sonar-web/src/main/js/apps/component-measures/home/AllMeasures.js b/server/sonar-web/src/main/js/apps/component-measures/home/AllMeasures.js index bb3cb74a2ff..9225f9ba49d 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/home/AllMeasures.js +++ b/server/sonar-web/src/main/js/apps/component-measures/home/AllMeasures.js @@ -18,7 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; - import AllMeasuresDomain from './AllMeasuresDomain'; import { getLeakPeriodLabel } from '../../../helpers/periods'; diff --git a/server/sonar-web/src/main/js/apps/component-measures/home/AllMeasuresDomain.js b/server/sonar-web/src/main/js/apps/component-measures/home/AllMeasuresDomain.js index 6f14109c27a..c5017b1d982 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/home/AllMeasuresDomain.js +++ b/server/sonar-web/src/main/js/apps/component-measures/home/AllMeasuresDomain.js @@ -18,7 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; - import HomeMeasuresList from './HomeMeasuresList'; import { getLocalizedMetricDomain } from '../../../helpers/l10n'; diff --git a/server/sonar-web/src/main/js/apps/component-measures/home/DomainMeasures.js b/server/sonar-web/src/main/js/apps/component-measures/home/DomainMeasures.js index 00d84915590..106f144c0d3 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/home/DomainMeasures.js +++ b/server/sonar-web/src/main/js/apps/component-measures/home/DomainMeasures.js @@ -18,7 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; - import HomeMeasuresList from './HomeMeasuresList'; import MeasureBubbleChartContainer from '../components/bubbleChart/MeasureBubbleChartContainer'; import { hasBubbleChart } from '../utils'; diff --git a/server/sonar-web/src/main/js/apps/component-measures/home/Home.js b/server/sonar-web/src/main/js/apps/component-measures/home/Home.js index 6b1faf5402f..306667e20f5 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/home/Home.js +++ b/server/sonar-web/src/main/js/apps/component-measures/home/Home.js @@ -19,7 +19,6 @@ */ import React from 'react'; import { Link, IndexLink } from 'react-router'; - import LeakPeriodLegend from '../components/LeakPeriodLegend'; import { getLeakPeriod } from '../../../helpers/periods'; import { translate, getLocalizedMetricDomain } from '../../../helpers/l10n'; diff --git a/server/sonar-web/src/main/js/apps/component-measures/home/HomeMeasuresList.js b/server/sonar-web/src/main/js/apps/component-measures/home/HomeMeasuresList.js index ce240293f58..c6335fbbf83 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/home/HomeMeasuresList.js +++ b/server/sonar-web/src/main/js/apps/component-measures/home/HomeMeasuresList.js @@ -20,7 +20,6 @@ import React from 'react'; import partition from 'lodash/partition'; import sortBy from 'lodash/sortBy'; - import MeasuresList from './MeasuresList'; import { domains } from '../config/domains'; import { getLocalizedMetricName } from '../../../helpers/l10n'; diff --git a/server/sonar-web/src/main/js/apps/component-measures/home/MeasureListValue.js b/server/sonar-web/src/main/js/apps/component-measures/home/MeasureListValue.js index b7ef268f81c..a6d9767e923 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/home/MeasureListValue.js +++ b/server/sonar-web/src/main/js/apps/component-measures/home/MeasureListValue.js @@ -18,7 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; - import Measure from '../components/Measure'; import { isDiffMetric } from '../utils'; diff --git a/server/sonar-web/src/main/js/apps/component-measures/home/MeasuresList.js b/server/sonar-web/src/main/js/apps/component-measures/home/MeasuresList.js index 42d3f46e94f..5186914c1b5 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/home/MeasuresList.js +++ b/server/sonar-web/src/main/js/apps/component-measures/home/MeasuresList.js @@ -19,7 +19,6 @@ */ import React from 'react'; import { Link } from 'react-router'; - import MeasureListValue from './MeasureListValue'; import { getLocalizedMetricName } from '../../../helpers/l10n'; diff --git a/server/sonar-web/src/main/js/apps/component-measures/home/reducer.js b/server/sonar-web/src/main/js/apps/component-measures/home/reducer.js index 1771e6a68bd..99b9bdc82bb 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/home/reducer.js +++ b/server/sonar-web/src/main/js/apps/component-measures/home/reducer.js @@ -21,7 +21,6 @@ import groupBy from 'lodash/groupBy'; import partition from 'lodash/partition'; import sortBy from 'lodash/sortBy'; import toPairs from 'lodash/toPairs'; - import { RECEIVE_MEASURES } from './actions'; import { getLocalizedMetricName } from '../../../helpers/l10n'; diff --git a/server/sonar-web/src/main/js/apps/component-measures/store/rootReducer.js b/server/sonar-web/src/main/js/apps/component-measures/store/rootReducer.js index f57fef25a4a..ff1c9c75895 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/store/rootReducer.js +++ b/server/sonar-web/src/main/js/apps/component-measures/store/rootReducer.js @@ -18,7 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { combineReducers } from 'redux'; - import appReducer from './../app/reducer'; import statusReducer from './statusReducer'; import homeReducer from '../home/reducer'; diff --git a/server/sonar-web/src/main/js/apps/component-measures/store/treeViewActions.js b/server/sonar-web/src/main/js/apps/component-measures/store/treeViewActions.js index 5697f7a2a79..2b4983ef65f 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/store/treeViewActions.js +++ b/server/sonar-web/src/main/js/apps/component-measures/store/treeViewActions.js @@ -18,7 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import initial from 'lodash/initial'; - import { getComponentTree } from '../../../api/components'; import { enhanceWithMeasure } from '../utils'; import { startFetching, stopFetching } from './statusActions'; diff --git a/server/sonar-web/src/main/js/apps/component-measures/store/treeViewReducer.js b/server/sonar-web/src/main/js/apps/component-measures/store/treeViewReducer.js index 99b6c0fc374..34346ee523c 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/store/treeViewReducer.js +++ b/server/sonar-web/src/main/js/apps/component-measures/store/treeViewReducer.js @@ -18,7 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import pick from 'lodash/pick'; - import { DISPLAY_HOME } from './../app/actions'; import { UPDATE_STORE, INIT } from './treeViewActions'; diff --git a/server/sonar-web/src/main/js/apps/custom-measures/create-view.js b/server/sonar-web/src/main/js/apps/custom-measures/create-view.js index d1dda2a31e8..7d33183eb47 100644 --- a/server/sonar-web/src/main/js/apps/custom-measures/create-view.js +++ b/server/sonar-web/src/main/js/apps/custom-measures/create-view.js @@ -36,10 +36,10 @@ export default FormView.extend({ // do not show global error 400: null } - }).done(function () { + }).done(() => { that.collection.refresh(); that.destroy(); - }).fail(function (jqXHR) { + }).fail(jqXHR => { that.enableForm(); that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings); }); diff --git a/server/sonar-web/src/main/js/apps/custom-measures/custom-measures.js b/server/sonar-web/src/main/js/apps/custom-measures/custom-measures.js index eb64353b809..abbe306371f 100644 --- a/server/sonar-web/src/main/js/apps/custom-measures/custom-measures.js +++ b/server/sonar-web/src/main/js/apps/custom-measures/custom-measures.js @@ -60,9 +60,7 @@ export default Backbone.Collection.extend({ }, getTakenMetrics () { - const metrics = this.map(function (model) { - return model.get('metric').id; - }); + const metrics = this.map(model => model.get('metric').id); return _.uniq(metrics); } diff --git a/server/sonar-web/src/main/js/apps/custom-measures/delete-view.js b/server/sonar-web/src/main/js/apps/custom-measures/delete-view.js index 4e86d48df91..f0e4f7fabae 100644 --- a/server/sonar-web/src/main/js/apps/custom-measures/delete-view.js +++ b/server/sonar-web/src/main/js/apps/custom-measures/delete-view.js @@ -37,10 +37,10 @@ export default ModalForm.extend({ // do not show global error 400: null } - }).done(function () { + }).done(() => { collection.refresh(); that.destroy(); - }).fail(function (jqXHR) { + }).fail(jqXHR => { that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings); }); } diff --git a/server/sonar-web/src/main/js/apps/custom-measures/form-view.js b/server/sonar-web/src/main/js/apps/custom-measures/form-view.js index c25c9470ef1..5ed6696cdab 100644 --- a/server/sonar-web/src/main/js/apps/custom-measures/form-view.js +++ b/server/sonar-web/src/main/js/apps/custom-measures/form-view.js @@ -52,9 +52,7 @@ export default ModalForm.extend({ getAvailableMetrics () { const takenMetrics = this.collection.getTakenMetrics(); - return this.metrics.toJSON().filter(function (metric) { - return takenMetrics.indexOf(metric.id) === -1; - }); + return this.metrics.toJSON().filter(metric => takenMetrics.indexOf(metric.id) === -1); }, serializeData () { diff --git a/server/sonar-web/src/main/js/apps/custom-measures/init.js b/server/sonar-web/src/main/js/apps/custom-measures/init.js index caf512737a0..10912adbe7a 100644 --- a/server/sonar-web/src/main/js/apps/custom-measures/init.js +++ b/server/sonar-web/src/main/js/apps/custom-measures/init.js @@ -58,7 +58,7 @@ const init = function (el, component) { this.customMeasures.fetch(); }; -App.on('start', function (options) { +App.on('start', options => { init.call(App, options.el, options.component); }); diff --git a/server/sonar-web/src/main/js/apps/custom-measures/update-view.js b/server/sonar-web/src/main/js/apps/custom-measures/update-view.js index e3de7acde10..ef5e3dc7d12 100644 --- a/server/sonar-web/src/main/js/apps/custom-measures/update-view.js +++ b/server/sonar-web/src/main/js/apps/custom-measures/update-view.js @@ -33,10 +33,10 @@ export default FormView.extend({ // do not show global error 400: null } - }).done(function () { + }).done(() => { that.collection.refresh(); that.destroy(); - }).fail(function (jqXHR) { + }).fail(jqXHR => { that.enableForm(); that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings); }); diff --git a/server/sonar-web/src/main/js/apps/groups/create-view.js b/server/sonar-web/src/main/js/apps/groups/create-view.js index f39b361be58..55dbef7c44d 100644 --- a/server/sonar-web/src/main/js/apps/groups/create-view.js +++ b/server/sonar-web/src/main/js/apps/groups/create-view.js @@ -34,10 +34,10 @@ export default FormView.extend({ // do not show global error 400: null } - }).done(function () { + }).done(() => { that.collection.refresh(); that.destroy(); - }).fail(function (jqXHR) { + }).fail(jqXHR => { that.enableForm(); that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings); }); diff --git a/server/sonar-web/src/main/js/apps/groups/delete-view.js b/server/sonar-web/src/main/js/apps/groups/delete-view.js index df29da5b6c1..9ac1c4d0b27 100644 --- a/server/sonar-web/src/main/js/apps/groups/delete-view.js +++ b/server/sonar-web/src/main/js/apps/groups/delete-view.js @@ -37,10 +37,10 @@ export default ModalForm.extend({ // do not show global error 400: null } - }).done(function () { + }).done(() => { collection.total--; that.destroy(); - }).fail(function (jqXHR) { + }).fail(jqXHR => { that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings); }); }, diff --git a/server/sonar-web/src/main/js/apps/groups/init.js b/server/sonar-web/src/main/js/apps/groups/init.js index 4ec6a7e95e6..6c62483d4e3 100644 --- a/server/sonar-web/src/main/js/apps/groups/init.js +++ b/server/sonar-web/src/main/js/apps/groups/init.js @@ -54,7 +54,7 @@ const init = function (el) { this.groups.fetch(); }; -App.on('start', function (el) { +App.on('start', el => { init.call(App, el); }); diff --git a/server/sonar-web/src/main/js/apps/groups/update-view.js b/server/sonar-web/src/main/js/apps/groups/update-view.js index da2a52615ed..a48462193b1 100644 --- a/server/sonar-web/src/main/js/apps/groups/update-view.js +++ b/server/sonar-web/src/main/js/apps/groups/update-view.js @@ -33,10 +33,10 @@ export default FormView.extend({ // do not show global error 400: null } - }).done(function () { + }).done(() => { that.collection.refresh(); that.destroy(); - }).fail(function (jqXHR) { + }).fail(jqXHR => { that.enableForm(); that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings); }); diff --git a/server/sonar-web/src/main/js/apps/issues/component-viewer/main.js b/server/sonar-web/src/main/js/apps/issues/component-viewer/main.js index 9b8e8ad6974..aa8835e3137 100644 --- a/server/sonar-web/src/main/js/apps/issues/component-viewer/main.js +++ b/server/sonar-web/src/main/js/apps/issues/component-viewer/main.js @@ -53,36 +53,24 @@ export default SourceViewer.extend({ } return selectedIssueView.find('.js-issue-' + action).click(); }; - key('up', 'componentViewer', function () { + key('up', 'componentViewer', () => { that.options.app.controller.selectPrev(); return false; }); - key('down', 'componentViewer', function () { + key('down', 'componentViewer', () => { that.options.app.controller.selectNext(); return false; }); - key('left,backspace', 'componentViewer', function () { + key('left,backspace', 'componentViewer', () => { that.options.app.controller.closeComponentViewer(); return false; }); - key('f', 'componentViewer', function () { - return doAction('transition'); - }); - key('a', 'componentViewer', function () { - return doAction('assign'); - }); - key('m', 'componentViewer', function () { - return doAction('assign-to-me'); - }); - key('p', 'componentViewer', function () { - return doAction('plan'); - }); - key('i', 'componentViewer', function () { - return doAction('set-severity'); - }); - return key('c', 'componentViewer', function () { - return doAction('comment'); - }); + key('f', 'componentViewer', () => doAction('transition')); + key('a', 'componentViewer', () => doAction('assign')); + key('m', 'componentViewer', () => doAction('assign-to-me')); + key('p', 'componentViewer', () => doAction('plan')); + key('i', 'componentViewer', () => doAction('set-severity')); + key('c', 'componentViewer', () => doAction('comment')); }, unbindShortcuts () { @@ -126,9 +114,7 @@ export default SourceViewer.extend({ selectIssue (e) { const key = $(e.currentTarget).data('issue-key'); - const issue = this.issues.find(function (model) { - return model.get('key') === key; - }); + const issue = this.issues.find(model => model.get('key') === key); const index = this.options.app.list.indexOf(issue); return this.options.app.state.set({ selectedIndex: index }); }, @@ -170,9 +156,7 @@ export default SourceViewer.extend({ if ((this.baseIssue != null) && this.baseIssue.has('index')) { index = Math.max(index, this.baseIssue.get('index')); } - return issues.filter(function (issue) { - return Math.abs(issue.get('index') - index) <= that.ISSUES_LIMIT / 2; - }); + return issues.filter(issue => Math.abs(issue.get('index') - index) <= that.ISSUES_LIMIT / 2); }, requestIssues () { @@ -183,10 +167,8 @@ export default SourceViewer.extend({ } else { r = $.Deferred().resolve().promise(); } - return r.done(function () { - that.issues.reset(that.options.app.list.filter(function (issue) { - return issue.get('component') === that.model.key(); - })); + return r.done(() => { + that.issues.reset(that.options.app.list.filter(issue => issue.get('component') === that.model.key())); that.issues.reset(that.limitIssues(that.issues)); return that.addIssuesPerLineMeta(that.issues); }); diff --git a/server/sonar-web/src/main/js/apps/issues/controller.js b/server/sonar-web/src/main/js/apps/issues/controller.js index 619bcacdb23..ff55d711134 100644 --- a/server/sonar-web/src/main/js/apps/issues/controller.js +++ b/server/sonar-web/src/main/js/apps/issues/controller.js @@ -53,7 +53,7 @@ export default Controller.extend({ if (this.options.app.state.get('isContext')) { _.extend(data, this.options.app.state.get('contextQuery')); } - return $.get(window.baseUrl + '/api/issues/search', data).done(function (r) { + return $.get(window.baseUrl + '/api/issues/search', data).done(r => { const issues = that.options.app.list.parseIssues(r); if (firstPage) { that.options.app.list.reset(issues); @@ -61,7 +61,7 @@ export default Controller.extend({ that.options.app.list.add(issues); } that.options.app.list.setIndex(); - FACET_DATA_FIELDS.forEach(function (field) { + FACET_DATA_FIELDS.forEach(field => { that.options.app.facets[field] = r[field]; }); that.options.app.facets.reset(that._allFacets()); @@ -107,8 +107,8 @@ export default Controller.extend({ if (this.options.app.state.get('isContext')) { _.extend(data, this.options.app.state.get('contextQuery')); } - return $.get(window.baseUrl + '/api/issues/search', data, function (r) { - FACET_DATA_FIELDS.forEach(function (field) { + return $.get(window.baseUrl + '/api/issues/search', data, r => { + FACET_DATA_FIELDS.forEach(field => { that.options.app.facets[field] = that._mergeCollections(that.options.app.facets[field], r[field]); }); const facetData = _.findWhere(r.facets, { property: id }); @@ -146,9 +146,7 @@ export default Controller.extend({ _.extend(filter, { assignees: '__me__' }); } const route = []; - _.map(filter, function (value, property) { - return route.push(`${property}=${encodeURIComponent(value)}`); - }); + _.map(filter, (value, property) => route.push(`${property}=${encodeURIComponent(value)}`)); return route.join(separator); }, diff --git a/server/sonar-web/src/main/js/apps/issues/facets/assignee-facet.js b/server/sonar-web/src/main/js/apps/issues/facets/assignee-facet.js index 535eceeca6c..6a90690d762 100644 --- a/server/sonar-web/src/main/js/apps/issues/facets/assignee-facet.js +++ b/server/sonar-web/src/main/js/apps/issues/facets/assignee-facet.js @@ -75,7 +75,7 @@ export default CustomValuesFacet.extend({ getValuesWithLabels () { const values = this.model.getValues(); const users = this.options.app.facets.users; - values.forEach(function (v) { + values.forEach(v => { const login = v.val; let name = ''; if (login) { @@ -111,9 +111,7 @@ export default CustomValuesFacet.extend({ }, sortValues (values) { - return _.sortBy(values, function (v) { - return v.val === '' ? -999999 : -v.count; - }); + return _.sortBy(values, v => v.val === '' ? -999999 : -v.count); }, serializeData () { diff --git a/server/sonar-web/src/main/js/apps/issues/facets/author-facet.js b/server/sonar-web/src/main/js/apps/issues/facets/author-facet.js index bdb039f805a..e8a3b60fad4 100644 --- a/server/sonar-web/src/main/js/apps/issues/facets/author-facet.js +++ b/server/sonar-web/src/main/js/apps/issues/facets/author-facet.js @@ -49,7 +49,7 @@ export default CustomValuesFacet.extend({ results (data) { return { more: false, - results: data.authors.map(function (author) { + results: data.authors.map(author => { return { id: author, text: author }; }) }; diff --git a/server/sonar-web/src/main/js/apps/issues/facets/creation-date-facet.js b/server/sonar-web/src/main/js/apps/issues/facets/creation-date-facet.js index 3a5a11fa616..404f558f9d2 100644 --- a/server/sonar-web/src/main/js/apps/issues/facets/creation-date-facet.js +++ b/server/sonar-web/src/main/js/apps/issues/facets/creation-date-facet.js @@ -22,7 +22,7 @@ import _ from 'underscore'; import moment from 'moment'; import BaseFacet from './base-facet'; import Template from '../templates/facets/issues-creation-date-facet.hbs'; -import '../../../components/widgets/barchart.js'; +import '../../../components/widgets/barchart'; import { formatMeasure } from '../../../helpers/measures'; export default BaseFacet.extend({ @@ -52,7 +52,7 @@ export default BaseFacet.extend({ }); const props = ['createdAfter', 'createdBefore', 'createdAt']; const query = this.options.app.state.get('query'); - props.forEach(function (prop) { + props.forEach(prop => { const value = query[prop]; if (value != null) { return that.$(`input[name=${prop}]`).val(value); @@ -62,13 +62,13 @@ export default BaseFacet.extend({ if (!(_.isArray(values) && values.length > 0)) { let date = moment(); values = []; - _.times(10, function () { + _.times(10, () => { values.push({ count: 0, val: date.toDate().toString() }); date = date.subtract(1, 'days'); }); values.reverse(); } - values = values.map(function (v) { + values = values.map(v => { const format = that.options.app.state.getFacetMode() === 'count' ? 'SHORT_INT' : 'SHORT_WORK_DUR'; const text = formatMeasure(v.count, format); return _.extend(v, { text }); diff --git a/server/sonar-web/src/main/js/apps/issues/facets/file-facet.js b/server/sonar-web/src/main/js/apps/issues/facets/file-facet.js index 134be19e085..42b0370e7bb 100644 --- a/server/sonar-web/src/main/js/apps/issues/facets/file-facet.js +++ b/server/sonar-web/src/main/js/apps/issues/facets/file-facet.js @@ -36,7 +36,7 @@ export default BaseFacet.extend({ getValuesWithLabels () { const values = this.model.getValues(); const source = this.options.app.facets.components; - values.forEach(function (v) { + values.forEach(v => { const key = v.val; let label = null; if (key) { diff --git a/server/sonar-web/src/main/js/apps/issues/facets/language-facet.js b/server/sonar-web/src/main/js/apps/issues/facets/language-facet.js index ab9b6671c0e..7fb91eca821 100644 --- a/server/sonar-web/src/main/js/apps/issues/facets/language-facet.js +++ b/server/sonar-web/src/main/js/apps/issues/facets/language-facet.js @@ -50,7 +50,7 @@ export default CustomValuesFacet.extend({ results (data) { return { more: false, - results: data.languages.map(function (lang) { + results: data.languages.map(lang => { return { id: lang.key, text: lang.name }; }) }; @@ -62,7 +62,7 @@ export default CustomValuesFacet.extend({ getValuesWithLabels () { const values = this.model.getValues(); const source = this.options.app.facets.languages; - values.forEach(function (v) { + values.forEach(v => { const key = v.val; let label = null; if (key) { diff --git a/server/sonar-web/src/main/js/apps/issues/facets/module-facet.js b/server/sonar-web/src/main/js/apps/issues/facets/module-facet.js index 937f4815bf9..e3bb21fde2b 100644 --- a/server/sonar-web/src/main/js/apps/issues/facets/module-facet.js +++ b/server/sonar-web/src/main/js/apps/issues/facets/module-facet.js @@ -24,7 +24,7 @@ export default BaseFacet.extend({ getValuesWithLabels () { const values = this.model.getValues(); const components = this.options.app.facets.components; - values.forEach(function (v) { + values.forEach(v => { const uuid = v.val; let label = uuid; if (uuid) { diff --git a/server/sonar-web/src/main/js/apps/issues/facets/project-facet.js b/server/sonar-web/src/main/js/apps/issues/facets/project-facet.js index bc6e193242c..a575924d5f3 100644 --- a/server/sonar-web/src/main/js/apps/issues/facets/project-facet.js +++ b/server/sonar-web/src/main/js/apps/issues/facets/project-facet.js @@ -71,7 +71,7 @@ export default CustomValuesFacet.extend({ results (data) { return { more: data.p * data.ps < data.total, - results: data.components.map(function (c) { + results: data.components.map(c => { return { id: c.uuid, text: c.name }; }) }; @@ -83,7 +83,7 @@ export default CustomValuesFacet.extend({ getValuesWithLabels () { const values = this.model.getValues(); const projects = this.options.app.facets.components; - values.forEach(function (v) { + values.forEach(v => { const uuid = v.val; let label = ''; if (uuid) { diff --git a/server/sonar-web/src/main/js/apps/issues/facets/reporter-facet.js b/server/sonar-web/src/main/js/apps/issues/facets/reporter-facet.js index 0c299b952ad..4b7bee47e11 100644 --- a/server/sonar-web/src/main/js/apps/issues/facets/reporter-facet.js +++ b/server/sonar-web/src/main/js/apps/issues/facets/reporter-facet.js @@ -39,7 +39,7 @@ export default CustomValuesFacet.extend({ getValuesWithLabels () { const values = this.model.getValues(); const source = this.options.app.facets.users; - values.forEach(function (v) { + values.forEach(v => { const key = v.val; let label = null; if (key) { diff --git a/server/sonar-web/src/main/js/apps/issues/facets/resolution-facet.js b/server/sonar-web/src/main/js/apps/issues/facets/resolution-facet.js index 43c2793e247..3eaa49156f3 100644 --- a/server/sonar-web/src/main/js/apps/issues/facets/resolution-facet.js +++ b/server/sonar-web/src/main/js/apps/issues/facets/resolution-facet.js @@ -60,9 +60,7 @@ export default BaseFacet.extend({ sortValues (values) { const order = ['', 'FIXED', 'FALSE-POSITIVE', 'WONTFIX', 'REMOVED']; - return _.sortBy(values, function (v) { - return order.indexOf(v.val); - }); + return _.sortBy(values, v => order.indexOf(v.val)); } }); diff --git a/server/sonar-web/src/main/js/apps/issues/facets/rule-facet.js b/server/sonar-web/src/main/js/apps/issues/facets/rule-facet.js index 343fa489e1c..6675a0c0d3b 100644 --- a/server/sonar-web/src/main/js/apps/issues/facets/rule-facet.js +++ b/server/sonar-web/src/main/js/apps/issues/facets/rule-facet.js @@ -49,7 +49,7 @@ export default CustomValuesFacet.extend({ return { q: term, p: page }; }, results (data) { - const results = data.rules.map(function (rule) { + const results = data.rules.map(rule => { const lang = rule.langName || translate('manual'); return { id: rule.key, @@ -68,7 +68,7 @@ export default CustomValuesFacet.extend({ getValuesWithLabels () { const values = this.model.getValues(); const rules = this.options.app.facets.rules; - values.forEach(function (v) { + values.forEach(v => { const key = v.val; let label = ''; let extra = ''; diff --git a/server/sonar-web/src/main/js/apps/issues/facets/severity-facet.js b/server/sonar-web/src/main/js/apps/issues/facets/severity-facet.js index baed7a76c99..5b3bafea666 100644 --- a/server/sonar-web/src/main/js/apps/issues/facets/severity-facet.js +++ b/server/sonar-web/src/main/js/apps/issues/facets/severity-facet.js @@ -26,9 +26,7 @@ export default BaseFacet.extend({ sortValues (values) { const order = ['BLOCKER', 'MINOR', 'CRITICAL', 'INFO', 'MAJOR']; - return _.sortBy(values, function (v) { - return order.indexOf(v.val); - }); + return _.sortBy(values, v => order.indexOf(v.val)); } }); diff --git a/server/sonar-web/src/main/js/apps/issues/facets/status-facet.js b/server/sonar-web/src/main/js/apps/issues/facets/status-facet.js index a0bfd985016..ed7500fbd20 100644 --- a/server/sonar-web/src/main/js/apps/issues/facets/status-facet.js +++ b/server/sonar-web/src/main/js/apps/issues/facets/status-facet.js @@ -26,9 +26,7 @@ export default BaseFacet.extend({ sortValues (values) { const order = ['OPEN', 'RESOLVED', 'REOPENED', 'CLOSED', 'CONFIRMED']; - return _.sortBy(values, function (v) { - return order.indexOf(v.val); - }); + return _.sortBy(values, v => order.indexOf(v.val)); } }); diff --git a/server/sonar-web/src/main/js/apps/issues/facets/tag-facet.js b/server/sonar-web/src/main/js/apps/issues/facets/tag-facet.js index 6bf0055b685..2ab8c47190e 100644 --- a/server/sonar-web/src/main/js/apps/issues/facets/tag-facet.js +++ b/server/sonar-web/src/main/js/apps/issues/facets/tag-facet.js @@ -46,7 +46,7 @@ export default CustomValuesFacet.extend({ return { q: term, ps: 10 }; }, results (data) { - const results = data.tags.map(function (tag) { + const results = data.tags.map(tag => { return { id: tag, text: tag }; }); return { more: false, results }; @@ -57,7 +57,7 @@ export default CustomValuesFacet.extend({ getValuesWithLabels () { const values = this.model.getValues(); - values.forEach(function (v) { + values.forEach(v => { v.label = v.val; v.extra = ''; }); diff --git a/server/sonar-web/src/main/js/apps/issues/facets/type-facet.js b/server/sonar-web/src/main/js/apps/issues/facets/type-facet.js index 2790b3a36a4..73bc116813a 100644 --- a/server/sonar-web/src/main/js/apps/issues/facets/type-facet.js +++ b/server/sonar-web/src/main/js/apps/issues/facets/type-facet.js @@ -26,9 +26,7 @@ export default BaseFacet.extend({ sortValues (values) { const order = ['BUG', 'VULNERABILITY', 'CODE_SMELL']; - return _.sortBy(values, function (v) { - return order.indexOf(v.val); - }); + return _.sortBy(values, v => order.indexOf(v.val)); } }); diff --git a/server/sonar-web/src/main/js/apps/issues/init.js b/server/sonar-web/src/main/js/apps/issues/init.js index 158189b2686..9bdbde6d8e9 100644 --- a/server/sonar-web/src/main/js/apps/issues/init.js +++ b/server/sonar-web/src/main/js/apps/issues/init.js @@ -72,7 +72,7 @@ const init = function ({ el, user }) { Backbone.history.start(); }; -App.on('start', function (el) { +App.on('start', el => { init.call(App, el); }); diff --git a/server/sonar-web/src/main/js/apps/issues/models/issue.js b/server/sonar-web/src/main/js/apps/issues/models/issue.js index 3ac85533697..6c1f425a540 100644 --- a/server/sonar-web/src/main/js/apps/issues/models/issue.js +++ b/server/sonar-web/src/main/js/apps/issues/models/issue.js @@ -22,9 +22,9 @@ import Issue from '../../../components/issue/models/issue'; export default Issue.extend({ reset (attrs, options) { const keepFields = ['index', 'selected', 'comments']; - keepFields.forEach(function (field) { + keepFields.forEach(field => { attrs[field] = this.get(field); - }.bind(this)); + }); return Issue.prototype.reset.call(this, attrs, options); } }); diff --git a/server/sonar-web/src/main/js/apps/issues/models/issues.js b/server/sonar-web/src/main/js/apps/issues/models/issues.js index adb43844c4d..12183136153 100644 --- a/server/sonar-web/src/main/js/apps/issues/models/issues.js +++ b/server/sonar-web/src/main/js/apps/issues/models/issues.js @@ -31,11 +31,9 @@ export default Backbone.Collection.extend({ _injectRelational (issue, source, baseField, lookupField) { const baseValue = issue[baseField]; if (baseValue != null && _.size(source)) { - const lookupValue = _.find(source, function (candidate) { - return candidate[lookupField] === baseValue; - }); + const lookupValue = _.find(source, candidate => candidate[lookupField] === baseValue); if (lookupValue != null) { - Object.keys(lookupValue).forEach(function (key) { + Object.keys(lookupValue).forEach(key => { const newKey = baseField + key.charAt(0).toUpperCase() + key.slice(1); issue[newKey] = lookupValue[key]; }); @@ -47,7 +45,7 @@ export default Backbone.Collection.extend({ _injectCommentsRelational (issue, users) { if (issue.comments) { const that = this; - const newComments = issue.comments.map(function (comment) { + const newComments = issue.comments.map(comment => { let newComment = _.extend({}, comment, { author: comment.login }); delete newComment.login; newComment = that._injectRelational(newComment, users, 'author', 'login'); @@ -81,7 +79,7 @@ export default Backbone.Collection.extend({ parseIssues (r) { const that = this; - return r.issues.map(function (issue, index) { + return r.issues.map((issue, index) => { _.extend(issue, { index }); issue = that._injectRelational(issue, r.components, 'component', 'key'); issue = that._injectRelational(issue, r.components, 'project', 'key'); @@ -96,14 +94,12 @@ export default Backbone.Collection.extend({ }, setIndex () { - return this.forEach(function (issue, index) { - return issue.set({ index }); - }); + return this.forEach((issue, index) => issue.set({ index })); }, selectByKeys (keys) { const that = this; - keys.forEach(function (key) { + keys.forEach(key => { const issue = that.get(key); if (issue) { issue.set({ selected: true }); diff --git a/server/sonar-web/src/main/js/apps/issues/workspace-header-view.js b/server/sonar-web/src/main/js/apps/issues/workspace-header-view.js index a618e107325..9035dfec2ba 100644 --- a/server/sonar-web/src/main/js/apps/issues/workspace-header-view.js +++ b/server/sonar-web/src/main/js/apps/issues/workspace-header-view.js @@ -60,7 +60,7 @@ export default WorkspaceHeaderView.extend({ $('#modal').dialog('close'); const selectedIndex = this.options.app.state.get('selectedIndex'); const selectedKeys = _.pluck(this.options.app.list.where({ selected: true }), 'id'); - this.options.app.controller.fetchList().done(function () { + this.options.app.controller.fetchList().done(() => { that.options.app.state.set({ selectedIndex }); that.options.app.list.selectByKeys(selectedKeys); }); @@ -80,7 +80,7 @@ export default WorkspaceHeaderView.extend({ }, selectNone () { - this.options.app.list.where({ selected: true }).forEach(function (issue) { + this.options.app.list.where({ selected: true }).forEach(issue => { issue.set({ selected: false }); }); this._suppressUpdate = false; @@ -88,7 +88,7 @@ export default WorkspaceHeaderView.extend({ }, selectAll () { - this.options.app.list.forEach(function (issue) { + this.options.app.list.forEach(issue => { issue.set({ selected: true }); }); this._suppressUpdate = false; diff --git a/server/sonar-web/src/main/js/apps/issues/workspace-list-item-view.js b/server/sonar-web/src/main/js/apps/issues/workspace-list-item-view.js index eef64f22edd..d99c5ef07de 100644 --- a/server/sonar-web/src/main/js/apps/issues/workspace-list-item-view.js +++ b/server/sonar-web/src/main/js/apps/issues/workspace-list-item-view.js @@ -72,14 +72,14 @@ export default IssueView.extend({ bottomRight: true, model: this.model }); - this.popup.on('select', function (property, value) { + this.popup.on('select', (property, value) => { const obj = {}; obj[property] = '' + value; - SHOULD_NULL.any.forEach(function (p) { + SHOULD_NULL.any.forEach(p => { obj[p] = null; }); if (SHOULD_NULL[property] != null) { - SHOULD_NULL[property].forEach(function (p) { + SHOULD_NULL[property].forEach(p => { obj[p] = null; }); } @@ -127,9 +127,7 @@ export default IssueView.extend({ index, selected }, { silent: true }); - return this.model.fetch(options).done(function () { - return that.trigger('reset'); - }); + return this.model.fetch(options).done(() => that.trigger('reset')); }, openComponentViewer () { diff --git a/server/sonar-web/src/main/js/apps/issues/workspace-list-view.js b/server/sonar-web/src/main/js/apps/issues/workspace-list-view.js index 19fbd97d5e7..453e6a5c5f0 100644 --- a/server/sonar-web/src/main/js/apps/issues/workspace-list-view.js +++ b/server/sonar-web/src/main/js/apps/issues/workspace-list-view.js @@ -45,37 +45,23 @@ export default WorkspaceListView.extend({ selectedIssueView.$('.js-issue-' + action).click(); }; WorkspaceListView.prototype.bindShortcuts.apply(this, arguments); - key('right', 'list', function () { + key('right', 'list', () => { const selectedIssue = that.collection.at(that.options.app.state.get('selectedIndex')); that.options.app.controller.showComponentViewer(selectedIssue); return false; }); - key('space', 'list', function () { + key('space', 'list', () => { const selectedIssue = that.collection.at(that.options.app.state.get('selectedIndex')); selectedIssue.set({ selected: !selectedIssue.get('selected') }); return false; }); - key('f', 'list', function () { - return doAction('transition'); - }); - key('a', 'list', function () { - return doAction('assign'); - }); - key('m', 'list', function () { - return doAction('assign-to-me'); - }); - key('p', 'list', function () { - return doAction('plan'); - }); - key('i', 'list', function () { - return doAction('set-severity'); - }); - key('c', 'list', function () { - return doAction('comment'); - }); - key('t', 'list', function () { - return doAction('edit-tags'); - }); + key('f', 'list', () => doAction('transition')); + key('a', 'list', () => doAction('assign')); + key('m', 'list', () => doAction('assign-to-me')); + key('p', 'list', () => doAction('plan')); + key('i', 'list', () => doAction('set-severity')); + key('c', 'list', () => doAction('comment')); + key('t', 'list', () => doAction('edit-tags')); }, unbindShortcuts () { diff --git a/server/sonar-web/src/main/js/apps/maintenance/init.js b/server/sonar-web/src/main/js/apps/maintenance/init.js index 3b812525570..8f964b5b33e 100644 --- a/server/sonar-web/src/main/js/apps/maintenance/init.js +++ b/server/sonar-web/src/main/js/apps/maintenance/init.js @@ -24,7 +24,7 @@ import MainView from './main-view'; const App = new Marionette.Application(); -App.on('start', function (options) { +App.on('start', options => { const viewOptions = _.extend(options, { model: new Backbone.Model() }); diff --git a/server/sonar-web/src/main/js/apps/maintenance/main-view.js b/server/sonar-web/src/main/js/apps/maintenance/main-view.js index 751578de956..123a98416a2 100644 --- a/server/sonar-web/src/main/js/apps/maintenance/main-view.js +++ b/server/sonar-web/src/main/js/apps/maintenance/main-view.js @@ -36,14 +36,14 @@ export default Marionette.ItemView.extend({ type: 'GET', url: window.baseUrl + '/api/system/' + (this.options.setup ? 'db_migration_status' : 'status') }; - this.pollingInternal = setInterval(function () { + this.pollingInternal = setInterval(() => { that.refresh(); }, 5000); }, refresh () { const that = this; - return Backbone.ajax(this.requestOptions).done(function (r) { + return Backbone.ajax(this.requestOptions).done(r => { that.model.set(r); that.render(); if (that.model.get('status') === 'UP' || that.model.get('state') === 'NO_MIGRATION') { @@ -64,7 +64,7 @@ export default Marionette.ItemView.extend({ Backbone.ajax({ url: window.baseUrl + '/api/system/migrate_db', type: 'POST' - }).done(function (r) { + }).done(r => { that.model.set(r); that.render(); }); @@ -75,7 +75,7 @@ export default Marionette.ItemView.extend({ }, goHome () { - setInterval(function () { + setInterval(() => { window.location = window.baseUrl + '/'; }, 2500); }, diff --git a/server/sonar-web/src/main/js/apps/metrics/create-view.js b/server/sonar-web/src/main/js/apps/metrics/create-view.js index d8a73fc9d62..1bd036a8e63 100644 --- a/server/sonar-web/src/main/js/apps/metrics/create-view.js +++ b/server/sonar-web/src/main/js/apps/metrics/create-view.js @@ -37,13 +37,13 @@ export default FormView.extend({ // do not show global error 400: null } - }).done(function () { + }).done(() => { that.collection.refresh(); if (that.options.domains.indexOf(metric.get('domain')) === -1) { that.options.domains.push(metric.get('domain')); } that.destroy(); - }).fail(function (jqXHR) { + }).fail(jqXHR => { that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings); that.enableForm(); }); diff --git a/server/sonar-web/src/main/js/apps/metrics/delete-view.js b/server/sonar-web/src/main/js/apps/metrics/delete-view.js index a63999b2e6a..f65f365462d 100644 --- a/server/sonar-web/src/main/js/apps/metrics/delete-view.js +++ b/server/sonar-web/src/main/js/apps/metrics/delete-view.js @@ -37,10 +37,10 @@ export default ModalForm.extend({ // do not show global error 400: null } - }).done(function () { + }).done(() => { collection.refresh(); that.destroy(); - }).fail(function (jqXHR) { + }).fail(jqXHR => { that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings); }); } diff --git a/server/sonar-web/src/main/js/apps/metrics/form-view.js b/server/sonar-web/src/main/js/apps/metrics/form-view.js index 93690b03cbe..0bd6f64f5e8 100644 --- a/server/sonar-web/src/main/js/apps/metrics/form-view.js +++ b/server/sonar-web/src/main/js/apps/metrics/form-view.js @@ -40,10 +40,8 @@ export default ModalForm.extend({ callback({ id: value, text: value }); }, query (options) { - const items = that.options.domains.filter(function (d) { - return d.toLowerCase().indexOf(options.term.toLowerCase()) !== -1; - }); - const results = items.map(function (item) { + const items = that.options.domains.filter(d => d.toLowerCase().indexOf(options.term.toLowerCase()) !== -1); + const results = items.map(item => { return { id: item, text: item }; }); options.callback({ results, more: false }); diff --git a/server/sonar-web/src/main/js/apps/metrics/init.js b/server/sonar-web/src/main/js/apps/metrics/init.js index 06f12f34ff2..a9422dc979a 100644 --- a/server/sonar-web/src/main/js/apps/metrics/init.js +++ b/server/sonar-web/src/main/js/apps/metrics/init.js @@ -60,18 +60,18 @@ const init = function (el) { }; App.requestDomains = function () { - return $.get(window.baseUrl + '/api/metrics/domains').done(function (r) { + return $.get(window.baseUrl + '/api/metrics/domains').done(r => { App.domains = r.domains; }); }; App.requestTypes = function () { - return $.get(window.baseUrl + '/api/metrics/types').done(function (r) { + return $.get(window.baseUrl + '/api/metrics/types').done(r => { App.types = r.types; }); }; -App.on('start', function (el) { - $.when(App.requestDomains(), App.requestTypes()).done(function () { +App.on('start', el => { + $.when(App.requestDomains(), App.requestTypes()).done(() => { init.call(App, el); }); }); diff --git a/server/sonar-web/src/main/js/apps/metrics/update-view.js b/server/sonar-web/src/main/js/apps/metrics/update-view.js index b559f1dc05b..ac82cf0e5bd 100644 --- a/server/sonar-web/src/main/js/apps/metrics/update-view.js +++ b/server/sonar-web/src/main/js/apps/metrics/update-view.js @@ -36,10 +36,10 @@ export default FormView.extend({ // do not show global error 400: null } - }).done(function () { + }).done(() => { that.collection.refresh(); that.destroy(); - }).fail(function (jqXHR) { + }).fail(jqXHR => { that.enableForm(); that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings); }); diff --git a/server/sonar-web/src/main/js/apps/overview/components/EmptyOverview.js b/server/sonar-web/src/main/js/apps/overview/components/EmptyOverview.js index 5d88e24b8d0..ca39f9f430b 100644 --- a/server/sonar-web/src/main/js/apps/overview/components/EmptyOverview.js +++ b/server/sonar-web/src/main/js/apps/overview/components/EmptyOverview.js @@ -18,7 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; - import { translate } from '../../../helpers/l10n'; const EmptyOverview = ({ component }) => { diff --git a/server/sonar-web/src/main/js/apps/overview/components/LeakPeriodLegend.js b/server/sonar-web/src/main/js/apps/overview/components/LeakPeriodLegend.js index a2129c56b13..113568e1212 100644 --- a/server/sonar-web/src/main/js/apps/overview/components/LeakPeriodLegend.js +++ b/server/sonar-web/src/main/js/apps/overview/components/LeakPeriodLegend.js @@ -19,7 +19,6 @@ */ import React from 'react'; import moment from 'moment'; - import { getPeriodDate, getPeriodLabel } from '../../../helpers/periods'; import { translateWithParameters } from '../../../helpers/l10n'; diff --git a/server/sonar-web/src/main/js/apps/overview/components/Timeline.js b/server/sonar-web/src/main/js/apps/overview/components/Timeline.js index 90a9728f4ca..baa755bae0c 100644 --- a/server/sonar-web/src/main/js/apps/overview/components/Timeline.js +++ b/server/sonar-web/src/main/js/apps/overview/components/Timeline.js @@ -20,7 +20,6 @@ import d3 from 'd3'; import React from 'react'; import shallowCompare from 'react-addons-shallow-compare'; - import { LineChart } from '../../../components/charts/line-chart'; const HEIGHT = 80; diff --git a/server/sonar-web/src/main/js/apps/overview/events/AnalysesList.js b/server/sonar-web/src/main/js/apps/overview/events/AnalysesList.js index 842a9680310..1d285126b38 100644 --- a/server/sonar-web/src/main/js/apps/overview/events/AnalysesList.js +++ b/server/sonar-web/src/main/js/apps/overview/events/AnalysesList.js @@ -29,9 +29,9 @@ import { getAnalyses } from '../../../store/projectActivity/duck'; type Props = { analyses?: Array<*>, - project: string; - fetchRecentProjectActivity: (project: string) => Promise<*>; -} + project: string, + fetchRecentProjectActivity: (project: string) => Promise<*> +}; class AnalysesList extends React.Component { mounted: boolean; diff --git a/server/sonar-web/src/main/js/apps/overview/main/Coverage.js b/server/sonar-web/src/main/js/apps/overview/main/Coverage.js index bfa8c94a754..8c11d412ab2 100644 --- a/server/sonar-web/src/main/js/apps/overview/main/Coverage.js +++ b/server/sonar-web/src/main/js/apps/overview/main/Coverage.js @@ -18,7 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; - import enhance from './enhance'; import { DrilldownLink } from '../../../components/shared/drilldown-link'; import { getMetricName } from '../helpers/metrics'; diff --git a/server/sonar-web/src/main/js/apps/overview/meta/Meta.js b/server/sonar-web/src/main/js/apps/overview/meta/Meta.js index 26be7ed8ea2..61e26530eee 100644 --- a/server/sonar-web/src/main/js/apps/overview/meta/Meta.js +++ b/server/sonar-web/src/main/js/apps/overview/meta/Meta.js @@ -18,7 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; - import MetaKey from './MetaKey'; import MetaLinks from './MetaLinks'; import MetaQualityGate from './MetaQualityGate'; diff --git a/server/sonar-web/src/main/js/apps/overview/meta/MetaKey.js b/server/sonar-web/src/main/js/apps/overview/meta/MetaKey.js index cc1e7f91b70..3098f452ac8 100644 --- a/server/sonar-web/src/main/js/apps/overview/meta/MetaKey.js +++ b/server/sonar-web/src/main/js/apps/overview/meta/MetaKey.js @@ -18,7 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; - import { translate } from '../../../helpers/l10n'; const MetaKey = ({ component }) => { diff --git a/server/sonar-web/src/main/js/apps/overview/qualityGate/EmptyQualityGate.js b/server/sonar-web/src/main/js/apps/overview/qualityGate/EmptyQualityGate.js index 56e607c05cb..569be5500a6 100644 --- a/server/sonar-web/src/main/js/apps/overview/qualityGate/EmptyQualityGate.js +++ b/server/sonar-web/src/main/js/apps/overview/qualityGate/EmptyQualityGate.js @@ -18,7 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; - import { translate } from '../../../helpers/l10n'; const EmptyQualityGate = () => { diff --git a/server/sonar-web/src/main/js/apps/overview/qualityGate/QualityGate.js b/server/sonar-web/src/main/js/apps/overview/qualityGate/QualityGate.js index 219a58d0895..8c8b39565e4 100644 --- a/server/sonar-web/src/main/js/apps/overview/qualityGate/QualityGate.js +++ b/server/sonar-web/src/main/js/apps/overview/qualityGate/QualityGate.js @@ -18,7 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; - import QualityGateConditions from './QualityGateConditions'; import EmptyQualityGate from './EmptyQualityGate'; import { ComponentType, MeasuresListType, PeriodsListType } from '../propTypes'; diff --git a/server/sonar-web/src/main/js/apps/overview/qualityGate/QualityGateConditions.js b/server/sonar-web/src/main/js/apps/overview/qualityGate/QualityGateConditions.js index fab13539419..0c49b1a7dc2 100644 --- a/server/sonar-web/src/main/js/apps/overview/qualityGate/QualityGateConditions.js +++ b/server/sonar-web/src/main/js/apps/overview/qualityGate/QualityGateConditions.js @@ -20,7 +20,6 @@ import React from 'react'; import shallowCompare from 'react-addons-shallow-compare'; import sortBy from 'lodash/sortBy'; - import QualityGateCondition from './QualityGateCondition'; import { ComponentType, ConditionsListType } from '../propTypes'; import { getMeasuresAndMeta } from '../../../api/measures'; diff --git a/server/sonar-web/src/main/js/apps/overview/qualityGate/__tests__/QualityGateCondition-test.js b/server/sonar-web/src/main/js/apps/overview/qualityGate/__tests__/QualityGateCondition-test.js index 403719f4318..4c7ce5c7a3e 100644 --- a/server/sonar-web/src/main/js/apps/overview/qualityGate/__tests__/QualityGateCondition-test.js +++ b/server/sonar-web/src/main/js/apps/overview/qualityGate/__tests__/QualityGateCondition-test.js @@ -19,7 +19,6 @@ */ import React from 'react'; import { shallow } from 'enzyme'; - import QualityGateCondition from '../QualityGateCondition'; import { DrilldownLink } from '../../../../components/shared/drilldown-link'; diff --git a/server/sonar-web/src/main/js/apps/permission-templates/components/NameCell.js b/server/sonar-web/src/main/js/apps/permission-templates/components/NameCell.js index 0e9a8b2e6be..78d1ded45ab 100644 --- a/server/sonar-web/src/main/js/apps/permission-templates/components/NameCell.js +++ b/server/sonar-web/src/main/js/apps/permission-templates/components/NameCell.js @@ -24,8 +24,7 @@ import { PermissionTemplateType } from '../propTypes'; export default class NameCell extends React.Component { static propTypes = { - permissionTemplate: PermissionTemplateType.isRequired, - topQualifiers: React.PropTypes.array.isRequired + permissionTemplate: PermissionTemplateType.isRequired }; render () { diff --git a/server/sonar-web/src/main/js/apps/permission-templates/utils.js b/server/sonar-web/src/main/js/apps/permission-templates/utils.js index c475b39b3a7..73b25d629c7 100644 --- a/server/sonar-web/src/main/js/apps/permission-templates/utils.js +++ b/server/sonar-web/src/main/js/apps/permission-templates/utils.js @@ -38,7 +38,6 @@ export function sortPermissions (permissions) { */ export function mergePermissionsToTemplates (permissionTemplates, basePermissions) { return permissionTemplates.map(permissionTemplate => { - // it's important to keep the order of the permission template's permissions // the same as the order of base permissions const permissions = basePermissions.map(basePermission => { diff --git a/server/sonar-web/src/main/js/apps/permission-templates/views/CreateView.js b/server/sonar-web/src/main/js/apps/permission-templates/views/CreateView.js index bd6ad52409f..07026ad82a9 100644 --- a/server/sonar-web/src/main/js/apps/permission-templates/views/CreateView.js +++ b/server/sonar-web/src/main/js/apps/permission-templates/views/CreateView.js @@ -34,10 +34,10 @@ export default FormView.extend({ // do not show global error 400: null } - }).done(function (r) { + }).done(r => { that.trigger('done', r); that.destroy(); - }).fail(function (jqXHR) { + }).fail(jqXHR => { that.enableForm(); that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings); }); diff --git a/server/sonar-web/src/main/js/apps/permission-templates/views/UpdateView.js b/server/sonar-web/src/main/js/apps/permission-templates/views/UpdateView.js index 99acd983e5f..7105d2eafaa 100644 --- a/server/sonar-web/src/main/js/apps/permission-templates/views/UpdateView.js +++ b/server/sonar-web/src/main/js/apps/permission-templates/views/UpdateView.js @@ -35,10 +35,10 @@ export default FormView.extend({ // do not show global error 400: null } - }).done(function () { + }).done(() => { that.options.refresh(); that.destroy(); - }).fail(function (jqXHR) { + }).fail(jqXHR => { that.enableForm(); that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings); }); diff --git a/server/sonar-web/src/main/js/apps/permission-templates/views/UsersView.js b/server/sonar-web/src/main/js/apps/permission-templates/views/UsersView.js index a5a13a741b2..237d7b20dba 100644 --- a/server/sonar-web/src/main/js/apps/permission-templates/views/UsersView.js +++ b/server/sonar-web/src/main/js/apps/permission-templates/views/UsersView.js @@ -35,7 +35,7 @@ export default Modal.extend({ }; }, - onCheckboxChange() { + onCheckboxChange () { const checked = this.$('#grant-to-project-creators').is(':checked'); if (checked) { addProjectCreatorToTemplate( diff --git a/server/sonar-web/src/main/js/apps/permissions/global/components/PageHeader.js b/server/sonar-web/src/main/js/apps/permissions/global/components/PageHeader.js index 260c26c9ea0..47d78c927ed 100644 --- a/server/sonar-web/src/main/js/apps/permissions/global/components/PageHeader.js +++ b/server/sonar-web/src/main/js/apps/permissions/global/components/PageHeader.js @@ -20,12 +20,10 @@ import React from 'react'; import { connect } from 'react-redux'; import { translate } from '../../../../helpers/l10n'; -import { loadHolders } from '../store/actions'; import { isPermissionsAppLoading } from '../../../../store/rootReducer'; class PageHeader extends React.Component { static propTypes = { - loadHolders: React.PropTypes.func.isRequired, loading: React.PropTypes.bool }; @@ -56,11 +54,6 @@ const mapStateToProps = state => ({ loading: isPermissionsAppLoading(state) }); -const mapDispatchToProps = dispatch => ({ - loadHolders: () => dispatch(loadHolders()) -}); - export default connect( - mapStateToProps, - mapDispatchToProps + mapStateToProps )(PageHeader); diff --git a/server/sonar-web/src/main/js/apps/permissions/shared/components/HoldersList.js b/server/sonar-web/src/main/js/apps/permissions/shared/components/HoldersList.js index ea5a6f1c4bb..39e0daa10a7 100644 --- a/server/sonar-web/src/main/js/apps/permissions/shared/components/HoldersList.js +++ b/server/sonar-web/src/main/js/apps/permissions/shared/components/HoldersList.js @@ -51,7 +51,7 @@ export default class HoldersList extends React.Component { }}> <div className="permission-column-inner"> <a href="#" - title={`Filter by "${p.name}" permission` } + title={`Filter by "${p.name}" permission`} data-toggle="tooltip" onClick={this.handlePermissionClick.bind(this, p.key)}> {p.name} diff --git a/server/sonar-web/src/main/js/apps/permissions/shared/components/SearchForm.js b/server/sonar-web/src/main/js/apps/permissions/shared/components/SearchForm.js index 35a4836ded4..5281cfbcc42 100644 --- a/server/sonar-web/src/main/js/apps/permissions/shared/components/SearchForm.js +++ b/server/sonar-web/src/main/js/apps/permissions/shared/components/SearchForm.js @@ -70,7 +70,7 @@ export default class SearchForm extends React.Component { className="search-box display-inline-block text-middle big-spacer-left" onSubmit={this.handleSubmit}> <button className="search-box-submit button-clean"> - <i className="icon-search"></i> + <i className="icon-search"/> </button> <input ref="searchInput" diff --git a/server/sonar-web/src/main/js/apps/project-admin/key/BulkUpdateForm.js b/server/sonar-web/src/main/js/apps/project-admin/key/BulkUpdateForm.js index db31d98063d..8769a2fd768 100644 --- a/server/sonar-web/src/main/js/apps/project-admin/key/BulkUpdateForm.js +++ b/server/sonar-web/src/main/js/apps/project-admin/key/BulkUpdateForm.js @@ -48,7 +48,7 @@ export default class BulkUpdateForm extends React.Component { name="replace" type="text" placeholder={translate('update_key.replace_example')} - required/> + required={true}/> </div> <div className="modal-field"> @@ -61,7 +61,7 @@ export default class BulkUpdateForm extends React.Component { name="by" type="text" placeholder={translate('update_key.by_example')} - required/> + required={true}/> <button ref="submit" id="bulk-update-see-results" diff --git a/server/sonar-web/src/main/js/apps/project-admin/key/UpdateForm.js b/server/sonar-web/src/main/js/apps/project-admin/key/UpdateForm.js index 1031ad1ba6c..fddf2e1fccf 100644 --- a/server/sonar-web/src/main/js/apps/project-admin/key/UpdateForm.js +++ b/server/sonar-web/src/main/js/apps/project-admin/key/UpdateForm.js @@ -67,7 +67,7 @@ export default class UpdateForm extends React.Component { value={value} type="text" placeholder={translate('update_key.new_key')} - required + required={true} onChange={this.handleChange.bind(this)}/> <div className="spacer-top"> diff --git a/server/sonar-web/src/main/js/apps/projectActivity/actions.js b/server/sonar-web/src/main/js/apps/projectActivity/actions.js index 83115bd1800..7f8b5ede05e 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/actions.js +++ b/server/sonar-web/src/main/js/apps/projectActivity/actions.js @@ -30,7 +30,7 @@ import { import { onFail } from '../../store/rootActions'; import { getProjectActivity } from '../../store/rootReducer'; -const rejectOnFail = (dispatch: Function) => (error: any) => { +const rejectOnFail = (dispatch: Function) => (error: Object) => { onFail(dispatch)(error); return Promise.reject(); }; diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityApp.js b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityApp.js index 6dc24183a22..57d8475bf83 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityApp.js +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityApp.js @@ -30,7 +30,7 @@ import './projectActivity.css'; type Props = { location: { query: { id: string } }, fetchProjectActivity: (project: string) => void, - filter: ?string, + /* eslint-disable react/no-unused-prop-types */ project: { configuration?: { showHistory: boolean } } }; diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityPageHeader.js b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityPageHeader.js index 091a02950f9..ce0725198b4 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityPageHeader.js +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityPageHeader.js @@ -24,8 +24,7 @@ import { translate } from '../../../helpers/l10n'; type Props = { changeFilter: (filter: ?string) => void, - filter: ?string, - project: string + filter: ?string }; export default class ProjectActivityPageHeader extends React.Component { diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/forms/AddEventForm.js b/server/sonar-web/src/main/js/apps/projectActivity/components/forms/AddEventForm.js index da895b642b4..2ab77262ce8 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/forms/AddEventForm.js +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/forms/AddEventForm.js @@ -31,9 +31,9 @@ type Props = { type State = { open: boolean, - processing: boolean; - name: string; -} + processing: boolean, + name: string +}; export default class AddEventForm extends React.Component { mounted: boolean; diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/forms/ChangeEventForm.js b/server/sonar-web/src/main/js/apps/projectActivity/components/forms/ChangeEventForm.js index 8ae9e6b1cb4..5269374f916 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/forms/ChangeEventForm.js +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/forms/ChangeEventForm.js @@ -33,7 +33,7 @@ type Props = { type State = { processing: boolean, name: string -} +}; export default class ChangeEventForm extends React.Component { mounted: boolean; diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/forms/RemoveAnalysisForm.js b/server/sonar-web/src/main/js/apps/projectActivity/components/forms/RemoveAnalysisForm.js index 482362772ff..3c8c5477747 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/forms/RemoveAnalysisForm.js +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/forms/RemoveAnalysisForm.js @@ -34,7 +34,7 @@ type Props = { type State = { open: boolean, processing: boolean -} +}; class RemoveAnalysisForm extends React.Component { mounted: boolean; diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/forms/RemoveEventForm.js b/server/sonar-web/src/main/js/apps/projectActivity/components/forms/RemoveEventForm.js index 893d164b7af..ed3d879a4f9 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/forms/RemoveEventForm.js +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/forms/RemoveEventForm.js @@ -34,7 +34,7 @@ type Props = { type State = { processing: boolean -} +}; export default class RemoveVersionForm extends React.Component { mounted: boolean; diff --git a/server/sonar-web/src/main/js/apps/projects-admin/main.js b/server/sonar-web/src/main/js/apps/projects-admin/main.js index c3a240b19db..f83187d8557 100644 --- a/server/sonar-web/src/main/js/apps/projects-admin/main.js +++ b/server/sonar-web/src/main/js/apps/projects-admin/main.js @@ -33,11 +33,10 @@ import ListFooter from '../../components/controls/ListFooter'; export default React.createClass({ propTypes: { - hasProvisionPermission: React.PropTypes.bool.isRequired, - topLevelQualifiers: React.PropTypes.array.isRequired + hasProvisionPermission: React.PropTypes.bool.isRequired }, - getInitialState() { + getInitialState () { return { ready: false, projects: [], @@ -54,11 +53,11 @@ export default React.createClass({ this.requestProjects = _.debounce(this.requestProjects, 250); }, - componentDidMount() { + componentDidMount () { this.requestProjects(); }, - getFilters() { + getFilters () { const filters = { ps: PAGE_SIZE }; if (this.state.page !== 1) { filters.p = this.state.page; @@ -69,7 +68,7 @@ export default React.createClass({ return filters; }, - requestProjects() { + requestProjects () { switch (this.state.type) { case TYPE.ALL: this.requestAllProjects(); @@ -86,12 +85,12 @@ export default React.createClass({ } }, - requestGhosts() { + requestGhosts () { const data = this.getFilters(); getGhosts(data).then(r => { - let projects = r.projects.map(project => { - return _.extend(project, { id: project.uuid, qualifier: 'TRK' }); - }); + let projects = r.projects.map(project => ( + _.extend(project, { id: project.uuid, qualifier: 'TRK' }) + )); if (this.state.page > 1) { projects = [].concat(this.state.projects, projects); } @@ -99,12 +98,12 @@ export default React.createClass({ }); }, - requestProvisioned() { + requestProvisioned () { const data = this.getFilters(); getProvisioned(data).then(r => { - let projects = r.projects.map(project => { - return _.extend(project, { id: project.uuid, qualifier: 'TRK' }); - }); + let projects = r.projects.map(project => ( + _.extend(project, { id: project.uuid, qualifier: 'TRK' }) + )); if (this.state.page > 1) { projects = [].concat(this.state.projects, projects); } @@ -112,7 +111,7 @@ export default React.createClass({ }); }, - requestAllProjects() { + requestAllProjects () { const data = this.getFilters(); data.qualifiers = this.state.qualifiers; getComponents(data).then(r => { @@ -124,12 +123,12 @@ export default React.createClass({ }); }, - loadMore() { + loadMore () { this.setState({ ready: false, page: this.state.page + 1 }, this.requestProjects); }, - onSearch(query) { + onSearch (query) { this.setState({ ready: false, page: 1, @@ -138,7 +137,7 @@ export default React.createClass({ }, this.requestProjects); }, - onTypeChanged(newType) { + onTypeChanged (newType) { this.setState({ ready: false, page: 1, @@ -149,7 +148,7 @@ export default React.createClass({ }, this.requestProjects); }, - onQualifierChanged(newQualifier) { + onQualifierChanged (newQualifier) { this.setState({ ready: false, page: 1, @@ -160,28 +159,26 @@ export default React.createClass({ }, this.requestProjects); }, - onProjectSelected(project) { + onProjectSelected (project) { const newSelection = _.uniq([].concat(this.state.selection, project.id)); this.setState({ selection: newSelection }); }, - onProjectDeselected(project) { + onProjectDeselected (project) { const newSelection = _.without(this.state.selection, project.id); this.setState({ selection: newSelection }); }, - onAllSelected() { - const newSelection = this.state.projects.map(project => { - return project.id; - }); + onAllSelected () { + const newSelection = this.state.projects.map(project => project.id); this.setState({ selection: newSelection }); }, - onAllDeselected() { + onAllDeselected () { this.setState({ selection: [] }); }, - deleteProjects() { + deleteProjects () { this.setState({ ready: false }); const ids = this.state.selection.join(','); deleteComponents({ ids }).then(() => { @@ -189,7 +186,7 @@ export default React.createClass({ }); }, - render() { + render () { return ( <div className="page page-limited"> <Header diff --git a/server/sonar-web/src/main/js/apps/projects-admin/projects.js b/server/sonar-web/src/main/js/apps/projects-admin/projects.js index 27387a3e780..d6b002248a4 100644 --- a/server/sonar-web/src/main/js/apps/projects-admin/projects.js +++ b/server/sonar-web/src/main/js/apps/projects-admin/projects.js @@ -29,8 +29,7 @@ import { translate } from '../../helpers/l10n'; export default class Projects extends React.Component { static propTypes = { projects: React.PropTypes.array.isRequired, - selection: React.PropTypes.array.isRequired, - refresh: React.PropTypes.func.isRequired + selection: React.PropTypes.array.isRequired }; componentWillMount () { diff --git a/server/sonar-web/src/main/js/apps/projects-admin/search.js b/server/sonar-web/src/main/js/apps/projects-admin/search.js index 24817c916f9..b995ddced12 100644 --- a/server/sonar-web/src/main/js/apps/projects-admin/search.js +++ b/server/sonar-web/src/main/js/apps/projects-admin/search.js @@ -30,17 +30,17 @@ export default React.createClass({ onSearch: React.PropTypes.func.isRequired }, - onSubmit(e) { + onSubmit (e) { e.preventDefault(); this.search(); }, - search() { + search () { const q = this.refs.input.value; this.props.onSearch(q); }, - getTypeOptions() { + getTypeOptions () { return [ { value: TYPE.ALL, label: 'All' }, { value: TYPE.PROVISIONED, label: 'Provisioned' }, @@ -48,16 +48,14 @@ export default React.createClass({ ]; }, - getQualifierOptions() { + getQualifierOptions () { const options = this.props.topLevelQualifiers.map(q => { return { value: q, label: translate('qualifiers', q) }; }); - return _.sortBy(options, option => { - return QUALIFIERS_ORDER.indexOf(option.value); - }); + return _.sortBy(options, option => QUALIFIERS_ORDER.indexOf(option.value)); }, - renderCheckbox() { + renderCheckbox () { const isAllChecked = this.props.projects.length > 0 && this.props.selection.length === this.props.projects.length; const thirdState = this.props.projects.length > 0 && @@ -72,11 +70,11 @@ export default React.createClass({ ); }, - renderSpinner() { + renderSpinner () { return <i className="spinner"/>; }, - onCheck(checked) { + onCheck (checked) { if (checked) { this.props.onAllSelected(); } else { @@ -91,13 +89,13 @@ export default React.createClass({ return <div className="spacer-top alert alert-info">{translate('bulk_deletion.ghosts.description')}</div>; }, - deleteProjects() { + deleteProjects () { new DeleteView({ deleteProjects: this.props.deleteProjects }).render(); }, - renderQualifierFilter() { + renderQualifierFilter () { const options = this.getQualifierOptions(); if (options.length < 2) { return null; @@ -113,7 +111,7 @@ export default React.createClass({ ); }, - render() { + render () { const isSomethingSelected = this.props.projects.length > 0 && this.props.selection.length > 0; return ( <div className="panel panel-vertical bordered-bottom spacer-bottom"> @@ -134,7 +132,7 @@ export default React.createClass({ <td className="text-middle"> <form onSubmit={this.onSubmit} className="search-box"> <button className="search-box-submit button-clean"> - <i className="icon-search"></i> + <i className="icon-search"/> </button> <input onChange={this.search} value={this.props.query} diff --git a/server/sonar-web/src/main/js/apps/projects-admin/views/BulkApplyTemplateView.js b/server/sonar-web/src/main/js/apps/projects-admin/views/BulkApplyTemplateView.js index d2fc1aba72e..c2f216edf35 100644 --- a/server/sonar-web/src/main/js/apps/projects-admin/views/BulkApplyTemplateView.js +++ b/server/sonar-web/src/main/js/apps/projects-admin/views/BulkApplyTemplateView.js @@ -62,7 +62,7 @@ export default ModalForm.extend({ return bulkApplyTemplate(data); }, - bulkApplyToSelected(permissionTemplate) { + bulkApplyToSelected (permissionTemplate) { const { selection } = this.options; let lastRequest = Promise.resolve(); diff --git a/server/sonar-web/src/main/js/apps/projects/components/AllProjects.js b/server/sonar-web/src/main/js/apps/projects/components/AllProjects.js index f7c3c04e7ef..2395c64f076 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/AllProjects.js +++ b/server/sonar-web/src/main/js/apps/projects/components/AllProjects.js @@ -25,7 +25,6 @@ import { parseUrlQuery } from '../store/utils'; export default class AllProjects extends React.Component { static propTypes = { - user: React.PropTypes.oneOfType([React.PropTypes.object, React.PropTypes.bool]), isFavorite: React.PropTypes.bool.isRequired, fetchProjects: React.PropTypes.func.isRequired }; diff --git a/server/sonar-web/src/main/js/apps/projects/components/ProjectCardMeasures.js b/server/sonar-web/src/main/js/apps/projects/components/ProjectCardMeasures.js index a6ea6ec3e97..eeba0355c19 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/ProjectCardMeasures.js +++ b/server/sonar-web/src/main/js/apps/projects/components/ProjectCardMeasures.js @@ -28,8 +28,7 @@ import { translate } from '../../../helpers/l10n'; export default class ProjectCardMeasures extends React.Component { static propTypes = { - measures: React.PropTypes.object, - languages: React.PropTypes.array + measures: React.PropTypes.object }; render () { diff --git a/server/sonar-web/src/main/js/apps/projects/filters/Filter.js b/server/sonar-web/src/main/js/apps/projects/filters/Filter.js index cab64031e7d..448f5cb2eb7 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/Filter.js +++ b/server/sonar-web/src/main/js/apps/projects/filters/Filter.js @@ -37,9 +37,7 @@ export default class Filter extends React.Component { halfWidth: React.PropTypes.bool, - getFilterUrl: React.PropTypes.func.isRequired, - - router: React.PropTypes.object + getFilterUrl: React.PropTypes.func.isRequired }; static defaultProps = { @@ -70,7 +68,7 @@ export default class Filter extends React.Component { renderOption (option) { const { property, value, facet, getFacetValueForOption } = this.props; const className = classNames('facet', 'search-navigator-facet', 'projects-facet', { - active: option === value, + 'active': option === value, 'search-navigator-facet-half': this.props.halfWidth }, this.props.optionClassName); diff --git a/server/sonar-web/src/main/js/apps/projects/filters/FilterContainer.js b/server/sonar-web/src/main/js/apps/projects/filters/FilterContainer.js index c753e163909..c36859517e8 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/FilterContainer.js +++ b/server/sonar-web/src/main/js/apps/projects/filters/FilterContainer.js @@ -17,11 +17,11 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import Filter from './Filter'; import { connect } from 'react-redux'; import { withRouter } from 'react-router'; import omitBy from 'lodash/omitBy'; import isNil from 'lodash/isNil'; +import Filter from './Filter'; import { getProjectsAppFacetByProperty, getProjectsAppMaxFacetValue } from '../../../store/rootReducer'; const mapStateToProps = (state, ownProps) => ({ diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/AddConditionForm.js b/server/sonar-web/src/main/js/apps/quality-gates/components/AddConditionForm.js index 02722807a43..d3e5cc3c4a4 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/AddConditionForm.js +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/AddConditionForm.js @@ -20,7 +20,6 @@ import _ from 'underscore'; import React from 'react'; import Select from 'react-select'; - import { translate, getLocalizedMetricName, getLocalizedMetricDomain } from '../../../helpers/l10n'; export default function AddConditionForm ({ metrics, onSelect }) { diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/Condition.js b/server/sonar-web/src/main/js/apps/quality-gates/components/Condition.js index ae7c34aa548..0109eafa2cb 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/Condition.js +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/Condition.js @@ -19,7 +19,6 @@ */ import React, { Component } from 'react'; import Select from 'react-select'; - import ThresholdInput from './ThresholdInput'; import DeleteConditionView from '../views/gate-conditions-delete-view'; import Checkbox from '../../../components/controls/Checkbox'; diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/Conditions.js b/server/sonar-web/src/main/js/apps/quality-gates/components/Conditions.js index ce2dddb2e21..eb0dccd6a41 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/Conditions.js +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/Conditions.js @@ -20,7 +20,6 @@ import _ from 'underscore'; import React from 'react'; import uniqBy from 'lodash/uniqBy'; - import ConditionsAlert from './ConditionsAlert'; import AddConditionForm from './AddConditionForm'; import Condition from './Condition'; @@ -107,7 +106,7 @@ export default class Conditions extends React.Component { <p>{translate('quality_gates.duplicated_conditions')}</p> <ul className="list-styled spacer-top"> {uniqDuplicates.map(d => ( - <li>{getLocalizedMetricName(d.metric)}</li> + <li key={d.metric.key}>{getLocalizedMetricName(d.metric)}</li> ))} </ul> </div> @@ -132,7 +131,7 @@ export default class Conditions extends React.Component { <th className="thin nowrap"> {translate('quality_gates.conditions.error')} </th> - {edit && <th></th>} + {edit && <th/>} </tr> </thead> <tbody> diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/ConditionsAlert.js b/server/sonar-web/src/main/js/apps/quality-gates/components/ConditionsAlert.js index c2f8d3274a5..34050b70bbc 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/ConditionsAlert.js +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/ConditionsAlert.js @@ -18,7 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React, { Component } from 'react'; - import { translate } from '../../../helpers/l10n'; export default class ConditionsAlert extends Component { @@ -50,17 +49,17 @@ export default class ConditionsAlert extends Component { {translate('quality_gates.health_icons')} <ul> <li className="little-spacer-top"> - <i className="icon-alert-ok"></i> + <i className="icon-alert-ok"/> {' '} {translate('alerts.notes.ok')} </li> <li className="little-spacer-top"> - <i className="icon-alert-warn"></i> + <i className="icon-alert-warn"/> {' '} {translate('alerts.notes.warn')} </li> <li className="little-spacer-top"> - <i className="icon-alert-error"></i> + <i className="icon-alert-error"/> {' '} {translate('alerts.notes.error')} </li> diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/Details.js b/server/sonar-web/src/main/js/apps/quality-gates/components/Details.js index d02601bfe6e..fb34bc951cb 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/Details.js +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/Details.js @@ -18,7 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React, { Component } from 'react'; - import { fetchQualityGate, setQualityGateAsDefault, unsetQualityGateAsDefault } from '../../../api/quality-gates'; import DetailsHeader from './DetailsHeader'; import DetailsContent from './DetailsContent'; @@ -63,7 +62,7 @@ export default class Details extends Component { new CopyView({ qualityGate, - onCopy: (newQualityGate) => { + onCopy: newQualityGate => { onCopy(newQualityGate); router.push(`/quality_gates/show/${newQualityGate.id}`); } @@ -88,7 +87,7 @@ export default class Details extends Component { new DeleteView({ qualityGate, - onDelete: (qualityGate) => { + onDelete: qualityGate => { onDelete(qualityGate); router.replace('/quality_gates'); } @@ -105,7 +104,7 @@ export default class Details extends Component { <div className="search-navigator-workspace-header" style={{ top: 30 }}> <h2 className="search-navigator-header-component"> </h2> </div> - <div className="search-navigator-workspace-details"></div> + <div className="search-navigator-workspace-details"/> </div> ); } diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/DetailsContent.js b/server/sonar-web/src/main/js/apps/quality-gates/components/DetailsContent.js index 5151d48e5c4..4f00ef69d26 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/DetailsContent.js +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/DetailsContent.js @@ -18,7 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React, { Component } from 'react'; - import Conditions from './Conditions'; import Projects from './Projects'; import { translate } from '../../../helpers/l10n'; diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/DetailsHeader.js b/server/sonar-web/src/main/js/apps/quality-gates/components/DetailsHeader.js index fc9675d28d8..d652963da32 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/DetailsHeader.js +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/DetailsHeader.js @@ -18,7 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; - import { translate } from '../../../helpers/l10n'; export default function DetailsHeader ({ qualityGate, edit, onRename, onCopy, onSetAsDefault, onDelete }) { diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/Intro.js b/server/sonar-web/src/main/js/apps/quality-gates/components/Intro.js index dbb43fbde68..94faf619bbf 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/Intro.js +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/Intro.js @@ -18,7 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; - import { translate } from '../../../helpers/l10n'; export default function Intro () { diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/List.js b/server/sonar-web/src/main/js/apps/quality-gates/components/List.js index 66b8ec046ef..8f7ae12eb51 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/List.js +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/List.js @@ -19,7 +19,6 @@ */ import React from 'react'; import { Link } from 'react-router'; - import { translate } from '../../../helpers/l10n'; export default function List ({ qualityGates }) { diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/ListHeader.js b/server/sonar-web/src/main/js/apps/quality-gates/components/ListHeader.js index 0ecd1fc56da..ccb8c1f016d 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/ListHeader.js +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/ListHeader.js @@ -18,7 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; - import CreateView from '../views/create-view'; import { translate } from '../../../helpers/l10n'; diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/Projects.js b/server/sonar-web/src/main/js/apps/quality-gates/components/Projects.js index 62b974bf76d..72e955ae95f 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/Projects.js +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/Projects.js @@ -18,7 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React, { Component } from 'react'; - import ProjectsView from '../views/gate-projects-view'; export default class Projects extends Component { @@ -57,7 +56,7 @@ export default class Projects extends Component { render () { return ( - <div ref="container"></div> + <div ref="container"/> ); } } diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/QualityGatesApp.js b/server/sonar-web/src/main/js/apps/quality-gates/components/QualityGatesApp.js index 9395bac2b25..1f85cd9b919 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/QualityGatesApp.js +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/QualityGatesApp.js @@ -18,10 +18,8 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React, { Component } from 'react'; - import ListHeader from './ListHeader'; import List from './List'; - import { fetchQualityGatesAppDetails, fetchQualityGates as fetchQualityGatesAPI diff --git a/server/sonar-web/src/main/js/apps/quality-gates/containers/QualityGatesAppContainer.js b/server/sonar-web/src/main/js/apps/quality-gates/containers/QualityGatesAppContainer.js index 033660a7f38..08a003cd538 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/containers/QualityGatesAppContainer.js +++ b/server/sonar-web/src/main/js/apps/quality-gates/containers/QualityGatesAppContainer.js @@ -18,7 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { connect } from 'react-redux'; - import { setState, addQualityGate, deleteQualityGate } from '../store/actions'; import QualityGateApp from '../components/QualityGatesApp'; import { getQualityGatesAppState } from '../../../store/rootReducer'; diff --git a/server/sonar-web/src/main/js/apps/quality-gates/views/gate-projects-view.js b/server/sonar-web/src/main/js/apps/quality-gates/views/gate-projects-view.js index 8c4cd9406a3..84ee4e5161a 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/views/gate-projects-view.js +++ b/server/sonar-web/src/main/js/apps/quality-gates/views/gate-projects-view.js @@ -19,7 +19,6 @@ */ import _ from 'underscore'; import Marionette from 'backbone.marionette'; - import Template from '../templates/quality-gate-detail-projects.hbs'; import '../../../components/SelectList'; import { translate } from '../../../helpers/l10n'; diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileDetails.js b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileDetails.js index 93020e2dff7..46c0b395ae2 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileDetails.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileDetails.js @@ -26,6 +26,7 @@ import { ProfileType } from '../propTypes'; export default class ProfileDetails extends React.Component { static propTypes = { + /* eslint-disable react/no-unused-prop-types */ profile: ProfileType, canAdmin: React.PropTypes.bool, updateProfiles: React.PropTypes.func diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/home/EvolutionRules.js b/server/sonar-web/src/main/js/apps/quality-profiles/home/EvolutionRules.js index 6e9ddc1c51f..002652f20b8 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/home/EvolutionRules.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/home/EvolutionRules.js @@ -53,10 +53,10 @@ export default class EvolutionRules extends React.Component { loadLatestRules () { const data = { 'available_since': PERIOD_START_MOMENT.format('YYYY-MM-DD'), - s: 'createdAt', - asc: false, - ps: RULES_LIMIT, - f: 'name,langName,actives' + 's': 'createdAt', + 'asc': false, + 'ps': RULES_LIMIT, + 'f': 'name,langName,actives' }; searchRules(data).then(r => { diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/views/ChangeProjectsView.js b/server/sonar-web/src/main/js/apps/quality-profiles/views/ChangeProjectsView.js index e2c1178a73b..2829cf81df3 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/views/ChangeProjectsView.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/views/ChangeProjectsView.js @@ -63,7 +63,7 @@ export default ModalFormView.extend({ }); }, - onDestroy() { + onDestroy () { this.options.loadProjects(); ModalFormView.prototype.onDestroy.apply(this, arguments); } diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/views/CreateProfileView.js b/server/sonar-web/src/main/js/apps/quality-profiles/views/CreateProfileView.js index 60d800bc9fa..f561b33aa05 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/views/CreateProfileView.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/views/CreateProfileView.js @@ -65,7 +65,7 @@ export default ModalFormView.extend({ that.emptyInput($(this)); $(this).addClass('hidden'); }); - importers.forEach(function (importer) { + importers.forEach(importer => { that.$(`.js-importer[data-key="${importer.key}"]`).removeClass('hidden'); }); }, @@ -77,9 +77,9 @@ export default ModalFormView.extend({ getImportersForLanguages (language) { if (language != null) { - return this.options.importers.filter(function (importer) { - return importer.languages.indexOf(language) !== -1; - }); + return this.options.importers.filter(importer => ( + importer.languages.indexOf(language) !== -1 + )); } else { return []; } diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/views/RestoreProfileView.js b/server/sonar-web/src/main/js/apps/quality-profiles/views/RestoreProfileView.js index 4fceffda657..874a5726581 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/views/RestoreProfileView.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/views/RestoreProfileView.js @@ -44,7 +44,7 @@ export default ModalFormView.extend({ }); }, - serializeData() { + serializeData () { return { ...ModalFormView.prototype.serializeData.apply(this, arguments), profile: this.profile, diff --git a/server/sonar-web/src/main/js/apps/sessions/components/LoginForm.js b/server/sonar-web/src/main/js/apps/sessions/components/LoginForm.js index 12010610e3e..b4efff30f64 100644 --- a/server/sonar-web/src/main/js/apps/sessions/components/LoginForm.js +++ b/server/sonar-web/src/main/js/apps/sessions/components/LoginForm.js @@ -33,7 +33,7 @@ export default class LoginForm extends React.Component { password: '' }; - handleSubmit = (e: any) => { + handleSubmit = (e: Object) => { e.preventDefault(); this.props.onSubmit(this.state.login, this.state.password); }; @@ -50,7 +50,7 @@ export default class LoginForm extends React.Component { <li key={identityProvider.key}> <a href={`${window.baseUrl}/sessions/init/${identityProvider.key}`} style={{ backgroundColor: identityProvider.backgroundColor }} - title={`Log in with ${identityProvider.name}` }> + title={`Log in with ${identityProvider.name}`}> <img alt={identityProvider.name} width="20" height="20" src={window.baseUrl + identityProvider.iconPath}/> <span>Log in with {identityProvider.name}</span> diff --git a/server/sonar-web/src/main/js/apps/sessions/components/LoginFormContainer.js b/server/sonar-web/src/main/js/apps/sessions/components/LoginFormContainer.js index 15f6822e766..3af16978f74 100644 --- a/server/sonar-web/src/main/js/apps/sessions/components/LoginFormContainer.js +++ b/server/sonar-web/src/main/js/apps/sessions/components/LoginFormContainer.js @@ -26,7 +26,7 @@ import { getAppState } from '../../../store/rootReducer'; import { getIdentityProviders } from '../../../api/users'; class LoginFormContainer extends React.Component { - mounted: bool; + mounted: boolean; static propTypes = { location: React.PropTypes.object.isRequired diff --git a/server/sonar-web/src/main/js/apps/sessions/components/Unauthorized.js b/server/sonar-web/src/main/js/apps/sessions/components/Unauthorized.js index 276c33809ec..8406042eaf9 100644 --- a/server/sonar-web/src/main/js/apps/sessions/components/Unauthorized.js +++ b/server/sonar-web/src/main/js/apps/sessions/components/Unauthorized.js @@ -31,7 +31,7 @@ export default class Unauthorized extends React.Component { return ( <div className="text-center"> <p id="unauthorized"> - You're not authorized to access this page. Please contact the administrator. + You're not authorized to access this page. Please contact the administrator. </p> {!!message && ( diff --git a/server/sonar-web/src/main/js/apps/settings/components/App.js b/server/sonar-web/src/main/js/apps/settings/components/App.js index 9a55ff3b008..a2a5ffd14c9 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/App.js +++ b/server/sonar-web/src/main/js/apps/settings/components/App.js @@ -32,7 +32,7 @@ import '../styles.css'; type Props = { component: { key: string }, defaultCategory: ?string, - fetchSettings(componentKey: ?string): Promise<any>, + fetchSettings(componentKey: ?string): Promise<*>, location: { query: {} } }; diff --git a/server/sonar-web/src/main/js/apps/settings/components/Definition.js b/server/sonar-web/src/main/js/apps/settings/components/Definition.js index 7f607de7f78..1fcc33d6c26 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/Definition.js +++ b/server/sonar-web/src/main/js/apps/settings/components/Definition.js @@ -28,7 +28,7 @@ import DefinitionChanges from './DefinitionChanges'; import { getPropertyName, getPropertyDescription, getSettingValue, isDefaultOrInherited } from '../utils'; import { translateWithParameters, translate } from '../../../helpers/l10n'; import { resetValue, saveValue } from '../store/actions'; -import { failValidation, passValidation } from '../store/settingsPage/validationMessages/actions'; +import { passValidation } from '../store/settingsPage/validationMessages/actions'; import { cancelChange, changeValue } from '../store/settingsPage/changedValues/actions'; import { TYPE_PASSWORD } from '../constants'; import { @@ -52,7 +52,6 @@ class Definition extends React.Component { cancelChange: React.PropTypes.func.isRequired, saveValue: React.PropTypes.func.isRequired, resetValue: React.PropTypes.func.isRequired, - failValidation: React.PropTypes.func.isRequired, passValidation: React.PropTypes.func.isRequired }; @@ -197,5 +196,5 @@ const mapStateToProps = (state, ownProps) => ({ export default connect( mapStateToProps, - { changeValue, saveValue, resetValue, failValidation, passValidation, cancelChange } + { changeValue, saveValue, resetValue, passValidation, cancelChange } )(Definition); diff --git a/server/sonar-web/src/main/js/apps/settings/components/DefinitionChanges.js b/server/sonar-web/src/main/js/apps/settings/components/DefinitionChanges.js index 97d48d20d8b..2e1afc3adbf 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/DefinitionChanges.js +++ b/server/sonar-web/src/main/js/apps/settings/components/DefinitionChanges.js @@ -32,13 +32,13 @@ export default class DefinitionChanges extends React.Component { return shallowCompare(this, nextProps, nextState); } - handleSaveClick (e: any) { + handleSaveClick (e: Object) { e.preventDefault(); e.target.blur(); this.props.onSave(); } - handleCancelChange (e: any) { + handleCancelChange (e: Object) { e.preventDefault(); e.target.blur(); this.props.onCancel(); diff --git a/server/sonar-web/src/main/js/apps/settings/components/DefinitionDefaults.js b/server/sonar-web/src/main/js/apps/settings/components/DefinitionDefaults.js index 9d561ac6174..830bcac102f 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/DefinitionDefaults.js +++ b/server/sonar-web/src/main/js/apps/settings/components/DefinitionDefaults.js @@ -29,7 +29,7 @@ export default class DefinitionDefaults extends React.Component { onReset: React.PropTypes.func.isRequired }; - handleReset (e: any) { + handleReset (e: Object) { e.preventDefault(); e.target.blur(); this.props.onReset(); diff --git a/server/sonar-web/src/main/js/apps/settings/components/EmailForm.js b/server/sonar-web/src/main/js/apps/settings/components/EmailForm.js index 1af5a0a8014..f4e551206b7 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/EmailForm.js +++ b/server/sonar-web/src/main/js/apps/settings/components/EmailForm.js @@ -77,7 +77,7 @@ class EmailForm extends React.Component { <input id="test-email-to" type="email" - required + required={true} value={this.state.recipient} disabled={this.state.loading} onChange={e => this.setState({ recipient: e.target.value })}/> @@ -100,7 +100,7 @@ class EmailForm extends React.Component { </label> <textarea id="test-email-title" - required + required={true} rows="5" value={this.state.message} disabled={this.state.loading} diff --git a/server/sonar-web/src/main/js/apps/settings/components/inputs/Input.js b/server/sonar-web/src/main/js/apps/settings/components/inputs/Input.js index 02fcbfacef2..b2ddc8e6959 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/inputs/Input.js +++ b/server/sonar-web/src/main/js/apps/settings/components/inputs/Input.js @@ -26,6 +26,7 @@ import { TYPE_PROPERTY_SET } from '../../constants'; export default class Input extends React.Component { static propTypes = { + /* eslint-disable react/no-unused-prop-types */ setting: React.PropTypes.object.isRequired, value: React.PropTypes.any, onChange: React.PropTypes.func.isRequired diff --git a/server/sonar-web/src/main/js/apps/settings/serverId/ServerIdApp.js b/server/sonar-web/src/main/js/apps/settings/serverId/ServerIdApp.js index 8474bbaa581..d1c301302bd 100644 --- a/server/sonar-web/src/main/js/apps/settings/serverId/ServerIdApp.js +++ b/server/sonar-web/src/main/js/apps/settings/serverId/ServerIdApp.js @@ -103,7 +103,7 @@ export default class ServerIdApp extends React.Component { <input id="server-id-organization" type="text" - required + required={true} value={this.state.organization} disabled={this.state.loading} onChange={e => this.setState({ organization: e.target.value })}/> @@ -122,7 +122,7 @@ export default class ServerIdApp extends React.Component { <input id="server-id-ip" type="text" - required + required={true} value={this.state.ip} disabled={this.state.loading} onChange={e => this.setState({ ip: e.target.value })}/> diff --git a/server/sonar-web/src/main/js/apps/settings/store/values/actions.js b/server/sonar-web/src/main/js/apps/settings/store/values/actions.js index e088215d7fd..08b98237090 100644 --- a/server/sonar-web/src/main/js/apps/settings/store/values/actions.js +++ b/server/sonar-web/src/main/js/apps/settings/store/values/actions.js @@ -19,6 +19,7 @@ */ // @flow import type { SettingValue } from '../../types'; + export const RECEIVE_VALUES: string = 'RECEIVE_VALUES'; /** diff --git a/server/sonar-web/src/main/js/apps/settings/store/values/reducer.js b/server/sonar-web/src/main/js/apps/settings/store/values/reducer.js index c57ed067c36..55f2182af2c 100644 --- a/server/sonar-web/src/main/js/apps/settings/store/values/reducer.js +++ b/server/sonar-web/src/main/js/apps/settings/store/values/reducer.js @@ -24,7 +24,7 @@ import { actions as appStateActions } from '../../../../store/appState/duck'; type State = { [key: string]: {} }; -const reducer = (state: State = {}, action: any) => { +const reducer = (state: State = {}, action: Object) => { if (action.type === RECEIVE_VALUES) { const settingsByKey = keyBy(action.settings, 'key'); return { ...state, ...settingsByKey }; diff --git a/server/sonar-web/src/main/js/apps/system/__tests__/system-test.js b/server/sonar-web/src/main/js/apps/system/__tests__/system-test.js index 4e038d05b0a..8061aa198d0 100644 --- a/server/sonar-web/src/main/js/apps/system/__tests__/system-test.js +++ b/server/sonar-web/src/main/js/apps/system/__tests__/system-test.js @@ -24,7 +24,7 @@ import ItemBoolean from '../item-boolean'; import ItemObject from '../item-object'; import ItemLogLevel from '../item-log-level'; -describe('Item Value', function () { +describe('Item Value', () => { it('should render string', () => { const result = shallow(<ItemValue value="/some/path/as/an/example"/>); expect(result.find('code').text()).toBe('/some/path/as/an/example'); @@ -65,7 +65,7 @@ describe('ItemObject', () => { }); }); -describe('Log Level', function () { +describe('Log Level', () => { it('should render select box', () => { const result = shallow(<ItemLogLevel value="INFO"/>); expect(result.find('select').length).toBe(1); diff --git a/server/sonar-web/src/main/js/apps/system/item-boolean.js b/server/sonar-web/src/main/js/apps/system/item-boolean.js index aa9e92b48fd..c858ec2bd6f 100644 --- a/server/sonar-web/src/main/js/apps/system/item-boolean.js +++ b/server/sonar-web/src/main/js/apps/system/item-boolean.js @@ -20,7 +20,7 @@ import React from 'react'; export default React.createClass({ - render() { + render () { if (this.props.value) { return <i className="icon-check"/>; } else { diff --git a/server/sonar-web/src/main/js/apps/system/item-log-level.js b/server/sonar-web/src/main/js/apps/system/item-log-level.js index 27ac5d84306..77ce23f8144 100644 --- a/server/sonar-web/src/main/js/apps/system/item-log-level.js +++ b/server/sonar-web/src/main/js/apps/system/item-log-level.js @@ -28,27 +28,30 @@ export default React.createClass({ return { level: this.props.value }; }, - onChange() { + onChange () { const newValue = this.refs.select.value; setLogLevel(newValue).then(() => { this.setState({ level: newValue }); }); }, - render() { - const options = LOG_LEVELS.map(level => { - return <option key={level} value={level}>{level}</option>; - }); + render () { + const options = LOG_LEVELS.map(level => ( + <option key={level} value={level}>{level}</option> + )); const warning = this.state.level !== 'INFO' ? ( - <div className="alert alert-danger spacer-top" style={{ wordBreak: 'normal' }}> - {translate('system.log_level.warning')} - </div> - ) : null; - return <div> - <select ref="select" + <div className="alert alert-danger spacer-top" style={{ wordBreak: 'normal' }}> + {translate('system.log_level.warning')} + </div> + ) : null; + return ( + <div> + <select + ref="select" onChange={this.onChange} value={this.state.level}>{options}</select> - {warning} - </div>; + {warning} + </div> + ); } }); diff --git a/server/sonar-web/src/main/js/apps/system/item-object.js b/server/sonar-web/src/main/js/apps/system/item-object.js index 93652bf7c4a..c8bec3651ed 100644 --- a/server/sonar-web/src/main/js/apps/system/item-object.js +++ b/server/sonar-web/src/main/js/apps/system/item-object.js @@ -21,13 +21,19 @@ import React from 'react'; import ItemValue from './item-value'; export default React.createClass({ - render() { + render () { const rows = Object.keys(this.props.value).map(key => { - return <tr key={key}> - <td className="thin nowrap">{key}</td> - <td><ItemValue value={this.props.value[key]}/></td> - </tr>; + return ( + <tr key={key}> + <td className="thin nowrap">{key}</td> + <td><ItemValue value={this.props.value[key]}/></td> + </tr> + ); }); - return <table className="data"><tbody>{rows}</tbody></table>; + return ( + <table className="data"> + <tbody>{rows}</tbody> + </table> + ); } }); diff --git a/server/sonar-web/src/main/js/apps/system/item-value.js b/server/sonar-web/src/main/js/apps/system/item-value.js index d3765865f80..94e38d779b7 100644 --- a/server/sonar-web/src/main/js/apps/system/item-value.js +++ b/server/sonar-web/src/main/js/apps/system/item-value.js @@ -23,7 +23,7 @@ import ItemObject from './item-object'; import ItemLogLevel from './item-log-level'; export default React.createClass({ - render() { + render () { if (this.props.name === 'Logs Level') { return <ItemLogLevel value={this.props.value}/>; } diff --git a/server/sonar-web/src/main/js/apps/system/main.js b/server/sonar-web/src/main/js/apps/system/main.js index 23c3af7e015..a95b94220cc 100644 --- a/server/sonar-web/src/main/js/apps/system/main.js +++ b/server/sonar-web/src/main/js/apps/system/main.js @@ -28,7 +28,7 @@ const SECTIONS_ORDER = ['SonarQube', 'Database', 'System', 'Elasticsearch State' 'Compute Engine Tasks', 'Compute Engine State', 'Compute Engine Database Connection', 'JvmProperties']; export default React.createClass({ - componentDidMount() { + componentDidMount () { getSystemInfo().then(info => this.setState({ sections: this.parseSections(info) })); }, @@ -58,55 +58,57 @@ export default React.createClass({ new RestartModal().render(); }, - render() { + render () { let sections = null; if (this.state && this.state.sections) { sections = this.state.sections - .filter(section => SECTIONS_ORDER.indexOf(section.name)>=0) - .map(section => { - return <Section key={section.name} section={section.name} items={section.items}/>; - }); + .filter(section => SECTIONS_ORDER.indexOf(section.name) >= 0) + .map(section => ( + <Section key={section.name} section={section.name} items={section.items}/> + )); } - return <div className="page"> - <header className="page-header"> - <h1 className="page-title">{translate('system_info.page')}</h1> - <div className="page-actions"> - <a href={window.baseUrl + '/api/system/info'} id="download-link">Download</a> - <div className="display-inline-block dropdown big-spacer-left"> - <button data-toggle="dropdown">Logs <i className="icon-dropdown"/></button> - <ul className="dropdown-menu"> - <li> - <a href={window.baseUrl + '/api/system/logs?process=app'} id="logs-link"> - Main Process - </a> - </li> - <li> - <a href={window.baseUrl + '/api/system/logs?process=ce'} id="ce-logs-link"> - Compute Engine - </a> - </li> - <li> - <a href={window.baseUrl + '/api/system/logs?process=es'} id="es-logs-link"> - Elasticsearch - </a> - </li> - <li> - <a href={window.baseUrl + '/api/system/logs?process=web'} id="web-logs-link"> - Web Server - </a> - </li> - </ul> - </div> - <button - id="restart-server-button" - className="big-spacer-left" - onClick={this.handleServerRestart}> - Restart Server - </button> + return ( + <div className="page"> + <header className="page-header"> + <h1 className="page-title">{translate('system_info.page')}</h1> + <div className="page-actions"> + <a href={window.baseUrl + '/api/system/info'} id="download-link">Download</a> + <div className="display-inline-block dropdown big-spacer-left"> + <button data-toggle="dropdown">Logs <i className="icon-dropdown"/></button> + <ul className="dropdown-menu"> + <li> + <a href={window.baseUrl + '/api/system/logs?process=app'} id="logs-link"> + Main Process + </a> + </li> + <li> + <a href={window.baseUrl + '/api/system/logs?process=ce'} id="ce-logs-link"> + Compute Engine + </a> + </li> + <li> + <a href={window.baseUrl + '/api/system/logs?process=es'} id="es-logs-link"> + Elasticsearch + </a> + </li> + <li> + <a href={window.baseUrl + '/api/system/logs?process=web'} id="web-logs-link"> + Web Server + </a> + </li> + </ul> + </div> + <button + id="restart-server-button" + className="big-spacer-left" + onClick={this.handleServerRestart}> + Restart Server + </button> + </div> + </header> + {sections} </div> - </header> - {sections} - </div>; + ); } }); diff --git a/server/sonar-web/src/main/js/apps/system/section.js b/server/sonar-web/src/main/js/apps/system/section.js index 42d55466b31..d586946865e 100644 --- a/server/sonar-web/src/main/js/apps/system/section.js +++ b/server/sonar-web/src/main/js/apps/system/section.js @@ -21,21 +21,25 @@ import React from 'react'; import ItemValue from './item-value'; export default React.createClass({ - render() { + render () { const items = this.props.items.map(item => { - return <tr key={item.name}> - <td className="thin"> - <div style={{ width: '25vw', overflow: 'hidden', textOverflow: 'ellipsis' }}>{item.name}</div> - </td> - <td style={{ wordBreak: 'break-all' }}><ItemValue name={item.name} value={item.value}/></td> - </tr>; + return ( + <tr key={item.name}> + <td className="thin"> + <div style={{ width: '25vw', overflow: 'hidden', textOverflow: 'ellipsis' }}>{item.name}</div> + </td> + <td style={{ wordBreak: 'break-all' }}><ItemValue name={item.name} value={item.value}/></td> + </tr> + ); }); - return <div className="big-spacer-bottom"> - <h3 className="spacer-bottom">{this.props.section}</h3> - <table className="data zebra" id={this.props.section}> - <tbody>{items}</tbody> - </table> - </div>; + return ( + <div className="big-spacer-bottom"> + <h3 className="spacer-bottom">{this.props.section}</h3> + <table className="data zebra" id={this.props.section}> + <tbody>{items}</tbody> + </table> + </div> + ); } }); diff --git a/server/sonar-web/src/main/js/apps/update-center/init.js b/server/sonar-web/src/main/js/apps/update-center/init.js index 0c7fe76fe83..df0487d4f72 100644 --- a/server/sonar-web/src/main/js/apps/update-center/init.js +++ b/server/sonar-web/src/main/js/apps/update-center/init.js @@ -71,9 +71,7 @@ const init = function ({ el, updateCenterActive }) { }); }; -App.on('start', function (options) { - return init.call(App, options); -}); +App.on('start', options => init.call(App, options)); export default function (el, updateCenterActive) { App.start({ el, updateCenterActive }); diff --git a/server/sonar-web/src/main/js/apps/update-center/plugins.js b/server/sonar-web/src/main/js/apps/update-center/plugins.js index 868c7acdab7..1c7c261902b 100644 --- a/server/sonar-web/src/main/js/apps/update-center/plugins.js +++ b/server/sonar-web/src/main/js/apps/update-center/plugins.js @@ -38,23 +38,19 @@ const Plugins = Backbone.Collection.extend({ parse (r) { const that = this; - return r.plugins.map(function (plugin) { + return r.plugins.map(plugin => { let updates = [ that._getLastWithStatus(plugin.updates, 'COMPATIBLE'), that._getLastWithStatus(plugin.updates, 'REQUIRES_SYSTEM_UPGRADE'), that._getLastWithStatus(plugin.updates, 'DEPS_REQUIRE_SYSTEM_UPGRADE') ].filter(_.identity); - updates = updates.map(function (update) { - return that._extendChangelog(plugin.updates, update); - }); + updates = updates.map(update => that._extendChangelog(plugin.updates, update)); return _.extend(plugin, { updates }); }); }, _getLastWithStatus (updates, status) { - const index = _.findLastIndex(updates, function (update) { - return update.status === status; - }); + const index = _.findLastIndex(updates, update => update.status === status); return index !== -1 ? updates[index] : null; }, @@ -115,13 +111,13 @@ const Plugins = Backbone.Collection.extend({ type: 'GET', url: window.baseUrl + '/api/plugins/pending', success (r) { - const installing = r.installing.map(function (plugin) { + const installing = r.installing.map(plugin => { return { key: plugin.key, _status: 'installing' }; }); - const updating = r.updating.map(function (plugin) { + const updating = r.updating.map(plugin => { return { key: plugin.key, _status: 'updating' }; }); - const uninstalling = r.removing.map(function (plugin) { + const uninstalling = r.removing.map(plugin => { return { key: plugin.key, _status: 'uninstalling' }; }); that._installedCount = installing.length; @@ -142,9 +138,7 @@ const Plugins = Backbone.Collection.extend({ type: 'GET', url: window.baseUrl + '/api/system/upgrades', success (r) { - that._systemUpdates = r.upgrades.map(function (update) { - return _.extend(update, { _system: true }); - }); + that._systemUpdates = r.upgrades.map(update => _.extend(update, { _system: true })); } }; return Backbone.ajax(opts); @@ -152,7 +146,7 @@ const Plugins = Backbone.Collection.extend({ fetchInstalled () { const that = this; - return $.when(this._fetchInstalled(), this._fetchUpdates(), this._fetchPending()).done(function () { + return $.when(this._fetchInstalled(), this._fetchUpdates(), this._fetchPending()).done(() => { const plugins = new Plugins(); plugins.set(that._installed); plugins.set(that._updates, { remove: false }); @@ -164,7 +158,7 @@ const Plugins = Backbone.Collection.extend({ fetchUpdates () { const that = this; return $.when(this._fetchInstalled(), this._fetchUpdates(), this._fetchPending()) - .done(function () { + .done(() => { const plugins = new Plugins(); plugins.set(that._installed); plugins.set(that._updates, { remove: true }); @@ -175,7 +169,7 @@ const Plugins = Backbone.Collection.extend({ fetchAvailable () { const that = this; - return $.when(this._fetchAvailable(), this._fetchPending()).done(function () { + return $.when(this._fetchAvailable(), this._fetchPending()).done(() => { const plugins = new Plugins(); plugins.set(that._available); plugins.set(that._pending, { add: false, remove: false }); @@ -185,13 +179,14 @@ const Plugins = Backbone.Collection.extend({ fetchSystemUpgrades () { const that = this; - return $.when(this._fetchSystemUpgrades()).done(function () { + return $.when(this._fetchSystemUpgrades()).done(() => { that.reset(that._systemUpdates); }); }, search (query) { - this.filter(function (model) { + /* eslint-disable array-callback-return */ + this.filter(model => { model.set({ _hidden: !model.match(query) }); }); }, @@ -205,7 +200,7 @@ const Plugins = Backbone.Collection.extend({ that._installedCount = 0; that._updatedCount = 0; that._uninstalledCount = 0; - that.forEach(function (model) { + that.forEach(model => { model.unset('_status'); }); that.trigger('change'); diff --git a/server/sonar-web/src/main/js/apps/update-center/search-view.js b/server/sonar-web/src/main/js/apps/update-center/search-view.js index 2cf558354a8..c316eccdced 100644 --- a/server/sonar-web/src/main/js/apps/update-center/search-view.js +++ b/server/sonar-web/src/main/js/apps/update-center/search-view.js @@ -84,7 +84,7 @@ export default Marionette.ItemView.extend({ focusSearch () { const that = this; - setTimeout(function () { + setTimeout(() => { that.$('#update-center-search-query').focus(); }, 0); }, diff --git a/server/sonar-web/src/main/js/apps/users/change-password-view.js b/server/sonar-web/src/main/js/apps/users/change-password-view.js index fb8f29e3c04..c68e9aabe6b 100644 --- a/server/sonar-web/src/main/js/apps/users/change-password-view.js +++ b/server/sonar-web/src/main/js/apps/users/change-password-view.js @@ -43,9 +43,9 @@ export default ModalForm.extend({ // do not show global error 400: null } - }).done(function () { + }).done(() => { that.destroy(); - }).fail(function (jqXHR) { + }).fail(jqXHR => { that.enableForm(); that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings); }); diff --git a/server/sonar-web/src/main/js/apps/users/create-view.js b/server/sonar-web/src/main/js/apps/users/create-view.js index 8f1768c6a8d..7e233230bc7 100644 --- a/server/sonar-web/src/main/js/apps/users/create-view.js +++ b/server/sonar-web/src/main/js/apps/users/create-view.js @@ -38,10 +38,10 @@ export default FormView.extend({ 400: null, 500: null } - }).done(function () { + }).done(() => { that.collection.refresh(); that.destroy(); - }).fail(function (jqXHR) { + }).fail(jqXHR => { that.enableForm(); that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings); }); diff --git a/server/sonar-web/src/main/js/apps/users/deactivate-view.js b/server/sonar-web/src/main/js/apps/users/deactivate-view.js index 1a546ece3f2..4d3c9d2fad3 100644 --- a/server/sonar-web/src/main/js/apps/users/deactivate-view.js +++ b/server/sonar-web/src/main/js/apps/users/deactivate-view.js @@ -37,10 +37,10 @@ export default ModalForm.extend({ // do not show global error 400: null } - }).done(function () { + }).done(() => { collection.total--; that.destroy(); - }).fail(function (jqXHR) { + }).fail(jqXHR => { that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings); }); } diff --git a/server/sonar-web/src/main/js/apps/users/form-view.js b/server/sonar-web/src/main/js/apps/users/form-view.js index 80115329fd2..cbe625b6080 100644 --- a/server/sonar-web/src/main/js/apps/users/form-view.js +++ b/server/sonar-web/src/main/js/apps/users/form-view.js @@ -55,9 +55,7 @@ export default ModalForm.extend({ const scmAccounts = this.$('[name="scmAccounts"]').map(function () { return $(this).val(); }).toArray(); - return scmAccounts.filter(function (value) { - return !!value; - }); + return scmAccounts.filter(value => !!value); }, addScmAccount () { diff --git a/server/sonar-web/src/main/js/apps/users/init.js b/server/sonar-web/src/main/js/apps/users/init.js index 490ea231426..b0247eb0d09 100644 --- a/server/sonar-web/src/main/js/apps/users/init.js +++ b/server/sonar-web/src/main/js/apps/users/init.js @@ -18,7 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import Marionette from 'backbone.marionette'; - import Layout from './layout'; import Users from './users'; import HeaderView from './header-view'; @@ -57,7 +56,7 @@ const init = function ({ el, currentUser }, providers) { this.users.fetch(); }; -App.on('start', function (options) { +App.on('start', options => { getIdentityProviders().then(r => init.call(App, options, r.identityProviders)); }); diff --git a/server/sonar-web/src/main/js/apps/users/list-view.js b/server/sonar-web/src/main/js/apps/users/list-view.js index 3f557d76db8..6caa6cd8736 100644 --- a/server/sonar-web/src/main/js/apps/users/list-view.js +++ b/server/sonar-web/src/main/js/apps/users/list-view.js @@ -18,7 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import Marionette from 'backbone.marionette'; - import ListItemView from './list-item-view'; import Template from './templates/users-list.hbs'; diff --git a/server/sonar-web/src/main/js/apps/users/tokens-view.js b/server/sonar-web/src/main/js/apps/users/tokens-view.js index ff85d106652..8ffac0f2391 100644 --- a/server/sonar-web/src/main/js/apps/users/tokens-view.js +++ b/server/sonar-web/src/main/js/apps/users/tokens-view.js @@ -20,7 +20,6 @@ import $ from 'jquery'; import _ from 'underscore'; import Clipboard from 'clipboard'; - import Modal from '../../components/common/modals'; import Template from './templates/users-tokens.hbs'; import { getTokens, generateToken, revokeToken } from '../../api/user-tokens'; @@ -68,7 +67,7 @@ export default Modal.extend({ }); }, - onRevokeTokenFormSubmit(e) { + onRevokeTokenFormSubmit (e) { e.preventDefault(); const tokenName = $(e.currentTarget).data('token'); const token = _.findWhere(this.tokens, { name: `${tokenName}` }); @@ -100,7 +99,7 @@ export default Modal.extend({ Modal.prototype.onDestroy.apply(this, arguments); }, - serializeData() { + serializeData () { return _.extend(Modal.prototype.serializeData.apply(this, arguments), { tokens: this.tokens, newToken: this.newToken, diff --git a/server/sonar-web/src/main/js/apps/users/update-view.js b/server/sonar-web/src/main/js/apps/users/update-view.js index c010ed75376..72ab0bda372 100644 --- a/server/sonar-web/src/main/js/apps/users/update-view.js +++ b/server/sonar-web/src/main/js/apps/users/update-view.js @@ -34,10 +34,10 @@ export default FormView.extend({ // do not show global error 400: null } - }).done(function () { + }).done(() => { that.collection.refresh(); that.destroy(); - }).fail(function (jqXHR) { + }).fail(jqXHR => { that.enableForm(); that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings); }); diff --git a/server/sonar-web/src/main/js/apps/web-api/components/Action.js b/server/sonar-web/src/main/js/apps/web-api/components/Action.js index cfe3a6df465..b6d5165e9ee 100644 --- a/server/sonar-web/src/main/js/apps/web-api/components/Action.js +++ b/server/sonar-web/src/main/js/apps/web-api/components/Action.js @@ -19,7 +19,6 @@ */ import React from 'react'; import { Link } from 'react-router'; - import { getActionKey } from '../utils'; import Params from './Params'; import ResponseExample from './ResponseExample'; diff --git a/server/sonar-web/src/main/js/apps/web-api/components/DeprecatedBadge.js b/server/sonar-web/src/main/js/apps/web-api/components/DeprecatedBadge.js index bf7b8c0d235..8680de0f2b1 100644 --- a/server/sonar-web/src/main/js/apps/web-api/components/DeprecatedBadge.js +++ b/server/sonar-web/src/main/js/apps/web-api/components/DeprecatedBadge.js @@ -18,7 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; - import { translate } from '../../../helpers/l10n'; export default function DeprecatedBadge ({ since }) { diff --git a/server/sonar-web/src/main/js/apps/web-api/components/Domain.js b/server/sonar-web/src/main/js/apps/web-api/components/Domain.js index 6fd54950711..6bfed0921c5 100644 --- a/server/sonar-web/src/main/js/apps/web-api/components/Domain.js +++ b/server/sonar-web/src/main/js/apps/web-api/components/Domain.js @@ -18,7 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; - import Action from './Action'; import InternalBadge from './InternalBadge'; import { getActionKey } from '../utils'; diff --git a/server/sonar-web/src/main/js/apps/web-api/components/InternalBadge.js b/server/sonar-web/src/main/js/apps/web-api/components/InternalBadge.js index 013af802b04..0602d7d0e68 100644 --- a/server/sonar-web/src/main/js/apps/web-api/components/InternalBadge.js +++ b/server/sonar-web/src/main/js/apps/web-api/components/InternalBadge.js @@ -18,7 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; - import { translate } from '../../../helpers/l10n'; export default function InternalBadge () { diff --git a/server/sonar-web/src/main/js/apps/web-api/components/Params.js b/server/sonar-web/src/main/js/apps/web-api/components/Params.js index 68649ad2a8b..623eba819f2 100644 --- a/server/sonar-web/src/main/js/apps/web-api/components/Params.js +++ b/server/sonar-web/src/main/js/apps/web-api/components/Params.js @@ -18,7 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; - import InternalBadge from './InternalBadge'; import DeprecatedBadge from './DeprecatedBadge'; diff --git a/server/sonar-web/src/main/js/apps/web-api/components/ResponseExample.js b/server/sonar-web/src/main/js/apps/web-api/components/ResponseExample.js index 70e1791c5b2..177be23b4f8 100644 --- a/server/sonar-web/src/main/js/apps/web-api/components/ResponseExample.js +++ b/server/sonar-web/src/main/js/apps/web-api/components/ResponseExample.js @@ -18,7 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; - import { fetchResponseExample as fetchResponseExampleApi } from '../../../api/web-api'; export default class ResponseExample extends React.Component { diff --git a/server/sonar-web/src/main/js/apps/web-api/components/Search.js b/server/sonar-web/src/main/js/apps/web-api/components/Search.js index 0784a4a33ea..51f29c7dfa6 100644 --- a/server/sonar-web/src/main/js/apps/web-api/components/Search.js +++ b/server/sonar-web/src/main/js/apps/web-api/components/Search.js @@ -19,7 +19,6 @@ */ import _ from 'underscore'; import React from 'react'; - import Checkbox from '../../../components/controls/Checkbox'; import { TooltipsContainer } from '../../../components/mixins/tooltips-mixin'; import { translate } from '../../../helpers/l10n'; @@ -66,6 +65,9 @@ export default class Search extends React.Component { <span style={{ cursor: 'pointer' }} title={translate('api_documentation.internal_tooltip')} + tabIndex="0" + role="checkbox" + aria-checked={showInternal ? 'true' : 'false'} onClick={onToggleInternal}> Show Internal API </span> @@ -85,6 +87,9 @@ export default class Search extends React.Component { <span style={{ cursor: 'pointer' }} title={translate('api_documentation.deprecation_tooltip')} + tabIndex="0" + role="checkbox" + aria-checked={showOnlyDeprecated ? 'true' : 'false'} onClick={onToggleDeprecated}> Show Only Deprecated API </span> diff --git a/server/sonar-web/src/main/js/components/RestartModal/index.js b/server/sonar-web/src/main/js/components/RestartModal/index.js index 3419139b365..b26ac03b263 100644 --- a/server/sonar-web/src/main/js/components/RestartModal/index.js +++ b/server/sonar-web/src/main/js/components/RestartModal/index.js @@ -26,15 +26,15 @@ const RestartModal = ModalForm.extend({ template: Template, restartingTemplate: RestartingTemplate, - initialize() { + initialize () { this.restarting = false; }, - getTemplate() { + getTemplate () { return this.restarting ? this.restartingTemplate : this.template; }, - onFormSubmit() { + onFormSubmit () { ModalForm.prototype.onFormSubmit.apply(this, arguments); this.restarting = true; this.render(); diff --git a/server/sonar-web/src/main/js/components/SelectList/index.js b/server/sonar-web/src/main/js/components/SelectList/index.js index e99ea016146..a2b155c2437 100644 --- a/server/sonar-web/src/main/js/components/SelectList/index.js +++ b/server/sonar-web/src/main/js/components/SelectList/index.js @@ -134,12 +134,12 @@ const SelectListItemView = Backbone.View.extend({ 403: null, 500: null } - }).done(function () { + }).done(() => { that.model.set('selected', !selected); - }).fail(function (jqXHR) { + }).fail(jqXHR => { that.render(); showError(jqXHR); - }).always(function () { + }).always(() => { that.$el.removeClass('progress'); }); } @@ -202,7 +202,7 @@ const SelectListView = Backbone.View.extend({ this.$listContainer .height(this.settings.height) .css('overflow', 'auto') - .on('scroll', function () { + .on('scroll', () => { that.scroll(); }); } else { @@ -216,7 +216,7 @@ const SelectListView = Backbone.View.extend({ .on('search', _.debounce(keyup, 250)); if (this.settings.focusSearch) { - setTimeout(function () { + setTimeout(() => { searchInput.focus(); }, 250); } @@ -241,16 +241,14 @@ const SelectListView = Backbone.View.extend({ }, renderList () { - this.listItemViews.forEach(function (view) { + this.listItemViews.forEach(view => { view.remove(); }); this.listItemViews = []; if (this.collection.length > 0) { this.collection.each(this.renderListItem, this); - } else { - if (this.settings.readOnly) { - this.renderEmpty(); - } + } else if (this.settings.readOnly) { + this.renderEmpty(); } this.$listContainer.scrollTop(0); }, diff --git a/server/sonar-web/src/main/js/components/__tests__/issue-test.js b/server/sonar-web/src/main/js/components/__tests__/issue-test.js index 66f124afaf1..e118eb920d3 100644 --- a/server/sonar-web/src/main/js/components/__tests__/issue-test.js +++ b/server/sonar-web/src/main/js/components/__tests__/issue-test.js @@ -19,59 +19,59 @@ */ import Issue from '../issue/models/issue'; -describe('Model', function () { - it('should have correct urlRoot', function () { +describe('Model', () => { + it('should have correct urlRoot', () => { const issue = new Issue(); expect(issue.urlRoot()).toBe('/api/issues'); }); - it('should parse response without root issue object', function () { + it('should parse response without root issue object', () => { const issue = new Issue(); const example = { a: 1 }; expect(issue.parse(example)).toEqual(example); }); - it('should parse response with the root issue object', function () { + it('should parse response with the root issue object', () => { const issue = new Issue(); const example = { a: 1 }; expect(issue.parse({ issue: example })).toEqual(example); }); - it('should reset attributes (no attributes initially)', function () { + it('should reset attributes (no attributes initially)', () => { const issue = new Issue(); const example = { a: 1 }; issue.reset(example); expect(issue.toJSON()).toEqual(example); }); - it('should reset attributes (override attribute)', function () { + it('should reset attributes (override attribute)', () => { const issue = new Issue({ a: 2 }); const example = { a: 1 }; issue.reset(example); expect(issue.toJSON()).toEqual(example); }); - it('should reset attributes (different attributes)', function () { + it('should reset attributes (different attributes)', () => { const issue = new Issue({ a: 2 }); const example = { b: 1 }; issue.reset(example); expect(issue.toJSON()).toEqual(example); }); - it('should unset `textRange` of a closed issue', function () { + it('should unset `textRange` of a closed issue', () => { const issue = new Issue(); const result = issue.parse({ issue: { status: 'CLOSED', textRange: { startLine: 5 } } }); expect(result.textRange).toBeFalsy(); }); - it('should unset `flows` of a closed issue', function () { + it('should unset `flows` of a closed issue', () => { const issue = new Issue(); const result = issue.parse({ issue: { status: 'CLOSED', flows: [1, 2, 3] } }); expect(result.flows).toEqual([]); }); - describe('Actions', function () { - it('should assign', function () { + describe('Actions', () => { + it('should assign', () => { const issue = new Issue({ key: 'issue-key' }); const spy = jest.fn(); issue._action = spy; @@ -82,7 +82,7 @@ describe('Model', function () { }); }); - it('should unassign', function () { + it('should unassign', () => { const issue = new Issue({ key: 'issue-key' }); const spy = jest.fn(); issue._action = spy; @@ -93,7 +93,7 @@ describe('Model', function () { }); }); - it('should plan', function () { + it('should plan', () => { const issue = new Issue({ key: 'issue-key' }); const spy = jest.fn(); issue._action = spy; @@ -101,7 +101,7 @@ describe('Model', function () { expect(spy).toBeCalledWith({ data: { plan: 'plan', issue: 'issue-key' }, url: '/api/issues/plan' }); }); - it('should unplan', function () { + it('should unplan', () => { const issue = new Issue({ key: 'issue-key' }); const spy = jest.fn(); issue._action = spy; @@ -109,7 +109,7 @@ describe('Model', function () { expect(spy).toBeCalledWith({ data: { plan: undefined, issue: 'issue-key' }, url: '/api/issues/plan' }); }); - it('should set severity', function () { + it('should set severity', () => { const issue = new Issue({ key: 'issue-key' }); const spy = jest.fn(); issue._action = spy; @@ -121,8 +121,8 @@ describe('Model', function () { }); }); - describe('#getLinearLocations', function () { - it('should return single line location', function () { + describe('#getLinearLocations', () => { + it('should return single line location', () => { const issue = new Issue({ textRange: { startLine: 1, endLine: 1, startOffset: 0, endOffset: 10 } }); const locations = issue.getLinearLocations(); expect(locations.length).toBe(1); @@ -132,7 +132,7 @@ describe('Model', function () { expect(locations[0].to).toBe(10); }); - it('should return location not from 0', function () { + it('should return location not from 0', () => { const issue = new Issue({ textRange: { startLine: 1, endLine: 1, startOffset: 5, endOffset: 10 } }); const locations = issue.getLinearLocations(); expect(locations.length).toBe(1); @@ -142,7 +142,7 @@ describe('Model', function () { expect(locations[0].to).toBe(10); }); - it('should return 2-lines location', function () { + it('should return 2-lines location', () => { const issue = new Issue({ textRange: { startLine: 2, endLine: 3, startOffset: 5, endOffset: 10 } }); const locations = issue.getLinearLocations(); expect(locations.length).toBe(2); @@ -156,7 +156,7 @@ describe('Model', function () { expect(locations[1].to).toBe(10); }); - it('should return 3-lines location', function () { + it('should return 3-lines location', () => { const issue = new Issue({ textRange: { startLine: 4, endLine: 6, startOffset: 5, endOffset: 10 } }); const locations = issue.getLinearLocations(); expect(locations.length).toBe(3); @@ -174,7 +174,7 @@ describe('Model', function () { expect(locations[2].to).toBe(10); }); - it('should return [] when no location', function () { + it('should return [] when no location', () => { const issue = new Issue(); const locations = issue.getLinearLocations(); expect(locations.length).toBe(0); diff --git a/server/sonar-web/src/main/js/components/__tests__/source-viewer-test.js b/server/sonar-web/src/main/js/components/__tests__/source-viewer-test.js index 5d27c5ad0b1..a3ef162d994 100644 --- a/server/sonar-web/src/main/js/components/__tests__/source-viewer-test.js +++ b/server/sonar-web/src/main/js/components/__tests__/source-viewer-test.js @@ -19,12 +19,12 @@ */ import helper from '../source-viewer/helpers/code-with-issue-locations-helper'; -describe('Code With Issue Locations Helper', function () { - it('should be a function', function () { +describe('Code With Issue Locations Helper', () => { + it('should be a function', () => { expect(helper).toBeTruthy(); }); - it('should mark one location', function () { + it('should mark one location', () => { const code = '<span class="k">if</span> (<span class="sym-2 sym">a</span> + <span class="c">1</span>) {'; const locations = [{ from: 1, to: 5 }]; const result = helper(code, locations, 'x'); @@ -39,7 +39,7 @@ describe('Code With Issue Locations Helper', function () { ].join('')); }); - it('should mark two locations', function () { + it('should mark two locations', () => { const code = 'abcdefghijklmnopqrst'; const locations = [ { from: 1, to: 6 }, @@ -55,7 +55,7 @@ describe('Code With Issue Locations Helper', function () { ].join('')); }); - it('should mark one locations', function () { + it('should mark one locations', () => { const code = '<span class="cppd"> * Copyright (C) 2008-2014 SonarSource</span>'; const locations = [{ from: 15, to: 20 }]; const result = helper(code, locations, 'x'); @@ -66,7 +66,7 @@ describe('Code With Issue Locations Helper', function () { ].join('')); }); - it('should mark two locations', function () { + it('should mark two locations', () => { const code = '<span class="cppd"> * Copyright (C) 2008-2014 SonarSource</span>'; const locations = [ { from: 24, to: 29 }, @@ -82,20 +82,20 @@ describe('Code With Issue Locations Helper', function () { ].join('')); }); - it('should parse line with < and >', function () { + it('should parse line with < and >', () => { const code = '<span class="j">#include <stdio.h></span>'; const result = helper(code, []); expect(result).toBe('<span class="j">#include <stdio.h></span>'); }); - it('should parse syntax and usage highlighting', function () { + it('should parse syntax and usage highlighting', () => { const code = '<span class="k"><span class="sym-3 sym">this</span></span>'; const expected = '<span class="k sym-3 sym">this</span>'; const result = helper(code, []); expect(result).toBe(expected); }); - it('should parse nested tags', function () { + it('should parse nested tags', () => { const code = '<span class="k"><span class="sym-3 sym">this</span> is</span>'; const expected = '<span class="k sym-3 sym">this</span><span class="k"> is</span>'; const result = helper(code, []); diff --git a/server/sonar-web/src/main/js/components/charts/LanguageDistribution.js b/server/sonar-web/src/main/js/components/charts/LanguageDistribution.js index 5105fca04b8..7a3376549f4 100644 --- a/server/sonar-web/src/main/js/components/charts/LanguageDistribution.js +++ b/server/sonar-web/src/main/js/components/charts/LanguageDistribution.js @@ -21,7 +21,6 @@ import find from 'lodash/find'; import sortBy from 'lodash/sortBy'; import React from 'react'; import shallowCompare from 'react-addons-shallow-compare'; - import { Histogram } from './histogram'; import { formatMeasure } from '../../helpers/measures'; import { getLanguages } from '../../api/languages'; diff --git a/server/sonar-web/src/main/js/components/charts/Timeline.js b/server/sonar-web/src/main/js/components/charts/Timeline.js index 8688f458d3e..1a5690953f7 100644 --- a/server/sonar-web/src/main/js/components/charts/Timeline.js +++ b/server/sonar-web/src/main/js/components/charts/Timeline.js @@ -22,7 +22,6 @@ import _ from 'underscore'; import d3 from 'd3'; import moment from 'moment'; import React from 'react'; - import { ResizeMixin } from '../mixins/resize-mixin'; import { TooltipsMixin } from '../mixins/tooltips-mixin'; diff --git a/server/sonar-web/src/main/js/components/charts/__tests__/bar-chart-test.js b/server/sonar-web/src/main/js/components/charts/__tests__/bar-chart-test.js index 5b0d0b2abfb..e3818f21031 100644 --- a/server/sonar-web/src/main/js/components/charts/__tests__/bar-chart-test.js +++ b/server/sonar-web/src/main/js/components/charts/__tests__/bar-chart-test.js @@ -21,7 +21,7 @@ import React from 'react'; import { shallow } from 'enzyme'; import { BarChart } from '../bar-chart'; -it('should display bars', function () { +it('should display bars', () => { const data = [ { x: 1, y: 10 }, { x: 2, y: 30 }, @@ -36,7 +36,7 @@ it('should display bars', function () { expect(chart.find('.bar-chart-bar').length).toBe(3); }); -it('should display ticks', function () { +it('should display ticks', () => { const data = [ { x: 1, y: 10 }, { x: 2, y: 30 }, @@ -53,7 +53,7 @@ it('should display ticks', function () { expect(chart.find('.bar-chart-tick').length).toBe(3); }); -it('should display values', function () { +it('should display values', () => { const data = [ { x: 1, y: 10 }, { x: 2, y: 30 }, @@ -70,7 +70,7 @@ it('should display values', function () { expect(chart.find('.bar-chart-tick').length).toBe(3); }); -it('should display bars, ticks and values', function () { +it('should display bars, ticks and values', () => { const data = [ { x: 1, y: 10 }, { x: 2, y: 30 }, diff --git a/server/sonar-web/src/main/js/components/charts/__tests__/line-chart-test.js b/server/sonar-web/src/main/js/components/charts/__tests__/line-chart-test.js index adbe6ce3462..9e0afab5e1b 100644 --- a/server/sonar-web/src/main/js/components/charts/__tests__/line-chart-test.js +++ b/server/sonar-web/src/main/js/components/charts/__tests__/line-chart-test.js @@ -21,7 +21,7 @@ import React from 'react'; import { shallow } from 'enzyme'; import { LineChart } from '../line-chart'; -it('should display line', function () { +it('should display line', () => { const data = [ { x: 1, y: 10 }, { x: 2, y: 30 }, @@ -31,7 +31,7 @@ it('should display line', function () { expect(chart.find('.line-chart-path').length).toBe(1); }); -it('should display ticks', function () { +it('should display ticks', () => { const data = [ { x: 1, y: 10 }, { x: 2, y: 30 }, @@ -47,7 +47,7 @@ it('should display ticks', function () { expect(chart.find('.line-chart-tick').length).toBe(3); }); -it('should display values', function () { +it('should display values', () => { const data = [ { x: 1, y: 10 }, { x: 2, y: 30 }, diff --git a/server/sonar-web/src/main/js/components/charts/__tests__/treemap-test.js b/server/sonar-web/src/main/js/components/charts/__tests__/treemap-test.js index ac5c72039a5..d7ef0a8d416 100644 --- a/server/sonar-web/src/main/js/components/charts/__tests__/treemap-test.js +++ b/server/sonar-web/src/main/js/components/charts/__tests__/treemap-test.js @@ -21,7 +21,7 @@ import React from 'react'; import { shallow } from 'enzyme'; import { Treemap, TreemapRect } from '../treemap'; -it('should display', function () { +it('should display', () => { const items = [ { size: 10, color: '#777', label: 'SonarQube :: Server' }, { size: 30, color: '#777', label: 'SonarQube :: Web' }, diff --git a/server/sonar-web/src/main/js/components/charts/__tests__/work-cloud-test.js b/server/sonar-web/src/main/js/components/charts/__tests__/work-cloud-test.js index 4ba52d60c34..b1be80c8159 100644 --- a/server/sonar-web/src/main/js/components/charts/__tests__/work-cloud-test.js +++ b/server/sonar-web/src/main/js/components/charts/__tests__/work-cloud-test.js @@ -21,7 +21,7 @@ import React from 'react'; import { shallow } from 'enzyme'; import { WordCloud, Word } from '../word-cloud'; -it('should display', function () { +it('should display', () => { const items = [ { size: 10, link: '#', text: 'SonarQube :: Server' }, { size: 30, link: '#', text: 'SonarQube :: Web' }, diff --git a/server/sonar-web/src/main/js/components/charts/bar-chart.js b/server/sonar-web/src/main/js/components/charts/bar-chart.js index 748474b25ad..c7a758a52bd 100644 --- a/server/sonar-web/src/main/js/components/charts/bar-chart.js +++ b/server/sonar-web/src/main/js/components/charts/bar-chart.js @@ -19,7 +19,6 @@ */ import d3 from 'd3'; import React from 'react'; - import { ResizeMixin } from './../mixins/resize-mixin'; import { TooltipsMixin } from './../mixins/tooltips-mixin'; @@ -36,7 +35,7 @@ export const BarChart = React.createClass({ mixins: [ResizeMixin, TooltipsMixin], - getDefaultProps() { + getDefaultProps () { return { xTicks: [], xValues: [], @@ -48,7 +47,7 @@ export const BarChart = React.createClass({ return { width: this.props.width, height: this.props.height }; }, - handleClick(point) { + handleClick (point) { this.props.onBarClick(point); }, @@ -66,14 +65,19 @@ export const BarChart = React.createClass({ tooltipAtts['title'] = d.tooltip; tooltipAtts['data-toggle'] = 'tooltip'; } - return <text key={index} - className="bar-chart-tick" - x={x} - y={y} - dy="1.5em" - onClick={this.props.onBarClick && this.handleClick.bind(this, point)} - style={{ cursor: this.props.onBarClick ? 'pointer' : 'default' }} - {...tooltipAtts}>{tick}</text>; + return ( + <text + key={index} + className="bar-chart-tick" + x={x} + y={y} + dy="1.5em" + onClick={this.props.onBarClick && this.handleClick.bind(this, point)} + style={{ cursor: this.props.onBarClick ? 'pointer' : 'default' }} + {...tooltipAtts}> + {tick} + </text> + ); }); return <g>{ticks}</g>; }, @@ -92,14 +96,19 @@ export const BarChart = React.createClass({ tooltipAtts['title'] = d.tooltip; tooltipAtts['data-toggle'] = 'tooltip'; } - return <text key={index} - className="bar-chart-tick" - x={x} - y={y} - dy="-1em" - onClick={this.props.onBarClick && this.handleClick.bind(this, point)} - style={{ cursor: this.props.onBarClick ? 'pointer' : 'default' }} - {...tooltipAtts}>{value}</text>; + return ( + <text + key={index} + className="bar-chart-tick" + x={x} + y={y} + dy="-1em" + onClick={this.props.onBarClick && this.handleClick.bind(this, point)} + style={{ cursor: this.props.onBarClick ? 'pointer' : 'default' }} + {...tooltipAtts}> + {value} + </text> + ); }); return <g>{ticks}</g>; }, @@ -115,15 +124,18 @@ export const BarChart = React.createClass({ tooltipAtts['title'] = d.tooltip; tooltipAtts['data-toggle'] = 'tooltip'; } - return <rect key={index} - className="bar-chart-bar" - {...tooltipAtts} - x={x} - y={y} - width={this.props.barsWidth} - height={height} - onClick={this.props.onBarClick && this.handleClick.bind(this, d)} - style={{ cursor: this.props.onBarClick ? 'pointer' : 'default' }}/>; + return ( + <rect + key={index} + className="bar-chart-bar" + {...tooltipAtts} + x={x} + y={y} + width={this.props.barsWidth} + height={height} + onClick={this.props.onBarClick && this.handleClick.bind(this, d)} + style={{ cursor: this.props.onBarClick ? 'pointer' : 'default' }}/> + ); }); return <g>{bars}</g>; }, @@ -148,12 +160,14 @@ export const BarChart = React.createClass({ .domain([0, maxY]) .range([availableHeight, 0]); - return <svg className="bar-chart" width={this.state.width} height={this.state.height}> - <g transform={`translate(${this.props.padding[3]}, ${this.props.padding[0]})`}> - {this.renderXTicks(xScale, yScale)} - {this.renderXValues(xScale, yScale)} - {this.renderBars(xScale, yScale)} - </g> - </svg>; + return ( + <svg className="bar-chart" width={this.state.width} height={this.state.height}> + <g transform={`translate(${this.props.padding[3]}, ${this.props.padding[0]})`}> + {this.renderXTicks(xScale, yScale)} + {this.renderXValues(xScale, yScale)} + {this.renderBars(xScale, yScale)} + </g> + </svg> + ); } }); diff --git a/server/sonar-web/src/main/js/components/charts/bubble-chart.js b/server/sonar-web/src/main/js/components/charts/bubble-chart.js index 3956e2ea7cd..e2516522b98 100644 --- a/server/sonar-web/src/main/js/components/charts/bubble-chart.js +++ b/server/sonar-web/src/main/js/components/charts/bubble-chart.js @@ -20,7 +20,6 @@ import _ from 'underscore'; import d3 from 'd3'; import React from 'react'; - import { ResizeMixin } from './../mixins/resize-mixin'; import { TooltipsMixin } from './../mixins/tooltips-mixin'; @@ -49,9 +48,11 @@ export const Bubble = React.createClass({ 'title': this.props.tooltip }; } - return <circle onClick={this.handleClick} className="bubble-chart-bubble" - r={this.props.r} {...tooltipAttrs} - transform={`translate(${this.props.x}, ${this.props.y})`}/>; + return ( + <circle onClick={this.handleClick} className="bubble-chart-bubble" + r={this.props.r} {...tooltipAttrs} + transform={`translate(${this.props.x}, ${this.props.y})`}/> + ); } }); @@ -72,7 +73,7 @@ export const BubbleChart = React.createClass({ mixins: [ResizeMixin, TooltipsMixin], - getDefaultProps() { + getDefaultProps () { return { sizeRange: [5, 45], displayXGrid: true, @@ -85,7 +86,7 @@ export const BubbleChart = React.createClass({ }; }, - getInitialState() { + getInitialState () { return { width: this.props.width, height: this.props.height }; }, @@ -105,7 +106,7 @@ export const BubbleChart = React.createClass({ return [availableHeight - dMaxY, dMinY]; }, - getTicks(scale, format) { + getTicks (scale, format) { const ticks = scale.ticks(TICKS_COUNT).map(tick => format(tick)); const uniqueTicksCount = _.uniq(ticks).length; const ticksCount = uniqueTicksCount < TICKS_COUNT ? uniqueTicksCount - 1 : TICKS_COUNT; @@ -121,12 +122,15 @@ export const BubbleChart = React.createClass({ const x = xScale(tick); const y1 = yScale.range()[0]; const y2 = yScale.range()[1]; - return <line key={index} - x1={x} - x2={x} - y1={y1} - y2={y2} - className="bubble-chart-grid"/>; + return ( + <line + key={index} + x1={x} + x2={x} + y1={y1} + y2={y2} + className="bubble-chart-grid"/> + ); }); return <g ref="xGrid">{lines}</g>; @@ -141,12 +145,15 @@ export const BubbleChart = React.createClass({ const y = yScale(tick); const x1 = xScale.range()[0]; const x2 = xScale.range()[1]; - return <line key={index} - x1={x1} - x2={x2} - y1={y} - y2={y} - className="bubble-chart-grid"/>; + return ( + <line + key={index} + x1={x1} + x2={x2} + y1={y} + y2={y} + className="bubble-chart-grid"/> + ); }); return <g ref="yGrid">{lines}</g>; @@ -161,11 +168,16 @@ export const BubbleChart = React.createClass({ const x = xScale(tick); const y = yScale.range()[0]; const innerText = this.props.formatXTick(tick); - return <text key={index} - className="bubble-chart-tick" - x={x} - y={y} - dy="1.5em">{innerText}</text>; + return ( + <text + key={index} + className="bubble-chart-tick" + x={x} + y={y} + dy="1.5em"> + {innerText} + </text> + ); }); return <g>{ticks}</g>; @@ -180,12 +192,17 @@ export const BubbleChart = React.createClass({ const x = xScale.range()[0]; const y = yScale(tick); const innerText = this.props.formatYTick(tick); - return <text key={index} - className="bubble-chart-tick bubble-chart-tick-y" - x={x} - y={y} - dx="-0.5em" - dy="0.3em">{innerText}</text>; + return ( + <text + key={index} + className="bubble-chart-tick bubble-chart-tick-y" + x={x} + y={y} + dx="-0.5em" + dy="0.3em"> + {innerText} + </text> + ); }); return <g>{ticks}</g>; @@ -219,24 +236,29 @@ export const BubbleChart = React.createClass({ const bubbles = _.sortBy(this.props.items, (a, b) => b.size - a.size) .map((item, index) => { - return <Bubble key={index} - link={item.link} - tooltip={item.tooltip} - x={xScale(item.x)} y={yScale(item.y)} r={sizeScale(item.size)} - onClick={this.props.onBubbleClick}/>; + return ( + <Bubble + key={index} + link={item.link} + tooltip={item.tooltip} + x={xScale(item.x)} y={yScale(item.y)} r={sizeScale(item.size)} + onClick={this.props.onBubbleClick}/> + ); }); const xTicks = this.getTicks(xScale, this.props.formatXTick); const yTicks = this.getTicks(yScale, this.props.formatYTick); - return <svg className="bubble-chart" width={this.state.width} height={this.state.height}> - <g transform={`translate(${this.props.padding[3]}, ${this.props.padding[0]})`}> - {this.renderXGrid(xTicks, xScale, yScale)} - {this.renderXTicks(xTicks, xScale, yScaleOriginal)} - {this.renderYGrid(yTicks, xScale, yScale)} - {this.renderYTicks(yTicks, xScaleOriginal, yScale)} - {bubbles} - </g> - </svg>; + return ( + <svg className="bubble-chart" width={this.state.width} height={this.state.height}> + <g transform={`translate(${this.props.padding[3]}, ${this.props.padding[0]})`}> + {this.renderXGrid(xTicks, xScale, yScale)} + {this.renderXTicks(xTicks, xScale, yScaleOriginal)} + {this.renderYGrid(yTicks, xScale, yScale)} + {this.renderYTicks(yTicks, xScaleOriginal, yScale)} + {bubbles} + </g> + </svg> + ); } }); diff --git a/server/sonar-web/src/main/js/components/charts/donut-chart.js b/server/sonar-web/src/main/js/components/charts/donut-chart.js index 3d3ce08e983..c4338533f85 100644 --- a/server/sonar-web/src/main/js/components/charts/donut-chart.js +++ b/server/sonar-web/src/main/js/components/charts/donut-chart.js @@ -19,12 +19,11 @@ */ import d3 from 'd3'; import React from 'react'; - import { ResizeMixin } from './../mixins/resize-mixin'; import { TooltipsMixin } from './../mixins/tooltips-mixin'; const Sector = React.createClass({ - render() { + render () { const arc = d3.svg.arc() .outerRadius(this.props.radius) .innerRadius(this.props.radius - this.props.thickness); @@ -39,11 +38,11 @@ export const DonutChart = React.createClass({ mixins: [ResizeMixin, TooltipsMixin], - getDefaultProps() { + getDefaultProps () { return { thickness: 6, padding: [0, 0, 0, 0] }; }, - getInitialState() { + getInitialState () { return { width: this.props.width, height: this.props.height }; }, @@ -62,19 +61,24 @@ export const DonutChart = React.createClass({ .sort(null) .value(d => d.value); const sectors = pie(this.props.data).map((d, i) => { - return <Sector key={i} - data={d} - radius={radius} - fill={this.props.data[i].fill} - thickness={this.props.thickness}/>; + return ( + <Sector + key={i} + data={d} + radius={radius} + fill={this.props.data[i].fill} + thickness={this.props.thickness}/> + ); }); - return <svg className="donut-chart" width={this.state.width} height={this.state.height}> - <g transform={`translate(${this.props.padding[3]}, ${this.props.padding[0]})`}> - <g transform={`translate(${radius}, ${radius})`}> - {sectors} - </g> - </g> - </svg>; + return ( + <svg className="donut-chart" width={this.state.width} height={this.state.height}> + <g transform={`translate(${this.props.padding[3]}, ${this.props.padding[0]})`}> + <g transform={`translate(${radius}, ${radius})`}> + {sectors} + </g> + </g> + </svg> + ); } }); diff --git a/server/sonar-web/src/main/js/components/charts/histogram.js b/server/sonar-web/src/main/js/components/charts/histogram.js index 2fdcfea8d21..3b8bc0c45b1 100644 --- a/server/sonar-web/src/main/js/components/charts/histogram.js +++ b/server/sonar-web/src/main/js/components/charts/histogram.js @@ -19,7 +19,6 @@ */ import d3 from 'd3'; import React from 'react'; - import { ResizeMixin } from './../mixins/resize-mixin'; import { TooltipsMixin } from './../mixins/tooltips-mixin'; @@ -37,7 +36,7 @@ export const Histogram = React.createClass({ mixins: [ResizeMixin, TooltipsMixin], - getDefaultProps() { + getDefaultProps () { return { xTicks: [], xValues: [], @@ -50,7 +49,7 @@ export const Histogram = React.createClass({ return { width: this.props.width, height: this.props.height }; }, - handleClick(point) { + handleClick (point) { this.props.onBarClick(point); }, @@ -64,19 +63,21 @@ export const Histogram = React.createClass({ const y = Math.round(yScale(point.y) + yScale.rangeBand() / 2 + this.props.barsHeight / 2); const label = tick.label ? tick.label : tick; const tooltip = tick.tooltip ? tick.tooltip : null; - return <text - key={index} - className="bar-chart-tick histogram-tick" - onClick={this.props.onBarClick && this.handleClick.bind(this, point)} - style={{ cursor: this.props.onBarClick ? 'pointer' : 'default' }} - data-title={tooltip} - data-toggle={tooltip ? 'tooltip' : null} - x={x} - y={y} - dx="-1em" - dy="0.3em"> - {label} - </text>; + return ( + <text + key={index} + className="bar-chart-tick histogram-tick" + onClick={this.props.onBarClick && this.handleClick.bind(this, point)} + style={{ cursor: this.props.onBarClick ? 'pointer' : 'default' }} + data-title={tooltip} + data-toggle={tooltip ? 'tooltip' : null} + x={x} + y={y} + dx="-1em" + dy="0.3em"> + {label} + </text> + ); }); return <g>{ticks}</g>; }, @@ -89,14 +90,19 @@ export const Histogram = React.createClass({ const point = this.props.data[index]; const x = xScale(point.x); const y = Math.round(yScale(point.y) + yScale.rangeBand() / 2 + this.props.barsHeight / 2); - return <text key={index} - onClick={this.props.onBarClick && this.handleClick.bind(this, point)} - className="bar-chart-tick histogram-value" - style={{ cursor: this.props.onBarClick ? 'pointer' : 'default' }} - x={x} - y={y} - dx="1em" - dy="0.3em">{value}</text>; + return ( + <text + key={index} + onClick={this.props.onBarClick && this.handleClick.bind(this, point)} + className="bar-chart-tick histogram-value" + style={{ cursor: this.props.onBarClick ? 'pointer' : 'default' }} + x={x} + y={y} + dx="1em" + dy="0.3em"> + {value} + </text> + ); }); return <g>{ticks}</g>; }, @@ -105,14 +111,17 @@ export const Histogram = React.createClass({ const bars = this.props.data.map((d, index) => { const x = Math.round(xScale(d.x)) + /* minimum bar width */ 1; const y = Math.round(yScale(d.y) + yScale.rangeBand() / 2); - return <rect key={index} - className="bar-chart-bar" - onClick={this.props.onBarClick && this.handleClick.bind(this, d)} - style={{ cursor: this.props.onBarClick ? 'pointer' : 'default' }} - x={0} - y={y} - width={x} - height={this.props.barsHeight}/>; + return ( + <rect + key={index} + className="bar-chart-bar" + onClick={this.props.onBarClick && this.handleClick.bind(this, d)} + style={{ cursor: this.props.onBarClick ? 'pointer' : 'default' }} + x={0} + y={y} + width={x} + height={this.props.barsHeight}/> + ); }); return <g>{bars}</g>; }, @@ -133,12 +142,14 @@ export const Histogram = React.createClass({ .domain(this.props.data.map(d => d.y)) .rangeRoundBands([0, availableHeight]); - return <svg className="bar-chart" width={this.state.width} height={this.state.height}> - <g transform={`translate(${this.props.padding[3]}, ${this.props.padding[0]})`}> - {this.renderTicks(xScale, yScale)} - {this.renderValues(xScale, yScale)} - {this.renderBars(xScale, yScale)} - </g> - </svg>; + return ( + <svg className="bar-chart" width={this.state.width} height={this.state.height}> + <g transform={`translate(${this.props.padding[3]}, ${this.props.padding[0]})`}> + {this.renderTicks(xScale, yScale)} + {this.renderValues(xScale, yScale)} + {this.renderBars(xScale, yScale)} + </g> + </svg> + ); } }); diff --git a/server/sonar-web/src/main/js/components/charts/line-chart.js b/server/sonar-web/src/main/js/components/charts/line-chart.js index 7bf02a1dbce..725a816986a 100644 --- a/server/sonar-web/src/main/js/components/charts/line-chart.js +++ b/server/sonar-web/src/main/js/components/charts/line-chart.js @@ -19,7 +19,6 @@ */ import d3 from 'd3'; import React from 'react'; - import { ResizeMixin } from './../mixins/resize-mixin'; import { TooltipsMixin } from './../mixins/tooltips-mixin'; @@ -39,7 +38,7 @@ export const LineChart = React.createClass({ mixins: [ResizeMixin, TooltipsMixin], - getDefaultProps() { + getDefaultProps () { return { displayBackdrop: true, displayPoints: true, @@ -51,7 +50,7 @@ export const LineChart = React.createClass({ }; }, - getInitialState() { + getInitialState () { return { width: this.props.width, height: this.props.height }; }, @@ -61,10 +60,10 @@ export const LineChart = React.createClass({ } const area = d3.svg.area() - .x(d => xScale(d.x)) - .y0(yScale.range()[0]) - .y1(d => yScale(d.y)) - .interpolate(this.props.interpolate); + .x(d => xScale(d.x)) + .y0(yScale.range()[0]) + .y1(d => yScale(d.y)) + .interpolate(this.props.interpolate); let data = this.props.data; if (this.props.backdropConstraints) { @@ -81,11 +80,14 @@ export const LineChart = React.createClass({ const points = this.props.data.map((point, index) => { const x = xScale(point.x); const y = yScale(point.y); - return <circle key={index} - className="line-chart-point" - r="3" - cx={x} - cy={y}/>; + return ( + <circle + key={index} + className="line-chart-point" + r="3" + cx={x} + cy={y}/> + ); }); return <g>{points}</g>; }, @@ -98,12 +100,15 @@ export const LineChart = React.createClass({ const x = xScale(point.x); const y1 = yScale.range()[0]; const y2 = yScale(point.y); - return <line key={index} - className="line-chart-grid" - x1={x} - x2={x} - y1={y1} - y2={y2}/>; + return ( + <line + key={index} + className="line-chart-grid" + x1={x} + x2={x} + y1={y1} + y2={y2}/> + ); }); return <g>{lines}</g>; }, @@ -116,11 +121,14 @@ export const LineChart = React.createClass({ const point = this.props.data[index]; const x = xScale(point.x); const y = yScale.range()[0]; - return <text key={index} - className="line-chart-tick" - x={x} - y={y} - dy="1.5em">{tick}</text>; + return ( + <text + key={index} + className="line-chart-tick" + x={x} + y={y} + dy="1.5em">{tick}</text> + ); }); return <g>{ticks}</g>; }, @@ -133,20 +141,23 @@ export const LineChart = React.createClass({ const point = this.props.data[index]; const x = xScale(point.x); const y = yScale(point.y); - return <text key={index} - className="line-chart-tick" - x={x} - y={y} - dy="-1em">{value}</text>; + return ( + <text + key={index} + className="line-chart-tick" + x={x} + y={y} + dy="-1em">{value}</text> + ); }); return <g>{ticks}</g>; }, renderLine (xScale, yScale) { const p = d3.svg.line() - .x(d => xScale(d.x)) - .y(d => yScale(d.y)) - .interpolate(this.props.interpolate); + .x(d => xScale(d.x)) + .y(d => yScale(d.y)) + .interpolate(this.props.interpolate); return <path className="line-chart-path" d={p(this.props.data)}/>; }, @@ -161,10 +172,10 @@ export const LineChart = React.createClass({ let maxY; const xScale = d3.scale.linear() - .domain(d3.extent(this.props.data, d => d.x)) - .range([0, availableWidth]); + .domain(d3.extent(this.props.data, d => d.x)) + .range([0, availableWidth]); const yScale = d3.scale.linear() - .range([availableHeight, 0]); + .range([availableHeight, 0]); if (this.props.domain) { maxY = this.props.domain[1]; @@ -174,15 +185,17 @@ export const LineChart = React.createClass({ yScale.domain([0, maxY]); } - return <svg className="line-chart" width={this.state.width} height={this.state.height}> - <g transform={`translate(${this.props.padding[3]}, ${this.props.padding[0]})`}> - {this.renderVerticalGrid(xScale, yScale, maxY)} - {this.renderBackdrop(xScale, yScale)} - {this.renderLine(xScale, yScale)} - {this.renderPoints(xScale, yScale)} - {this.renderXTicks(xScale, yScale)} - {this.renderXValues(xScale, yScale)} - </g> - </svg>; + return ( + <svg className="line-chart" width={this.state.width} height={this.state.height}> + <g transform={`translate(${this.props.padding[3]}, ${this.props.padding[0]})`}> + {this.renderVerticalGrid(xScale, yScale, maxY)} + {this.renderBackdrop(xScale, yScale)} + {this.renderLine(xScale, yScale)} + {this.renderPoints(xScale, yScale)} + {this.renderXTicks(xScale, yScale)} + {this.renderXValues(xScale, yScale)} + </g> + </svg> + ); } }); diff --git a/server/sonar-web/src/main/js/components/charts/treemap-breadcrumbs.js b/server/sonar-web/src/main/js/components/charts/treemap-breadcrumbs.js index 16f97bec6ef..5b5cfd29e47 100644 --- a/server/sonar-web/src/main/js/components/charts/treemap-breadcrumbs.js +++ b/server/sonar-web/src/main/js/components/charts/treemap-breadcrumbs.js @@ -18,7 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; - import QualifierIcon from '../shared/qualifier-icon'; export const TreemapBreadcrumbs = React.createClass({ @@ -30,35 +29,41 @@ export const TreemapBreadcrumbs = React.createClass({ }).isRequired).isRequired }, - handleItemClick(item, e) { + handleItemClick (item, e) { e.preventDefault(); this.props.onRectangleClick(item); }, - handleReset(e) { + handleReset (e) { e.preventDefault(); this.props.onReset(); }, - renderHome() { - return <span className="treemap-breadcrumbs-item"> - <a onClick={this.handleReset} className="icon-home" href="#"/> - </span>; + renderHome () { + return ( + <span className="treemap-breadcrumbs-item"> + <a onClick={this.handleReset} className="icon-home" href="#"/> + </span> + ); }, - renderBreadcrumbsItems(b) { - return <span key={b.key} className="treemap-breadcrumbs-item" title={b.name}> - <i className="icon-chevron-right"/> - <QualifierIcon qualifier={b.qualifier}/> - <a onClick={this.handleItemClick.bind(this, b)} href="#">{b.name}</a> - </span>; + renderBreadcrumbsItems (b) { + return ( + <span key={b.key} className="treemap-breadcrumbs-item" title={b.name}> + <i className="icon-chevron-right"/> + <QualifierIcon qualifier={b.qualifier}/> + <a onClick={this.handleItemClick.bind(this, b)} href="#">{b.name}</a> + </span> + ); }, - render() { + render () { const breadcrumbs = this.props.breadcrumbs.map(this.renderBreadcrumbsItems); - return <div className="treemap-breadcrumbs"> - {this.props.breadcrumbs.length ? this.renderHome() : null} - {breadcrumbs} - </div>; + return ( + <div className="treemap-breadcrumbs"> + {this.props.breadcrumbs.length ? this.renderHome() : null} + {breadcrumbs} + </div> + ); } }); diff --git a/server/sonar-web/src/main/js/components/charts/treemap.js b/server/sonar-web/src/main/js/components/charts/treemap.js index 51be0727226..a45ffc93b84 100644 --- a/server/sonar-web/src/main/js/components/charts/treemap.js +++ b/server/sonar-web/src/main/js/components/charts/treemap.js @@ -20,7 +20,6 @@ import _ from 'underscore'; import d3 from 'd3'; import React from 'react'; - import { TreemapBreadcrumbs } from './treemap-breadcrumbs'; import { ResizeMixin } from './../mixins/resize-mixin'; import { TooltipsMixin } from './../mixins/tooltips-mixin'; @@ -53,11 +52,10 @@ export const TreemapRect = React.createClass({ height: React.PropTypes.number.isRequired, fill: React.PropTypes.string.isRequired, label: React.PropTypes.string.isRequired, - prefix: React.PropTypes.string, onClick: React.PropTypes.func }, - renderLink() { + renderLink () { if (!this.props.link) { return null; } @@ -66,12 +64,14 @@ export const TreemapRect = React.createClass({ return null; } - return <a onClick={e => e.stopPropagation()} - className="treemap-link" - href={this.props.link} - style={{ fontSize: 12 }}> - <span className="icon-link"/> - </a>; + return ( + <a onClick={e => e.stopPropagation()} + className="treemap-link" + href={this.props.link} + style={{ fontSize: 12 }}> + <span className="icon-link"/> + </a> + ); }, render () { @@ -93,14 +93,20 @@ export const TreemapRect = React.createClass({ cursor: typeof this.props.onClick === 'function' ? 'pointer' : 'default' }; const isTextVisible = this.props.width >= 40 && this.props.height >= 40; - return <div className="treemap-cell" - {...tooltipAttrs} - style={cellStyles} - onClick={this.props.onClick}> - <div className="treemap-inner" dangerouslySetInnerHTML={{ __html: this.props.label }} - style={{ maxWidth: this.props.width, visibility: isTextVisible ? 'visible' : 'hidden' }}/> - {this.renderLink()} - </div>; + /* eslint-disable jsx-a11y/onclick-has-focus, jsx-a11y/onclick-has-role */ + return ( + <div + className="treemap-cell" + {...tooltipAttrs} + style={cellStyles} + onClick={this.props.onClick}> + <div + className="treemap-inner" + dangerouslySetInnerHTML={{ __html: this.props.label }} + style={{ maxWidth: this.props.width, visibility: isTextVisible ? 'visible' : 'hidden' }}/> + {this.renderLink()} + </div> + ); } }); @@ -113,17 +119,19 @@ export const Treemap = React.createClass({ mixins: [ResizeMixin, TooltipsMixin], - getInitialState() { + getInitialState () { return { width: this.props.width, height: this.props.height }; }, renderWhenNoData () { - return <div className="sonar-d3"> - <div className="treemap-container" style={{ width: this.state.width, height: this.state.height }}> - {translate('no_data')} - </div> - <TreemapBreadcrumbs {...this.props}/> - </div>; + return ( + <div className="sonar-d3"> + <div className="treemap-container" style={{ width: this.state.width, height: this.state.height }}> + {translate('no_data')} + </div> + <TreemapBreadcrumbs {...this.props}/> + </div> + ); }, render () { @@ -152,24 +160,29 @@ export const Treemap = React.createClass({ const key = node.label; const label = prefixLength ? `${prefix}<br>${node.label.substr(prefixLength)}` : node.label; const onClick = this.props.canBeClicked(node) ? () => this.props.onRectangleClick(node) : null; - return <TreemapRect key={key} - x={node.x} - y={node.y} - width={node.dx} - height={node.dy} - fill={node.color} - label={label} - prefix={prefix} - tooltip={node.tooltip} - link={node.link} - onClick={onClick}/>; + return ( + <TreemapRect + key={key} + x={node.x} + y={node.y} + width={node.dx} + height={node.dy} + fill={node.color} + label={label} + prefix={prefix} + tooltip={node.tooltip} + link={node.link} + onClick={onClick}/> + ); }); - return <div className="sonar-d3"> - <div className="treemap-container" style={{ width: this.state.width, height: this.state.height }}> - {rectangles} - </div> - <TreemapBreadcrumbs {...this.props}/> - </div>; + return ( + <div className="sonar-d3"> + <div className="treemap-container" style={{ width: this.state.width, height: this.state.height }}> + {rectangles} + </div> + <TreemapBreadcrumbs {...this.props}/> + </div> + ); } }); diff --git a/server/sonar-web/src/main/js/components/charts/word-cloud.js b/server/sonar-web/src/main/js/components/charts/word-cloud.js index ccaa88d3cf8..d7fbec6d617 100644 --- a/server/sonar-web/src/main/js/components/charts/word-cloud.js +++ b/server/sonar-web/src/main/js/components/charts/word-cloud.js @@ -20,7 +20,6 @@ import _ from 'underscore'; import d3 from 'd3'; import React from 'react'; - import { TooltipsMixin } from './../mixins/tooltips-mixin'; export const Word = React.createClass({ @@ -51,7 +50,7 @@ export const WordCloud = React.createClass({ mixins: [TooltipsMixin], - getDefaultProps() { + getDefaultProps () { return { sizeRange: [10, 24] }; diff --git a/server/sonar-web/src/main/js/components/common/action-options-view.js b/server/sonar-web/src/main/js/components/common/action-options-view.js index 56dc6dcf624..ac6798e68ce 100644 --- a/server/sonar-web/src/main/js/components/common/action-options-view.js +++ b/server/sonar-web/src/main/js/components/common/action-options-view.js @@ -81,24 +81,12 @@ export default PopupView.extend({ const that = this; this.currentKeyScope = key.getScope(); key.setScope(this.keyScope); - key('down', this.keyScope, function () { - return that.selectNextOption(); - }); - key('up', this.keyScope, function () { - return that.selectPreviousOption(); - }); - key('return', this.keyScope, function () { - return that.selectActiveOption(); - }); - key('escape', this.keyScope, function () { - return that.destroy(); - }); - key('backspace', this.keyScope, function () { - return false; - }); - key('shift+tab', this.keyScope, function () { - return false; - }); + key('down', this.keyScope, () => that.selectNextOption()); + key('up', this.keyScope, () => that.selectPreviousOption()); + key('return', this.keyScope, () => that.selectActiveOption()); + key('escape', this.keyScope, () => that.destroy()); + key('backspace', this.keyScope, () => false); + key('shift+tab', this.keyScope, () => false); }, unbindShortcuts () { diff --git a/server/sonar-web/src/main/js/components/common/modal-form.js b/server/sonar-web/src/main/js/components/common/modal-form.js index a4a54d3bc6d..d26cb26f0aa 100644 --- a/server/sonar-web/src/main/js/components/common/modal-form.js +++ b/server/sonar-web/src/main/js/components/common/modal-form.js @@ -38,7 +38,7 @@ export default ModalView.extend({ onRender () { ModalView.prototype.onRender.apply(this, arguments); const that = this; - setTimeout(function () { + setTimeout(() => { that.$(':tabbable').first().focus(); }, 0); }, @@ -57,13 +57,13 @@ export default ModalView.extend({ showErrors (errors, warnings) { const container = this.ui.messagesContainer.empty(); if (_.isArray(errors)) { - errors.forEach(function (error) { + errors.forEach(error => { const html = `<div class="alert alert-danger">${error.msg}</div>`; container.append(html); }); } if (_.isArray(warnings)) { - warnings.forEach(function (warn) { + warnings.forEach(warn => { const html = `<div class="alert alert-warning">${warn.msg}</div>`; container.append(html); }); diff --git a/server/sonar-web/src/main/js/components/common/modals.js b/server/sonar-web/src/main/js/components/common/modals.js index 9b9c6259144..04b5cc64bf0 100644 --- a/server/sonar-web/src/main/js/components/common/modals.js +++ b/server/sonar-web/src/main/js/components/common/modals.js @@ -40,7 +40,7 @@ export default Marionette.ItemView.extend({ this.renderOverlay(); this.keyScope = key.getScope(); key.setScope('modal'); - key('escape', 'modal', function () { + key('escape', 'modal', () => { that.destroy(); return false; }); @@ -52,7 +52,7 @@ export default Marionette.ItemView.extend({ show () { const that = this; - setTimeout(function () { + setTimeout(() => { that.$el.addClass('in'); $('.' + that.overlayClassName).addClass('in'); }, 0); @@ -83,7 +83,7 @@ export default Marionette.ItemView.extend({ attachCloseEvents () { const that = this; - $('body').on('click.' + EVENT_SCOPE, function () { + $('body').on('click.' + EVENT_SCOPE, () => { $('body').off('click.' + EVENT_SCOPE); that.destroy(); }); diff --git a/server/sonar-web/src/main/js/components/common/popup.js b/server/sonar-web/src/main/js/components/common/popup.js index 82639c56234..b73198052d8 100644 --- a/server/sonar-web/src/main/js/components/common/popup.js +++ b/server/sonar-web/src/main/js/components/common/popup.js @@ -48,14 +48,14 @@ export default Marionette.ItemView.extend({ attachCloseEvents () { const that = this; - key('escape', function () { + key('escape', () => { that.destroy(); }); - $('body').on('click.bubble-popup', function () { + $('body').on('click.bubble-popup', () => { $('body').off('click.bubble-popup'); that.destroy(); }); - this.options.triggerEl.on('click.bubble-popup', function (e) { + this.options.triggerEl.on('click.bubble-popup', e => { that.options.triggerEl.off('click.bubble-popup'); e.stopPropagation(); that.destroy(); diff --git a/server/sonar-web/src/main/js/components/controls/DateInput.js b/server/sonar-web/src/main/js/components/controls/DateInput.js index 2d15e9130c7..4f011cef19e 100644 --- a/server/sonar-web/src/main/js/components/controls/DateInput.js +++ b/server/sonar-web/src/main/js/components/controls/DateInput.js @@ -24,6 +24,7 @@ import './styles.css'; export default class DateInput extends React.Component { static propTypes = { + /* eslint-disable react/no-unused-prop-types */ value: React.PropTypes.string, format: React.PropTypes.string, name: React.PropTypes.string, diff --git a/server/sonar-web/src/main/js/components/issue/collections/issues.js b/server/sonar-web/src/main/js/components/issue/collections/issues.js index 23e18757daa..32ce94a282c 100644 --- a/server/sonar-web/src/main/js/components/issue/collections/issues.js +++ b/server/sonar-web/src/main/js/components/issue/collections/issues.js @@ -31,11 +31,9 @@ export default Backbone.Collection.extend({ _injectRelational (issue, source, baseField, lookupField) { const baseValue = issue[baseField]; if (baseValue != null && _.size(source)) { - const lookupValue = _.find(source, function (candidate) { - return candidate[lookupField] === baseValue; - }); + const lookupValue = _.find(source, candidate => candidate[lookupField] === baseValue); if (lookupValue != null) { - Object.keys(lookupValue).forEach(function (key) { + Object.keys(lookupValue).forEach(key => { const newKey = baseField + key.charAt(0).toUpperCase() + key.slice(1); issue[newKey] = lookupValue[key]; }); @@ -47,7 +45,7 @@ export default Backbone.Collection.extend({ _injectCommentsRelational (issue, users) { if (issue.comments) { const that = this; - const newComments = issue.comments.map(function (comment) { + const newComments = issue.comments.map(comment => { let newComment = _.extend({}, comment, { author: comment.login }); delete newComment.login; newComment = that._injectRelational(newComment, users, 'author', 'login'); @@ -89,7 +87,7 @@ export default Backbone.Collection.extend({ maxResultsReached: r.p * r.ps >= r.total }; - return r.issues.map(function (issue) { + return r.issues.map(issue => { issue = that._injectRelational(issue, r.components, 'component', 'key'); issue = that._injectRelational(issue, r.components, 'project', 'key'); issue = that._injectRelational(issue, r.components, 'subProject', 'key'); diff --git a/server/sonar-web/src/main/js/components/issue/issue-view.js b/server/sonar-web/src/main/js/components/issue/issue-view.js index dcab97f7e5c..74835638e37 100644 --- a/server/sonar-web/src/main/js/components/issue/issue-view.js +++ b/server/sonar-web/src/main/js/components/issue/issue-view.js @@ -78,9 +78,7 @@ export default Marionette.ItemView.extend({ const key = this.model.get('key'); const componentUuid = this.model.get('componentUuid'); this.model.reset({ key, componentUuid }, { silent: true }); - return this.model.fetch(options).done(function () { - return that.trigger('reset'); - }); + return this.model.fetch(options).done(() => that.trigger('reset')); }, showChangeLog (e) { @@ -89,7 +87,7 @@ export default Marionette.ItemView.extend({ const changeLog = new ChangeLog(); return changeLog.fetch({ data: { issue: this.model.get('key') } - }).done(function () { + }).done(() => { if (that.popup) { that.popup.destroy(); } @@ -228,10 +226,10 @@ export default Marionette.ItemView.extend({ const that = this; this.disableControls(); return this.model.customAction(action) - .done(function () { + .done(() => { that.updateAfterAction(true); }) - .fail(function () { + .fail(() => { that.enableControls(); }); }, diff --git a/server/sonar-web/src/main/js/components/issue/models/issue.js b/server/sonar-web/src/main/js/components/issue/models/issue.js index 030f58cf35e..245fc678362 100644 --- a/server/sonar-web/src/main/js/components/issue/models/issue.js +++ b/server/sonar-web/src/main/js/components/issue/models/issue.js @@ -57,11 +57,9 @@ export default Backbone.Model.extend({ _injectRelational (issue, source, baseField, lookupField) { const baseValue = issue[baseField]; if (baseValue != null && _.size(source)) { - const lookupValue = _.find(source, function (candidate) { - return candidate[lookupField] === baseValue; - }); + const lookupValue = _.find(source, candidate => candidate[lookupField] === baseValue); if (lookupValue != null) { - Object.keys(lookupValue).forEach(function (key) { + Object.keys(lookupValue).forEach(key => { const newKey = baseField + key.charAt(0).toUpperCase() + key.slice(1); issue[newKey] = lookupValue[key]; }); @@ -73,7 +71,7 @@ export default Backbone.Model.extend({ _injectCommentsRelational (issue, users) { if (issue.comments) { const that = this; - const newComments = issue.comments.map(function (comment) { + const newComments = issue.comments.map(comment => { let newComment = _.extend({}, comment, { author: comment.login }); delete newComment.login; newComment = that._injectRelational(newComment, users, 'author', 'login'); @@ -226,7 +224,7 @@ export default Backbone.Model.extend({ url: this.urlRoot() + '/do_transition', data: { issue: this.id, transition } }, options); - return this._action(opts).done(function () { + return this._action(opts).done(() => { that.trigger('transition', transition); }); }, diff --git a/server/sonar-web/src/main/js/components/issue/views/assign-form-view.js b/server/sonar-web/src/main/js/components/issue/views/assign-form-view.js index 5a608cdecea..8ae74f15ae7 100644 --- a/server/sonar-web/src/main/js/components/issue/views/assign-form-view.js +++ b/server/sonar-web/src/main/js/components/issue/views/assign-form-view.js @@ -55,7 +55,7 @@ export default ActionOptionsView.extend({ const that = this; ActionOptionsView.prototype.onRender.apply(this, arguments); this.renderTags(); - setTimeout(function () { + setTimeout(() => { that.$('input').focus(); }, 100); }, @@ -120,7 +120,7 @@ export default ActionOptionsView.extend({ search (query) { const that = this; if (query.length > 1) { - $.get(window.baseUrl + '/api/users/search', { q: query }).done(function (data) { + $.get(window.baseUrl + '/api/users/search', { q: query }).done(data => { that.resetAssignees(data.users); }); } else { @@ -130,7 +130,7 @@ export default ActionOptionsView.extend({ resetAssignees (users) { if (users) { - this.assignees = users.map(function (user) { + this.assignees = users.map(user => { return { id: user.login, text: user.name }; }); } else { @@ -152,8 +152,6 @@ export default ActionOptionsView.extend({ }, makeUnique (assignees) { - return _.uniq(assignees, false, function (assignee) { - return assignee.id; - }); + return _.uniq(assignees, false, assignee => assignee.id); } }); diff --git a/server/sonar-web/src/main/js/components/issue/views/comment-form-view.js b/server/sonar-web/src/main/js/components/issue/views/comment-form-view.js index 4773d372c20..fd4174363b4 100644 --- a/server/sonar-web/src/main/js/components/issue/views/comment-form-view.js +++ b/server/sonar-web/src/main/js/components/issue/views/comment-form-view.js @@ -43,7 +43,7 @@ export default PopupView.extend({ onRender () { const that = this; PopupView.prototype.onRender.apply(this, arguments); - setTimeout(function () { + setTimeout(() => { that.ui.textarea.focus(); }, 100); }, @@ -97,9 +97,9 @@ export default PopupView.extend({ this.disableForm(); this.options.detailView.disableControls(); return $.post(url, data) - .done(function () { + .done(() => { that.options.detailView.updateAfterAction(true); - }).fail(function () { + }).fail(() => { that.enableForm(); that.options.detailView.enableControls(); }); diff --git a/server/sonar-web/src/main/js/components/issue/views/tags-form-view.js b/server/sonar-web/src/main/js/components/issue/views/tags-form-view.js index ac0ae0ec342..d392a851b9c 100644 --- a/server/sonar-web/src/main/js/components/issue/views/tags-form-view.js +++ b/server/sonar-web/src/main/js/components/issue/views/tags-form-view.js @@ -50,7 +50,7 @@ export default ActionOptionsView.extend({ requestTags (query) { const that = this; - return $.get(window.baseUrl + '/api/issues/tags', { ps: 10, q: query }).done(function (data) { + return $.get(window.baseUrl + '/api/issues/tags', { ps: 10, q: query }).done(data => { that.tags = data.tags; that.renderTags(); }); @@ -60,7 +60,7 @@ export default ActionOptionsView.extend({ const that = this; ActionOptionsView.prototype.onRender.apply(this, arguments); this.renderTags(); - setTimeout(function () { + setTimeout(() => { that.$('input').focus(); }, 100); }, @@ -72,9 +72,7 @@ export default ActionOptionsView.extend({ filterTags (tags) { const that = this; - return _.filter(tags, function (tag) { - return tag.indexOf(that.query) !== -1; - }); + return _.filter(tags, tag => tag.indexOf(that.query) !== -1); }, renderTags () { @@ -139,9 +137,7 @@ export default ActionOptionsView.extend({ key: this.model.id, tags: tags.join() } - }).fail(function () { - return that.model.set({ tags: _tags }); - }); + }).fail(() => that.model.set({ tags: _tags })); }, onInputClick (e) { @@ -181,7 +177,7 @@ export default ActionOptionsView.extend({ }, resetAssignees (users) { - this.assignees = users.map(function (user) { + this.assignees = users.map(user => { return { id: user.login, text: user.name }; }); this.renderTags(); diff --git a/server/sonar-web/src/main/js/components/mixins/resize-mixin.js b/server/sonar-web/src/main/js/components/mixins/resize-mixin.js index ff0ce1f2204..b93e35f5717 100644 --- a/server/sonar-web/src/main/js/components/mixins/resize-mixin.js +++ b/server/sonar-web/src/main/js/components/mixins/resize-mixin.js @@ -40,7 +40,7 @@ export const ResizeMixin = { this.setState({ width: newWidth, height: newHeight }); }, - isResizable() { + isResizable () { return !this.props.width || !this.props.height; } }; diff --git a/server/sonar-web/src/main/js/components/mixins/tooltips-mixin.js b/server/sonar-web/src/main/js/components/mixins/tooltips-mixin.js index 13f67901447..3805ba09b41 100644 --- a/server/sonar-web/src/main/js/components/mixins/tooltips-mixin.js +++ b/server/sonar-web/src/main/js/components/mixins/tooltips-mixin.js @@ -26,7 +26,7 @@ export const TooltipsMixin = { this.initTooltips(); }, - componentWillUpdate() { + componentWillUpdate () { this.hideTooltips(); }, @@ -34,7 +34,7 @@ export const TooltipsMixin = { this.initTooltips(); }, - componentWillUnmount() { + componentWillUnmount () { this.destroyTooltips(); }, @@ -65,7 +65,7 @@ export const TooltipsContainer = React.createClass({ this.initTooltips(); }, - componentWillUpdate() { + componentWillUpdate () { this.destroyTooltips(); }, @@ -73,7 +73,7 @@ export const TooltipsContainer = React.createClass({ this.initTooltips(); }, - componentWillUnmount() { + componentWillUnmount () { this.destroyTooltips(); }, diff --git a/server/sonar-web/src/main/js/components/navigator/controller.js b/server/sonar-web/src/main/js/components/navigator/controller.js index c97a8e5d482..eb40fb3e113 100644 --- a/server/sonar-web/src/main/js/components/navigator/controller.js +++ b/server/sonar-web/src/main/js/components/navigator/controller.js @@ -29,7 +29,7 @@ export default Marionette.Controller.extend({ }, _allFacets () { - return this.options.app.state.get('allFacets').map(function (facet) { + return this.options.app.state.get('allFacets').map(facet => { return { property: facet }; }); }, @@ -39,22 +39,18 @@ export default Marionette.Controller.extend({ let facets = this.options.app.state.get('facets'); const criteria = Object.keys(this.options.app.state.get('query')); facets = facets.concat(criteria); - facets = facets.map(function (facet) { + facets = facets.map(facet => { return that.options.app.state.get('transform')[facet] != null ? that.options.app.state.get('transform')[facet] : facet; }); facets = _.uniq(facets); - return facets.filter(function (facet) { - return that.options.app.state.get('allFacets').indexOf(facet) !== -1; - }); + return facets.filter(facet => that.options.app.state.get('allFacets').indexOf(facet) !== -1); }, _facetsFromServer () { const that = this; const facets = this._enabledFacets(); - return facets.filter(function (facet) { - return that.options.app.state.get('facetsFromServer').indexOf(facet) !== -1; - }); + return facets.filter(facet => that.options.app.state.get('facetsFromServer').indexOf(facet) !== -1); }, fetchList () { @@ -72,7 +68,7 @@ export default Marionette.Controller.extend({ facet.set({ enabled: true }); } else { this.requestFacet(id) - .done(function () { + .done(() => { facet.set({ enabled: true }); }); } @@ -104,7 +100,7 @@ export default Marionette.Controller.extend({ parseQuery (query, separator) { separator = separator || '|'; const q = {}; - (query || '').split(separator).forEach(function (t) { + (query || '').split(separator).forEach(t => { const tokens = t.split('='); if (tokens[0] && tokens[1] != null) { q[tokens[0]] = decodeURIComponent(tokens[1]); @@ -117,7 +113,7 @@ export default Marionette.Controller.extend({ separator = separator || '|'; const filter = this.options.app.state.get('query'); const route = []; - _.map(filter, function (value, property) { + _.map(filter, (value, property) => { route.push(`${property}=${encodeURIComponent(value)}`); }); return route.join(separator); @@ -132,15 +128,13 @@ export default Marionette.Controller.extend({ const index = this.options.app.state.get('selectedIndex') + 1; if (index < this.options.app.list.length) { this.options.app.state.set({ selectedIndex: index }); + } else if (!this.options.app.state.get('maxResultsReached')) { + const that = this; + this.fetchNextPage().done(() => { + that.options.app.state.set({ selectedIndex: index }); + }); } else { - if (!this.options.app.state.get('maxResultsReached')) { - const that = this; - this.fetchNextPage().done(function () { - that.options.app.state.set({ selectedIndex: index }); - }); - } else { - this.options.app.list.trigger('limitReached'); - } + this.options.app.list.trigger('limitReached'); } }, diff --git a/server/sonar-web/src/main/js/components/navigator/facets-view.js b/server/sonar-web/src/main/js/components/navigator/facets-view.js index 2bf2158f036..2e004cf643d 100644 --- a/server/sonar-web/src/main/js/components/navigator/facets-view.js +++ b/server/sonar-web/src/main/js/components/navigator/facets-view.js @@ -40,12 +40,8 @@ export default Marionette.CollectionView.extend({ }, updateState () { - const enabledFacets = this.collection.filter(function (model) { - return model.get('enabled'); - }); - const enabledFacetIds = enabledFacets.map(function (model) { - return model.id; - }); + const enabledFacets = this.collection.filter(model => model.get('enabled')); + const enabledFacetIds = enabledFacets.map(model => model.id); this.options.app.state.set({ facets: enabledFacetIds }); } diff --git a/server/sonar-web/src/main/js/components/navigator/facets/base-facet.js b/server/sonar-web/src/main/js/components/navigator/facets/base-facet.js index b6b2946729b..03808a96619 100644 --- a/server/sonar-web/src/main/js/components/navigator/facets/base-facet.js +++ b/server/sonar-web/src/main/js/components/navigator/facets/base-facet.js @@ -45,7 +45,7 @@ export default Marionette.ItemView.extend({ const property = this.model.get('property'); const value = this.options.app.state.get('query')[property]; if (typeof value === 'string') { - value.split(',').forEach(function (s) { + value.split(',').forEach(s => { const facet = that.$('.js-facet').filter(`[data-value="${s}"]`); if (facet.length > 0) { facet.addClass('active'); @@ -95,7 +95,7 @@ export default Marionette.ItemView.extend({ }, sortValues (values) { - return values.slice().sort(function (left, right) { + return values.slice().sort((left, right) => { if (left.count !== right.count) { return right.count - left.count; } diff --git a/server/sonar-web/src/main/js/components/navigator/models/state.js b/server/sonar-web/src/main/js/components/navigator/models/state.js index 8c287de5e15..ae50145697d 100644 --- a/server/sonar-web/src/main/js/components/navigator/models/state.js +++ b/server/sonar-web/src/main/js/components/navigator/models/state.js @@ -37,7 +37,7 @@ export default Backbone.Model.extend({ clearQuery (query) { const q = {}; - Object.keys(query).forEach(function (key) { + Object.keys(query).forEach(key => { if (query[key]) { q[key] = query[key]; } @@ -47,7 +47,7 @@ export default Backbone.Model.extend({ _areQueriesEqual (a, b) { let equal = Object.keys(a).length === Object.keys(b).length; - Object.keys(a).forEach(function (key) { + Object.keys(a).forEach(key => { equal = equal && a[key] === b[key]; }); return equal; diff --git a/server/sonar-web/src/main/js/components/navigator/workspace-header-view.js b/server/sonar-web/src/main/js/components/navigator/workspace-header-view.js index 10610eb1b91..f1de179458a 100644 --- a/server/sonar-web/src/main/js/components/navigator/workspace-header-view.js +++ b/server/sonar-web/src/main/js/components/navigator/workspace-header-view.js @@ -84,7 +84,7 @@ export default Marionette.ItemView.extend({ flashPagination () { const flashElement = this.$('.search-navigator-header-pagination'); flashElement.addClass('in'); - setTimeout(function () { + setTimeout(() => { flashElement.removeClass('in'); }, 2000); }, diff --git a/server/sonar-web/src/main/js/components/navigator/workspace-list-view.js b/server/sonar-web/src/main/js/components/navigator/workspace-list-view.js index b533058a41c..4b084890ada 100644 --- a/server/sonar-web/src/main/js/components/navigator/workspace-list-view.js +++ b/server/sonar-web/src/main/js/components/navigator/workspace-list-view.js @@ -64,7 +64,7 @@ export default Marionette.CompositeView.extend({ bindScrollEvents () { const that = this; - $(window).on('scroll.workspace-list-view', function () { + $(window).on('scroll.workspace-list-view', () => { that.onScroll(); }); }, @@ -75,12 +75,12 @@ export default Marionette.CompositeView.extend({ bindShortcuts () { const that = this; - key('up', 'list', function () { + key('up', 'list', () => { that.options.app.controller.selectPrev(); return false; }); - key('down', 'list', function () { + key('down', 'list', () => { that.options.app.controller.selectNext(); return false; }); @@ -95,7 +95,7 @@ export default Marionette.CompositeView.extend({ if (!this.options.app.state.get('maxResultsReached')) { const that = this; this.unbindScrollEvents(); - this.options.app.controller.fetchNextPage().done(function () { + this.options.app.controller.fetchNextPage().done(() => { that.bindScrollEvents(); }); } diff --git a/server/sonar-web/src/main/js/components/router/router.js b/server/sonar-web/src/main/js/components/router/router.js deleted file mode 100644 index aacb5b9af1d..00000000000 --- a/server/sonar-web/src/main/js/components/router/router.js +++ /dev/null @@ -1,66 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact 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. - */ -let listener; - -export const RouterMixin = { - getDefaultProps() { - return { urlRoot: '/' }; - }, - - getInitialState() { - return { route: this.getRoute() }; - }, - - getRoute() { - const path = window.location.pathname; - if (path.indexOf(this.props.urlRoot) === 0) { - return path.substr(this.props.urlRoot.length); - } else { - return null; - } - }, - - componentDidMount () { - /* jscs:disable safeContextKeyword */ - listener = this; - window.addEventListener('popstate', this.handleRouteChange); - }, - - componentWillUnmount() { - window.removeEventListener('popstate', this.handleRouteChange); - }, - - handleRouteChange() { - const route = this.getRoute(); - this.setState({ route }); - }, - - navigate (route) { - const url = this.props.urlRoot + route + window.location.search + window.location.hash; - window.history.pushState({ route }, document.title, url); - this.setState({ route }); - } -}; - -export function navigate (route) { - if (listener) { - listener.navigate(route); - } -} diff --git a/server/sonar-web/src/main/js/components/select-list/controls.js b/server/sonar-web/src/main/js/components/select-list/controls.js index b2e002f7236..0a31afb88c1 100644 --- a/server/sonar-web/src/main/js/components/select-list/controls.js +++ b/server/sonar-web/src/main/js/components/select-list/controls.js @@ -23,16 +23,16 @@ import RadioToggle from '../controls/RadioToggle'; import { translate } from '../../helpers/l10n'; export default React.createClass({ - componentWillMount() { + componentWillMount () { this.search = _.debounce(this.search, 100); }, - search() { + search () { const query = this.refs.search.value; this.props.search(query); }, - onCheck(value) { + onCheck (value) { switch (value) { case 'selected': this.props.loadSelected(); @@ -45,7 +45,7 @@ export default React.createClass({ } }, - render() { + render () { const selectionOptions = [ { value: 'selected', label: 'Selected' }, { value: 'deselected', label: 'Not Selected' }, diff --git a/server/sonar-web/src/main/js/components/select-list/footer.js b/server/sonar-web/src/main/js/components/select-list/footer.js index 215644688b8..ce5c3b534c7 100644 --- a/server/sonar-web/src/main/js/components/select-list/footer.js +++ b/server/sonar-web/src/main/js/components/select-list/footer.js @@ -26,12 +26,12 @@ export default React.createClass({ loadMore: React.PropTypes.func.isRequired }, - loadMore(e) { + loadMore (e) { e.preventDefault(); this.props.loadMore(); }, - renderLoadMoreLink() { + renderLoadMoreLink () { const hasMore = this.props.total > this.props.count; if (!hasMore) { return null; @@ -39,7 +39,7 @@ export default React.createClass({ return <a onClick={this.loadMore} className="spacer-left" href="#">show more</a>; }, - render() { + render () { return ( <footer className="spacer-top note text-center"> {this.props.count}/{this.props.total} shown diff --git a/server/sonar-web/src/main/js/components/select-list/item.js b/server/sonar-web/src/main/js/components/select-list/item.js index 7e57216b1e1..6dcdf33af2b 100644 --- a/server/sonar-web/src/main/js/components/select-list/item.js +++ b/server/sonar-web/src/main/js/components/select-list/item.js @@ -28,7 +28,7 @@ export default React.createClass({ deselectItem: React.PropTypes.func.isRequired }, - onCheck(checked) { + onCheck (checked) { if (checked) { this.props.selectItem(this.props.item); } else { @@ -36,7 +36,7 @@ export default React.createClass({ } }, - render() { + render () { const renderedItem = this.props.renderItem(this.props.item); return ( <li className="panel panel-vertical"> diff --git a/server/sonar-web/src/main/js/components/select-list/list.js b/server/sonar-web/src/main/js/components/select-list/list.js index c514ca13430..92604b288a3 100644 --- a/server/sonar-web/src/main/js/components/select-list/list.js +++ b/server/sonar-web/src/main/js/components/select-list/list.js @@ -22,6 +22,7 @@ import Item from './item'; export default React.createClass({ propTypes: { + /* eslint-disable react/no-unused-prop-types */ items: React.PropTypes.array.isRequired, renderItem: React.PropTypes.func.isRequired, getItemKey: React.PropTypes.func.isRequired, @@ -29,10 +30,10 @@ export default React.createClass({ deselectItem: React.PropTypes.func.isRequired }, - render() { + render () { const renderedItems = this.props.items.map(item => { const key = this.props.getItemKey(item); - return <Item key={key} {...this.props} item={item} />; + return <Item key={key} {...this.props} item={item}/>; }); return ( <ul>{renderedItems}</ul> diff --git a/server/sonar-web/src/main/js/components/select-list/main.js b/server/sonar-web/src/main/js/components/select-list/main.js index cf6e2dd25fd..b763e6463d6 100644 --- a/server/sonar-web/src/main/js/components/select-list/main.js +++ b/server/sonar-web/src/main/js/components/select-list/main.js @@ -24,6 +24,7 @@ import Footer from './footer'; export default React.createClass({ propTypes: { + /* eslint-disable react/no-unused-prop-types */ loadItems: React.PropTypes.func.isRequired, renderItem: React.PropTypes.func.isRequired, getItemKey: React.PropTypes.func.isRequired, @@ -31,15 +32,15 @@ export default React.createClass({ deselectItem: React.PropTypes.func.isRequired }, - getInitialState() { + getInitialState () { return { items: [], total: 0, selection: 'selected', query: null }; }, - componentDidMount() { + componentDidMount () { this.loadItems(); }, - loadItems() { + loadItems () { const options = { selection: this.state.selection, query: this.state.query, @@ -50,7 +51,7 @@ export default React.createClass({ }); }, - loadMoreItems() { + loadMoreItems () { const options = { selection: this.state.selection, query: this.state.query, @@ -62,23 +63,23 @@ export default React.createClass({ }); }, - loadSelected() { + loadSelected () { this.setState({ selection: 'selected', query: null }, this.loadItems); }, - loadDeselected() { + loadDeselected () { this.setState({ selection: 'deselected', query: null }, this.loadItems); }, - loadAll() { + loadAll () { this.setState({ selection: 'all', query: null }, this.loadItems); }, - search(query) { + search (query) { this.setState({ query }, this.loadItems); }, - render() { + render () { return ( <div className="select-list-container"> <Controls diff --git a/server/sonar-web/src/main/js/components/shared/complexity-distribution.js b/server/sonar-web/src/main/js/components/shared/complexity-distribution.js index 4771ae96489..d6145addd61 100644 --- a/server/sonar-web/src/main/js/components/shared/complexity-distribution.js +++ b/server/sonar-web/src/main/js/components/shared/complexity-distribution.js @@ -18,7 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; - import { BarChart } from '../charts/bar-chart'; import { formatMeasure } from '../../helpers/measures'; import { translateWithParameters } from '../../helpers/l10n'; @@ -48,20 +47,22 @@ export const ComplexityDistribution = React.createClass({ const xValues = data.map(point => formatMeasure(point.y, 'INT')); - return <BarChart data={data} - xTicks={xTicks} - xValues={xValues} - height={HEIGHT} - barsWidth={20} - padding={[25, 10, 25, 10]}/>; + return ( + <BarChart + data={data} + xTicks={xTicks} + xValues={xValues} + height={HEIGHT} + barsWidth={20} + padding={[25, 10, 25, 10]}/> + ); }, render () { // TODO remove inline styling return ( - <div - className="overview-bar-chart" - style={{ height: HEIGHT, paddingTop: 10, paddingBottom: 15 }}> + <div className="overview-bar-chart" + style={{ height: HEIGHT, paddingTop: 10, paddingBottom: 15 }}> {this.renderBarChart()} </div> ); diff --git a/server/sonar-web/src/main/js/components/shared/drilldown-link.js b/server/sonar-web/src/main/js/components/shared/drilldown-link.js index 086c3091af4..209f8ce5c21 100644 --- a/server/sonar-web/src/main/js/components/shared/drilldown-link.js +++ b/server/sonar-web/src/main/js/components/shared/drilldown-link.js @@ -49,11 +49,11 @@ const ISSUE_MEASURES = [ ]; export const DrilldownLink = React.createClass({ - isIssueMeasure() { + isIssueMeasure () { return ISSUE_MEASURES.indexOf(this.props.metric) !== -1; }, - propsToIssueParams() { + propsToIssueParams () { const params = {}; if (this.props.periodDate) { @@ -111,7 +111,7 @@ export const DrilldownLink = React.createClass({ return params; }, - renderIssuesLink() { + renderIssuesLink () { const url = getComponentIssuesUrl( this.props.component, this.propsToIssueParams()); @@ -121,7 +121,7 @@ export const DrilldownLink = React.createClass({ ); }, - render() { + render () { if (this.isIssueMeasure()) { return this.renderIssuesLink(); } diff --git a/server/sonar-web/src/main/js/components/shared/pending-icon.js b/server/sonar-web/src/main/js/components/shared/pending-icon.js index 8a9488ff0e5..99ac5b83973 100644 --- a/server/sonar-web/src/main/js/components/shared/pending-icon.js +++ b/server/sonar-web/src/main/js/components/shared/pending-icon.js @@ -20,7 +20,7 @@ import React from 'react'; export default React.createClass({ - render() { + render () { /* eslint max-len: 0 */ return ( <svg width="16" height="16" className="icon-pending"> diff --git a/server/sonar-web/src/main/js/components/shared/qualifier-icon.js b/server/sonar-web/src/main/js/components/shared/qualifier-icon.js index 3e6bbd643a5..156a7254f67 100644 --- a/server/sonar-web/src/main/js/components/shared/qualifier-icon.js +++ b/server/sonar-web/src/main/js/components/shared/qualifier-icon.js @@ -20,7 +20,7 @@ import React from 'react'; export default React.createClass({ - render() { + render () { if (!this.props.qualifier) { return null; } diff --git a/server/sonar-web/src/main/js/components/shared/severity-helper.js b/server/sonar-web/src/main/js/components/shared/severity-helper.js index 818d8068e77..9e020e945bf 100644 --- a/server/sonar-web/src/main/js/components/shared/severity-helper.js +++ b/server/sonar-web/src/main/js/components/shared/severity-helper.js @@ -22,7 +22,7 @@ import SeverityIcon from './severity-icon'; import { translate } from '../../helpers/l10n'; export default React.createClass({ - render() { + render () { if (!this.props.severity) { return null; } diff --git a/server/sonar-web/src/main/js/components/shared/severity-icon.js b/server/sonar-web/src/main/js/components/shared/severity-icon.js index 08c08746709..72d2211db28 100644 --- a/server/sonar-web/src/main/js/components/shared/severity-icon.js +++ b/server/sonar-web/src/main/js/components/shared/severity-icon.js @@ -20,11 +20,11 @@ import React from 'react'; export default React.createClass({ - render() { + render () { if (!this.props.severity) { return null; } const className = 'icon-severity-' + this.props.severity.toLowerCase(); - return <i className={className}></i>; + return <i className={className}/>; } }); diff --git a/server/sonar-web/src/main/js/components/source-viewer/SourceViewer.js b/server/sonar-web/src/main/js/components/source-viewer/SourceViewer.js index 98943abe6d9..b305768254b 100644 --- a/server/sonar-web/src/main/js/components/source-viewer/SourceViewer.js +++ b/server/sonar-web/src/main/js/components/source-viewer/SourceViewer.js @@ -18,7 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; - import BaseSourceViewer from './main'; import { getPeriodDate, getPeriodLabel } from '../../helpers/periods'; diff --git a/server/sonar-web/src/main/js/components/source-viewer/helpers/code-with-issue-locations-helper.js b/server/sonar-web/src/main/js/components/source-viewer/helpers/code-with-issue-locations-helper.js index 0345f56563d..f0b7395ab62 100644 --- a/server/sonar-web/src/main/js/components/source-viewer/helpers/code-with-issue-locations-helper.js +++ b/server/sonar-web/src/main/js/components/source-viewer/helpers/code-with-issue-locations-helper.js @@ -54,7 +54,7 @@ function splitByTokens (code, rootClassName = '') { const container = document.createElement('div'); let tokens = []; container.innerHTML = code; - [].forEach.call(container.childNodes, function (node) { + [].forEach.call(container.childNodes, node => { if (node.nodeType === 1) { // ELEMENT NODE const fullClassName = rootClassName ? (rootClassName + ' ' + node.className) : node.className; @@ -77,10 +77,10 @@ function splitByTokens (code, rootClassName = '') { * @returns {Array} */ function highlightIssueLocations (tokens, issueLocations, className) { - issueLocations.forEach(function (location) { + issueLocations.forEach(location => { const nextTokens = []; let acc = 0; - tokens.forEach(function (token) { + tokens.forEach(token => { const x = intersect(acc, acc + token.text.length, location.from, location.to); const p1 = part(token.text, acc, x.from, acc); const p2 = part(token.text, x.from, x.to, acc); @@ -109,9 +109,9 @@ function highlightIssueLocations (tokens, issueLocations, className) { * @returns {string} */ function generateHTML (tokens) { - return tokens.map(function (token) { - return `<span class="${token.className}">${_.escape(token.text)}</span>`; - }).join(''); + return tokens.map(token => ( + `<span class="${token.className}">${_.escape(token.text)}</span>` + )).join(''); } /** diff --git a/server/sonar-web/src/main/js/components/source-viewer/main.js b/server/sonar-web/src/main/js/components/source-viewer/main.js index 980e7e98447..eea632a201a 100644 --- a/server/sonar-web/src/main/js/components/source-viewer/main.js +++ b/server/sonar-web/src/main/js/components/source-viewer/main.js @@ -106,9 +106,7 @@ export default Marionette.LayoutView.extend({ }, onDestroy () { - this.issueViews.forEach(function (view) { - return view.destroy(); - }); + this.issueViews.forEach(view => view.destroy()); this.issueViews = []; this.clearTooltips(); this.unbindScrollEvents(); @@ -126,7 +124,7 @@ export default Marionette.LayoutView.extend({ const that = this; const opts = typeof options === 'object' ? options : {}; const finalize = function () { - that.requestIssues().done(function () { + that.requestIssues().done(() => { if (!that.isDestroyed) { that.render(); that.trigger('loaded'); @@ -138,10 +136,10 @@ export default Marionette.LayoutView.extend({ .clear() .set(_.result(this.model, 'defaults')) .set({ uuid: id }); - this.requestComponent().done(function () { + this.requestComponent().done(() => { that.requestSource(opts.aroundLine) .done(finalize) - .fail(function () { + .fail(() => { that.model.set({ source: [ { line: 0 } @@ -168,7 +166,7 @@ export default Marionette.LayoutView.extend({ that.trigger('loaded'); } } - }).done(function (r) { + }).done(r => { that.model.set(r); that.model.set({ isUnitTest: r.q === 'UTS' }); }); @@ -209,12 +207,12 @@ export default Marionette.LayoutView.extend({ // don't display global error 403: null } - }).done(function (r) { + }).done(r => { let source = (r.sources || []).slice(0); if (source.length === 0 || (source.length > 0 && _.first(source).line === 1)) { source.unshift({ line: 0 }); } - source = source.map(function (row) { + source = source.map(row => { return _.extend(row, { coverageStatus: that.getCoverageStatus(row) }); @@ -228,7 +226,7 @@ export default Marionette.LayoutView.extend({ hasSourceAfter: r.sources.length === linesRequested }); that.model.checkIfHasDuplications(); - }).fail(function (request) { + }).fail(request => { if (request.status === 403) { that.model.set({ source: [], @@ -244,13 +242,13 @@ export default Marionette.LayoutView.extend({ const that = this; const url = window.baseUrl + '/api/duplications/show'; const options = { uuid: this.model.id }; - return $.get(url, options, function (data) { + return $.get(url, options, data => { const hasDuplications = data.duplications != null; let duplications = []; if (hasDuplications) { duplications = {}; - data.duplications.forEach(function (d) { - d.blocks.forEach(function (b) { + data.duplications.forEach(d => { + d.blocks.forEach(b => { if (b._ref === '1') { const lineFrom = b.from; const lineTo = b.from + b.size - 1; @@ -260,7 +258,7 @@ export default Marionette.LayoutView.extend({ } }); }); - duplications = _.pairs(duplications).map(function (line) { + duplications = _.pairs(duplications).map(line => { return { line: +line[0], duplicated: line[1] @@ -292,29 +290,27 @@ export default Marionette.LayoutView.extend({ ps: this.ISSUES_LIMIT } }; - return this.issues.fetch(options).done(function () { + return this.issues.fetch(options).done(() => { that.addIssuesPerLineMeta(that.issues); }); }, _sortBySeverity (issues) { const order = ['BLOCKER', 'CRITICAL', 'MAJOR', 'MINOR', 'INFO']; - return _.sortBy(issues, function (issue) { - return order.indexOf(issue.severity); - }); + return _.sortBy(issues, issue => order.indexOf(issue.severity)); }, addIssuesPerLineMeta (issues) { const that = this; const lines = {}; - issues.forEach(function (issue) { + issues.forEach(issue => { const line = issue.get('line') || 0; if (!_.isArray(lines[line])) { lines[line] = []; } lines[line].push(issue.toJSON()); }); - const issuesPerLine = _.pairs(lines).map(function (line) { + const issuesPerLine = _.pairs(lines).map(line => { return { line: +line[0], issues: that._sortBySeverity(line[1]) @@ -326,8 +322,8 @@ export default Marionette.LayoutView.extend({ addIssueLocationsMeta (issues) { const issueLocations = []; - issues.forEach(function (issue) { - issue.getLinearLocations().forEach(function (location) { + issues.forEach(issue => { + issue.getLinearLocations().forEach(location => { const record = _.findWhere(issueLocations, { line: location.line }); if (record) { record.issueLocations.push({ from: location.from, to: location.to }); @@ -373,9 +369,9 @@ export default Marionette.LayoutView.extend({ showIssuesForLine (line) { this.$(`.source-line-code[data-line-number="${line}"]`).find('.issue-list').removeClass('hidden'); - const issues = this.issues.filter(function (issue) { - return (issue.get('line') === line) || (!issue.get('line') && !line); - }); + const issues = this.issues.filter(issue => ( + (issue.get('line') === line) || (!issue.get('line') && !line) + )); issues.forEach(this.renderIssue, this); }, @@ -425,7 +421,7 @@ export default Marionette.LayoutView.extend({ sourceFileLineNumber: line, ps: 1000 }; - return $.get(url, options).done(function (data) { + return $.get(url, options).done(data => { const popup = new CoveragePopupView({ row, collection: new Backbone.Collection(data.tests), @@ -439,7 +435,7 @@ export default Marionette.LayoutView.extend({ const that = this; const lineNumber = $(e.currentTarget).closest('.source-line').data('line-number'); this.clearTooltips(); - this.requestDuplications().done(function () { + this.requestDuplications().done(() => { that.render(); that.$el.addClass('source-duplications-expanded'); @@ -459,11 +455,9 @@ export default Marionette.LayoutView.extend({ const index = $(e.currentTarget).data('index'); const line = $(e.currentTarget).data('line-number'); let blocks = this.model.get('duplications')[index - 1].blocks; - const inRemovedComponent = _.some(blocks, function (b) { - return b._ref == null; - }); + const inRemovedComponent = _.some(blocks, b => b._ref == null); let foundOne = false; - blocks = _.filter(blocks, function (b) { + blocks = _.filter(blocks, b => { const outOfBounds = b.from > line || b.from + b.size < line; const currentFile = b._ref === '1'; const shouldDisplayForCurrentFile = outOfBounds || foundOne; @@ -606,7 +600,7 @@ export default Marionette.LayoutView.extend({ from: Math.max(1, firstLine - this.LINES_AROUND), to: firstLine - 1 }; - return $.get(url, options).done(function (data) { + return $.get(url, options).done(data => { source = (data.sources || []).concat(source); if (source.length > that.TOTAL_LINES_LIMIT + 1) { source = source.slice(0, that.TOTAL_LINES_LIMIT); @@ -615,7 +609,7 @@ export default Marionette.LayoutView.extend({ if (source.length === 0 || (source.length > 0 && _.first(source).line === 1)) { source.unshift({ line: 0 }); } - source = source.map(function (row) { + source = source.map(row => { return _.extend(row, { coverageStatus: that.getCoverageStatus(row) }); @@ -653,13 +647,13 @@ export default Marionette.LayoutView.extend({ from: lastLine + 1, to: lastLine + this.LINES_AROUND }; - return $.get(url, options).done(function (data) { + return $.get(url, options).done(data => { source = source.concat(data.sources); if (source.length > that.TOTAL_LINES_LIMIT + 1) { source = source.slice(source.length - that.TOTAL_LINES_LIMIT); that.model.set({ hasSourceBefore: true }); } - source = source.map(function (row) { + source = source.map(row => { return _.extend(row, { coverageStatus: that.getCoverageStatus(row) }); @@ -680,7 +674,7 @@ export default Marionette.LayoutView.extend({ if (that.model.get('hasSourceBefore') || that.model.get('hasSourceAfter')) { that.bindScrollEvents(); } - }).fail(function () { + }).fail(() => { that.model.set({ hasSourceAfter: false }); @@ -695,7 +689,7 @@ export default Marionette.LayoutView.extend({ const lines = this.model.get('source'); const $lines = this.$('.source-line'); this.model.set('filterLinesFunc', func); - lines.forEach(function (line, idx) { + lines.forEach((line, idx) => { const $line = $($lines[idx]); const filtered = func(line) && line.line > 0; $line.toggleClass('source-line-shadowed', !filtered); @@ -706,7 +700,7 @@ export default Marionette.LayoutView.extend({ filterLinesByDate (date, label) { const sinceDate = moment(date).toDate(); this.sinceLabel = label; - this.filterLines(function (line) { + this.filterLines(line => { const scmDate = moment(line.scmDate).toDate(); return scmDate >= sinceDate; }); @@ -741,9 +735,9 @@ export default Marionette.LayoutView.extend({ textRange: issue.get('textRange') }; let _locations = [primaryLocation]; - issue.get('flows').forEach(function (flow) { + issue.get('flows').forEach(flow => { const flowLocationsCount = _.size(flow.locations); - const flowLocations = flow.locations.map(function (location, index) { + const flowLocations = flow.locations.map((location, index) => { const _location = _.extend({}, location); if (flowLocationsCount > 1) { _.extend(_location, { index: flowLocationsCount - index }); diff --git a/server/sonar-web/src/main/js/components/source-viewer/measures-overlay.js b/server/sonar-web/src/main/js/components/source-viewer/measures-overlay.js index aaf665a5271..0323148cba2 100644 --- a/server/sonar-web/src/main/js/components/source-viewer/measures-overlay.js +++ b/server/sonar-web/src/main/js/components/source-viewer/measures-overlay.js @@ -79,9 +79,7 @@ export default ModalView.extend({ .outerRadius(radius); const pie = d3.layout.pie() .sort(null) - .value(function (d) { - return d; - }); + .value(d => d); const colors = function (i) { return i === 0 ? options.color : options.baseColor; }; @@ -90,9 +88,7 @@ export default ModalView.extend({ sectors.enter() .append('path') - .style('fill', function (d, i) { - return colors(i); - }) + .style('fill', (d, i) => colors(i)) .attr('d', arc); }); }, @@ -110,10 +106,8 @@ export default ModalView.extend({ url, async: false, data: { ps: 9999 } - }).done(function (data) { - metrics = _.filter(data.metrics, function (metric) { - return metric.type !== 'DATA' && !metric.hidden; - }); + }).done(data => { + metrics = _.filter(data.metrics, metric => metric.type !== 'DATA' && !metric.hidden); metrics = _.sortBy(metrics, 'name'); }); return metrics; @@ -135,11 +129,9 @@ export default ModalView.extend({ }, prepareMetrics (metrics) { - metrics = _.filter(metrics, function (metric) { - return metric.value != null; - }); + metrics = _.filter(metrics, metric => metric.value != null); return _.sortBy( - _.map(_.pairs(_.groupBy(metrics, 'domain')), function (domain) { + _.map(_.pairs(_.groupBy(metrics, 'domain')), domain => { return { name: domain[0], metrics: domain[1] @@ -183,12 +175,10 @@ export default ModalView.extend({ facets: 'types,severities,tags' }; - $.get(url, options).done(function (data) { + $.get(url, options).done(data => { const typesFacet = data.facets.find(facet => facet.property === 'types').values; const typesOrder = ['BUG', 'VULNERABILITY', 'CODE_SMELL']; - const sortedTypesFacet = _.sortBy(typesFacet, function (v) { - return typesOrder.indexOf(v.val); - }); + const sortedTypesFacet = _.sortBy(typesFacet, v => typesOrder.indexOf(v.val)); const severitiesFacet = data.facets.find(facet => facet.property === 'severities').values; const sortedSeveritiesFacet = _.sortBy(severitiesFacet, facet => window.severityComparator(facet.val)); @@ -213,13 +203,11 @@ export default ModalView.extend({ const url = window.baseUrl + '/api/tests/list'; const options = { testFileId: this.model.id }; - $.get(url, options).done(function (data) { + $.get(url, options).done(data => { that.model.set({ tests: data.tests }); that.testSorting = 'status'; that.testAsc = true; - that.sortTests(function (test) { - return `${that.testsOrder.indexOf(test.status)}_______${test.name}`; - }); + that.sortTests(test => `${that.testsOrder.indexOf(test.status)}_______${test.name}`); resolve(); }); }); @@ -259,9 +247,7 @@ export default ModalView.extend({ if (this.testSorting === 'status') { this.testAsc = !this.testAsc; } - this.sortTests(function (test) { - return `${that.testsOrder.indexOf(test.status)}_______${test.name}`; - }); + this.sortTests(test => `${that.testsOrder.indexOf(test.status)}_______${test.name}`); this.testSorting = 'status'; this.render(); }, @@ -272,7 +258,7 @@ export default ModalView.extend({ const url = window.baseUrl + '/api/tests/covered_files'; const options = { testId }; this.testsScroll = $(e.currentTarget).scrollParent().scrollTop(); - return $.get(url, options).done(function (data) { + return $.get(url, options).done(data => { that.coveredFiles = data.files; that.selectedTest = _.findWhere(that.model.get('tests'), { id: testId }); that.render(); diff --git a/server/sonar-web/src/main/js/components/source-viewer/more-actions.js b/server/sonar-web/src/main/js/components/source-viewer/more-actions.js index 91e42331749..31b9d4a2653 100644 --- a/server/sonar-web/src/main/js/components/source-viewer/more-actions.js +++ b/server/sonar-web/src/main/js/components/source-viewer/more-actions.js @@ -36,7 +36,7 @@ export default Marionette.ItemView.extend({ onRender () { const that = this; - $('body').on('click.component-viewer-more-actions', function () { + $('body').on('click.component-viewer-more-actions', () => { $('body').off('click.component-viewer-more-actions'); that.destroy(); }); diff --git a/server/sonar-web/src/main/js/components/source-viewer/popups/coverage-popup.js b/server/sonar-web/src/main/js/components/source-viewer/popups/coverage-popup.js index 4f1918625eb..2f6d67c67ad 100644 --- a/server/sonar-web/src/main/js/components/source-viewer/popups/coverage-popup.js +++ b/server/sonar-web/src/main/js/components/source-viewer/popups/coverage-popup.js @@ -44,7 +44,7 @@ export default Popup.extend({ serializeData () { const row = this.options.row || {}; const tests = _.groupBy(this.collection.toJSON(), 'fileId'); - const testFiles = _.map(tests, function (testSet) { + const testFiles = _.map(tests, testSet => { const test = testSet[0]; return { file: { diff --git a/server/sonar-web/src/main/js/components/source-viewer/popups/duplication-popup.js b/server/sonar-web/src/main/js/components/source-viewer/popups/duplication-popup.js index 6aa3f7e2c7e..209cea7bf16 100644 --- a/server/sonar-web/src/main/js/components/source-viewer/popups/duplication-popup.js +++ b/server/sonar-web/src/main/js/components/source-viewer/popups/duplication-popup.js @@ -41,13 +41,13 @@ export default Popup.extend({ const that = this; const files = this.model.get('duplicationFiles'); const groupedBlocks = _.groupBy(this.collection.toJSON(), '_ref'); - let duplications = _.map(groupedBlocks, function (blocks, fileRef) { + let duplications = _.map(groupedBlocks, (blocks, fileRef) => { return { blocks, file: files[fileRef] }; }); - duplications = _.sortBy(duplications, function (d) { + duplications = _.sortBy(duplications, d => { const a = d.file.projectName !== that.model.get('projectName'); const b = d.file.subProjectName !== that.model.get('subProjectName'); const c = d.file.key !== that.model.get('key'); diff --git a/server/sonar-web/src/main/js/components/source-viewer/source.js b/server/sonar-web/src/main/js/components/source-viewer/source.js index 8a085468bb4..b862fbc73cf 100644 --- a/server/sonar-web/src/main/js/components/source-viewer/source.js +++ b/server/sonar-web/src/main/js/components/source-viewer/source.js @@ -44,7 +44,7 @@ export default Backbone.Model.extend({ const source = this.get('source'); let metaIdx = 0; let metaLine = meta[metaIdx]; - source.forEach(function (line) { + source.forEach(line => { while (metaLine != null && line.line > metaLine.line) { metaLine = meta[++metaIdx]; } @@ -59,11 +59,11 @@ export default Backbone.Model.extend({ addDuplications (duplications) { const source = this.get('source'); if (source != null) { - source.forEach(function (line) { + source.forEach(line => { const lineDuplications = []; - duplications.forEach(function (d, i) { + duplications.forEach((d, i) => { let duplicated = false; - d.blocks.forEach(function (b) { + d.blocks.forEach(b => { if (b._ref === '1') { const lineFrom = b.from; const lineTo = b.from + b.size - 1; @@ -84,7 +84,7 @@ export default Backbone.Model.extend({ const source = this.get('source'); let hasDuplications = false; if (source != null) { - source.forEach(function (line) { + source.forEach(line => { if (line.duplicated) { hasDuplications = true; } @@ -94,9 +94,7 @@ export default Backbone.Model.extend({ }, hasCoverage (source) { - return _.some(source, function (line) { - return line.coverageStatus != null; - }); + return _.some(source, line => line.coverageStatus != null); } }); diff --git a/server/sonar-web/src/main/js/components/widgets/barchart.js b/server/sonar-web/src/main/js/components/widgets/barchart.js index 956c6f6098b..318749693b2 100644 --- a/server/sonar-web/src/main/js/components/widgets/barchart.js +++ b/server/sonar-web/src/main/js/components/widgets/barchart.js @@ -64,12 +64,8 @@ $.fn.barchart = function (data) { const plot = svg.append('g') .classed('plot', true); const xScale = d3.scale.ordinal() - .domain(data.map(function (d, i) { - return i; - })); - const yScaleMax = d3.max(data, function (d) { - return d.count; - }); + .domain(data.map((d, i) => i)); + const yScaleMax = d3.max(data, d => d.count); const yScale = d3.scale.linear() .domain([0, yScaleMax]); @@ -88,21 +84,17 @@ $.fn.barchart = function (data) { if (barWidth > 0) { const barsEnter = bars.enter() .append('g') - .attr('transform', function (d, i) { - return trans(xScale(i), Math.ceil(options.availableHeight - yScale(d.count))); - }); + .attr('transform', (d, i) => ( + trans(xScale(i), Math.ceil(options.availableHeight - yScale(d.count))) + )); barsEnter.append('rect') .style('fill', options.color) .attr('width', barWidth) - .attr('height', function (d) { - return Math.floor(yScale(d.count)); - }) + .attr('height', d => Math.floor(yScale(d.count))) .style('cursor', 'pointer') - .attr('data-period-start', function (d) { - return moment(d.val).format(DATE_FORMAT); - }) - .attr('data-period-end', function (d, i) { + .attr('data-period-start', d => moment(d.val).format(DATE_FORMAT)) + .attr('data-period-end', (d, i) => { const ending = i < data.length - 1 ? moment(data[i + 1].val) : options.endDate; if (ending) { return ending.format(DATE_FORMAT); @@ -110,7 +102,7 @@ $.fn.barchart = function (data) { return ''; } }) - .attr('title', function (d, i) { + .attr('title', (d, i) => { const beginning = moment(d.val); const ending = i < data.length - 1 ? moment(data[i + 1].val).subtract(1, 'days') : options.endDate; if (ending) { @@ -123,16 +115,14 @@ $.fn.barchart = function (data) { .attr('data-placement', 'bottom') .attr('data-toggle', 'tooltip'); - const maxValue = d3.max(data, function (d) { - return d.count; - }); + const maxValue = d3.max(data, d => d.count); let isValueShown = false; barsEnter.append('text') .classed('subtitle', true) .attr('transform', trans(barWidth / 2, -4)) .style('text-anchor', 'middle') - .text(function (d) { + .text(d => { const text = !isValueShown && d.count === maxValue ? d.text : ''; isValueShown = d.count === maxValue; return text; diff --git a/server/sonar-web/src/main/js/components/workspace/main.js b/server/sonar-web/src/main/js/components/workspace/main.js index 28381164816..a6b65e7e7f4 100644 --- a/server/sonar-web/src/main/js/components/workspace/main.js +++ b/server/sonar-web/src/main/js/components/workspace/main.js @@ -39,13 +39,13 @@ Workspace.prototype = { this.items = new Items(); this.items.load(); - this.items.on('change', function () { + this.items.on('change', () => { that.save(); }); this.itemsView = new ItemsView({ collection: this.items }); this.itemsView.render().$el.appendTo(document.body); - this.itemsView.on('click', function (model) { + this.itemsView.on('click', model => { that.open(model); }); }, @@ -92,11 +92,11 @@ Workspace.prototype = { model.trigger('showViewer'); this.viewerView = new Viewer({ model }); this.viewerView - .on('viewerMinimize', function () { + .on('viewerMinimize', () => { model.trigger('hideViewer'); that.closeComponentViewer(); }) - .on('viewerClose', function (m) { + .on('viewerClose', m => { that.closeComponentViewer(); m.destroy(); }); @@ -116,10 +116,10 @@ Workspace.prototype = { showRule (model) { const that = this; - this.fetchRule(model).done(function () { + this.fetchRule(model).done(() => { model.set({ exist: true }); that.showViewer(RuleView, model); - }).fail(function () { + }).fail(() => { model.set({ exist: false }); that.showViewer(RuleView, model); }); @@ -128,7 +128,7 @@ Workspace.prototype = { fetchRule (model) { const url = window.baseUrl + '/api/rules/show'; const options = { key: model.get('key') }; - return $.get(url, options).done(function (r) { + return $.get(url, options).done(r => { model.set(r.rule); }); } diff --git a/server/sonar-web/src/main/js/components/workspace/views/viewer-view.js b/server/sonar-web/src/main/js/components/workspace/views/viewer-view.js index f944db98b5c..44accb70df1 100644 --- a/server/sonar-web/src/main/js/components/workspace/views/viewer-view.js +++ b/server/sonar-web/src/main/js/components/workspace/views/viewer-view.js @@ -34,7 +34,7 @@ export default BaseView.extend({ const viewer = new SourceViewer(); const options = this.model.toJSON(); viewer.open(this.model.get('uuid'), { workspace: true }); - viewer.on('loaded', function () { + viewer.on('loaded', () => { that.model.set({ name: viewer.model.get('name'), q: viewer.model.get('q') diff --git a/server/sonar-web/src/main/js/helpers/__tests__/measures-test.js b/server/sonar-web/src/main/js/helpers/__tests__/measures-test.js index 438fd223f90..e1f5a348666 100644 --- a/server/sonar-web/src/main/js/helpers/__tests__/measures-test.js +++ b/server/sonar-web/src/main/js/helpers/__tests__/measures-test.js @@ -25,7 +25,7 @@ const ONE_MINUTE = 1; const ONE_HOUR = ONE_MINUTE * 60; const ONE_DAY = HOURS_IN_DAY * ONE_HOUR; -beforeEach(function () { +beforeEach(() => { resetBundle({ 'work_duration.x_days': '{0}d', 'work_duration.x_hours': '{0}h', @@ -37,8 +37,8 @@ beforeEach(function () { }); }); -describe('#formatMeasure()', function () { - it('should format INT', function () { +describe('#formatMeasure()', () => { + it('should format INT', () => { expect(formatMeasure(0, 'INT')).toBe('0'); expect(formatMeasure(1, 'INT')).toBe('1'); expect(formatMeasure(-5, 'INT')).toBe('-5'); @@ -49,7 +49,7 @@ describe('#formatMeasure()', function () { expect(formatMeasure(1234567890, 'INT')).toBe('1,234,567,890'); }); - it('should format SHORT_INT', function () { + it('should format SHORT_INT', () => { expect(formatMeasure(0, 'SHORT_INT')).toBe('0'); expect(formatMeasure(1, 'SHORT_INT')).toBe('1'); expect(formatMeasure(999, 'SHORT_INT')).toBe('999'); @@ -60,7 +60,7 @@ describe('#formatMeasure()', function () { expect(formatMeasure(1234567890, 'SHORT_INT')).toBe('1b'); }); - it('should format FLOAT', function () { + it('should format FLOAT', () => { expect(formatMeasure(0.0, 'FLOAT')).toBe('0.0'); expect(formatMeasure(1.0, 'FLOAT')).toBe('1.0'); expect(formatMeasure(1.3, 'FLOAT')).toBe('1.3'); @@ -72,14 +72,14 @@ describe('#formatMeasure()', function () { expect(formatMeasure(1234567890.0, 'FLOAT')).toBe('1,234,567,890.0'); }); - it('should respect FLOAT precision', function () { + it('should respect FLOAT precision', () => { expect(formatMeasure(0.1, 'FLOAT')).toBe('0.1'); expect(formatMeasure(0.12, 'FLOAT')).toBe('0.12'); expect(formatMeasure(0.12345, 'FLOAT')).toBe('0.12345'); expect(formatMeasure(0.123456, 'FLOAT')).toBe('0.12346'); }); - it('should format PERCENT', function () { + it('should format PERCENT', () => { expect(formatMeasure(0.0, 'PERCENT')).toBe('0.0%'); expect(formatMeasure(1.0, 'PERCENT')).toBe('1.0%'); expect(formatMeasure(1.3, 'PERCENT')).toBe('1.3%'); @@ -88,7 +88,7 @@ describe('#formatMeasure()', function () { expect(formatMeasure(100.0, 'PERCENT')).toBe('100.0%'); }); - it('should format WORK_DUR', function () { + it('should format WORK_DUR', () => { expect(formatMeasure(0, 'WORK_DUR')).toBe('0'); expect(formatMeasure(5 * ONE_DAY, 'WORK_DUR')).toBe('5d'); expect(formatMeasure(2 * ONE_HOUR, 'WORK_DUR')).toBe('2h'); @@ -103,7 +103,7 @@ describe('#formatMeasure()', function () { expect(formatMeasure(-1 * ONE_MINUTE, 'WORK_DUR')).toBe('-1min'); }); - it('should format SHORT_WORK_DUR', function () { + it('should format SHORT_WORK_DUR', () => { expect(formatMeasure(0, 'SHORT_WORK_DUR')).toBe('0'); expect(formatMeasure(5 * ONE_DAY, 'SHORT_WORK_DUR')).toBe('5d'); expect(formatMeasure(2 * ONE_HOUR, 'SHORT_WORK_DUR')).toBe('2h'); @@ -127,7 +127,7 @@ describe('#formatMeasure()', function () { expect(formatMeasure(1234567 * ONE_DAY + 2 * ONE_HOUR, 'SHORT_WORK_DUR')).toBe('1md'); }); - it('should format RATING', function () { + it('should format RATING', () => { expect(formatMeasure(1, 'RATING')).toBe('A'); expect(formatMeasure(2, 'RATING')).toBe('B'); expect(formatMeasure(3, 'RATING')).toBe('C'); @@ -135,14 +135,14 @@ describe('#formatMeasure()', function () { expect(formatMeasure(5, 'RATING')).toBe('E'); }); - it('should format LEVEL', function () { + it('should format LEVEL', () => { expect(formatMeasure('ERROR', 'LEVEL')).toBe('Error'); expect(formatMeasure('WARN', 'LEVEL')).toBe('Warning'); expect(formatMeasure('OK', 'LEVEL')).toBe('Ok'); expect(formatMeasure('UNKNOWN', 'LEVEL')).toBe('UNKNOWN'); }); - it('should format MILLISEC', function () { + it('should format MILLISEC', () => { expect(formatMeasure(0, 'MILLISEC')).toBe('0ms'); expect(formatMeasure(1, 'MILLISEC')).toBe('1ms'); expect(formatMeasure(173, 'MILLISEC')).toBe('173ms'); @@ -151,21 +151,21 @@ describe('#formatMeasure()', function () { expect(formatMeasure(17862325, 'MILLISEC')).toBe('298min'); }); - it('should not format unknown type', function () { + it('should not format unknown type', () => { expect(formatMeasure('random value', 'RANDOM_TYPE')).toBe('random value'); }); - it('should return null if value is empty string', function () { + it('should return null if value is empty string', () => { expect(formatMeasure('', 'PERCENT')).toBeNull(); }); - it('should not fail without parameters', function () { + it('should not fail without parameters', () => { expect(formatMeasure()).toBeNull(); }); }); -describe('#formatMeasureVariation()', function () { - it('should format INT', function () { +describe('#formatMeasureVariation()', () => { + it('should format INT', () => { expect(formatMeasureVariation(0, 'INT')).toBe('+0'); expect(formatMeasureVariation(1, 'INT')).toBe('+1'); expect(formatMeasureVariation(-1, 'INT')).toBe('-1'); @@ -173,7 +173,7 @@ describe('#formatMeasureVariation()', function () { expect(formatMeasureVariation(-1529, 'INT')).toBe('-1,529'); }); - it('should format SHORT_INT', function () { + it('should format SHORT_INT', () => { expect(formatMeasureVariation(0, 'SHORT_INT')).toBe('+0'); expect(formatMeasureVariation(1, 'SHORT_INT')).toBe('+1'); expect(formatMeasureVariation(-1, 'SHORT_INT')).toBe('-1'); @@ -183,7 +183,7 @@ describe('#formatMeasureVariation()', function () { expect(formatMeasureVariation(-10678, 'SHORT_INT')).toBe('-11k'); }); - it('should format FLOAT', function () { + it('should format FLOAT', () => { expect(formatMeasureVariation(0.0, 'FLOAT')).toBe('+0.0'); expect(formatMeasureVariation(1.0, 'FLOAT')).toBe('+1.0'); expect(formatMeasureVariation(-1.0, 'FLOAT')).toBe('-1.0'); @@ -191,14 +191,14 @@ describe('#formatMeasureVariation()', function () { expect(formatMeasureVariation(-50.89, 'FLOAT')).toBe('-50.89'); }); - it('should respect FLOAT precision', function () { + it('should respect FLOAT precision', () => { expect(formatMeasureVariation(0.1, 'FLOAT')).toBe('+0.1'); expect(formatMeasureVariation(0.12, 'FLOAT')).toBe('+0.12'); expect(formatMeasureVariation(0.12345, 'FLOAT')).toBe('+0.12345'); expect(formatMeasureVariation(0.123456, 'FLOAT')).toBe('+0.12346'); }); - it('should format PERCENT', function () { + it('should format PERCENT', () => { expect(formatMeasureVariation(0.0, 'PERCENT')).toBe('+0.0%'); expect(formatMeasureVariation(1.0, 'PERCENT')).toBe('+1.0%'); expect(formatMeasureVariation(-1.0, 'PERCENT')).toBe('-1.0%'); @@ -206,7 +206,7 @@ describe('#formatMeasureVariation()', function () { expect(formatMeasureVariation(-50.89, 'PERCENT')).toBe('-50.9%'); }); - it('should format WORK_DUR', function () { + it('should format WORK_DUR', () => { expect(formatMeasureVariation(0, 'WORK_DUR')).toBe('+0'); expect(formatMeasureVariation(5 * ONE_DAY, 'WORK_DUR')).toBe('+5d'); expect(formatMeasureVariation(2 * ONE_HOUR, 'WORK_DUR')).toBe('+2h'); @@ -216,7 +216,7 @@ describe('#formatMeasureVariation()', function () { expect(formatMeasureVariation(-1 * ONE_MINUTE, 'WORK_DUR')).toBe('-1min'); }); - it('should format SHORT_WORK_DUR', function () { + it('should format SHORT_WORK_DUR', () => { expect(formatMeasureVariation(0, 'SHORT_WORK_DUR')).toBe('+0'); expect(formatMeasureVariation(5 * ONE_DAY, 'SHORT_WORK_DUR')).toBe('+5d'); expect(formatMeasureVariation(2 * ONE_HOUR, 'SHORT_WORK_DUR')).toBe('+2h'); @@ -240,11 +240,11 @@ describe('#formatMeasureVariation()', function () { expect(formatMeasureVariation(1234567 * ONE_DAY + 2 * ONE_HOUR, 'SHORT_WORK_DUR')).toBe('+1md'); }); - it('should not format unknown type', function () { + it('should not format unknown type', () => { expect(formatMeasureVariation('random value', 'RANDOM_TYPE')).toBe('random value'); }); - it('should not fail without parameters', function () { + it('should not fail without parameters', () => { expect(formatMeasureVariation()).toBeNull(); }); }); diff --git a/server/sonar-web/src/main/js/helpers/__tests__/path-test.js b/server/sonar-web/src/main/js/helpers/__tests__/path-test.js index 16177a734ca..67adb95a1c1 100644 --- a/server/sonar-web/src/main/js/helpers/__tests__/path-test.js +++ b/server/sonar-web/src/main/js/helpers/__tests__/path-test.js @@ -19,48 +19,48 @@ */ import { collapsedDirFromPath, fileFromPath } from '../path'; -describe('#collapsedDirFromPath()', function () { - it('should return null when pass null', function () { +describe('#collapsedDirFromPath()', () => { + it('should return null when pass null', () => { expect(collapsedDirFromPath(null)).toBeNull(); }); - it('should return "/" when pass "/"', function () { + it('should return "/" when pass "/"', () => { expect(collapsedDirFromPath('/')).toBe('/'); }); - it('should not cut short path', function () { + it('should not cut short path', () => { expect(collapsedDirFromPath('src/main/js/components/state.js')).toBe('src/main/js/components/'); }); - it('should cut long path', function () { + it('should cut long path', () => { expect(collapsedDirFromPath('src/main/js/components/navigator/app/models/state.js')) .toBe('src/.../js/components/navigator/app/models/'); }); - it('should cut very long path', function () { + it('should cut very long path', () => { expect(collapsedDirFromPath('src/main/another/js/components/navigator/app/models/state.js')) .toBe('src/.../js/components/navigator/app/models/'); }); }); -describe('#fileFromPath()', function () { - it('should return null when pass null', function () { +describe('#fileFromPath()', () => { + it('should return null when pass null', () => { expect(fileFromPath(null)).toBeNull(); }); - it('should return empty string when pass "/"', function () { + it('should return empty string when pass "/"', () => { expect(fileFromPath('/')).toBe(''); }); - it('should return file name when pass only file name', function () { + it('should return file name when pass only file name', () => { expect(fileFromPath('file.js')).toBe('file.js'); }); - it('should return file name when pass file path', function () { + it('should return file name when pass file path', () => { expect(fileFromPath('src/main/js/file.js')).toBe('file.js'); }); - it('should return file name when pass file name without extension', function () { + it('should return file name when pass file name without extension', () => { expect(fileFromPath('src/main/file')).toBe('file'); }); }); diff --git a/server/sonar-web/src/main/js/helpers/__tests__/urls-test.js b/server/sonar-web/src/main/js/helpers/__tests__/urls-test.js index ba69a1bde67..2b290d7114a 100644 --- a/server/sonar-web/src/main/js/helpers/__tests__/urls-test.js +++ b/server/sonar-web/src/main/js/helpers/__tests__/urls-test.js @@ -26,60 +26,60 @@ const METRIC = 'coverage'; let oldBaseUrl; -beforeEach(function () { +beforeEach(() => { oldBaseUrl = window.baseUrl; }); -afterEach(function () { +afterEach(() => { window.baseUrl = oldBaseUrl; }); -describe('#getComponentUrl', function () { - it('should return component url', function () { +describe('#getComponentUrl', () => { + it('should return component url', () => { expect(getComponentUrl(SIMPLE_COMPONENT_KEY)).toBe('/dashboard?id=' + SIMPLE_COMPONENT_KEY); }); - it('should encode component key', function () { + it('should encode component key', () => { expect(getComponentUrl(COMPLEX_COMPONENT_KEY)).toBe('/dashboard?id=' + COMPLEX_COMPONENT_KEY_ENCODED); }); - it('should take baseUrl into account', function () { + it('should take baseUrl into account', () => { window.baseUrl = '/context'; expect(getComponentUrl(COMPLEX_COMPONENT_KEY)).toBe('/context/dashboard?id=' + COMPLEX_COMPONENT_KEY_ENCODED); }); }); -describe('#getComponentIssuesUrl', function () { - it('should work without parameters', function () { +describe('#getComponentIssuesUrl', () => { + it('should work without parameters', () => { expect(getComponentIssuesUrl(SIMPLE_COMPONENT_KEY, {})).toBe( '/component_issues?id=' + SIMPLE_COMPONENT_KEY + '#'); }); - it('should encode component key', function () { + it('should encode component key', () => { expect(getComponentIssuesUrl(COMPLEX_COMPONENT_KEY, {})).toBe( '/component_issues?id=' + COMPLEX_COMPONENT_KEY_ENCODED + '#'); }); - it('should work with parameters', function () { + it('should work with parameters', () => { expect(getComponentIssuesUrl(SIMPLE_COMPONENT_KEY, { resolved: 'false' })).toBe( '/component_issues?id=' + SIMPLE_COMPONENT_KEY + '#resolved=false'); }); - it('should encode parameters', function () { + it('should encode parameters', () => { expect(getComponentIssuesUrl(SIMPLE_COMPONENT_KEY, { componentUuids: COMPLEX_COMPONENT_KEY })).toBe( '/component_issues?id=' + SIMPLE_COMPONENT_KEY + '#componentUuids=' + COMPLEX_COMPONENT_KEY_ENCODED); }); }); -describe('#getComponentDrilldownUrl', function () { - it('should return component drilldown url', function () { +describe('#getComponentDrilldownUrl', () => { + it('should return component drilldown url', () => { expect(getComponentDrilldownUrl(SIMPLE_COMPONENT_KEY, METRIC)).toEqual({ pathname: '/component_measures/metric/' + METRIC, query: { id: SIMPLE_COMPONENT_KEY } }); }); - it('should encode component key', function () { + it('should encode component key', () => { expect(getComponentDrilldownUrl(COMPLEX_COMPONENT_KEY, METRIC)).toEqual({ pathname: '/component_measures/metric/' + METRIC, query: { id: COMPLEX_COMPONENT_KEY } diff --git a/server/sonar-web/src/main/js/helpers/handlebars/all.js b/server/sonar-web/src/main/js/helpers/handlebars/all.js index 2019577fe2e..235dfc0d323 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/all.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/all.js @@ -20,8 +20,6 @@ module.exports = function (...args) { const options = args[args.length - 1]; const list = args.slice(0, -1); - const all = list.reduce(function (prev, current) { - return prev && current; - }, true); + const all = list.reduce((prev, current) => prev && current, true); return all ? options.fn(this) : options.inverse(this); }; diff --git a/server/sonar-web/src/main/js/helpers/handlebars/any.js b/server/sonar-web/src/main/js/helpers/handlebars/any.js index a82aacd80c2..a80870804f5 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/any.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/any.js @@ -20,8 +20,6 @@ module.exports = function (...args) { const options = args[args.length - 1]; const list = args.slice(0, -1); - const any = list.reduce(function (prev, current) { - return prev || current; - }, false); + const any = list.reduce((prev, current) => prev || current, false); return any ? options.fn(this) : options.inverse(this); }; diff --git a/server/sonar-web/src/main/js/helpers/handlebars/componentDashboardPermalink.js b/server/sonar-web/src/main/js/helpers/handlebars/componentDashboardPermalink.js index 4409bdfa442..163cc9bf737 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/componentDashboardPermalink.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/componentDashboardPermalink.js @@ -32,8 +32,6 @@ module.exports = function (componentKey, dashboardKey) { } } - const query = params.map(function (p) { - return p.key + '=' + encodeURIComponent(p.value); - }).join('&'); + const query = params.map(p => p.key + '=' + encodeURIComponent(p.value)).join('&'); return window.baseUrl + '/dashboard/index?' + query; }; diff --git a/server/sonar-web/src/main/js/helpers/handlebars/default.js b/server/sonar-web/src/main/js/helpers/handlebars/default.js index deabad32ed6..c11ad2ca3aa 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/default.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/default.js @@ -19,7 +19,5 @@ */ module.exports = function (...args) { const list = args.slice(0, -1); - return list.reduce(function (prev, current) { - return prev != null ? prev : current; - }, null); + return list.reduce((prev, current) => prev != null ? prev : current, null); }; diff --git a/server/sonar-web/src/main/js/helpers/handlebars/eachChanged.js b/server/sonar-web/src/main/js/helpers/handlebars/eachChanged.js index 9c415b1dfca..c2c90e109e1 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/eachChanged.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/eachChanged.js @@ -21,7 +21,7 @@ import _ from 'underscore'; module.exports = function (context, property, options) { let ret = ''; - context.forEach(function (d, i) { + context.forEach((d, i) => { const changed = i > 0 ? d[property] !== context[i - 1][property] : true; const c = _.extend({ changed }, d); ret += options.fn(c); diff --git a/server/sonar-web/src/main/js/helpers/handlebars/eachEven.js b/server/sonar-web/src/main/js/helpers/handlebars/eachEven.js index ca20b14eaad..062740d6790 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/eachEven.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/eachEven.js @@ -19,7 +19,7 @@ */ module.exports = function (context, options) { let ret = ''; - context.forEach(function (d, i) { + context.forEach((d, i) => { if (i % 2 === 0) { ret += options.fn(d); } diff --git a/server/sonar-web/src/main/js/helpers/handlebars/eachIndex.js b/server/sonar-web/src/main/js/helpers/handlebars/eachIndex.js index 37eb85e2301..6d1153548f7 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/eachIndex.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/eachIndex.js @@ -21,7 +21,7 @@ import _ from 'underscore'; module.exports = function (context, options) { let ret = ''; - context.forEach(function (d, i) { + context.forEach((d, i) => { const c = _.extend({ index: i }, d); ret += options.fn(c); }); diff --git a/server/sonar-web/src/main/js/helpers/handlebars/eachOdd.js b/server/sonar-web/src/main/js/helpers/handlebars/eachOdd.js index ea74fd6ddeb..0ff8267802f 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/eachOdd.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/eachOdd.js @@ -19,7 +19,7 @@ */ module.exports = function (context, options) { let ret = ''; - context.forEach(function (d, i) { + context.forEach((d, i) => { if (i % 2 === 1) { ret += options.fn(d); } diff --git a/server/sonar-web/src/main/js/helpers/handlebars/eachWithPrevious.js b/server/sonar-web/src/main/js/helpers/handlebars/eachWithPrevious.js index 70ddf847fb6..f2278c37590 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/eachWithPrevious.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/eachWithPrevious.js @@ -23,7 +23,7 @@ module.exports = function (context, options) { let ret = ''; if (Array.isArray(context)) { - context.forEach(function (element, index, list) { + context.forEach((element, index, list) => { const previous = index > 0 ? list[index - 1] : null; const c = _.extend({ '_previous': previous }, element); ret += options.fn(c); diff --git a/server/sonar-web/src/main/js/helpers/handlebars/ifNotEmpty.js b/server/sonar-web/src/main/js/helpers/handlebars/ifNotEmpty.js index d0bd9d4e067..23f8e6525d6 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/ifNotEmpty.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/ifNotEmpty.js @@ -20,8 +20,6 @@ module.exports = function (...args) { const options = args[args.length - 1]; const list = args.slice(0, -1); - const notEmpty = list.reduce(function (prev, current) { - return prev || (current && current.length > 0); - }, false); + const notEmpty = list.reduce((prev, current) => prev || (current && current.length > 0), false); return notEmpty ? options.fn(this) : options.inverse(this); }; diff --git a/server/sonar-web/src/main/js/helpers/handlebars/issueFilterItemLink.js b/server/sonar-web/src/main/js/helpers/handlebars/issueFilterItemLink.js index 10b926d86a2..6aefdb3087e 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/issueFilterItemLink.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/issueFilterItemLink.js @@ -22,7 +22,7 @@ import _ from 'underscore'; function getQuery (query, separator) { separator = separator || '|'; const route = []; - _.forEach(query, function (value, property) { + _.forEach(query, (value, property) => { route.push(`${property}=${encodeURIComponent(value)}`); }); return route.join(separator); diff --git a/server/sonar-web/src/main/js/helpers/handlebars/issueFilterTotalLink.js b/server/sonar-web/src/main/js/helpers/handlebars/issueFilterTotalLink.js index 96e6863eefc..99124f03c09 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/issueFilterTotalLink.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/issueFilterTotalLink.js @@ -22,7 +22,7 @@ import _ from 'underscore'; function getQuery (query, separator) { separator = separator || '|'; const route = []; - _.forEach(query, function (value, property) { + _.forEach(query, (value, property) => { route.push(`${property}=${encodeURIComponent(value)}`); }); return route.join(separator); diff --git a/server/sonar-web/src/main/js/helpers/handlebars/log.js b/server/sonar-web/src/main/js/helpers/handlebars/log.js index c1190223b11..8c373edbc0d 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/log.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/log.js @@ -19,5 +19,5 @@ */ module.exports = function (...args) { /* eslint no-console: 0 */ - console.log.apply(console, args.slice(0, -1)); + console.log(...args.slice(0, -1)); }; diff --git a/server/sonar-web/src/main/js/helpers/handlebars/operators.js b/server/sonar-web/src/main/js/helpers/handlebars/operators.js index 7d7625ee5bd..a608417d4e2 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/operators.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/operators.js @@ -20,7 +20,5 @@ module.exports = function (options) { const ops = ['LT', 'GT', 'EQ', 'NE']; - return ops.reduce(function (prev, current) { - return prev + options.fn(current); - }, ''); + return ops.reduce((prev, current) => prev + options.fn(current), ''); }; diff --git a/server/sonar-web/src/main/js/helpers/handlebars/recursive.js b/server/sonar-web/src/main/js/helpers/handlebars/recursive.js index b6153cad05b..22422d044f7 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/recursive.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/recursive.js @@ -26,8 +26,8 @@ module.exports = function (children, options) { audaciousFn = options.fn; } - children.forEach(function (child) { - out = out + audaciousFn(child); + children.forEach(child => { + out += audaciousFn(child); }); return out; diff --git a/server/sonar-web/src/main/js/helpers/handlebars/show.js b/server/sonar-web/src/main/js/helpers/handlebars/show.js index 7606767eb31..2c2713055fe 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/show.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/show.js @@ -19,7 +19,7 @@ */ module.exports = function (...args) { let ret = null; - args.forEach(function (arg) { + args.forEach(arg => { if (typeof arg === 'string' && ret == null) { ret = arg; } diff --git a/server/sonar-web/src/main/js/helpers/handlebars/sources.js b/server/sonar-web/src/main/js/helpers/handlebars/sources.js index b76d12978b8..79b38792b8c 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/sources.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/sources.js @@ -25,7 +25,7 @@ module.exports = function (source, scm, options) { scm = null; } - const sources = _.map(source, function (code, line) { + const sources = _.map(source, (code, line) => { return { code, lineNumber: line, @@ -33,7 +33,7 @@ module.exports = function (source, scm, options) { }; }); - return sources.reduce(function (prev, current, index) { - return prev + options.fn(_.extend({ first: index === 0 }, current)); - }, ''); + return sources.reduce((prev, current, index) => ( + prev + options.fn(_.extend({ first: index === 0 }, current)) + ), ''); }; diff --git a/server/sonar-web/src/main/js/helpers/handlebars/sum.js b/server/sonar-web/src/main/js/helpers/handlebars/sum.js index 5a059782067..952abac5bd4 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/sum.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/sum.js @@ -19,7 +19,5 @@ */ module.exports = function (...args) { const list = args.slice(0, -1); - return list.reduce(function (p, c) { - return p + +c; - }, 0); + return list.reduce((p, c) => p + +c, 0); }; diff --git a/server/sonar-web/src/main/js/helpers/handlebars/withoutFirst.js b/server/sonar-web/src/main/js/helpers/handlebars/withoutFirst.js index 3e2d7628348..e224f9b992c 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/withoutFirst.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/withoutFirst.js @@ -19,9 +19,7 @@ */ module.exports = function (list, options) { if (list && list.length > 1) { - return list.slice(1).reduce(function (prev, current) { - return prev + options.fn(current); - }, ''); + return list.slice(1).reduce((prev, current) => prev + options.fn(current), ''); } else { return ''; } diff --git a/server/sonar-web/src/main/js/helpers/l10n.js b/server/sonar-web/src/main/js/helpers/l10n.js index d77ff416682..2fa9781f116 100644 --- a/server/sonar-web/src/main/js/helpers/l10n.js +++ b/server/sonar-web/src/main/js/helpers/l10n.js @@ -28,7 +28,7 @@ export function translate (...keys: string[]) { return messages[messageKey] || messageKey; } -export function translateWithParameters (messageKey: string, ...parameters: Array<string|number>) { +export function translateWithParameters (messageKey: string, ...parameters: Array<string | number>) { const message = messages[messageKey]; if (message) { return parameters @@ -118,7 +118,7 @@ export function requestMessages () { }); } -export function resetBundle (bundle: any) { +export function resetBundle (bundle: Object) { messages = bundle; } diff --git a/server/sonar-web/src/main/js/helpers/latinize.js b/server/sonar-web/src/main/js/helpers/latinize.js index 9eb3af47608..38bc498cb62 100644 --- a/server/sonar-web/src/main/js/helpers/latinize.js +++ b/server/sonar-web/src/main/js/helpers/latinize.js @@ -380,9 +380,7 @@ for (let i = 0; i < defaultDiacriticsRemovalap.length; i++) { // "what?" version ... http://jsperf.com/diacritics/12 function removeDiacritics (str) { - return str.replace(/[^\u0000-\u007E]/g, function (a) { - return diacriticsMap[a] || a; - }); + return str.replace(/[^\u0000-\u007E]/g, a => diacriticsMap[a] || a); } export default removeDiacritics; diff --git a/server/sonar-web/src/main/js/helpers/request.js b/server/sonar-web/src/main/js/helpers/request.js index b58d1dda053..0a21213ffdf 100644 --- a/server/sonar-web/src/main/js/helpers/request.js +++ b/server/sonar-web/src/main/js/helpers/request.js @@ -228,6 +228,6 @@ export function requestDelete (url: string, data?: Object): Promise<Object> { * @param response * @returns {Promise} */ -export function delay (response: any): Promise<any> { +export function delay (response: *): Promise<*> { return new Promise(resolve => setTimeout(() => resolve(response), 1200)); } diff --git a/server/sonar-web/src/main/js/store/appState/duck.js b/server/sonar-web/src/main/js/store/appState/duck.js index a9d2180dd03..1fe430c990a 100644 --- a/server/sonar-web/src/main/js/store/appState/duck.js +++ b/server/sonar-web/src/main/js/store/appState/duck.js @@ -27,7 +27,7 @@ type AppState = { export type Action = { type: string, appState: AppState -} +}; export const actions = { SET_APP_STATE: 'SET_APP_STATE', diff --git a/server/sonar-web/src/main/js/store/projectActivity/analyses.js b/server/sonar-web/src/main/js/store/projectActivity/analyses.js index b60abff4b23..9d0cae3f87f 100644 --- a/server/sonar-web/src/main/js/store/projectActivity/analyses.js +++ b/server/sonar-web/src/main/js/store/projectActivity/analyses.js @@ -28,8 +28,8 @@ import type { } from './duck'; type Analysis = { - key: string; - date: string; + key: string, + date: string, events: Array<string> }; diff --git a/server/sonar-web/src/main/js/store/projectActivity/duck.js b/server/sonar-web/src/main/js/store/projectActivity/duck.js index 00ddb08b6d2..acd497e0158 100644 --- a/server/sonar-web/src/main/js/store/projectActivity/duck.js +++ b/server/sonar-web/src/main/js/store/projectActivity/duck.js @@ -30,14 +30,14 @@ import type { State as PagingState } from './paging'; export type Event = { key: string, - name: string; - category: string; - description?: string; + name: string, + category: string, + description?: string }; export type Analysis = { - key: string; - date: string; + key: string, + date: string, events: Array<Event> }; diff --git a/server/sonar-web/src/main/js/store/projectActivity/events.js b/server/sonar-web/src/main/js/store/projectActivity/events.js index 88e6fc27b26..089683558bb 100644 --- a/server/sonar-web/src/main/js/store/projectActivity/events.js +++ b/server/sonar-web/src/main/js/store/projectActivity/events.js @@ -30,9 +30,9 @@ import type { export type State = { [key: string]: { key: string, - name: string; - category: string; - description?: string; + name: string, + category: string, + description?: string, } }; diff --git a/server/sonar-web/src/main/js/store/rootReducer.js b/server/sonar-web/src/main/js/store/rootReducer.js index c7d223c78bf..0077b62ce5e 100644 --- a/server/sonar-web/src/main/js/store/rootReducer.js +++ b/server/sonar-web/src/main/js/store/rootReducer.js @@ -26,7 +26,6 @@ import languages, * as fromLanguages from './languages/reducer'; import measures, * as fromMeasures from './measures/reducer'; import globalMessages, * as fromGlobalMessages from './globalMessages/duck'; import projectActivity from './projectActivity/duck'; - import measuresApp, * as fromMeasuresApp from '../apps/component-measures/store/rootReducer'; import permissionsApp, * as fromPermissionsApp from '../apps/permissions/shared/store/rootReducer'; import projectAdminApp, * as fromProjectAdminApp from '../apps/project-admin/store/rootReducer'; diff --git a/server/sonar-web/yarn.lock b/server/sonar-web/yarn.lock index 653d4d9f9b3..65deded399b 100644 --- a/server/sonar-web/yarn.lock +++ b/server/sonar-web/yarn.lock @@ -228,7 +228,7 @@ aws4@^1.2.1: version "1.5.0" resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.5.0.tgz#0a29ffb79c31c9e712eeb087e8e7a64b4a56d755" -babel-code-frame@^6.20.0, babel-code-frame@^6.8.0: +babel-code-frame@^6.16.0, babel-code-frame@^6.20.0, babel-code-frame@^6.8.0: version "6.20.0" resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-6.20.0.tgz#b968f839090f9a8bc6d41938fb96cb84f7387b26" dependencies: @@ -236,7 +236,7 @@ babel-code-frame@^6.20.0, babel-code-frame@^6.8.0: esutils "^2.0.2" js-tokens "^2.0.0" -babel-core@6.14.0: +babel-core@6.14.0, babel-core@^6.0.0: version "6.14.0" resolved "https://registry.yarnpkg.com/babel-core/-/babel-core-6.14.0.tgz#c9e13ed4e2f97329215496fd9fb48f2b3bcb9b42" dependencies: @@ -262,7 +262,7 @@ babel-core@6.14.0: slash "^1.0.0" source-map "^0.5.0" -babel-core@^6.0.0, babel-core@^6.14.0, babel-core@^6.18.0: +babel-core@^6.14.0, babel-core@^6.18.0: version "6.20.0" resolved "https://registry.yarnpkg.com/babel-core/-/babel-core-6.20.0.tgz#ab0d7176d9dea434e66badadaf92237865eab1ec" dependencies: @@ -1576,18 +1576,18 @@ date-now@^0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/date-now/-/date-now-0.1.4.tgz#eaf439fd4d4848ad74e5cc7dbef200672b9e345b" +debug@2.2.0, debug@~2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/debug/-/debug-2.2.0.tgz#f87057e995b1a1f6ae6a4960664137bc56f039da" + dependencies: + ms "0.7.1" + debug@^2.1.0, debug@^2.1.1, debug@^2.2.0: version "2.3.3" resolved "https://registry.yarnpkg.com/debug/-/debug-2.3.3.tgz#40c453e67e6e13c901ddec317af8986cda9eff8c" dependencies: ms "0.7.2" -debug@~2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/debug/-/debug-2.2.0.tgz#f87057e995b1a1f6ae6a4960664137bc56f039da" - dependencies: - ms "0.7.1" - decamelize@^1.0.0, decamelize@^1.1.1, decamelize@^1.1.2: version "1.2.0" resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" @@ -1663,14 +1663,7 @@ diff@^3.0.0: version "3.1.0" resolved "https://registry.yarnpkg.com/diff/-/diff-3.1.0.tgz#9406c73a401e6c2b3ba901c5e2c44eb6a60c5385" -doctrine@1.2.x: - version "1.2.3" - resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-1.2.3.tgz#6aec6bbd62cf89dd498cae70c0ed9f49da873a6a" - dependencies: - esutils "^2.0.2" - isarray "^1.0.0" - -doctrine@^1.2.2: +doctrine@1.5.0, doctrine@^1.2.2: version "1.5.0" resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-1.5.0.tgz#379dce730f6166f76cefa4e6707a159b02c5a6fa" dependencies: @@ -1859,7 +1852,7 @@ es6-map@^0.1.3: es6-symbol "~3.1.0" event-emitter "~0.3.4" -es6-set@^0.1.4, es6-set@~0.1.3: +es6-set@~0.1.3: version "0.1.4" resolved "https://registry.yarnpkg.com/es6-set/-/es6-set-0.1.4.tgz#9516b6761c2964b92ff479456233a247dc707ce8" dependencies: @@ -1913,10 +1906,6 @@ escope@^3.6.0: esrecurse "^4.1.0" estraverse "^4.1.1" -eslint-config-react-app@0.2.1: - version "0.2.1" - resolved "https://registry.yarnpkg.com/eslint-config-react-app/-/eslint-config-react-app-0.2.1.tgz#ad510d0d0ae11575d0eabe5493ba6e66fb93e68e" - eslint-import-resolver-node@^0.2.0: version "0.2.3" resolved "https://registry.yarnpkg.com/eslint-import-resolver-node/-/eslint-import-resolver-node-0.2.3.tgz#5add8106e8c928db2cba232bcd9efa846e3da16c" @@ -1933,62 +1922,66 @@ eslint-loader@1.5.0: loader-utils "^0.2.7" object-assign "^4.0.1" -eslint-plugin-flowtype@2.18.1: - version "2.18.1" - resolved "https://registry.yarnpkg.com/eslint-plugin-flowtype/-/eslint-plugin-flowtype-2.18.1.tgz#f027524c58b90d27a0544e74c082fba070afd9c8" +eslint-module-utils@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/eslint-module-utils/-/eslint-module-utils-2.0.0.tgz#a6f8c21d901358759cdc35dbac1982ae1ee58bce" + dependencies: + debug "2.2.0" + pkg-dir "^1.0.0" + +eslint-plugin-flowtype@^2.29.1: + version "2.29.1" + resolved "https://registry.yarnpkg.com/eslint-plugin-flowtype/-/eslint-plugin-flowtype-2.29.1.tgz#74cc5603ff0baff6e224482bbd17406b0980f6c3" dependencies: lodash "^4.15.0" -eslint-plugin-import@1.12.0: - version "1.12.0" - resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-1.12.0.tgz#11307eb08179f43692fa845ba8542e82fa333e21" +eslint-plugin-import@^2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.2.0.tgz#72ba306fad305d67c4816348a4699a4229ac8b4e" dependencies: builtin-modules "^1.1.1" contains-path "^0.1.0" debug "^2.2.0" - doctrine "1.2.x" - es6-map "^0.1.3" - es6-set "^0.1.4" + doctrine "1.5.0" eslint-import-resolver-node "^0.2.0" + eslint-module-utils "^2.0.0" + has "^1.0.1" lodash.cond "^4.3.0" - lodash.endswith "^4.0.1" - lodash.find "^4.3.0" - lodash.findindex "^4.3.0" - object-assign "^4.0.1" - pkg-dir "^1.0.0" + minimatch "^3.0.3" pkg-up "^1.0.0" -eslint-plugin-jsx-a11y@2.2.2: - version "2.2.2" - resolved "https://registry.yarnpkg.com/eslint-plugin-jsx-a11y/-/eslint-plugin-jsx-a11y-2.2.2.tgz#ac893b4f9ecb7534bc0373ff6a47388835d3a859" +eslint-plugin-jsx-a11y@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/eslint-plugin-jsx-a11y/-/eslint-plugin-jsx-a11y-3.0.2.tgz#9f0eabcafde3d2a2600d96a66adb90d099e841fe" dependencies: damerau-levenshtein "^1.0.0" jsx-ast-utils "^1.0.0" object-assign "^4.0.1" -eslint-plugin-react@6.3.0: - version "6.3.0" - resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-6.3.0.tgz#fac3504a02917fc8b15f7f28514058cffde9cb76" +eslint-plugin-react@^6.8.0: + version "6.8.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-6.8.0.tgz#741ab5438a094532e5ce1bbb935d6832356f492d" dependencies: doctrine "^1.2.2" - jsx-ast-utils "^1.3.1" + jsx-ast-utils "^1.3.4" -eslint@3.5.0: - version "3.5.0" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-3.5.0.tgz#22fc9f780ea5bca1306fab2b6d3336b0fa62c754" +eslint@^3.12.2: + version "3.12.2" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-3.12.2.tgz#6be5a9aa29658252abd7f91e9132bab1f26f3c34" dependencies: + babel-code-frame "^6.16.0" chalk "^1.1.3" concat-stream "^1.4.6" debug "^2.1.1" doctrine "^1.2.2" escope "^3.6.0" - espree "^3.1.6" + espree "^3.3.1" estraverse "^4.2.0" esutils "^2.0.2" file-entry-cache "^2.0.0" glob "^7.0.3" - globals "^9.2.0" - ignore "^3.1.5" + globals "^9.14.0" + ignore "^3.2.0" imurmurhash "^0.1.4" inquirer "^0.12.0" is-my-json-valid "^2.10.0" @@ -1999,19 +1992,19 @@ eslint@3.5.0: lodash "^4.0.0" mkdirp "^0.5.0" natural-compare "^1.4.0" - optionator "^0.8.1" + optionator "^0.8.2" path-is-inside "^1.0.1" pluralize "^1.2.1" progress "^1.1.8" require-uncached "^1.0.2" - shelljs "^0.6.0" + shelljs "^0.7.5" strip-bom "^3.0.0" strip-json-comments "~1.0.1" table "^3.7.8" text-table "~0.2.0" user-home "^2.0.0" -espree@^3.1.6: +espree@^3.3.1: version "3.3.2" resolved "https://registry.yarnpkg.com/espree/-/espree-3.3.2.tgz#dbf3fadeb4ecb4d4778303e50103b3d36c88b89c" dependencies: @@ -2435,7 +2428,7 @@ glob@5.x: once "^1.3.0" path-is-absolute "^1.0.0" -glob@^7.0.3, glob@^7.0.5: +glob@^7.0.0, glob@^7.0.3, glob@^7.0.5: version "7.1.1" resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.1.tgz#805211df04faaf1c63a3600306cdf5ade50b2ec8" dependencies: @@ -2453,7 +2446,7 @@ global@^4.3.0: min-document "^2.19.0" process "~0.5.1" -globals@^9.0.0, globals@^9.2.0: +globals@^9.0.0, globals@^9.14.0: version "9.14.0" resolved "https://registry.yarnpkg.com/globals/-/globals-9.14.0.tgz#8859936af0038741263053b39d0e76ca241e4034" @@ -2725,7 +2718,7 @@ ieee754@^1.1.4: version "1.1.8" resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.1.8.tgz#be33d40ac10ef1926701f6f08a2d86fbfd1ad3e4" -ignore@^3.1.5: +ignore@^3.2.0: version "3.2.0" resolved "https://registry.yarnpkg.com/ignore/-/ignore-3.2.0.tgz#8d88f03c3002a0ac52114db25d2c673b0bf1e435" @@ -2797,6 +2790,10 @@ interpret@^0.6.4: version "0.6.6" resolved "https://registry.yarnpkg.com/interpret/-/interpret-0.6.6.tgz#fecd7a18e7ce5ca6abfb953e1f86213a49f1625b" +interpret@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.0.1.tgz#d579fb7f693b858004947af39fa0db49f795602c" + invariant@^2.0.0, invariant@^2.2.0, invariant@^2.2.1: version "2.2.2" resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.2.tgz#9e1f56ac0acdb6bf303306f338be3b204ae60360" @@ -3378,7 +3375,7 @@ jsprim@^1.2.2: json-schema "0.2.3" verror "1.3.6" -jsx-ast-utils@^1.0.0, jsx-ast-utils@^1.3.1: +jsx-ast-utils@^1.0.0, jsx-ast-utils@^1.3.4: version "1.3.4" resolved "https://registry.yarnpkg.com/jsx-ast-utils/-/jsx-ast-utils-1.3.4.tgz#0257ed1cc4b1e65b39d7d9940f9fb4f20f7ba0a9" dependencies: @@ -3571,22 +3568,10 @@ lodash.defaults@^4.0.1: version "4.2.0" resolved "https://registry.yarnpkg.com/lodash.defaults/-/lodash.defaults-4.2.0.tgz#d09178716ffea4dde9e5fb7b37f6f0802274580c" -lodash.endswith@^4.0.1: - version "4.2.1" - resolved "https://registry.yarnpkg.com/lodash.endswith/-/lodash.endswith-4.2.1.tgz#fed59ac1738ed3e236edd7064ec456448b37bc09" - lodash.filter@^4.4.0: version "4.6.0" resolved "https://registry.yarnpkg.com/lodash.filter/-/lodash.filter-4.6.0.tgz#668b1d4981603ae1cc5a6fa760143e480b4c4ace" -lodash.find@^4.3.0: - version "4.6.0" - resolved "https://registry.yarnpkg.com/lodash.find/-/lodash.find-4.6.0.tgz#cb0704d47ab71789ffa0de8b97dd926fb88b13b1" - -lodash.findindex@^4.3.0: - version "4.6.0" - resolved "https://registry.yarnpkg.com/lodash.findindex/-/lodash.findindex-4.6.0.tgz#a3245dee61fb9b6e0624b535125624bb69c11106" - lodash.flatten@^4.2.0: version "4.4.0" resolved "https://registry.yarnpkg.com/lodash.flatten/-/lodash.flatten-4.4.0.tgz#f31c22225a9632d2bbf8e4addbef240aa765a61f" @@ -3785,7 +3770,7 @@ min-document@^2.19.0: dependencies: dom-walk "^0.1.0" -"minimatch@2 || 3", minimatch@^3.0.0, minimatch@^3.0.2: +"minimatch@2 || 3", minimatch@^3.0.0, minimatch@^3.0.2, minimatch@^3.0.3: version "3.0.3" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.3.tgz#2a4e4090b96b2db06a9d7df01055a62a77c9b774" dependencies: @@ -4107,7 +4092,7 @@ optimist@~0.3, optimist@~0.3.5: dependencies: wordwrap "~0.0.2" -optionator@^0.8.1: +optionator@^0.8.1, optionator@^0.8.2: version "0.8.2" resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.8.2.tgz#364c5e409d3f4d6301d6c0b4c05bba50180aeb64" dependencies: @@ -4820,6 +4805,12 @@ readline2@^1.0.1: is-fullwidth-code-point "^1.0.0" mute-stream "0.0.5" +rechoir@^0.6.2: + version "0.6.2" + resolved "https://registry.yarnpkg.com/rechoir/-/rechoir-0.6.2.tgz#85204b54dba82d5742e28c96756ef43af50e3384" + dependencies: + resolve "^1.1.6" + recursive-readdir@2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/recursive-readdir/-/recursive-readdir-2.1.0.tgz#78b7bfd79582d3d7596b8ff1bd29fbd50229f6aa" @@ -5143,9 +5134,13 @@ shebang-regex@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3" -shelljs@^0.6.0: - version "0.6.1" - resolved "https://registry.yarnpkg.com/shelljs/-/shelljs-0.6.1.tgz#ec6211bed1920442088fe0f70b2837232ed2c8a8" +shelljs@^0.7.5: + version "0.7.5" + resolved "https://registry.yarnpkg.com/shelljs/-/shelljs-0.7.5.tgz#2eef7a50a21e1ccf37da00df767ec69e30ad0675" + dependencies: + glob "^7.0.0" + interpret "^1.0.0" + rechoir "^0.6.2" shellwords@^0.1.0: version "0.1.0" |