Skip to content

Commit

Permalink
Fix many more style issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
mstange committed May 14, 2016
1 parent bf5c87f commit b93a71f
Show file tree
Hide file tree
Showing 17 changed files with 220 additions and 175 deletions.
86 changes: 57 additions & 29 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,35 +21,63 @@ module.exports = {
2,
{ "SwitchCase": 1 }
],
"linebreak-style": [
"error",
"unix"
],
"quotes": [
"error",
"single"
],
"semi": [
"error",
"always"
],
"no-extra-semi": [
"error"
],
"comma-dangle": [
"error",
"always-multiline"
],
"no-console": [
"error",
{ allow: ["log", "warn", "error"] }
],
"eqeqeq": [
"error"
],
"valid-jsdoc": [
"error"
]
"linebreak-style": [ "error", "unix" ],
"quotes": [ "error", "single" ],
"semi": [ "error", "always" ],
"no-extra-semi": "error",
"comma-dangle": [ "error", "always-multiline" ],
"no-console": [ "error", { allow: ["log", "warn", "error"] } ],
"eqeqeq": "error",
"valid-jsdoc": "error",
"consistent-return": "error",
"curly": ["error", "all" ],
"dot-location": ["error", "property"],
"dot-notation": "error",
"no-alert": "error",
"no-caller": "error",
"no-else-return": "error",
"no-eval": "error",
"no-implied-eval": "error",
"no-extend-native": "error",
"no-native-reassign": "error",
"no-extra-bind": "error",
"no-labels": "error",
"no-implicit-globals": "error",
"no-invalid-this": "error",
"no-iterator": "error",
"no-lone-blocks": "error",
"no-loop-func": "error",
"no-multi-spaces": "error",
"no-param-reassign": "error",
"no-proto": "error",
"no-return-assign": "error",
"no-script-url": "error",
"no-self-compare": "error",
"no-throw-literal": "error",
"no-unmodified-loop-condition": "error",
"no-unused-expressions": "error",
"no-useless-concat": "error",
"no-useless-escape": "error",
"no-void": "error",
"no-with": "error",
"radix": "error",
"yoda": ["error", "never", { "exceptRange": true }],
"brace-style": ["error", "1tbs", { "allowSingleLine": true }],
"camelcase": "error",
"comma-spacing": "error",
"comma-style": "error",
"jsx-quotes": ["error", "prefer-single"],
"key-spacing": "error",
"keyword-spacing": "error",
"no-new-object": "error",
"no-spaced-func": "error",
"semi-spacing": "error",
"space-in-parens": ["error", "never"],
"spaced-comment": "error",
"generator-star-spacing": "error",
"no-duplicate-imports": "error",
"no-var": "error",
"prefer-const": "error"
},
"settings": {
"react": {
Expand Down
3 changes: 2 additions & 1 deletion src/actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ class ColascedFunctionsUpdateDispatcher {
};
} else {
const oldMap = this._updates[threadIndex].oldFuncToNewFuncMap;
this._updates[threadIndex].oldFuncToNewFuncMap = new Map(function*() { yield* oldMap; yield* oldFuncToNewFuncMap;}());
this._updates[threadIndex].oldFuncToNewFuncMap =
new Map(function *() { yield* oldMap; yield* oldFuncToNewFuncMap;}());
}
}

Expand Down
24 changes: 12 additions & 12 deletions src/async-storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,17 @@
*/

