diff options
Diffstat (limited to 'server/sonar-web/src/main/js/apps')
54 files changed, 99 insertions, 53 deletions
diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/TaskActions.tsx b/server/sonar-web/src/main/js/apps/background-tasks/components/TaskActions.tsx index 748acacd729..285e7a4d50f 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/components/TaskActions.tsx +++ b/server/sonar-web/src/main/js/apps/background-tasks/components/TaskActions.tsx @@ -69,9 +69,9 @@ export default class TaskActions extends React.PureComponent<Props, State> { render() { const { component, task } = this.props; - const canFilter = component == undefined; + const canFilter = component === undefined; const canCancel = task.status === STATUSES.PENDING; - const canShowStacktrace = task.errorMessage != undefined; + const canShowStacktrace = task.errorMessage !== undefined; const hasActions = canFilter || canCancel || task.hasScannerContext || canShowStacktrace; if (!hasActions) { diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/Workers.tsx b/server/sonar-web/src/main/js/apps/background-tasks/components/Workers.tsx index 9c51b4a9c10..87fa85e25e7 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/components/Workers.tsx +++ b/server/sonar-web/src/main/js/apps/background-tasks/components/Workers.tsx @@ -83,7 +83,7 @@ export default class Workers extends React.PureComponent<{}, State> { }; toggleNoSupportPopup = (show?: boolean) => { - if (show != undefined) { + if (show !== undefined) { this.setState({ noSupportPopup: show }); } else { this.setState(state => ({ noSupportPopup: !state.noSupportPopup })); diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/ScannerContext-test.tsx b/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/ScannerContext-test.tsx index af7194151d6..64cd98c8f77 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/ScannerContext-test.tsx +++ b/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/ScannerContext-test.tsx @@ -17,6 +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. */ +/* eslint-disable import/first, import/order */ jest.mock('../../../../api/ce', () => ({ getTask: jest.fn() })); diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/Stacktrace-test.tsx b/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/Stacktrace-test.tsx index 979af8df09e..28bddab75a8 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/Stacktrace-test.tsx +++ b/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/Stacktrace-test.tsx @@ -17,6 +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. */ +/* eslint-disable import/first, import/order */ jest.mock('../../../../api/ce', () => ({ getTask: jest.fn() })); diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/WorkersForm-test.tsx b/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/WorkersForm-test.tsx index 813eff21896..94bd72f7542 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/WorkersForm-test.tsx +++ b/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/WorkersForm-test.tsx @@ -17,6 +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. */ +/* eslint-disable import/first, import/order */ jest.mock('../../../../api/ce', () => ({ setWorkerCount: () => Promise.resolve() })); diff --git a/server/sonar-web/src/main/js/apps/code/components/App.tsx b/server/sonar-web/src/main/js/apps/code/components/App.tsx index aa773ae2177..2fd66d70ad7 100644 --- a/server/sonar-web/src/main/js/apps/code/components/App.tsx +++ b/server/sonar-web/src/main/js/apps/code/components/App.tsx @@ -222,8 +222,8 @@ export default class App extends React.PureComponent<Props, State> { <Breadcrumbs branch={branchName} breadcrumbs={breadcrumbs} rootComponent={component} /> )} - {sourceViewer == undefined && - components != undefined && ( + {sourceViewer === undefined && + components !== undefined && ( <div className={componentsClassName}> <Components baseComponent={baseComponent} @@ -234,12 +234,12 @@ export default class App extends React.PureComponent<Props, State> { </div> )} - {sourceViewer == undefined && - components != undefined && ( + {sourceViewer === undefined && + components !== undefined && ( <ListFooter count={components.length} total={total} loadMore={this.handleLoadMore} /> )} - {sourceViewer != undefined && ( + {sourceViewer !== undefined && ( <div className="spacer-top"> <SourceViewer branch={branchName} component={sourceViewer.key} /> </div> diff --git a/server/sonar-web/src/main/js/apps/code/components/ComponentName.tsx b/server/sonar-web/src/main/js/apps/code/components/ComponentName.tsx index c0947e98ec0..65f855700ed 100644 --- a/server/sonar-web/src/main/js/apps/code/components/ComponentName.tsx +++ b/server/sonar-web/src/main/js/apps/code/components/ComponentName.tsx @@ -59,7 +59,7 @@ export default function ComponentName(props: Props) { const { branch, component, rootComponent, previous, canBrowse = false } = props; const areBothDirs = component.qualifier === 'DIR' && previous && previous.qualifier === 'DIR'; const prefix = - areBothDirs && previous != undefined + areBothDirs && previous !== undefined ? mostCommitPrefix([component.name + '/', previous.name + '/']) : ''; const name = prefix ? ( diff --git a/server/sonar-web/src/main/js/apps/issues/components/ComponentBreadcrumbs.tsx b/server/sonar-web/src/main/js/apps/issues/components/ComponentBreadcrumbs.tsx index 6e4b9a13805..b086fb5a125 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/ComponentBreadcrumbs.tsx +++ b/server/sonar-web/src/main/js/apps/issues/components/ComponentBreadcrumbs.tsx @@ -61,8 +61,8 @@ export default function ComponentBreadcrumbs({ branch, component, issue, organiz )} {displaySubProject && - issue.subProject != undefined && - issue.subProjectName != undefined && ( + issue.subProject !== undefined && + issue.subProjectName !== undefined && ( <span title={issue.subProjectName}> <Link to={getProjectUrl(issue.subProject, branch)} className="link-no-underline"> {limitComponentName(issue.subProjectName)} diff --git a/server/sonar-web/src/main/js/apps/portfolio/components/Activity.tsx b/server/sonar-web/src/main/js/apps/portfolio/components/Activity.tsx index 66cef7e572d..7816da08c76 100644 --- a/server/sonar-web/src/main/js/apps/portfolio/components/Activity.tsx +++ b/server/sonar-web/src/main/js/apps/portfolio/components/Activity.tsx @@ -103,8 +103,8 @@ export default class Activity extends React.PureComponent<Props> { {this.state.loading ? ( <i className="spinner" /> ) : ( - this.state.metrics != undefined && - this.state.history != undefined && ( + this.state.metrics !== undefined && + this.state.history !== undefined && ( <AnyPreviewGraph history={this.state.history} metrics={this.state.metrics} diff --git a/server/sonar-web/src/main/js/apps/portfolio/components/App.tsx b/server/sonar-web/src/main/js/apps/portfolio/components/App.tsx index ec7f35fc0b2..7d3efb507bf 100644 --- a/server/sonar-web/src/main/js/apps/portfolio/components/App.tsx +++ b/server/sonar-web/src/main/js/apps/portfolio/components/App.tsx @@ -98,10 +98,10 @@ export default class App extends React.PureComponent<Props, State> { ); } - isEmpty = () => this.state.measures == undefined || this.state.measures['ncloc'] == undefined; + isEmpty = () => this.state.measures === undefined || this.state.measures['ncloc'] === undefined; isNotComputed = () => - this.state.measures && this.state.measures['reliability_rating'] == undefined; + this.state.measures && this.state.measures['reliability_rating'] === undefined; renderSpinner() { return ( @@ -151,8 +151,8 @@ export default class App extends React.PureComponent<Props, State> { <MaintainabilityBox component={component.key} measures={measures!} /> </div> - {subComponents != undefined && - totalSubComponents != undefined && ( + {subComponents !== undefined && + totalSubComponents !== undefined && ( <WorstProjects component={component.key} subComponents={subComponents} diff --git a/server/sonar-web/src/main/js/apps/portfolio/components/__tests__/Activity-test.tsx b/server/sonar-web/src/main/js/apps/portfolio/components/__tests__/Activity-test.tsx index 1959dc4daaf..e0fc5b8ff9d 100644 --- a/server/sonar-web/src/main/js/apps/portfolio/components/__tests__/Activity-test.tsx +++ b/server/sonar-web/src/main/js/apps/portfolio/components/__tests__/Activity-test.tsx @@ -17,6 +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. */ +/* eslint-disable import/first, import/order */ jest.mock('../../../../helpers/storage', () => ({ getCustomGraph: () => ['coverage'], getGraph: () => 'custom' diff --git a/server/sonar-web/src/main/js/apps/portfolio/components/__tests__/App-test.tsx b/server/sonar-web/src/main/js/apps/portfolio/components/__tests__/App-test.tsx index e9c93fb7279..0a894272da3 100644 --- a/server/sonar-web/src/main/js/apps/portfolio/components/__tests__/App-test.tsx +++ b/server/sonar-web/src/main/js/apps/portfolio/components/__tests__/App-test.tsx @@ -17,6 +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. */ +/* eslint-disable import/first, import/order */ jest.mock('../../../../api/measures', () => ({ getMeasures: jest.fn(() => Promise.resolve([])) })); @@ -27,12 +28,14 @@ jest.mock('../../../../api/components', () => ({ // mock Activity to not deal with localstorage jest.mock('../Activity', () => ({ + // eslint-disable-next-line default: function Activity() { return null; } })); jest.mock('../Report', () => ({ + // eslint-disable-next-line default: function Report() { return null; } diff --git a/server/sonar-web/src/main/js/apps/portfolio/components/__tests__/Report-test.tsx b/server/sonar-web/src/main/js/apps/portfolio/components/__tests__/Report-test.tsx index 1a21649ae06..7b725a0ee5e 100644 --- a/server/sonar-web/src/main/js/apps/portfolio/components/__tests__/Report-test.tsx +++ b/server/sonar-web/src/main/js/apps/portfolio/components/__tests__/Report-test.tsx @@ -17,6 +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. */ +/* eslint-disable import/first, import/order */ jest.mock('../../../../api/report', () => { const report = require.requireActual('../../../../api/report'); report.getReportStatus = jest.fn(() => Promise.resolve({})); diff --git a/server/sonar-web/src/main/js/apps/portfolio/components/__tests__/Subscription-test.tsx b/server/sonar-web/src/main/js/apps/portfolio/components/__tests__/Subscription-test.tsx index 4fa146bc940..003d49545a6 100644 --- a/server/sonar-web/src/main/js/apps/portfolio/components/__tests__/Subscription-test.tsx +++ b/server/sonar-web/src/main/js/apps/portfolio/components/__tests__/Subscription-test.tsx @@ -17,6 +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. */ +/* eslint-disable import/first, import/order */ jest.mock('../../../../api/report', () => { const report = require.requireActual('../../../../api/report'); report.subscribe = jest.fn(() => Promise.resolve()); diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/App.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/App.tsx index 5ff696ef9d7..19092afe655 100644 --- a/server/sonar-web/src/main/js/apps/projectBranches/components/App.tsx +++ b/server/sonar-web/src/main/js/apps/projectBranches/components/App.tsx @@ -18,15 +18,15 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; +import { FormattedMessage } from 'react-intl'; +import { Link } from 'react-router'; import BranchRow from './BranchRow'; import LongBranchesPattern from './LongBranchesPattern'; import { Branch } from '../../../app/types'; import { sortBranchesAsTree } from '../../../helpers/branches'; import { translate } from '../../../helpers/l10n'; import { getValues } from '../../../api/settings'; -import { FormattedMessage } from 'react-intl'; import { formatMeasure } from '../../../helpers/measures'; -import { Link } from 'react-router'; interface Props { branches: Branch[]; diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/BranchRow.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/BranchRow.tsx index 3cbc25df9a4..5290f17718c 100644 --- a/server/sonar-web/src/main/js/apps/projectBranches/components/BranchRow.tsx +++ b/server/sonar-web/src/main/js/apps/projectBranches/components/BranchRow.tsx @@ -18,8 +18,8 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; -import { Branch } from '../../../app/types'; import * as classNames from 'classnames'; +import { Branch } from '../../../app/types'; import DeleteBranchModal from './DeleteBranchModal'; import LeakPeriodForm from './LeakPeriodForm'; import BranchStatus from '../../../components/common/BranchStatus'; diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/RenameBranchModal.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/RenameBranchModal.tsx index 181fee72365..02bd8572c9c 100644 --- a/server/sonar-web/src/main/js/apps/projectBranches/components/RenameBranchModal.tsx +++ b/server/sonar-web/src/main/js/apps/projectBranches/components/RenameBranchModal.tsx @@ -109,7 +109,7 @@ export default class RenameBranchModal extends React.PureComponent<Props, State> required={true} size={50} type="text" - value={this.state.name != undefined ? this.state.name : branch.name} + value={this.state.name !== undefined ? this.state.name : branch.name} /> </div> </div> diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/App-test.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/App-test.tsx index 9ffafb34d72..166c8d4a99a 100644 --- a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/App-test.tsx +++ b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/App-test.tsx @@ -17,6 +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. */ +/* eslint-disable import/first, import/order */ jest.mock('../../../../api/settings', () => ({ getValues: jest.fn(() => Promise.resolve([])) })); diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/DeleteBranchModal-test.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/DeleteBranchModal-test.tsx index b2870587114..c5455dbcac6 100644 --- a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/DeleteBranchModal-test.tsx +++ b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/DeleteBranchModal-test.tsx @@ -17,6 +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. */ +/* eslint-disable import/first */ jest.mock('../../../../api/branches', () => ({ deleteBranch: jest.fn() })); import * as React from 'react'; diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/LongBranchesPattern-test.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/LongBranchesPattern-test.tsx index ff142d2065c..48c79f25fed 100644 --- a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/LongBranchesPattern-test.tsx +++ b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/LongBranchesPattern-test.tsx @@ -17,6 +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. */ +/* eslint-disable import/first, import/order */ jest.mock('../../../../api/settings', () => ({ getValues: jest.fn(() => Promise.resolve([])) })); @@ -40,7 +41,7 @@ it('renders', () => { it('opens form', () => { const wrapper = shallow(<LongBranchesPattern project="project" />); - (wrapper.instance() as LongBranchesPattern) .mounted = true; + (wrapper.instance() as LongBranchesPattern).mounted = true; wrapper.setState({ loading: false, setting: { value: 'release-.*' } }); click(wrapper.find('a')); diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/RenameBranchModal-test.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/RenameBranchModal-test.tsx index 3a1c962d68e..9c2b6602815 100644 --- a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/RenameBranchModal-test.tsx +++ b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/RenameBranchModal-test.tsx @@ -17,6 +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. */ +/* eslint-disable import/first */ jest.mock('../../../../api/branches', () => ({ renameBranch: jest.fn() })); import * as React from 'react'; diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/SettingForm-test.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/SettingForm-test.tsx index f74831cd522..60ffeb3fbb4 100644 --- a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/SettingForm-test.tsx +++ b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/SettingForm-test.tsx @@ -17,6 +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. */ +/* eslint-disable import/first, import/order */ jest.mock('../../../../api/settings', () => ({ setSimpleSettingValue: jest.fn(() => Promise.resolve()), resetSettingValue: jest.fn(() => Promise.resolve()) diff --git a/server/sonar-web/src/main/js/apps/projectQualityGate/__tests__/App-test.tsx b/server/sonar-web/src/main/js/apps/projectQualityGate/__tests__/App-test.tsx index ac0d97d33d7..4fa2bc575af 100644 --- a/server/sonar-web/src/main/js/apps/projectQualityGate/__tests__/App-test.tsx +++ b/server/sonar-web/src/main/js/apps/projectQualityGate/__tests__/App-test.tsx @@ -17,6 +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. */ +/* eslint-disable import/first, import/order */ jest.mock('../../../api/quality-gates', () => ({ associateGateWithProject: jest.fn(() => Promise.resolve()), dissociateGateWithProject: jest.fn(() => Promise.resolve()), diff --git a/server/sonar-web/src/main/js/apps/projectQualityProfiles/__tests__/App-test.tsx b/server/sonar-web/src/main/js/apps/projectQualityProfiles/__tests__/App-test.tsx index 2323bad9cfe..9e873f1187f 100644 --- a/server/sonar-web/src/main/js/apps/projectQualityProfiles/__tests__/App-test.tsx +++ b/server/sonar-web/src/main/js/apps/projectQualityProfiles/__tests__/App-test.tsx @@ -17,6 +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. */ +/* eslint-disable import/first, import/order */ jest.mock('../../../api/quality-profiles', () => ({ associateProject: jest.fn(() => Promise.resolve()), dissociateProject: jest.fn(() => Promise.resolve()), @@ -116,7 +117,7 @@ function randomProfile(key: string, language: string, isDefault = false) { isDefault, key, name: key, - language: language, + language, languageName: language, organization: 'org' }; diff --git a/server/sonar-web/src/main/js/apps/projectQualityProfiles/__tests__/Table-test.tsx b/server/sonar-web/src/main/js/apps/projectQualityProfiles/__tests__/Table-test.tsx index 84e70359fab..14b93b8fc10 100644 --- a/server/sonar-web/src/main/js/apps/projectQualityProfiles/__tests__/Table-test.tsx +++ b/server/sonar-web/src/main/js/apps/projectQualityProfiles/__tests__/Table-test.tsx @@ -42,7 +42,7 @@ function randomProfile(key: string, language: string) { activeDeprecatedRuleCount: 0, key, name: key, - language: language, + language, languageName: language, organization: 'org' }; diff --git a/server/sonar-web/src/main/js/apps/projects/__tests__/utils-test.ts b/server/sonar-web/src/main/js/apps/projects/__tests__/utils-test.ts index e40971e373b..7f4330bbf52 100644 --- a/server/sonar-web/src/main/js/apps/projects/__tests__/utils-test.ts +++ b/server/sonar-web/src/main/js/apps/projects/__tests__/utils-test.ts @@ -49,6 +49,7 @@ describe('cumulativeMapFacetValues', () => { { val: '4', count: 2 }, { val: '5', count: 0 } ]) + // eslint-disable-next-line ).toEqual({ '1': 50, '2': 9, '3': 8, '4': 2, '5': 0 }); }); it('should correctly cumulate facets with NO_DATA items', () => { diff --git a/server/sonar-web/src/main/js/apps/projects/components/AllProjects.tsx b/server/sonar-web/src/main/js/apps/projects/components/AllProjects.tsx index 4181d618a10..65bdfac3f43 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/AllProjects.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/AllProjects.tsx @@ -51,7 +51,6 @@ interface State { export default class AllProjects extends React.PureComponent<Props, State> { mounted: boolean; - state: State = { loading: true, query: {} }; static contextTypes = { currentUser: PropTypes.object.isRequired, @@ -59,6 +58,11 @@ export default class AllProjects extends React.PureComponent<Props, State> { router: PropTypes.object.isRequired }; + constructor(props: Props) { + super(props); + this.state = { loading: true, query: {} }; + } + componentDidMount() { this.mounted = true; if (this.props.isFavorite && !this.context.currentUser.isLoggedIn) { @@ -88,7 +92,7 @@ export default class AllProjects extends React.PureComponent<Props, State> { getSort = () => this.state.query.sort || 'name'; - isFiltered = () => Object.values(this.state.query).some(value => value != undefined); + isFiltered = () => Object.values(this.state.query).some(value => value !== undefined); stopLoading = () => { if (this.mounted) { @@ -280,10 +284,10 @@ export default class AllProjects extends React.PureComponent<Props, State> { /> )} <ListFooter - count={this.state.projects != undefined ? this.state.projects.length : 0} + count={this.state.projects !== undefined ? this.state.projects.length : 0} loadMore={this.fetchMoreProjects} ready={!this.state.loading} - total={this.state.total != undefined ? this.state.total : 0} + total={this.state.total !== undefined ? this.state.total : 0} /> </div> ); diff --git a/server/sonar-web/src/main/js/apps/projects/components/ProjectCardLanguages.tsx b/server/sonar-web/src/main/js/apps/projects/components/ProjectCardLanguages.tsx index 4bf823864e0..277a3b6eec8 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/ProjectCardLanguages.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/ProjectCardLanguages.tsx @@ -37,7 +37,7 @@ export default class ProjectCardLanguages extends React.PureComponent<Props> { }; render() { - if (this.props.distribution == undefined) { + if (this.props.distribution === undefined) { return null; } diff --git a/server/sonar-web/src/main/js/apps/projects/components/ProjectCardOverall.tsx b/server/sonar-web/src/main/js/apps/projects/components/ProjectCardOverall.tsx index 80ce9ceadb0..7dcae1fe7a2 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/ProjectCardOverall.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/ProjectCardOverall.tsx @@ -43,7 +43,7 @@ export default function ProjectCardOverall({ organization, project }: Props) { return ( <div data-key={project.key} className="boxed-group project-card"> <div className="boxed-group-header clearfix"> - {project.isFavorite != undefined && ( + {project.isFavorite !== undefined && ( <Favorite className="spacer-right" component={project.key} diff --git a/server/sonar-web/src/main/js/apps/projects/components/ProjectCardOverallMeasures.tsx b/server/sonar-web/src/main/js/apps/projects/components/ProjectCardOverallMeasures.tsx index 8c3cdc978f2..5bba45518c1 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/ProjectCardOverallMeasures.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/ProjectCardOverallMeasures.tsx @@ -34,7 +34,7 @@ interface Props { } export default function ProjectCardOverallMeasures({ measures }: Props) { - if (measures == undefined) { + if (measures === undefined) { return null; } diff --git a/server/sonar-web/src/main/js/apps/projects/components/__tests__/AllProjects-test.tsx b/server/sonar-web/src/main/js/apps/projects/components/__tests__/AllProjects-test.tsx index 5afb5f49874..c696b9509c9 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/__tests__/AllProjects-test.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/__tests__/AllProjects-test.tsx @@ -17,19 +17,23 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/* eslint-disable import/first, import/order */ jest.mock('../ProjectsList', () => ({ + // eslint-disable-next-line default: function ProjectsList() { return null; } })); jest.mock('../PageHeader', () => ({ + // eslint-disable-next-line default: function PageHeader() { return null; } })); jest.mock('../PageSidebar', () => ({ + // eslint-disable-next-line default: function PageSidebar() { return null; } diff --git a/server/sonar-web/src/main/js/apps/projects/components/__tests__/DefaultPageSelector-test.tsx b/server/sonar-web/src/main/js/apps/projects/components/__tests__/DefaultPageSelector-test.tsx index ce03b94e0b3..b5d80b02f7e 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/__tests__/DefaultPageSelector-test.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/__tests__/DefaultPageSelector-test.tsx @@ -17,7 +17,9 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/* eslint-disable import/first, import/order */ jest.mock('../AllProjects', () => ({ + // eslint-disable-next-line default: function AllProjects() { return null; } diff --git a/server/sonar-web/src/main/js/apps/projects/components/__tests__/FavoriteFilter-test.tsx b/server/sonar-web/src/main/js/apps/projects/components/__tests__/FavoriteFilter-test.tsx index b7971fb416a..658ee1ab158 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/__tests__/FavoriteFilter-test.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/__tests__/FavoriteFilter-test.tsx @@ -17,6 +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. */ +/* eslint-disable import/first */ jest.mock('../../../../helpers/storage', () => ({ saveAll: jest.fn(), saveFavorite: jest.fn() diff --git a/server/sonar-web/src/main/js/apps/projects/filters/Filter.tsx b/server/sonar-web/src/main/js/apps/projects/filters/Filter.tsx index 2da7a189b2a..655dd4ce491 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/Filter.tsx +++ b/server/sonar-web/src/main/js/apps/projects/filters/Filter.tsx @@ -85,7 +85,7 @@ export default class Filter extends React.PureComponent<Props> { } renderOptionBar(facetValue: number | undefined) { - if (facetValue == undefined || !this.props.maxFacetValue) { + if (facetValue === undefined || !this.props.maxFacetValue) { return null; } return ( diff --git a/server/sonar-web/src/main/js/apps/projects/utils.ts b/server/sonar-web/src/main/js/apps/projects/utils.ts index c8f99c27b56..7ad9dd4e7c0 100644 --- a/server/sonar-web/src/main/js/apps/projects/utils.ts +++ b/server/sonar-web/src/main/js/apps/projects/utils.ts @@ -198,7 +198,7 @@ export function fetchProjects( const value = isDiffMetric(measure.metric) ? getPeriodValue(measure, 1) : measure.value; - if (value != undefined) { + if (value !== undefined) { componentMeasures[measure.metric] = value; } }); @@ -248,7 +248,7 @@ function convertToQueryData( if (sort.s) { data.s = sort.s; } - if (sort.hasOwnProperty('asc')) { + if (sort.asc !== undefined) { data.asc = sort.asc; } return data; diff --git a/server/sonar-web/src/main/js/apps/projectsManagement/BulkApplyTemplateModal.tsx b/server/sonar-web/src/main/js/apps/projectsManagement/BulkApplyTemplateModal.tsx index 314988d7eed..3e81e28cb5c 100644 --- a/server/sonar-web/src/main/js/apps/projectsManagement/BulkApplyTemplateModal.tsx +++ b/server/sonar-web/src/main/js/apps/projectsManagement/BulkApplyTemplateModal.tsx @@ -69,7 +69,7 @@ export default class BulkApplyTemplateModal extends React.PureComponent<Props, S loading: false, permissionTemplate: permissionTemplates.length > 0 ? permissionTemplates[0].id : undefined, - permissionTemplates: permissionTemplates + permissionTemplates }); } }, diff --git a/server/sonar-web/src/main/js/apps/projectsManagement/Search.tsx b/server/sonar-web/src/main/js/apps/projectsManagement/Search.tsx index d41a5c5e1bb..94318dbae7c 100644 --- a/server/sonar-web/src/main/js/apps/projectsManagement/Search.tsx +++ b/server/sonar-web/src/main/js/apps/projectsManagement/Search.tsx @@ -22,8 +22,7 @@ import * as Select from 'react-select'; import { sortBy } from 'lodash'; import BulkApplyTemplateModal from './BulkApplyTemplateModal'; import DeleteModal from './DeleteModal'; -import { QUALIFIERS_ORDER } from './utils'; -import { Project } from './utils'; +import { QUALIFIERS_ORDER, Project } from './utils'; import { Organization } from '../../app/types'; import Checkbox from '../../components/controls/Checkbox'; import { translate } from '../../helpers/l10n'; diff --git a/server/sonar-web/src/main/js/apps/projectsManagement/__tests__/App-test.tsx b/server/sonar-web/src/main/js/apps/projectsManagement/__tests__/App-test.tsx index 0fb6b1d21d0..dadd3a45a1b 100644 --- a/server/sonar-web/src/main/js/apps/projectsManagement/__tests__/App-test.tsx +++ b/server/sonar-web/src/main/js/apps/projectsManagement/__tests__/App-test.tsx @@ -17,6 +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. */ +/* eslint-disable import/first, import/order */ jest.mock('lodash', () => { const lodash = require.requireActual('lodash'); lodash.debounce = (fn: Function) => (...args: any[]) => fn(args); @@ -25,6 +26,7 @@ jest.mock('lodash', () => { // actual version breaks `mount` jest.mock('rc-tooltip', () => ({ + // eslint-disable-next-line default: function Tooltip() { return null; } @@ -81,7 +83,7 @@ it('searches', () => { expect(getComponents).lastCalledWith({ ...defaultSearchParameters, q: 'foo', qualifiers: 'TRK' }); }); -it('loads more', async () => { +it('loads more', () => { const wrapper = mountRender(); wrapper.find('ListFooter').prop<Function>('loadMore')(); expect(getComponents).lastCalledWith({ ...defaultSearchParameters, p: 2, qualifiers: 'TRK' }); diff --git a/server/sonar-web/src/main/js/apps/projectsManagement/__tests__/BulkApplyTemplateModal-test.tsx b/server/sonar-web/src/main/js/apps/projectsManagement/__tests__/BulkApplyTemplateModal-test.tsx index cdb33cf7f33..75368168411 100644 --- a/server/sonar-web/src/main/js/apps/projectsManagement/__tests__/BulkApplyTemplateModal-test.tsx +++ b/server/sonar-web/src/main/js/apps/projectsManagement/__tests__/BulkApplyTemplateModal-test.tsx @@ -17,6 +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. */ +/* eslint-disable import/first, import/order */ jest.mock('../../../api/permissions', () => ({ bulkApplyTemplate: jest.fn(() => Promise.resolve()), getPermissionTemplates: jest.fn(() => Promise.resolve({ permissionTemplates: [] })) diff --git a/server/sonar-web/src/main/js/apps/projectsManagement/__tests__/CreateProjectForm-test.tsx b/server/sonar-web/src/main/js/apps/projectsManagement/__tests__/CreateProjectForm-test.tsx index bd8c3114b4e..c514345b78a 100644 --- a/server/sonar-web/src/main/js/apps/projectsManagement/__tests__/CreateProjectForm-test.tsx +++ b/server/sonar-web/src/main/js/apps/projectsManagement/__tests__/CreateProjectForm-test.tsx @@ -17,6 +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. */ +/* eslint-disable import/first, import/order */ jest.mock('../../../api/components', () => ({ createProject: jest.fn(({ name }: { name: string }) => Promise.resolve({ project: { key: name, name } }) diff --git a/server/sonar-web/src/main/js/apps/projectsManagement/__tests__/DeleteModal-test.tsx b/server/sonar-web/src/main/js/apps/projectsManagement/__tests__/DeleteModal-test.tsx index 976be4403a8..d73e5306632 100644 --- a/server/sonar-web/src/main/js/apps/projectsManagement/__tests__/DeleteModal-test.tsx +++ b/server/sonar-web/src/main/js/apps/projectsManagement/__tests__/DeleteModal-test.tsx @@ -17,6 +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. */ +/* eslint-disable import/first, import/order */ jest.mock('../../../api/components', () => ({ bulkDeleteProjects: jest.fn(() => Promise.resolve()) })); diff --git a/server/sonar-web/src/main/js/apps/projectsManagement/__tests__/Projects-test.tsx b/server/sonar-web/src/main/js/apps/projectsManagement/__tests__/Projects-test.tsx index 792e29ccc48..cc29a0e243d 100644 --- a/server/sonar-web/src/main/js/apps/projectsManagement/__tests__/Projects-test.tsx +++ b/server/sonar-web/src/main/js/apps/projectsManagement/__tests__/Projects-test.tsx @@ -17,6 +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. */ +/* eslint-disable import/first */ jest.mock('../../permissions/project/views/ApplyTemplateView'); import * as React from 'react'; diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileContainer.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileContainer.tsx index 1d16a885659..d159d8354a3 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileContainer.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileContainer.tsx @@ -32,7 +32,7 @@ interface Props { onRequestFail: (reasong: any) => void; organization: string | null; profiles: Profile[]; - router: { replace: ({}) => void }; + router: { replace: (path: any) => void }; updateProfiles: () => Promise<void>; } diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfilePermissionsForm.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfilePermissionsForm.tsx index fe94b38b03d..8d892127fc7 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfilePermissionsForm.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfilePermissionsForm.tsx @@ -82,7 +82,7 @@ export default class ProfilePermissionsForm extends React.PureComponent<Props, S const { selected } = this.state; if (selected) { this.setState({ submitting: true }); - if ((selected as User).login != undefined) { + if ((selected as User).login !== undefined) { this.handleUserAdd(selected as User); } else { this.handleGroupAdd(selected as Group); diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfilePermissionsFormSelect.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfilePermissionsFormSelect.tsx index e265206a49f..911bf55cca4 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfilePermissionsFormSelect.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfilePermissionsFormSelect.tsx @@ -113,7 +113,7 @@ export default class ProfilePermissionsFormSelect extends React.PureComponent<Pr } function isUser(option: Option): option is User { - return (option as User).login != undefined; + return (option as User).login !== undefined; } function getStringValue(option: Option) { diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfilePermissions-test.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfilePermissions-test.tsx index c61a60d83a8..fc13a173960 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfilePermissions-test.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfilePermissions-test.tsx @@ -17,6 +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. */ +/* eslint-disable import/first, import/order */ jest.mock('../../../../api/quality-profiles', () => ({ searchUsers: jest.fn(() => Promise.resolve([])), searchGroups: jest.fn(() => Promise.resolve([])) diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfilePermissionsForm-test.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfilePermissionsForm-test.tsx index 603967ba787..a71948cbbbd 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfilePermissionsForm-test.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfilePermissionsForm-test.tsx @@ -17,6 +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. */ +/* eslint-disable import/first, import/order */ jest.mock('../../../../api/quality-profiles', () => ({ addUser: jest.fn(() => Promise.resolve()), addGroup: jest.fn(() => Promise.resolve()) diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfilePermissionsFormSelect-test.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfilePermissionsFormSelect-test.tsx index 3483c66c085..7a029559e80 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfilePermissionsFormSelect-test.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfilePermissionsFormSelect-test.tsx @@ -17,6 +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. */ +/* eslint-disable import/first */ jest.mock('lodash', () => { const lodash = require.requireActual('lodash'); lodash.debounce = (fn: Function) => (...args: any[]) => fn(...args); diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfilePermissionsGroup-test.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfilePermissionsGroup-test.tsx index d792b2c36bf..d9edeb1d1a1 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfilePermissionsGroup-test.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfilePermissionsGroup-test.tsx @@ -17,6 +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. */ +/* eslint-disable import/first, import/order */ jest.mock('../../../../api/quality-profiles', () => ({ removeGroup: jest.fn(() => Promise.resolve()) })); diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfilePermissionsUser-test.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfilePermissionsUser-test.tsx index 6fbd6f8ec9b..f2b26b8ce41 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfilePermissionsUser-test.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfilePermissionsUser-test.tsx @@ -17,6 +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. */ +/* eslint-disable import/first, import/order */ jest.mock('../../../../api/quality-profiles', () => ({ removeUser: jest.fn(() => Promise.resolve()) })); diff --git a/server/sonar-web/src/main/js/apps/system/components/App.tsx b/server/sonar-web/src/main/js/apps/system/components/App.tsx index 2211ed17dd5..a8108bf1865 100644 --- a/server/sonar-web/src/main/js/apps/system/components/App.tsx +++ b/server/sonar-web/src/main/js/apps/system/components/App.tsx @@ -41,12 +41,16 @@ interface State { export default class App extends React.PureComponent<Props, State> { mounted: boolean; - state: State = { loading: true }; static contextTypes = { router: PropTypes.object }; + constructor(props: Props) { + super(props); + this.state = { loading: true }; + } + componentDidMount() { this.mounted = true; this.fetchSysInfo(); diff --git a/server/sonar-web/src/main/js/apps/system/utils.ts b/server/sonar-web/src/main/js/apps/system/utils.ts index 7048439a678..7d6ccca5a0d 100644 --- a/server/sonar-web/src/main/js/apps/system/utils.ts +++ b/server/sonar-web/src/main/js/apps/system/utils.ts @@ -94,7 +94,7 @@ export function getSearchNodes(sysInfoData: ClusterSysInfo): NodeInfo[] { export function isCluster(sysInfoData?: SysInfo): boolean { return ( - sysInfoData != undefined && sysInfoData['System'] && sysInfoData['System'][HA_FIELD] === true + sysInfoData !== undefined && sysInfoData['System'] && sysInfoData['System'][HA_FIELD] === true ); } @@ -165,8 +165,8 @@ export function getStandaloneSecondarySections(sysInfoData: SysInfo): SysInfoSec } export function groupSections(sysInfoData: SysValueObject) { - let mainSection: SysValueObject = {}; - let sections: SysInfoSection = {}; + const mainSection: SysValueObject = {}; + const sections: SysInfoSection = {}; each(sysInfoData, (item, key) => { if (typeof item !== 'object' || item instanceof Array) { mainSection[key] = item; diff --git a/server/sonar-web/src/main/js/apps/web-api/components/WebApiApp.tsx b/server/sonar-web/src/main/js/apps/web-api/components/WebApiApp.tsx index ebc579d5ca5..8ddcd805b10 100644 --- a/server/sonar-web/src/main/js/apps/web-api/components/WebApiApp.tsx +++ b/server/sonar-web/src/main/js/apps/web-api/components/WebApiApp.tsx @@ -44,17 +44,21 @@ interface State { export default class WebApiApp extends React.PureComponent<Props, State> { mounted: boolean; - state: State = { - domains: [], - searchQuery: '', - showDeprecated: false, - showInternal: false - }; static contextTypes = { router: PropTypes.object.isRequired }; + constructor(props: Props) { + super(props); + this.state = { + domains: [], + searchQuery: '', + showDeprecated: false, + showInternal: false + }; + } + componentDidMount() { this.mounted = true; this.fetchList(); diff --git a/server/sonar-web/src/main/js/apps/web-api/components/__tests__/Domain-test.tsx b/server/sonar-web/src/main/js/apps/web-api/components/__tests__/Domain-test.tsx index 4114f4944e0..539f425e8d4 100644 --- a/server/sonar-web/src/main/js/apps/web-api/components/__tests__/Domain-test.tsx +++ b/server/sonar-web/src/main/js/apps/web-api/components/__tests__/Domain-test.tsx @@ -77,7 +77,7 @@ it('should not render internal actions', () => { it('should render only actions matching the query', () => { const actions = [ACTION, { ...ACTION, key: 'bar', description: 'Bar desc' }]; - const domain = { ...DOMAIN, actions: actions }; + const domain = { ...DOMAIN, actions }; expect( shallow(<Domain {...DEFAULT_PROPS} domain={domain} searchQuery="Foo" />) ).toMatchSnapshot(); @@ -89,7 +89,7 @@ it('should also render actions with a description matching the query', () => { { ...ACTION, key: 'bar', description: 'Bar desc' }, { ...ACTION, key: 'baz', description: 'foobar' } ]; - const domain = { ...DOMAIN, actions: actions }; + const domain = { ...DOMAIN, actions }; expect( shallow(<Domain {...DEFAULT_PROPS} domain={domain} searchQuery="Foo" />) ).toMatchSnapshot(); |