Skip to content
This repository has been archived by the owner on May 2, 2018. It is now read-only.

Commit

Permalink
Fix errors reported by eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
tromey authored and juliandescottes committed Feb 17, 2017
1 parent d5df958 commit 89d30d3
Show file tree
Hide file tree
Showing 16 changed files with 55 additions and 53 deletions.
1 change: 0 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ module.exports = {
],
"env": {
"es6": true,
"node": true,
"browser": true
},
"globals": {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "src/index.js",
"scripts": {
"start": "node bin/dev-server.js",
"lint-js": "eslint src/**/*.js",
"lint-js": "eslint src",
"firefox": "./node_modules/.bin/start-firefox --start --location https://devtools-html.github.io/debugger-examples/",
"chrome": "./node_modules/.bin/start-chrome",
"copy-assets": "node bin/copy-assets",
Expand Down
2 changes: 0 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
const React = require("react");

const { MODE } = require("./reps/constants");
const { REPS } = require("./reps/rep");
const {
Expand Down
2 changes: 1 addition & 1 deletion src/launchpad/actions/expressions.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function evaluateInput(input) {
const packet = await client.clientCommands.evaluate(input, {});
dispatch(addExpression(input, packet));
} catch (err) {
console.warn("Error when evaluating expression", err)
console.warn("Error when evaluating expression", err);
}
};
}
Expand Down
10 changes: 5 additions & 5 deletions src/launchpad/components/Console.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,23 @@ const ResultsList = createFactory(require("./ResultsList"));
require("./Console.css");

const Console = React.createClass({
displayName: "Console",

propTypes: {
client: PropTypes.object.isRequired,
shortcuts: PropTypes.object.isRequired,
clearExpressions: PropTypes.func.isRequired,
},

displayName: "Console",

componentDidMount: function() {
componentDidMount: function () {
this.props.shortcuts.on("CmdOrCtrl+Shift+L", this.props.clearExpressions);
},

componentWillUnmount: function() {
componentWillUnmount: function () {
this.props.shortcuts.off("CmdOrCtrl+Shift+L");
},

render: function() {
render: function () {
let {
addInput,
changeCurrentInput,
Expand Down
17 changes: 8 additions & 9 deletions src/launchpad/components/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ require("./Header.css");

const Header = React.createClass({

displayName: "Header",

propTypes: {
addInput: PropTypes.func.isRequired,
changeCurrentInput: PropTypes.func.isRequired,
Expand All @@ -16,20 +18,18 @@ const Header = React.createClass({
navigateInputHistory: PropTypes.func.isRequired,
},

displayName: "Header",

onSubmitForm: function(e) {
onSubmitForm: function (e) {
e.preventDefault();
let data = new FormData(e.target);
let expression = data.get("expression");
this.props.addInput(expression);
},

onInputChange: function(e) {
onInputChange: function (e) {
this.props.changeCurrentInput(e.target.value);
},

onInputKeyDown: function(e) {
onInputKeyDown: function (e) {
if (["ArrowUp", "ArrowDown"].includes(e.key)) {
this.props.navigateInputHistory(e.key === "ArrowUp"
? constants.DIR_BACKWARD
Expand All @@ -38,7 +38,7 @@ const Header = React.createClass({
}
},

onClearButtonClick: function(e) {
onClearButtonClick: function (e) {
this.props.clearResultsList();
},

Expand All @@ -50,9 +50,8 @@ const Header = React.createClass({

return dom.header(
{ className: "console-header" },
dom.form({
onSubmit: this.onSubmitForm,
},
dom.form(
{ onSubmit: this.onSubmitForm, },
dom.h1({}, "Reps"),
dom.input({
type: "text",
Expand Down
8 changes: 4 additions & 4 deletions src/launchpad/components/QuickLinks.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ const samples = require("../samples.js");

const QuickLinks = React.createClass({

displayName: "QuickLinks",

propTypes: {
evaluate: PropTypes.func.isRequired
},

displayName: "QuickLinks",

evaluateExpressions(expressions) {
expressions.forEach(
expression => this.props.evaluate(expression)
Expand All @@ -21,7 +21,7 @@ const QuickLinks = React.createClass({
return Object.keys(samples)
.map(label => {
let expressions = samples[label];
let length = expressions.length;
let length = expressions.length;
return dom.button(
{
key: label,
Expand All @@ -31,7 +31,7 @@ const QuickLinks = React.createClass({
onClick: () => this.evaluateExpressions(expressions)
},
label
)
);
});
},

Expand Down
33 changes: 16 additions & 17 deletions src/launchpad/components/Result.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,26 @@ const Grip = require("../../reps/grip");
const { getSelectableInInspectorGrips } = require("../../reps/rep-utils");

const Result = React.createClass({
displayName: "Result",

propTypes: {
expression: PropTypes.object.isRequired,
showResultPacket: PropTypes.func.isRequired,
hideResultPacket: PropTypes.func.isRequired,
},

displayName: "Result",

copyPacketToClipboard: function(e, packet) {
copyPacketToClipboard: function (e, packet) {
e.stopPropagation();

var textField = document.createElement('textarea');
let textField = document.createElement("textarea");
textField.innerHTML = JSON.stringify(packet, null, " ");
document.body.appendChild(textField);
textField.select();
document.execCommand('copy');
document.execCommand("copy");
textField.remove();
},

onHeaderClick: function() {
onHeaderClick: function () {
const {expression} = this.props;
if (expression.showPacket === true) {
this.props.hideResultPacket();
Expand All @@ -35,13 +35,13 @@ const Result = React.createClass({
}
},

renderRepInAllModes: function({ object }) {
renderRepInAllModes: function ({ object }) {
return Object.keys(MODE).map(modeKey =>
this.renderRep({ object, modeKey })
);
},

renderRep: function({ object, modeKey }) {
renderRep: function ({ object, modeKey }) {
return dom.div(
{
className: `rep-element ${modeKey}`,
Expand All @@ -63,16 +63,16 @@ const Result = React.createClass({
);
},

renderPacket: function(expression) {
renderPacket: function (expression) {
let {packet, showPacket} = expression;
let headerClassName = showPacket ? "packet-expanded" : "packet-collapsed";
let headerLabel = showPacket ? "Hide expression packet" : "Show expression packet";

return dom.div({ className: "packet" },
dom.header({
className: headerClassName,
onClick: this.onHeaderClick,
},
className: headerClassName,
onClick: this.onHeaderClick,
},
headerLabel,
showPacket && dom.button({
className: "copy-packet-button",
Expand All @@ -81,15 +81,14 @@ const Result = React.createClass({
),
showPacket &&
dom.div({className: "packet-rep"}, Rep({object: packet}))
)
);
},

render: function() {
render: function () {
let {expression} = this.props;
let {input, packet} = expression;
return dom.div({
className: "rep-row"
},
return dom.div(
{ className: "rep-row" },
dom.div({ className: "rep-input" }, input),
dom.div({ className: "reps" }, this.renderRepInAllModes({
object: packet.exception || packet.result
Expand Down
6 changes: 3 additions & 3 deletions src/launchpad/components/ResultsList.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ const ImPropTypes = require("react-immutable-proptypes");
const Result = createFactory(require("./Result"));

const ResultsList = React.createClass({
displayName: "ResultsList",

propTypes: {
expressions: ImPropTypes.map.isRequired,
showResultPacket: PropTypes.func.isRequired,
hideResultPacket: PropTypes.func.isRequired,
},

displayName: "ResultsList",

render: function() {
render: function () {
let {
expressions,
showResultPacket,
Expand Down
6 changes: 4 additions & 2 deletions src/launchpad/reducers/expressions.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ try {
storedExpressions = JSON.parse(
window.localStorage.getItem(constants.LS_EXPRESSIONS_KEY)
);
} catch (e) {}
} catch (e) {
// Ignore.
}

const initialState = storedExpressions
? Immutable.fromJS(storedExpressions)
Expand All @@ -19,7 +21,7 @@ function update(state = initialState, action) {
case constants.ADD_EXPRESSION:
let newState = state.set(key, Immutable.Map(value));
window.localStorage.setItem(
constants.LS_EXPRESSIONS_KEY,
constants.LS_EXPRESSIONS_KEY,
JSON.stringify(newState.toJS())
);
return newState;
Expand Down
2 changes: 1 addition & 1 deletion src/launchpad/reducers/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function update(state = initialState, action) {
return state.withMutations(map => {
map
.set("currentValue", history.get(newNavigationKey) || fallbackValue)
.set("currentNavigationKey", newNavigationKey|| fallbackNavigationKey);
.set("currentNavigationKey", newNavigationKey || fallbackNavigationKey);
});
}

Expand Down
4 changes: 1 addition & 3 deletions src/launchpad/selectors/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ function getCurrentInputValue(state) {
return getInputState(state).get("currentValue");
}



module.exports = {
getCurrentInputValue,
getExpressions,
};
};
1 change: 0 additions & 1 deletion src/launchpad/utils/redux/middleware/promise.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ function seqIdGen() {

function promiseMiddleware({ dispatch, getState }) {
return next => action => {

if (!action || !Object.keys(action).includes(PROMISE)) {
return next(action);
}
Expand Down
2 changes: 1 addition & 1 deletion src/launchpad/utils/redux/middleware/thunk.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ function thunk(makeArgs) {
};
};
}
exports.thunk = thunk;
exports.thunk = thunk;
1 change: 0 additions & 1 deletion src/launchpad/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ function filterByKey(obj, predicate) {
}, {});
}

let keyCounter = 0;
function generateKey() {
return `${performance.now()}`;
}
Expand Down
11 changes: 10 additions & 1 deletion src/test/mochitest/head.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* eslint no-unused-vars: [2, {"vars": "local"}] */

/* Entirely disable no-unused-vars, because the second line here
doesn't seem to work with eslint 3.15.0 -- it doesn't suppress
other no-unused-vars errors. */
/* eslint-disable no-unused-vars */
/* eslint no-unused-vars: ["error", {"vars": "local"}] */

/* globals is */

/* Not really a module. */
/* eslint-disable strict */
"use strict";

var { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
Expand Down

0 comments on commit 89d30d3

Please sign in to comment.