From 2e06a921076f73f901b333eb7fa236f7971ff3ac Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Fri, 9 Feb 2018 13:50:43 +0100 Subject: [PATCH] enable eslint rules to enforce newlines (#3043) --- server/sonar-web/.eslintrc | 6 ++++++ server/sonar-web/src/main/js/api/metrics.ts | 1 + .../nav/component/__tests__/ComponentNavMenu-test.tsx | 1 + server/sonar-web/src/main/js/apps/issues/components/App.js | 1 + server/sonar-web/src/main/js/apps/overview/main/Coverage.js | 1 + .../src/main/js/apps/overview/main/Duplications.js | 1 + .../src/main/js/apps/users/components/PasswordForm.tsx | 2 ++ .../src/main/js/apps/users/components/UserForm.tsx | 3 +++ .../main/js/apps/users/components/UserScmAccountInput.tsx | 1 + .../src/main/js/apps/users/components/UsersSelectSearch.tsx | 1 + .../src/main/js/components/controls/SearchSelect.tsx | 1 + server/sonar-web/src/main/js/helpers/measures.ts | 1 + server/sonar-web/src/main/js/store/notifications/duck.js | 1 + 13 files changed, 21 insertions(+) diff --git a/server/sonar-web/.eslintrc b/server/sonar-web/.eslintrc index 16ebf9a4f53..d03895d0134 100644 --- a/server/sonar-web/.eslintrc +++ b/server/sonar-web/.eslintrc @@ -88,6 +88,7 @@ "consistent-this": ["warn", "that"], "func-name-matching": "error", "func-style": ["warn", "declaration", { "allowArrowFunctions": true }], + "lines-between-class-members": ["error", "always", { "exceptAfterSingleLine": true }], "max-depth": "warn", "max-lines": ["warn", 1000], "max-params": ["warn", 4], @@ -101,6 +102,11 @@ "no-unneeded-ternary": "warn", "one-var": ["warn", "never"], "operator-assignment": "warn", + "padding-line-between-statements": [ + "error", + { "blankLine": "always", "prev": "*", "next": ["class", "function"] }, + { "blankLine": "always", "prev": ["class", "function"], "next": "*" } + ], // es2015 "no-duplicate-imports": "error", diff --git a/server/sonar-web/src/main/js/api/metrics.ts b/server/sonar-web/src/main/js/api/metrics.ts index 1dfb0e7789f..c84d8890aac 100644 --- a/server/sonar-web/src/main/js/api/metrics.ts +++ b/server/sonar-web/src/main/js/api/metrics.ts @@ -34,6 +34,7 @@ export function getMetrics(data: { p?: number; ps?: number }): Promise { return inner(data); + function inner( data: { p?: number; ps?: number } = { ps: 500 }, prev?: MetricsResponse diff --git a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNavMenu-test.tsx b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNavMenu-test.tsx index 353eb41b50b..eb400536ed1 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNavMenu-test.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNavMenu-test.tsx @@ -105,6 +105,7 @@ it('should work for long-living branches', () => { it('should work for all qualifiers', () => { ['TRK', 'BRC', 'VW', 'SVW', 'APP'].forEach(checkWithQualifier); expect.assertions(5); + function checkWithQualifier(qualifier: string) { const component = { ...baseComponent, configuration: { showSettings: true }, qualifier }; expect( diff --git a/server/sonar-web/src/main/js/apps/issues/components/App.js b/server/sonar-web/src/main/js/apps/issues/components/App.js index a4f0a861a95..a6068133e94 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/App.js +++ b/server/sonar-web/src/main/js/apps/issues/components/App.js @@ -904,6 +904,7 @@ export default class App extends React.PureComponent { ); } + render() { const { component } = this.props; const { openIssue, paging } = this.state; 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 ecc08743527..6d800e2a8f6 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 @@ -182,4 +182,5 @@ class Coverage extends React.PureComponent { ); } } + export default enhance(Coverage); diff --git a/server/sonar-web/src/main/js/apps/overview/main/Duplications.js b/server/sonar-web/src/main/js/apps/overview/main/Duplications.js index e668ff8efc2..3f94296f6b3 100644 --- a/server/sonar-web/src/main/js/apps/overview/main/Duplications.js +++ b/server/sonar-web/src/main/js/apps/overview/main/Duplications.js @@ -171,4 +171,5 @@ class Duplications extends React.PureComponent { ); } } + export default enhance(Duplications); diff --git a/server/sonar-web/src/main/js/apps/users/components/PasswordForm.tsx b/server/sonar-web/src/main/js/apps/users/components/PasswordForm.tsx index 053ece8b03d..1caef1c894a 100644 --- a/server/sonar-web/src/main/js/apps/users/components/PasswordForm.tsx +++ b/server/sonar-web/src/main/js/apps/users/components/PasswordForm.tsx @@ -70,8 +70,10 @@ export default class PasswordForm extends React.PureComponent { handleConfirmPasswordChange = (event: React.SyntheticEvent) => this.setState({ confirmPassword: event.currentTarget.value }); + handleNewPasswordChange = (event: React.SyntheticEvent) => this.setState({ newPassword: event.currentTarget.value }); + handleOldPasswordChange = (event: React.SyntheticEvent) => this.setState({ oldPassword: event.currentTarget.value }); diff --git a/server/sonar-web/src/main/js/apps/users/components/UserForm.tsx b/server/sonar-web/src/main/js/apps/users/components/UserForm.tsx index 867d503b933..2cb241d0b1a 100644 --- a/server/sonar-web/src/main/js/apps/users/components/UserForm.tsx +++ b/server/sonar-web/src/main/js/apps/users/components/UserForm.tsx @@ -91,10 +91,13 @@ export default class UserForm extends React.PureComponent { handleEmailChange = (event: React.SyntheticEvent) => this.setState({ email: event.currentTarget.value }); + handleLoginChange = (event: React.SyntheticEvent) => this.setState({ login: event.currentTarget.value }); + handleNameChange = (event: React.SyntheticEvent) => this.setState({ name: event.currentTarget.value }); + handlePasswordChange = (event: React.SyntheticEvent) => this.setState({ password: event.currentTarget.value }); diff --git a/server/sonar-web/src/main/js/apps/users/components/UserScmAccountInput.tsx b/server/sonar-web/src/main/js/apps/users/components/UserScmAccountInput.tsx index 48db1e71bc0..6f93c423cd2 100644 --- a/server/sonar-web/src/main/js/apps/users/components/UserScmAccountInput.tsx +++ b/server/sonar-web/src/main/js/apps/users/components/UserScmAccountInput.tsx @@ -30,6 +30,7 @@ export interface Props { export default class UserScmAccountInput extends React.PureComponent { handleChange = (event: React.SyntheticEvent) => this.props.onChange(this.props.idx, event.currentTarget.value); + handleRemove = () => this.props.onRemove(this.props.idx); render() { diff --git a/server/sonar-web/src/main/js/apps/users/components/UsersSelectSearch.tsx b/server/sonar-web/src/main/js/apps/users/components/UsersSelectSearch.tsx index 4b605759a84..2d54fee167c 100644 --- a/server/sonar-web/src/main/js/apps/users/components/UsersSelectSearch.tsx +++ b/server/sonar-web/src/main/js/apps/users/components/UsersSelectSearch.tsx @@ -55,6 +55,7 @@ export default class UsersSelectSearch extends React.PureComponent this.handleSearch = debounce(this.handleSearch, 250); this.state = { searchResult: [], isLoading: false, search: '' }; } + componentDidMount() { this.mounted = true; this.handleSearch(this.state.search); diff --git a/server/sonar-web/src/main/js/components/controls/SearchSelect.tsx b/server/sonar-web/src/main/js/components/controls/SearchSelect.tsx index 07f9b2dac2a..6d6403c41c2 100644 --- a/server/sonar-web/src/main/js/components/controls/SearchSelect.tsx +++ b/server/sonar-web/src/main/js/components/controls/SearchSelect.tsx @@ -68,6 +68,7 @@ export default class SearchSelect extends React.PureComponent { get minimumQueryLength() { return this.props.minimumQueryLength !== undefined ? this.props.minimumQueryLength : 2; } + get resetOnBlur() { return this.props.resetOnBlur !== undefined ? this.props.resetOnBlur : true; } diff --git a/server/sonar-web/src/main/js/helpers/measures.ts b/server/sonar-web/src/main/js/helpers/measures.ts index b6354557ad1..da64a3d6654 100644 --- a/server/sonar-web/src/main/js/helpers/measures.ts +++ b/server/sonar-web/src/main/js/helpers/measures.ts @@ -315,6 +315,7 @@ function getRatingGrid(): string { } let maintainabilityRatingGrid: number[]; + function getMaintainabilityRatingGrid(): number[] { if (maintainabilityRatingGrid) { return maintainabilityRatingGrid; diff --git a/server/sonar-web/src/main/js/store/notifications/duck.js b/server/sonar-web/src/main/js/store/notifications/duck.js index 8dce9f8895c..0861944491c 100644 --- a/server/sonar-web/src/main/js/store/notifications/duck.js +++ b/server/sonar-web/src/main/js/store/notifications/duck.js @@ -104,6 +104,7 @@ function onAddNotification(state /*: NotificationsState */, notification /*: Not function isNotificationsEqual(a /*: Notification */, b /*: Notification */) { return a.channel === b.channel && a.type === b.type && a.project === b.project; } + return uniqWith([...state, notification], isNotificationsEqual); } -- 2.39.5