From dd0aea4c14e6b13e50ea916ca28077a74e0efd12 Mon Sep 17 00:00:00 2001 From: Chris Troutner Date: Mon, 6 Jul 2020 14:31:29 -0700 Subject: [PATCH] Additional linting --- .eslintrc.json | 10 ++++ package.json | 3 +- src/components/admin-lte/wallet/import.js | 22 ++++----- src/components/admin-lte/wallet/index.js | 6 ++- src/components/admin-lte/wallet/info.js | 22 ++++----- src/components/footer/index.js | 4 +- src/components/qr-scanner/modal.js | 38 ++++++++------- src/components/qr-scanner/qr-scanner.js | 57 ++++++++++++----------- src/pages/404.js | 4 +- src/pages/page-2.js | 4 +- 10 files changed, 92 insertions(+), 78 deletions(-) create mode 100644 .eslintrc.json diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000..1cb87bd --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,10 @@ +{ + "extends": "standard", + "env": { + "node": true, + "mocha": true + }, + "parserOptions": { + "ecmaVersion": 10 + } +} diff --git a/package.json b/package.json index f153049..d8503b4 100644 --- a/package.json +++ b/package.json @@ -9,12 +9,11 @@ "build": "gatsby build --prefix-paths", "build:normal": "gatsby build", "develop": "gatsby develop", - "format": "prettier --write \"**/*.{js,jsx,json,md}\"", "lint": "standard --env mocha --fix", "start": "npm run develop", "serve": "gatsby serve", "clean": "gatsby clean", - "test": "echo \"Write tests! -> https://gatsby.dev/unit-testing\"" + "test": "npm run lint" }, "dependencies": { "adminlte-2-react": "^0.1.27", diff --git a/src/components/admin-lte/wallet/import.js b/src/components/admin-lte/wallet/import.js index bde23b6..6b18401 100644 --- a/src/components/admin-lte/wallet/import.js +++ b/src/components/admin-lte/wallet/import.js @@ -157,27 +157,25 @@ class ImportWallet extends React.Component { } validateInputs () { - try { - const { mnemonic } = _this.state - if (mnemonic) { - const spaceCount = mnemonic.split(' ').length // mnemonic.match(/ /g).length + const { mnemonic } = _this.state + if (mnemonic) { + const spaceCount = mnemonic.split(' ').length // mnemonic.match(/ /g).length - if (spaceCount !== 12) { - console.log('reject') - throw new Error('mnemonic must contain 12 words') - } - } else { - throw new Error('12 word mnemonic is required') + if (spaceCount !== 12) { + console.log('reject') + throw new Error('mnemonic must contain 12 words') } - } catch (error) { - throw error + } else { + throw new Error('12 word mnemonic is required') } } } + ImportWallet.propTypes = { walletInfo: PropTypes.object.isRequired, setWalletInfo: PropTypes.func.isRequired, updateBalance: PropTypes.func.isRequired, setBchWallet: PropTypes.func.isRequired } + export default ImportWallet diff --git a/src/components/admin-lte/wallet/index.js b/src/components/admin-lte/wallet/index.js index 8c5800a..8f9a795 100644 --- a/src/components/admin-lte/wallet/index.js +++ b/src/components/admin-lte/wallet/index.js @@ -1,3 +1,5 @@ +/* eslint-disable */ + import React from 'react' import PropTypes from 'prop-types' import { Content } from 'adminlte-2-react' @@ -27,7 +29,7 @@ class Wallet extends React.Component { {_this.props.walletInfo.mnemonic && _this.props.walletInfo.from === 'created' && ( - + )} + )} diff --git a/src/components/admin-lte/wallet/info.js b/src/components/admin-lte/wallet/info.js index 1632766..6aa176a 100644 --- a/src/components/admin-lte/wallet/info.js +++ b/src/components/admin-lte/wallet/info.js @@ -1,30 +1,30 @@ -import React from "react" +import React from 'react' -import { Row, Col, Box } from "adminlte-2-react" -import { FontAwesomeIcon } from "@fortawesome/react-fontawesome" +import { Row, Col, Box } from 'adminlte-2-react' +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' class InfoWallets extends React.Component { - state = {} + // state = {} - render() { + render () { return ( - + - +

Webs Wallets

- +

Bitcoin.com Mint is an open source, non-custodial web wallet supporting SLP and BCH. Web wallets offer user convenience, diff --git a/src/components/footer/index.js b/src/components/footer/index.js index ad86a5a..0c4326e 100644 --- a/src/components/footer/index.js +++ b/src/components/footer/index.js @@ -17,7 +17,7 @@ class Footer extends React.Component { Permissionless Software Foundation @@ -28,7 +28,7 @@ class Footer extends React.Component { Github diff --git a/src/components/qr-scanner/modal.js b/src/components/qr-scanner/modal.js index 520f0e6..8900273 100644 --- a/src/components/qr-scanner/modal.js +++ b/src/components/qr-scanner/modal.js @@ -1,40 +1,42 @@ -import React, { Component } from "react" -import PropTypes from "prop-types" -import { Content, Button } from "adminlte-2-react" -import QScanner from "./qr-scanner" +import React, { Component } from 'react' +import PropTypes from 'prop-types' +import { Content, Button } from 'adminlte-2-react' +import QScanner from './qr-scanner' let _this class ScannerModal extends Component { - constructor(props) { + constructor (props) { super(props) _this = this this.state = {} + + this.modalFooter = ( + <> + -

{this.state.result}

+

{this.state.result}

) } - changeMode() { - let mode = _this.state.facingMode === "user" ? "environment" : "user" + + handleChangeMode () { + const mode = _this.state.facingMode === 'user' ? 'environment' : 'user' console.log(`changing to ${mode} mode`) _this.setState({ - facingMode: mode, + facingMode: mode }) } } QScanner.propTypes = { onError: PropTypes.func, - onScan: PropTypes.func, + onScan: PropTypes.func } export default QScanner diff --git a/src/pages/404.js b/src/pages/404.js index 59356af..30df068 100644 --- a/src/pages/404.js +++ b/src/pages/404.js @@ -1,11 +1,11 @@ import React from 'react' import Layout from '../components/layout' -import SEO from '../components/seo' +import Seo from '../components/seo' const NotFoundPage = () => ( - +

NOT FOUND

You just hit a route that doesn't exist... the sadness.

diff --git a/src/pages/page-2.js b/src/pages/page-2.js index aaf46a7..55eda8b 100644 --- a/src/pages/page-2.js +++ b/src/pages/page-2.js @@ -2,11 +2,11 @@ import React from 'react' import { Link } from 'gatsby' import Layout from '../components/layout' -import SEO from '../components/seo' +import Seo from '../components/seo' const SecondPage = () => ( - +

Hi from the second page

Welcome to page 2

Go back to the homepage