From 1355d080cfa97eadfde70e6945e30f49a38ac28e Mon Sep 17 00:00:00 2001 From: Grégoire Aubert Date: Mon, 25 Mar 2019 14:10:40 +0100 Subject: Update prettier to last version * Prettier format all modules --- .../SourceViewer/components/DuplicationPopup.tsx | 13 +- .../js/components/SourceViewer/components/Line.tsx | 15 +- .../SourceViewer/components/LineCode.tsx | 27 +- .../SourceViewer/components/MeasuresOverlay.tsx | 97 ++-- .../components/__tests__/MeasuresOverlay-test.tsx | 27 +- .../__snapshots__/MeasuresOverlay-test.tsx.snap | 491 +++++++++++++++++++++ .../components/SourceViewer/helpers/highlight.ts | 9 +- .../src/main/js/components/charts/LineChart.tsx | 12 +- .../src/main/js/components/common/MultiSelect.tsx | 8 +- .../src/main/js/components/controls/Tooltip.tsx | 2 +- .../main/js/components/facet/ListStyleFacet.tsx | 26 +- .../js/components/facet/ListStyleFacetFooter.tsx | 11 +- .../src/main/js/components/issue/IssueView.tsx | 25 +- .../components/issue/__tests__/IssueView-test.tsx | 57 +++ .../__snapshots__/IssueView-test.tsx.snap | 137 ++++++ .../issue/components/IssueActionsBar.tsx | 15 +- .../src/main/js/components/nav/NavBar.tsx | 2 +- .../src/main/js/components/workspace/Workspace.tsx | 4 +- 18 files changed, 824 insertions(+), 154 deletions(-) create mode 100644 server/sonar-web/src/main/js/components/issue/__tests__/IssueView-test.tsx create mode 100644 server/sonar-web/src/main/js/components/issue/__tests__/__snapshots__/IssueView-test.tsx.snap (limited to 'server/sonar-web/src/main/js/components') diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/DuplicationPopup.tsx b/server/sonar-web/src/main/js/components/SourceViewer/components/DuplicationPopup.tsx index f35ea78319e..90c2b80ff22 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/components/DuplicationPopup.tsx +++ b/server/sonar-web/src/main/js/components/SourceViewer/components/DuplicationPopup.tsx @@ -128,13 +128,12 @@ export default class DuplicationPopup extends React.PureComponent { {duplication.file.projectName} - {duplication.file.subProject && - duplication.file.subProjectName && ( -
- - {duplication.file.subProjectName} -
- )} + {duplication.file.subProject && duplication.file.subProjectName && ( +
+ + {duplication.file.subProjectName} +
+ )} )} diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/Line.tsx b/server/sonar-web/src/main/js/components/SourceViewer/components/Line.tsx index 7955f4df686..34da94c78b8 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/components/Line.tsx +++ b/server/sonar-web/src/main/js/components/SourceViewer/components/Line.tsx @@ -141,14 +141,13 @@ export default class Line extends React.PureComponent { /> ))} - {this.props.displayIssues && - !this.props.displayAllIssues && ( - - )} + {this.props.displayIssues && !this.props.displayAllIssues && ( + + )} {
 (this.codeNode = node)}>{renderedTokens}
