Skip to content

Commit

Permalink
Add an eslint rule about no space between function name and argument …
Browse files Browse the repository at this point in the history
…list, and fix occurrences.
  • Loading branch information
mstange committed Dec 2, 2016
1 parent 2bb1374 commit a319971
Show file tree
Hide file tree
Showing 14 changed files with 29 additions and 24 deletions.
7 changes: 6 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,12 @@ module.exports = {
"no-duplicate-imports": "error",
"no-var": "error",
"prefer-const": "error",
"array-bracket-spacing": "error"
"array-bracket-spacing": "error",
"space-before-function-paren": ["error", {
"anonymous": "always",
"named": "never",
"asyncArrow": "always",
}],
},
"settings": {
"react": {
Expand Down
14 changes: 7 additions & 7 deletions src/common/summarize-profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const categories = [
// [match.prefix, 'Interpret(', 'script.interpreter',
];

export function summarizeProfile (profile) {
export function summarizeProfile(profile) {
const categories = categorizeThreadSamples(profile);
const rollingSummaries = calculateRollingSummaries(profile, categories);
const summaries = summarizeCategories(profile, categories);
Expand Down Expand Up @@ -178,7 +178,7 @@ function calculateSummaryPercentages(summary) {
}


function logUncategorizedSamples (uncategorized, maxLogLength = 10) {
function logUncategorizedSamples(uncategorized, maxLogLength = 10) {
const entries = Object.entries(uncategorized);
/* eslint-disable no-console */
console.log(`Top ${maxLogLength} uncategorized stacks`);
Expand All @@ -197,7 +197,7 @@ function logUncategorizedSamples (uncategorized, maxLogLength = 10) {
* @param {array} profile - The current profile.
* @returns {array} Stacks mapped to categories.
*/
export function categorizeThreadSamples (profile) {
export function categorizeThreadSamples(profile) {
const uncategorized = {};
const summaries = profile.threads.map(thread => (
thread.samples.stack
Expand All @@ -218,7 +218,7 @@ export function categorizeThreadSamples (profile) {
* @param {object} threadCategories - Each thread's categories for the samples.
* @returns {object} The summaries of each thread.
*/
export function summarizeCategories (profile, threadCategories) {
export function summarizeCategories(profile, threadCategories) {
return threadCategories.map(categories => (
categories.reduce(summarizeSampleCategories, {})
))
Expand All @@ -227,7 +227,7 @@ export function summarizeCategories (profile, threadCategories) {
// .sort((a, b) => Object.keys(b.summary).length - Object.keys(a.summary).length);
}

export function calculateRollingSummaries (profile, threadCategories, segmentCount = 40, rolling = 4) {
export function calculateRollingSummaries(profile, threadCategories, segmentCount = 40, rolling = 4) {
const [minTime, maxTime] = profile.threads.map(thread => {
return [thread.samples.time[0], thread.samples.time[thread.samples.time.length - 1]];
})
Expand Down Expand Up @@ -271,15 +271,15 @@ export function calculateRollingSummaries (profile, threadCategories, segmentCou
});
}

function times (n, fn) {
function times(n, fn) {
const results = Array(n);
for (let i = 0; i < n; i++) {
results[i] = fn(i);
}
return results;
}

function mapObj (object, fn) {
function mapObj(object, fn) {
let i = 0;
const mappedObj = {};
for (const key in object) {
Expand Down
2 changes: 1 addition & 1 deletion src/common/test/summarize-profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ describe('summarize-profile', function () {
});
});

function forEachObj (object, fn) {
function forEachObj(object, fn) {
let i = 0;
for (const key in object) {
if (object.hasOwnProperty(key)) {
Expand Down
2 changes: 1 addition & 1 deletion src/content/actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export function startSymbolicating() {
}

export function doneSymbolicating() {
return function(dispatch, getState) {
return function (dispatch, getState) {
dispatch({ type: 'DONE_SYMBOLICATING' });
// TODO - Do not use selectors here.
dispatch({
Expand Down
6 changes: 3 additions & 3 deletions src/content/components/SummarizeLineGraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,14 @@ SummarizeLineGraph.propTypes = {

export default SummarizeLineGraph;

function round (n) {
function round(n) {
return Math.round(n * 1000) / 1000;
}

function moveTo (x, y) {
function moveTo(x, y) {
return `M${x},${y}`;
}

function lineTo (x, y) {
function lineTo(x, y) {
return `L${x},${y}`;
}
2 changes: 1 addition & 1 deletion src/content/components/SummarizeProfileExpand.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { Component, PropTypes } from 'react';
import SummarizeLineGraph from './SummarizeLineGraph';

class SummarizeProfileExpand extends Component {
render () {
render() {
const {summary, thread, isExpanded, expand, collapse, expandLength} = this.props;
// Only show the expand/collapse button when it is warranted.
if (summary.length > expandLength) {
Expand Down
2 changes: 1 addition & 1 deletion src/content/components/SummarizeProfileHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const PERCENT_TIME_TITLE = 'The percentage of time represents the percentage of
'recording.';

class SummarizeProfileHeader extends Component {
render () {
render() {
const {threadName} = this.props;
return (
<div>
Expand Down
2 changes: 1 addition & 1 deletion src/content/components/SummarizeProfileThread.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default SummarizeProfileThread;
* @param {number} n - The number.
* @returns {string} The formatted string.
*/
function displayPercentage (n) {
function displayPercentage(n) {
const percentage = Math.round(n * 1000);
const integer = Math.floor(percentage / 10);
const decimal = Math.floor(percentage - integer * 10);
Expand Down
2 changes: 1 addition & 1 deletion src/content/containers/ProfileSummaryView.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ ProfileSummaryView.propTypes = {
expandProfileSummaryThread: PropTypes.func,
};

function fill (size, fn) {
function fill(size, fn) {
const array = Array(size);
for (let i = 0; i < size; i++) {
array[i] = fn(i);
Expand Down
2 changes: 1 addition & 1 deletion src/content/gz.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import ZeeWorker from 'file-loader!./zee-worker.js';
const zeeWorker = new Worker(ZeeWorker);
const zeeCallbacks = [];

zeeWorker.onmessage = function(msg) {
zeeWorker.onmessage = function (msg) {
zeeCallbacks[msg.data.callbackID][msg.data.type](msg.data.data);
zeeCallbacks[msg.data.callbackID] = null;
};
Expand Down
2 changes: 1 addition & 1 deletion src/content/messages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ import { profileSummaryProcessed } from '../actions';
const messages = {};
export default messages;

messages.PROFILE_SUMMARY_PROCESSED = function(message, call) {
messages.PROFILE_SUMMARY_PROCESSED = function (message, call) {
call(profileSummaryProcessed, message.summary);
};
2 changes: 1 addition & 1 deletion src/content/reducers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ function profile(state = {}, action) {
}
}

function summaryView (state = {summary: null, expanded: null}, action) {
function summaryView(state = {summary: null, expanded: null}, action) {
switch (action.type) {
case 'PROFILE_SUMMARY_PROCESSED': {
return Object.assign({}, state, { summary: action.summary, expanded: new Set() });
Expand Down
4 changes: 2 additions & 2 deletions src/worker/actions/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { summarizeProfile } from '../../common/summarize-profile';

export function processProfileSummary () {
return function(dispatch, getState) {
export function processProfileSummary() {
return function (dispatch, getState) {
dispatch({
toContent: true,
type: 'PROFILE_SUMMARY_PROCESSED',
Expand Down
4 changes: 2 additions & 2 deletions src/worker/messages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import {processProfileSummary, profileProcessed} from '../actions';
const messages = {};
export default messages;

messages.PROFILE_PROCESSED = function(message, call) {
messages.PROFILE_PROCESSED = function (message, call) {
call(profileProcessed, message.profile);
};

messages.SUMMARIZE_PROFILE = function(message, call) {
messages.SUMMARIZE_PROFILE = function (message, call) {
call(processProfileSummary);
};

0 comments on commit a319971

Please sign in to comment.