export function getStore(dbName) {
let DBVERSION = 1;
let STORENAME = 'keyvaluestore';
const DBVERSION = 1;
const STORENAME = 'keyvaluestore';
let db = null;

function withStore(type, onsuccess, onerror) {
if (db) {
let transaction = db.transaction(STORENAME, type);
let store = transaction.objectStore(STORENAME);
const transaction = db.transaction(STORENAME, type);
const store = transaction.objectStore(STORENAME);
onsuccess(store);
} else {
let openreq = indexedDB.open(dbName, DBVERSION);
const openreq = indexedDB.open(dbName, DBVERSION);
openreq.onerror = function withStoreOnError() {
onerror();
};
Expand All @@ -61,8 +61,8 @@ export function getStore(dbName) {
};
openreq.onsuccess = function withStoreOnSuccess() {
db = openreq.result;
let transaction = db.transaction(STORENAME, type);
let store = transaction.objectStore(STORENAME);
const transaction = db.transaction(STORENAME, type);
const store = transaction.objectStore(STORENAME);
onsuccess(store);
};
}
Expand Down Expand Up @@ -91,7 +91,7 @@ export function getStore(dbName) {
return new Promise((resolve, reject) => {
withStore('readwrite', (store) => {
store.transaction.oncomplete = resolve;
let req = store.put(value, key);
const req = store.put(value, key);
req.onerror = function setItemOnError() {
reject('Error in asyncStorage.setItem(): ', req.error.name);
};
Expand All @@ -103,7 +103,7 @@ export function getStore(dbName) {
return new Promise((resolve, reject) => {
withStore('readwrite', (store) => {
store.transaction.oncomplete = resolve;
let req = store.delete(key);
const req = store.delete(key);
req.onerror = function removeItemOnError() {
reject('Error in asyncStorage.removeItem(): ', req.error.name);
};
Expand All @@ -115,7 +115,7 @@ export function getStore(dbName) {
return new Promise((resolve, reject) => {
withStore('readwrite', (store) => {
store.transaction.oncomplete = resolve;
let req = store.clear();
const req = store.clear();
req.onerror = function clearOnError() {
reject('Error in asyncStorage.clear(): ', req.error.name);
};
Expand Down Expand Up @@ -148,13 +148,13 @@ export function getStore(dbName) {
let req;
withStore('readonly', (store) => {
store.transaction.oncomplete = function onComplete() {
let cursor = req.result;
const cursor = req.result;
resolve(cursor ? cursor.key : null);
};
let advanced = false;
req = store.openCursor();
req.onsuccess = function keyOnSuccess() {
let cursor = req.result;
const cursor = req.result;
if (!cursor) {
// this means there weren"t enough keys
return;
Expand Down
11 changes: 6 additions & 5 deletions src/components/Histogram.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,19 @@ class Histogram extends Component {
if (selectedFuncStack !== -1 && selectedFuncStack !== null) {
selectedFuncStackDepth = funcStackTable.depth[selectedFuncStack];
}
function hasSelectedFuncStackPrefix(funcStack) {
let depth = funcStackTable.depth[funcStack];
while (depth > selectedFuncStackDepth) {
function hasSelectedFuncStackPrefix(funcStackPrefix) {
let funcStack = funcStackPrefix;
for (let depth = funcStackTable.depth[funcStack];
depth > selectedFuncStackDepth; depth--) {
funcStack = funcStackTable.prefix[funcStack];
depth--;
}
return funcStack === selectedFuncStack;
}
for (let i = 0; i < sampleFuncStacks.length; i++) {
const sampleTime = thread.samples.time[i];
if (sampleTime + intervalMs < range[0] || sampleTime > range[1])
if (sampleTime + intervalMs < range[0] || sampleTime > range[1]) {
continue;
}
const funcStack = sampleFuncStacks[i];
const isHighlighted = hasSelectedFuncStackPrefix(funcStack);
const sampleHeight = funcStackTable.depth[funcStack] * yPixelsPerDepth;
Expand Down
5 changes: 3 additions & 2 deletions src/components/ProfileTreeView.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class ProfileTreeView extends Component{
{ propName: 'totalTimePercent', title: '' },
{ propName: 'selfTime', title: 'Self' },
];
this._mainColumn = { propName:'name', title: '' };
this._mainColumn = { propName: 'name', title: '' };
}

componentWillMount() {
Expand Down Expand Up @@ -38,8 +38,9 @@ class ProfileTreeView extends Component{
newExpandedFuncStacks.push(currentFuncStack);
for (let i = 0; i < maxInterestingDepth; i++) {
const children = this._tree.getChildren(currentFuncStack);
if (children.length === 0)
if (children.length === 0) {
break;
}
currentFuncStack = children[0];
newExpandedFuncStacks.push(currentFuncStack);
}
Expand Down
3 changes: 1 addition & 2 deletions src/components/ProfileViewer.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import React, { Component, PropTypes } from 'react';
import { connect } from 'react-redux';
import shallowequal from 'shallowequal';
import { getTimeRangeIncludingAllThreads } from '../profile-data';
import { getFuncStackInfo, filterThreadToJSOnly, getFuncStackFromFuncArray, getStackAsFuncArray, invertCallstack } from '../profile-data';
import { getFuncStackInfo, getTimeRangeIncludingAllThreads, filterThreadToJSOnly, getFuncStackFromFuncArray, getStackAsFuncArray, invertCallstack } from '../profile-data';
import ProfileTreeView from '../components/ProfileTreeView';
import ProfileThreadHeaderBar from '../components/ProfileThreadHeaderBar';
import ProfileViewSidebar from '../components/ProfileViewSidebar';
Expand Down
3 changes: 2 additions & 1 deletion src/components/TreeView.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,9 @@ class TreeView extends Component {
}

_onKeyDown(event) {
if (event.ctrlKey || event.altKey || event.metaKey)
if (event.ctrlKey || event.altKey || event.metaKey) {
return;
}

if (event.keyCode < 37 || event.keyCode > 40) {
if (event.keyCode !== 0 ||
Expand Down
5 changes: 3 additions & 2 deletions src/components/VirtualList.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,9 @@ class VirtualList extends Component {
style={{height: Math.max(0, visibleRangeStart) * itemHeight + 'px'}} />
{
items.map((item, i) => {
if (i < visibleRangeStart || i >= visibleRangeEnd)
return;
if (i < visibleRangeStart || i >= visibleRangeEnd) {
return null;
}
return <VirtualListRow key={i} index={i} renderItem={renderItem} item={item} items={items}/>;
})
}
Expand Down
6 changes: 3 additions & 3 deletions src/containers/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ class App extends Component {
dispatch(Actions.waitingForProfileFromAddon());

window.geckoProfilerPromise.then((geckoProfiler) => {
geckoProfiler.getProfile().then(profile => {
profile = preprocessProfile(profile);
geckoProfiler.getProfile().then(rawProfile => {
const profile = preprocessProfile(rawProfile);
dispatch(Actions.receiveProfileFromAddon(profile));

const symbolStore = new SymbolStore('cleopatra-async-storage', {
requestSymbolTable: (pdbName, breakpadId) => {
let requestedLib = { pdbName, breakpadId };
const requestedLib = { pdbName, breakpadId };
dispatch(Actions.requestingSymbolTable(requestedLib));
return geckoProfiler.getSymbolTable(pdbName, breakpadId).then(symbolTable => {
dispatch(Actions.receivedSymbolTableReply(requestedLib));
Expand Down
Loading

0 comments on commit b93a71f

Please sign in to comment.