- {showIssues && - issues.length > 0 && ( - - )} + {showIssues && issues.length > 0 && ( + + )} ); } diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/MeasuresOverlay.tsx b/server/sonar-web/src/main/js/components/SourceViewer/components/MeasuresOverlay.tsx index 9f6834cfa65..c7486388662 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/components/MeasuresOverlay.tsx +++ b/server/sonar-web/src/main/js/components/SourceViewer/components/MeasuresOverlay.tsx @@ -189,61 +189,54 @@ export default class MeasuresOverlay extends React.PureComponent { {this.renderBigMeasure(measures.violations)} {this.renderBigMeasure(measures.sqale_index)} - {measures.violations && - !!measures.violations.value && ( - <> - {typesFacet && ( -
-
- {sortBy(typesFacet, f => ISSUE_TYPES.indexOf(f.val)).map(f => ( -
- - - {translate('issue.type', f.val)} - - - {formatMeasure(f.count, 'SHORT_INT')} - -
- ))} -
+ {measures.violations && !!measures.violations.value && ( + <> + {typesFacet && ( +
+
+ {sortBy(typesFacet, f => ISSUE_TYPES.indexOf(f.val)).map(f => ( +
+ + + {translate('issue.type', f.val)} + + {formatMeasure(f.count, 'SHORT_INT')} +
+ ))}
- )} - {severitiesFacet && ( -
-
- {sortBy(severitiesFacet, f => SEVERITIES.indexOf(f.val)).map(f => ( -
- - - - - {formatMeasure(f.count, 'SHORT_INT')} - -
- ))} -
+
+ )} + {severitiesFacet && ( +
+
+ {sortBy(severitiesFacet, f => SEVERITIES.indexOf(f.val)).map(f => ( +
+ + + + {formatMeasure(f.count, 'SHORT_INT')} +
+ ))}
- )} - {tagsFacet && ( -
-
- {tagsFacet.map(f => ( -
- - - {f.val} - - - {formatMeasure(f.count, 'SHORT_INT')} - -
- ))} -
+
+ )} + {tagsFacet && ( +
+
+ {tagsFacet.map(f => ( +
+ + + {f.val} + + {formatMeasure(f.count, 'SHORT_INT')} +
+ ))}
- )} - - )} +
+ )} + + )}
); diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/MeasuresOverlay-test.tsx b/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/MeasuresOverlay-test.tsx index d3e5ff08330..0abc29938c7 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/MeasuresOverlay-test.tsx +++ b/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/MeasuresOverlay-test.tsx @@ -91,7 +91,8 @@ jest.mock('../../../../api/measures', () => ({ { metric: 'security_remediation_effort', value: '0' }, { metric: 'statements', value: '3' }, { metric: 'skipped_tests', value: '0' }, - { metric: 'test_failures', value: '0' } + { metric: 'test_failures', value: '0' }, + { metric: 'violations', value: '1' } ]) })); @@ -129,6 +130,7 @@ jest.mock('../../../../api/metrics', () => ({ { key: 'statements', type: 'INT', domain: 'Size' }, { key: 'skipped_tests', type: 'INT', domain: 'Tests' }, { key: 'test_failures', type: 'INT', domain: 'Tests' }, + { key: 'violations', type: 'INT', domain: 'Issues' }, // next two must be filtered out { key: 'data', type: 'DATA' }, { key: 'hidden', hidden: true } @@ -155,13 +157,7 @@ const branchLike: T.ShortLivingBranch = { }; it('should render source file', async () => { - const wrapper = shallow( - - ); + const wrapper = shallowRender(); await waitAndUpdate(wrapper); expect(wrapper).toMatchSnapshot(); @@ -170,13 +166,18 @@ it('should render source file', async () => { }); it('should render test file', async () => { - const wrapper = shallow( + const wrapper = shallowRender({ sourceViewerFile: { ...sourceViewerFile, q: 'UTS' } }); + await waitAndUpdate(wrapper); + expect(wrapper).toMatchSnapshot(); +}); + +function shallowRender(props: Partial = {}) { + return shallow( ); - await waitAndUpdate(wrapper); - expect(wrapper).toMatchSnapshot(); -}); +} diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/__snapshots__/MeasuresOverlay-test.tsx.snap b/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/__snapshots__/MeasuresOverlay-test.tsx.snap index 94cea5cdf1b..2472c038a73 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/__snapshots__/MeasuresOverlay-test.tsx.snap +++ b/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/__snapshots__/MeasuresOverlay-test.tsx.snap @@ -164,6 +164,25 @@ exports[`should render source file 1`] = `
+
+ + + + + violations + +
+
+
+
+ + + issue.type.BUG + + + 1 + +
+
+ + + issue.type.VULNERABILITY + + + 0 + +
+
+ + + issue.type.CODE_SMELL + + + 2 + +
+
+
+
+
+
+ + + + + 5 + +
+
+ + + + + 4 + +
+
+ + + + + 1 + +
+
+ + + + + 3 + +
+
+ + + + + 2 + +
+
+
+
+
+
+ + + bad-practice + + + 1 + +
+
+ + + cert + + + 3 + +
+
+ + + design + + + 1 + +
+
+
+
+ + + + + violations + +
+
+
+
+ + + issue.type.BUG + + + 1 + +
+
+ + + issue.type.VULNERABILITY + + + 0 + +
+
+ + + issue.type.CODE_SMELL + + + 2 + +
+
+
+
+
+
+ + + + + 5 + +
+
+ + + + + 4 + +
+
+ + + + + 1 + +
+
+ + + + + 3 + +
+
+ + + + + 2 + +
+
+
+
+
+
+ + + bad-practice + + + 1 + +
+
+ + + cert + + + 3 + +
+
+ + + design + + + 1 + +
+
+
+ - symbolRegExp.test(token.className) - ? { ...token, className: `${token.className} highlighted` } - : token + return tokens.map(token => + symbolRegExp.test(token.className) + ? { ...token, className: `${token.className} highlighted` } + : token ); } diff --git a/server/sonar-web/src/main/js/components/charts/LineChart.tsx b/server/sonar-web/src/main/js/components/charts/LineChart.tsx index 39aaf3d2f82..a937fa7e7fd 100644 --- a/server/sonar-web/src/main/js/components/charts/LineChart.tsx +++ b/server/sonar-web/src/main/js/components/charts/LineChart.tsx @@ -74,11 +74,13 @@ export default class LineChart extends React.PureComponent { return null; } - const points = this.props.data.filter(point => point.y != null).map((point, index) => { - const x = xScale(point.x); - const y = yScale(point.y || 0); - return ; - }); + const points = this.props.data + .filter(point => point.y != null) + .map((point, index) => { + const x = xScale(point.x); + const y = yScale(point.y || 0); + return ; + }); return {points}; } diff --git a/server/sonar-web/src/main/js/components/common/MultiSelect.tsx b/server/sonar-web/src/main/js/components/common/MultiSelect.tsx index e2870be58d0..ab0d53888b6 100644 --- a/server/sonar-web/src/main/js/components/common/MultiSelect.tsx +++ b/server/sonar-web/src/main/js/components/common/MultiSelect.tsx @@ -314,11 +314,9 @@ export default class MultiSelect extends React.PureComponent { renderLabel={renderLabel} /> )} - {!showNewElement && - selectedElements.length < 1 && - unselectedElements.length < 1 && ( -
  • {translateWithParameters('no_results_for_x', query)}
  • - )} + {!showNewElement && selectedElements.length < 1 && unselectedElements.length < 1 && ( +
  • {translateWithParameters('no_results_for_x', query)}
  • + )} {footerNode}
    diff --git a/server/sonar-web/src/main/js/components/controls/Tooltip.tsx b/server/sonar-web/src/main/js/components/controls/Tooltip.tsx index d1f85357ac5..7917b491ff8 100644 --- a/server/sonar-web/src/main/js/components/controls/Tooltip.tsx +++ b/server/sonar-web/src/main/js/components/controls/Tooltip.tsx @@ -66,7 +66,7 @@ export default function Tooltip(props: Props) { } export class TooltipInner extends React.Component { - throttledPositionTooltip: (() => void); + throttledPositionTooltip: () => void; mouseEnterTimeout?: number; mouseLeaveTimeout?: number; tooltipNode?: HTMLElement | null; diff --git a/server/sonar-web/src/main/js/components/facet/ListStyleFacet.tsx b/server/sonar-web/src/main/js/components/facet/ListStyleFacet.tsx index 0845c888738..a10f486cbe9 100644 --- a/server/sonar-web/src/main/js/components/facet/ListStyleFacet.tsx +++ b/server/sonar-web/src/main/js/components/facet/ListStyleFacet.tsx @@ -299,12 +299,11 @@ export default class ListStyleFacet extends React.Component, State - {mightHaveMoreResults && - this.state.showFullList && ( - - {translate('facet_might_have_more_results')} - - )} + {mightHaveMoreResults && this.state.showFullList && ( + + {translate('facet_might_have_more_results')} + + )} ); } @@ -407,14 +406,13 @@ export default class ListStyleFacet extends React.Component, State - {this.props.open && - !disabled && ( - <> - {this.renderSearch()} - {showList ? this.renderList() : this.renderSearchResults()} - - - )} + {this.props.open && !disabled && ( + <> + {this.renderSearch()} + {showList ? this.renderList() : this.renderSearchResults()} + + + )} ); } diff --git a/server/sonar-web/src/main/js/components/facet/ListStyleFacetFooter.tsx b/server/sonar-web/src/main/js/components/facet/ListStyleFacetFooter.tsx index ccafff05264..f469684eeac 100644 --- a/server/sonar-web/src/main/js/components/facet/ListStyleFacetFooter.tsx +++ b/server/sonar-web/src/main/js/components/facet/ListStyleFacetFooter.tsx @@ -59,12 +59,11 @@ export default class ListStyleFacetFooter extends React.PureComponent { )} - {this.props.showLess && - allShown && ( - - {translate('show_less')} - - )} + {this.props.showLess && allShown && ( + + {translate('show_less')} + + )} ); } diff --git a/server/sonar-web/src/main/js/components/issue/IssueView.tsx b/server/sonar-web/src/main/js/components/issue/IssueView.tsx index 06d2eb4173d..f5cb65b0241 100644 --- a/server/sonar-web/src/main/js/components/issue/IssueView.tsx +++ b/server/sonar-web/src/main/js/components/issue/IssueView.tsx @@ -97,19 +97,18 @@ export default class IssueView extends React.PureComponent { onChange={this.props.onChange} togglePopup={this.props.togglePopup} /> - {issue.comments && - issue.comments.length > 0 && ( -
    - {issue.comments.map(comment => ( - - ))} -
    - )} + {issue.comments && issue.comments.length > 0 && ( +
    + {issue.comments.map(comment => ( + + ))} +
    + )} {hasCheckbox && ( <> { + const wrapper = shallowRender(); + expect(wrapper).toMatchSnapshot(); +}); + +function shallowRender(props: Partial = {}) { + return shallow( + + ); +} diff --git a/server/sonar-web/src/main/js/components/issue/__tests__/__snapshots__/IssueView-test.tsx.snap b/server/sonar-web/src/main/js/components/issue/__tests__/__snapshots__/IssueView-test.tsx.snap new file mode 100644 index 00000000000..b76291398cd --- /dev/null +++ b/server/sonar-web/src/main/js/components/issue/__tests__/__snapshots__/IssueView-test.tsx.snap @@ -0,0 +1,137 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`should render correctly 1`] = ` +
    + + +
    + +
    +
    +`; diff --git a/server/sonar-web/src/main/js/components/issue/components/IssueActionsBar.tsx b/server/sonar-web/src/main/js/components/issue/components/IssueActionsBar.tsx index c8da6cf250b..cdacdb47572 100644 --- a/server/sonar-web/src/main/js/components/issue/components/IssueActionsBar.tsx +++ b/server/sonar-web/src/main/js/components/issue/components/IssueActionsBar.tsx @@ -138,14 +138,13 @@ export default class IssueActionsBar extends React.PureComponent { /> )} - {!isSecurityHotspot && - issue.effort && ( -
  • - - {translateWithParameters('issue.x_effort', issue.effort)} - -
  • - )} + {!isSecurityHotspot && issue.effort && ( +
  • + + {translateWithParameters('issue.x_effort', issue.effort)} + +
  • + )} {canComment && ( { - throttledFollowHorizontalScroll: (() => void); + throttledFollowHorizontalScroll: () => void; constructor(props: Props) { super(props); diff --git a/server/sonar-web/src/main/js/components/workspace/Workspace.tsx b/server/sonar-web/src/main/js/components/workspace/Workspace.tsx index 4647079df4b..38c419c105c 100644 --- a/server/sonar-web/src/main/js/components/workspace/Workspace.tsx +++ b/server/sonar-web/src/main/js/components/workspace/Workspace.tsx @@ -133,8 +133,8 @@ export default class Workspace extends React.PureComponent<{}, State> { if (this.mounted) { const { key, name, qualifier } = details; this.setState((state: State) => ({ - components: state.components.map( - component => (component.key === key ? { ...component, name, qualifier } : component) + components: state.components.map(component => + component.key === key ? { ...component, name, qualifier } : component ) })); } -- cgit v1.2.3