Skip to content

Commit

Permalink
Remove unused vars from applications
Browse files Browse the repository at this point in the history
  • Loading branch information
lgeiger committed Oct 11, 2018
1 parent 3cb27aa commit 689f5ff
Show file tree
Hide file tree
Showing 31 changed files with 45 additions and 105 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Expand Up @@ -9,3 +9,5 @@ build/
packages/**/node_modules
applications/**/node_modules
coverage
node_modules/
*/**/__snapshots__/
2 changes: 1 addition & 1 deletion .eslintrc
Expand Up @@ -20,7 +20,7 @@
"react/display-name": 0,
"react/no-unescaped-entities": 0,
"react/no-deprecated": 1,
"no-unused-vars": 1
"no-unused-vars": 2
},
"settings": {
"react": {
Expand Down
2 changes: 1 addition & 1 deletion applications/commuter/babel.config.js
@@ -1,5 +1,5 @@
module.exports = function(api) {
const env = api.env();
const env = api.env(); // eslint-disable-line no-unused-vars

const config = {
presets: ["@babel/preset-env", "@babel/preset-react", "@babel/preset-flow"],
Expand Down
1 change: 1 addition & 0 deletions applications/commuter/backend/config.js
Expand Up @@ -6,6 +6,7 @@ function deprecate(env: Object, oldVar: string, newVar: string) {
}
}

// eslint-disable-next-line no-unused-vars
function populateLocalStorageOptions(env): Object {
let baseDirectory = process.env.COMMUTER_LOCAL_STORAGE_BASEDIRECTORY;

Expand Down
3 changes: 2 additions & 1 deletion applications/commuter/backend/content-providers/local/fs.js
Expand Up @@ -41,7 +41,8 @@ function createContentResponse(
path.join(parsedFilePath.dir, parsedFilePath.base)
);
// $FlowFixMe: fs-extra
const writable = Boolean(fs.constants.W_OK & stat.mode);
// TODO: is `writable` meant to be used?
// const writable = Boolean(fs.constants.W_OK & stat.mode);
const created: Date = stat.birthtime;
const last_modified = stat.mtime;

Expand Down
Expand Up @@ -42,7 +42,7 @@ function createRouter(config: Object): express.Router {

router.delete("/*", (req: $Request, res: $Response) => {
const path = req.params["0"];
const cb = (err, data) => {
const cb = err => {
if (err) res.status(500).json(errObject(err, path));
else res.status(204).send(); //as per jupyter contents api
};
Expand All @@ -52,7 +52,7 @@ function createRouter(config: Object): express.Router {

router.post("/*", (req: $Request, res: $Response) => {
const path = req.params["0"];
const cb = (err, data) => {
const cb = err => {
if (err) res.status(500).json(errObject(err, path));
else res.status(201).send();
};
Expand Down
Expand Up @@ -4,6 +4,7 @@ import type { $Request, $Response } from "express";

const express = require("express");

// eslint-disable-next-line no-unused-vars
function createDiscoveryRouter(options?: Object): express.Router {
const router = express.Router();
router.get("/*", (req: $Request, res: $Response) => {
Expand Down
5 changes: 2 additions & 3 deletions applications/commuter/backend/routes/api/index.js
@@ -1,7 +1,6 @@
// @flow
const express = require("express"),
path = require("path"),
bodyParser = require("body-parser");
const express = require("express");
const bodyParser = require("body-parser");

import type { Middleware, $Request, $Response } from "express";

Expand Down
5 changes: 1 addition & 4 deletions applications/commuter/backend/routes/index.js
@@ -1,9 +1,6 @@
// @flow

import type { $Request, $Response } from "express";

const express = require("express"),
path = require("path");
const express = require("express");

const createAPIRouter = require("./api");

Expand Down
15 changes: 7 additions & 8 deletions applications/commuter/backend/server.js
Expand Up @@ -6,13 +6,12 @@ const front = require("../frontend");

const { parse } = require("url");

const express = require("express"),
http = require("http"),
path = require("path"),
morgan = require("morgan"),
config = require("./config"),
Log = require("log"),
log = new Log("info");
const express = require("express");
const http = require("http");
const morgan = require("morgan");
const config = require("./config");
const Log = require("log");
const log = new Log("info");

function createServer() {
const frontend = front.createNextApp();
Expand Down Expand Up @@ -54,7 +53,7 @@ function createServer() {
renderAccepts.has(accepts[0]) ||
renderAccepts.has(accepts[1])
) {
const { pathname, query } = parse(req.url, true);
const { query } = parse(req.url, true);
const viewPath = req.params["0"] || "/";
const q = Object.assign({}, { viewPath }, query);
return frontend.app.render(req, res, "/view", q);
Expand Down
2 changes: 0 additions & 2 deletions applications/commuter/components/body.js
@@ -1,8 +1,6 @@
// @flow
import * as React from "react";

import type { ChildrenArray } from "react";

type BodyProps = {
children?: React.Node
};
Expand Down
7 changes: 1 addition & 6 deletions applications/commuter/components/browse-header.js
@@ -1,7 +1,5 @@
// @flow
import * as React from "react";
import Head from "next/head";
import NProgress from "nprogress";
import Router from "next/router";

import NextLink from "next/link";
Expand Down Expand Up @@ -36,20 +34,17 @@ class BrowseHeader extends React.Component<*> {
};

render() {
const activeItem = "browse";
const { path, basepath } = this.props;
let paths = trim(path, "/").split("/");
// Empty path to start off
if (paths.length === 1 && paths[0] === "") {
paths = [];
}
let breadCrumbs = [];

// TODO: Ensure this works under an app subpath (which is not implemented yet)
const filePath = basepath.replace(/view\/?/, "files/") + path;

const serverSide = typeof document === "undefined";

// const serverSide = typeof document === "undefined";
const viewingNotebook = filePath.endsWith(".ipynb");

return (
Expand Down
5 changes: 2 additions & 3 deletions applications/commuter/components/contents/csv.js
@@ -1,8 +1,7 @@
// @flow
import * as React from "react";

const d3 = Object.assign({}, require("d3-dsv"));

// const d3 = Object.assign({}, require("d3-dsv"));
// import DataTransform from "@nteract/transform-dataresource";

export default class CSVView extends React.Component<*> {
Expand All @@ -11,7 +10,7 @@ export default class CSVView extends React.Component<*> {
}

render() {
const data = d3.csvParse(this.props.entry.content);
// const data = d3.csvParse(this.props.entry.content);
return <div>No support for csv at this time</div>;
// return <DataTransform data={{ data }} metadata={{}} theme="light" />;
}
Expand Down
21 changes: 1 addition & 20 deletions applications/commuter/components/contents/zeppelin.js
@@ -1,7 +1,7 @@
// @flow
import * as React from "react";

import { JSONTransform, HTMLTransform } from "@nteract/transforms";
import { HTMLTransform } from "@nteract/transforms";

import { Source } from "@nteract/presentational-components";

Expand Down Expand Up @@ -143,24 +143,6 @@ const DSVTable = (props: { data: Array<Object> }) => {
);
};

const UnsupportedResult = props => (
<React.Fragment>
<h1>UNSUPPORTED ZEPPELIN RESULT</h1>
<p>
Post an issue to{" "}
<a
href="https://github.com/nteract/commuter/issues/new"
target="_blank"
rel="noreferrer noopener"
>
commuter
</a>{" "}
to let us know about it
</p>
<JSONTransform data={props.result} />
</React.Fragment>
);

// Old style Zeppelin
const Message = props => {
switch (props.type) {
Expand All @@ -186,7 +168,6 @@ const Result = props => {
case "TABLE":
if (!props.result.columnNames || !props.result.rows) {
const data = d3.tsvParse(props.result.msg);
const columnNames = Object.keys(data[0]);

return <DSVTable data={data} />;
}
Expand Down
3 changes: 1 addition & 2 deletions applications/commuter/components/header.js
@@ -1,11 +1,10 @@
// @flow
import * as React from "react";
import Head from "next/head";
import Link from "next/link";
import NProgress from "nprogress";
import Router from "next/router";

Router.onRouteChangeStart = url => {
Router.onRouteChangeStart = () => {
NProgress.start();
};
Router.onRouteChangeComplete = () => NProgress.done();
Expand Down
1 change: 0 additions & 1 deletion applications/commuter/next.config.js
@@ -1,4 +1,3 @@
const path = require("path");
const configurator = require("@nteract/webpack-configurator");

const webpack = require("webpack");
Expand Down
6 changes: 3 additions & 3 deletions applications/commuter/pages/discover.js
Expand Up @@ -9,8 +9,6 @@ import Body from "../components/body";

import { getJSON } from "../shims/ajax";

import { theme } from "../theme";

const Authors = props => (
<span className="authors">
{props.authors.map(author => author.name).join(", ")}
Expand Down Expand Up @@ -81,7 +79,9 @@ const DiscoveryItem = (props: DiscoveryItemProps) => (
<p>{props.metadata.nteract.description}</p>
</div>
<div className="post-tags">
{props.metadata.nteract.tags.map(tag => <Tag key={tag}>{tag}</Tag>)}
{props.metadata.nteract.tags.map(tag => (
<Tag key={tag}>{tag}</Tag>
))}
</div>
</div>
<style jsx>{`
Expand Down
5 changes: 2 additions & 3 deletions applications/commuter/pages/view.js
@@ -1,11 +1,8 @@
// @flow
import * as React from "react";
import Link from "next/link";

import { getJSON } from "../shims/ajax";

import { join as pathJoin } from "path";

import Header from "../components/header";
import BrowseHeader from "../components/browse-header";
import Body from "../components/body";
Expand Down Expand Up @@ -73,6 +70,8 @@ class ViewPage extends React.Component<ViewPageProps, ViewPageState> {
} else {
const configScriptElement = document.getElementById("serverConfig");
if (configScriptElement !== null) {
// TODO: is this realy meant to not be used?
// eslint-disable-next-line no-unused-vars
const config = JSON.parse(configScriptElement.textContent);
}
this.state = { config };
Expand Down
@@ -1,8 +1,6 @@
/* @flow strict */
import * as React from "react";

import { areComponentsEqual } from "react-hot-loader";

type NavSectionProps = {
children: React.Node
};
Expand Down
@@ -1,9 +1,6 @@
/* @flow strict */
import * as React from "react";

import { selectors } from "@nteract/core";
import type { AppState } from "@nteract/core";

import { WideLogo } from "@nteract/logos";

type ThemedLogoProps = {
Expand All @@ -20,12 +17,4 @@ ThemedLogo.defaultProps = {
theme: "light"
};

const mapStateToProps = (
state: AppState,
ownProps: { height: ?number }
): * => ({
height: ownProps.height,
theme: selectors.currentTheme(state)
});

export { ThemedLogo };
@@ -1,10 +1,9 @@
/* @flow strict */

import * as React from "react";
import * as Immutable from "immutable";
const urljoin = require("url-join");

import { selectors, actions } from "@nteract/core";
import { selectors } from "@nteract/core";

import { ThemedLogo } from "../components/themed-logo.js";

Expand All @@ -26,7 +25,6 @@ import type {
KernelspecProps,
JupyterHostRecord,
ContentRef,
ContentRecord,
DirectoryContentRecord
} from "@nteract/core";

Expand Down
@@ -1,15 +1,12 @@
/* @flow strict */

import * as React from "react";
import * as Immutable from "immutable";

import { selectors, actions } from "@nteract/core";
import type { ContentRef, FileContentRecord, AppState } from "@nteract/core";
import { selectors } from "@nteract/core";
import type { ContentRef, AppState } from "@nteract/core";

import { LoadingIcon, SavingingIcon, ErrorIcon } from "@nteract/iron-icons";

import moment from "moment";

import { ThemedLogo } from "../../components/themed-logo";
import { Nav, NavSection } from "../../components/nav";

Expand Down
@@ -1,7 +1,7 @@
/* @flow strict */
import * as React from "react";

import type { AppState, ContentRef, FileContentRecord } from "@nteract/core";
import type { AppState, ContentRef } from "@nteract/core";
import { selectors, actions } from "@nteract/core";

import { connect } from "react-redux";
Expand Down
Expand Up @@ -9,26 +9,15 @@ import * as React from "react";

import { selectors } from "@nteract/core";

import type {
KernelspecRecord,
KernelspecProps,
AppState,
JupyterHostRecord,
ContentRef
} from "@nteract/core";

import css from "styled-jsx/css";
import type { AppState, ContentRef } from "@nteract/core";

const urljoin = require("url-join");

import { default as Directory } from "./directory";
import { default as File } from "./file";
import { default as Notebook } from "./notebook";

import { ThemedLogo } from "../components/themed-logo";

import { WideLogo } from "@nteract/logos";

import { Nav, NavSection } from "../components/nav";

import { connect } from "react-redux";
Expand Down
Expand Up @@ -78,7 +78,7 @@ export default class Notebook extends React.Component<Props, State> {
}

registerTransform(transform: { MIMETYPE: string }) {
this.setState((prevState, props) => {
this.setState(prevState => {
return {
transforms: { ...prevState.transforms, [transform.MIMETYPE]: transform }
};
Expand Down Expand Up @@ -113,7 +113,7 @@ export default class Notebook extends React.Component<Props, State> {

import(/* webpackChunkName: "vega-transform" */ "@nteract/transform-vega").then(
module => {
this.setState((prevState, props) => {
this.setState(prevState => {
return {
transforms: {
...prevState.transforms,
Expand Down

0 comments on commit 689f5ff

Please sign in to comment.