diff --git a/.eslintrc.js b/.eslintrc.js index c992f3b2da..e45109a0d2 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -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": { diff --git a/src/common/summarize-profile.js b/src/common/summarize-profile.js index a1a7ad245e..1d0207e058 100644 --- a/src/common/summarize-profile.js +++ b/src/common/summarize-profile.js @@ -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); @@ -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`); @@ -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 @@ -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, {}) )) @@ -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]]; }) @@ -271,7 +271,7 @@ 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); @@ -279,7 +279,7 @@ function times (n, fn) { return results; } -function mapObj (object, fn) { +function mapObj(object, fn) { let i = 0; const mappedObj = {}; for (const key in object) { diff --git a/src/common/test/summarize-profile.js b/src/common/test/summarize-profile.js index 7e62b0e45e..ea0816924a 100644 --- a/src/common/test/summarize-profile.js +++ b/src/common/test/summarize-profile.js @@ -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)) { diff --git a/src/content/actions/index.js b/src/content/actions/index.js index 620d466ad3..c4c25f0060 100644 --- a/src/content/actions/index.js +++ b/src/content/actions/index.js @@ -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({ diff --git a/src/content/components/SummarizeLineGraph.js b/src/content/components/SummarizeLineGraph.js index ab990103e6..544eb4419a 100644 --- a/src/content/components/SummarizeLineGraph.js +++ b/src/content/components/SummarizeLineGraph.js @@ -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}`; } diff --git a/src/content/components/SummarizeProfileExpand.js b/src/content/components/SummarizeProfileExpand.js index 91f8d72be6..11e1b8e364 100644 --- a/src/content/components/SummarizeProfileExpand.js +++ b/src/content/components/SummarizeProfileExpand.js @@ -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) { diff --git a/src/content/components/SummarizeProfileHeader.js b/src/content/components/SummarizeProfileHeader.js index b83e6b9eee..c3fd57f332 100644 --- a/src/content/components/SummarizeProfileHeader.js +++ b/src/content/components/SummarizeProfileHeader.js @@ -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 (
diff --git a/src/content/components/SummarizeProfileThread.js b/src/content/components/SummarizeProfileThread.js index 74178b178e..f6a26d873e 100644 --- a/src/content/components/SummarizeProfileThread.js +++ b/src/content/components/SummarizeProfileThread.js @@ -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); diff --git a/src/content/containers/ProfileSummaryView.js b/src/content/containers/ProfileSummaryView.js index 4e6ca5c358..6ca47e532b 100644 --- a/src/content/containers/ProfileSummaryView.js +++ b/src/content/containers/ProfileSummaryView.js @@ -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); diff --git a/src/content/gz.js b/src/content/gz.js index 74cada266f..70fcaf6a33 100644 --- a/src/content/gz.js +++ b/src/content/gz.js @@ -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; }; diff --git a/src/content/messages/index.js b/src/content/messages/index.js index be5a8669a6..f39a1fbbe4 100644 --- a/src/content/messages/index.js +++ b/src/content/messages/index.js @@ -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); }; diff --git a/src/content/reducers/index.js b/src/content/reducers/index.js index 334e551496..e70e9b3519 100644 --- a/src/content/reducers/index.js +++ b/src/content/reducers/index.js @@ -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() }); diff --git a/src/worker/actions/index.js b/src/worker/actions/index.js index bcbb0b1470..398a3674b2 100644 --- a/src/worker/actions/index.js +++ b/src/worker/actions/index.js @@ -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', diff --git a/src/worker/messages/index.js b/src/worker/messages/index.js index f4047b18b6..41ac31a8f4 100644 --- a/src/worker/messages/index.js +++ b/src/worker/messages/index.js @@ -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); };