Skip to content

Commit

Permalink
upgrade prettier (#1954)
Browse files Browse the repository at this point in the history
  • Loading branch information
stas-vilchik committed Apr 20, 2017
1 parent 36c9fa0 commit f6e90fd
Show file tree
Hide file tree
Showing 206 changed files with 1,526 additions and 1,500 deletions.
4 changes: 3 additions & 1 deletion server/sonar-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@
"less-loader": "2.2.3",
"path-exists": "2.1.0",
"postcss-loader": "0.8.0",
"prettier-eslint-cli": "^3.1.3",
"prettier": "1.2.2",
"prettier-eslint": "5.1.0",
"prettier-eslint-cli": "3.4.1",
"react-addons-test-utils": "15.4.2",
"react-dev-utils": "0.2.1",
"react-transform-hmr": "1.0.4",
Expand Down
2 changes: 1 addition & 1 deletion server/sonar-web/src/main/js/api/issues.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export function getTags(query: {}): Promise<*> {

export function extractAssignees(facet: Array<{ val: string }>, response: IssuesResponse) {
return facet.map(item => {
const user = response.users ? response.users.find(user => user.login = item.val) : null;
const user = response.users ? response.users.find(user => user.login === item.val) : null;
return { ...item, user };
});
}
Expand Down
3 changes: 2 additions & 1 deletion server/sonar-web/src/main/js/api/quality-gates.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ export function fetchQualityGates() {
...qualityGate,
isDefault: qualityGate.id === r.default
};
}));
})
);
}

export function fetchQualityGate(id) {
Expand Down
25 changes: 11 additions & 14 deletions server/sonar-web/src/main/js/api/system.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,17 @@ export function restart() {
const POLLING_INTERVAL = 2000;

function pollStatus(cb) {
setTimeout(
() => {
getSystemStatus()
.then(r => {
if (r.status === 'UP') {
cb();
} else {
pollStatus(cb);
}
})
.catch(() => pollStatus(cb));
},
POLLING_INTERVAL
);
setTimeout(() => {
getSystemStatus()
.then(r => {
if (r.status === 'UP') {
cb();
} else {
pollStatus(cb);
}
})
.catch(() => pollStatus(cb));
}, POLLING_INTERVAL);
}

function promiseStatus() {
Expand Down
3 changes: 2 additions & 1 deletion server/sonar-web/src/main/js/api/web-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ export function fetchWebApi(showInternal: boolean = true): Promise<Array<Domain>
const internal = !domain.actions.find(action => !action.internal);

return { ...domain, deprecated, internal };
}));
})
);
}

export function fetchResponseExample(domain: string, action: string): Promise<{ example: string }> {
Expand Down
3 changes: 2 additions & 1 deletion server/sonar-web/src/main/js/app/components/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ class App extends React.PureComponent {
this.props.fetchAppState(),
this.props.fetchOrganizations(),
this.props.fetchLanguages()
]))
])
)
.then(this.finishLoading, this.finishLoading);
}

Expand Down
6 changes: 2 additions & 4 deletions server/sonar-web/src/main/js/app/components/Landing.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@ import { getCurrentUser } from '../../store/rootReducer';

