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 (