class Landing extends React.PureComponent {
static propTypes = {
currentUser: React.PropTypes.oneOfType([
React.PropTypes.bool,
React.PropTypes.object
]).isRequired
currentUser: React.PropTypes.oneOfType([React.PropTypes.bool, React.PropTypes.object])
.isRequired
};

componentDidMount() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class ProjectContainer extends React.PureComponent {
configuration: {},
qualifier: string
},
fetchProject: (string) => Promise<*>
fetchProject: string => Promise<*>
};
componentDidMount() {
this.fetchProject();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type Props = {
key: string,
title: string
},
onFail: (string) => void,
onFail: string => void,
options?: {},
router: Object
};
Expand Down Expand Up @@ -86,7 +86,7 @@ class Extension extends React.PureComponent {
render() {
return (
<div>
<div ref={container => this.container = container} />
<div ref={container => (this.container = container)} />
</div>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ type Props = {
function ProjectAdminPageExtension(props: Props) {
const { extensionKey, pluginKey } = props.params;
const { component } = props;
const extension = component.configuration &&
const extension =
component.configuration &&
component.configuration.extensions.find(p => p.key === `${pluginKey}/${extensionKey}`);
return extension
? <Extension extension={extension} options={{ component }} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ export default class ComponentNavMeta extends React.PureComponent {
render() {
const metaList = [];
const canSeeBackgroundTasks = this.props.conf.showBackgroundTasks;
const backgroundTasksUrl = window.baseUrl +
const backgroundTasksUrl =
window.baseUrl +
`/project/background_tasks?id=${encodeURIComponent(this.props.component.key)}`;

if (this.props.isInProgress) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ class GlobalNavBranding extends React.PureComponent {

render() {
const homeController = this.props.currentUser.isLoggedIn ? '/projects' : '/about';
const homeLinkClassName = 'navbar-brand' +
(this.props.customLogoUrl ? ' navbar-brand-custom' : '');
const homeLinkClassName =
'navbar-brand' + (this.props.customLogoUrl ? ' navbar-brand-custom' : '');
return (
<div className="navbar-header">
<Link to={homeController} className={homeLinkClassName}>{this.renderLogo()}</Link>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ class GlobalNavUser extends React.PureComponent {
name: string
},
location: Object,
router: { push: (string) => void }
router: { push: string => void }
};

handleLogin = e => {
e.preventDefault();
const shouldReturnToCurrentPage = window.location.pathname !== `${window.baseUrl}/about`;
if (shouldReturnToCurrentPage) {
const returnTo = encodeURIComponent(window.location.pathname + window.location.search);
window.location = window.baseUrl +
`/sessions/new?return_to=${returnTo}${window.location.hash}`;
window.location =
window.baseUrl + `/sessions/new?return_to=${returnTo}${window.location.hash}`;
} else {
window.location = `${window.baseUrl}/sessions/new`;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,9 @@ export default Marionette.LayoutView.extend({
onRender() {
const that = this;
this.resultsRegion.show(this.resultsView);
setTimeout(
() => {
that.$('.js-search-input').focus();
},
0
);
setTimeout(() => {
that.$('.js-search-input').focus();
}, 0);
},

onKeyDown(e) {
Expand Down Expand Up @@ -191,7 +188,8 @@ export default Marionette.LayoutView.extend({
const recentHistory = RecentHistory.get();
const customOrganizations = areThereCustomOrganizations();
const history = recentHistory.map((historyItem, index) => {
const url = window.baseUrl +
const url =
window.baseUrl +
'/dashboard/index?id=' +
encodeURIComponent(historyItem.key) +
window.dashboardParameters(true);
Expand Down Expand Up @@ -229,7 +227,8 @@ export default Marionette.LayoutView.extend({
const collection = [];
r.results.forEach(({ items, q }) => {
items.forEach((item, index) => {
const showOrganization = customOrganizations &&
const showOrganization =
customOrganizations &&
item.organization != null &&
SHOW_ORGANIZATION_FOR_QUALIFIERS.includes(q);
const organization = showOrganization ? getOrganization(item.organization) : null;
Expand Down
2 changes: 1 addition & 1 deletion server/sonar-web/src/main/js/app/utils/configureLocale.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import moment from 'moment';

const getPreferredLanguage = () =>
window.navigator.languages ? window.navigator.languages[0] : window.navigator.language;
(window.navigator.languages ? window.navigator.languages[0] : window.navigator.language);

const configureLocale = () => {
moment.locale(getPreferredLanguage());
Expand Down
2 changes: 1 addition & 1 deletion server/sonar-web/src/main/js/app/utils/getHistory.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ const ensureHistory = () => {
return history;
};

export default () => history ? history : ensureHistory();
export default () => (history ? history : ensureHistory());
2 changes: 1 addition & 1 deletion server/sonar-web/src/main/js/app/utils/getStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ const createStore = () => {
return store;
};

export default () => store ? store : createStore();
export default () => (store ? store : createStore());
21 changes: 8 additions & 13 deletions server/sonar-web/src/main/js/app/utils/startAjaxMonitoring.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ const Process = Backbone.Model.extend({
let msg = message || translate('process.fail');
if (msg === 'process.fail') {
// no translation
msg = 'An error happened, some parts of the page might not render correctly. ' +
msg =
'An error happened, some parts of the page might not render correctly. ' +
'Please contact the administrator if you keep on experiencing this error.';
}
clearInterval(this.get('timer'));
Expand All @@ -64,12 +65,9 @@ const Process = Backbone.Model.extend({
message: msg
});
this.set('state', 'failed');
setTimeout(
() => {
that.finish({ force: true });
},
5000
);
setTimeout(() => {
that.finish({ force: true });
}, 5000);
}
});

Expand Down Expand Up @@ -123,12 +121,9 @@ function addBackgroundProcess() {
const uid = uniqueId('process');
const process = new Process({
id: uid,
timer: setTimeout(
() => {
process.timeout();
},
defaults.timeout
)
timer: setTimeout(() => {
process.timeout();
}, defaults.timeout)
});
processes.add(process);
return uid;
Expand Down
13 changes: 6 additions & 7 deletions server/sonar-web/src/main/js/apps/about/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@
import { getValues } from '../../api/settings';
import { receiveValues } from '../settings/store/values/actions';

export const fetchAboutPageSettings = (): Function =>
(dispatch: Function): Promise<*> => {
const keys = ['sonar.lf.aboutText'];
export const fetchAboutPageSettings = (): Function => (dispatch: Function): Promise<*> => {
const keys = ['sonar.lf.aboutText'];

return getValues(keys.join()).then(values => {
dispatch(receiveValues(values));
});
};
return getValues(keys.join()).then(values => {
dispatch(receiveValues(values));
});
};
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import { getRulesUrl } from '../../../helpers/urls';

const link = 'https://redirect.sonarsource.com/doc/rules.html';

const owaspTags = 'owasp-a1,owasp-a2,owasp-a3,owasp-a4,owasp-a5,' +
'owasp-a6,owasp-a7,owasp-a8,owasp-a9,owasp-a10';
const owaspTags =
'owasp-a1,owasp-a2,owasp-a3,owasp-a4,owasp-a5,owasp-a6,owasp-a7,owasp-a8,owasp-a9,owasp-a10';
const sans25Tags = 'sans-top25-porous,sans-top25-risky,sans-top25-insecure';

type Props = {
Expand Down
3 changes: 2 additions & 1 deletion server/sonar-web/src/main/js/apps/about/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ const routes = [
{
getIndexRoute(_, callback) {
require.ensure([], require =>
callback(null, { component: require('./components/AboutApp').default }));
callback(null, { component: require('./components/AboutApp').default })
);
}
}
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ class Projects extends React.PureComponent {
value: project.key,
label: project.name,
organization: project.organization
})))
}))
)
.then(options => {
cb(null, { options });
});
Expand Down
55 changes: 26 additions & 29 deletions server/sonar-web/src/main/js/apps/account/notifications/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,36 +28,33 @@ import {
} from '../../../store/notifications/duck';
import type { Notification } from '../../../store/notifications/duck';

export const fetchNotifications = () =>
(dispatch: Function) => {
const onFulfil = (response: GetNotificationsResponse) => {
const organizations = response.notifications
.filter(n => n.organization)
.map(n => n.organization);
export const fetchNotifications = () => (dispatch: Function) => {
const onFulfil = (response: GetNotificationsResponse) => {
const organizations = response.notifications
.filter(n => n.organization)
.map(n => n.organization);

dispatch(fetchOrganizations(organizations)).then(() => {
dispatch(
receiveNotifications(
response.notifications,
response.channels,
response.globalTypes,
response.perProjectTypes
)
);
});
};

return api.getNotifications().then(onFulfil, onFail(dispatch));
dispatch(fetchOrganizations(organizations)).then(() => {
dispatch(
receiveNotifications(
response.notifications,
response.channels,
response.globalTypes,
response.perProjectTypes
)
);
});
};

export const addNotification = (n: Notification) =>
(dispatch: Function) =>
api
.addNotification(n.channel, n.type, n.project)
.then(() => dispatch(addNotificationAction(n)), onFail(dispatch));
return api.getNotifications().then(onFulfil, onFail(dispatch));
};

export const addNotification = (n: Notification) => (dispatch: Function) =>
api
.addNotification(n.channel, n.type, n.project)
.then(() => dispatch(addNotificationAction(n)), onFail(dispatch));

export const removeNotification = (n: Notification) =>
(dispatch: Function) =>
api
.removeNotification(n.channel, n.type, n.project)
.then(() => dispatch(removeNotificationAction(n)), onFail(dispatch));
export const removeNotification = (n: Notification) => (dispatch: Function) =>
api
.removeNotification(n.channel, n.type, n.project)
.then(() => dispatch(removeNotificationAction(n)), onFail(dispatch));
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class CreateOrganizationForm extends React.PureComponent {
state: State;
props: {
createOrganization: () => Promise<*>,
router: { push: (string) => void }
router: { push: string => void }
};

constructor(props) {
Expand Down

0 comments on commit f6e90fd

Please sign in to comment.