Additional linting

This commit is contained in:
Chris Troutner
2020-07-06 14:31:29 -07:00
parent 77e5625b0e
commit dd0aea4c14
10 changed files with 92 additions and 78 deletions
+10
View File
@@ -0,0 +1,10 @@
{
"extends": "standard",
"env": {
"node": true,
"mocha": true
},
"parserOptions": {
"ecmaVersion": 10
}
}
+1 -2
View File
@@ -9,12 +9,11 @@
"build": "gatsby build --prefix-paths", "build": "gatsby build --prefix-paths",
"build:normal": "gatsby build", "build:normal": "gatsby build",
"develop": "gatsby develop", "develop": "gatsby develop",
"format": "prettier --write \"**/*.{js,jsx,json,md}\"",
"lint": "standard --env mocha --fix", "lint": "standard --env mocha --fix",
"start": "npm run develop", "start": "npm run develop",
"serve": "gatsby serve", "serve": "gatsby serve",
"clean": "gatsby clean", "clean": "gatsby clean",
"test": "echo \"Write tests! -> https://gatsby.dev/unit-testing\"" "test": "npm run lint"
}, },
"dependencies": { "dependencies": {
"adminlte-2-react": "^0.1.27", "adminlte-2-react": "^0.1.27",
+10 -12
View File
@@ -157,27 +157,25 @@ class ImportWallet extends React.Component {
} }
validateInputs () { validateInputs () {
try { const { mnemonic } = _this.state
const { mnemonic } = _this.state if (mnemonic) {
if (mnemonic) { const spaceCount = mnemonic.split(' ').length // mnemonic.match(/ /g).length
const spaceCount = mnemonic.split(' ').length // mnemonic.match(/ /g).length
if (spaceCount !== 12) { if (spaceCount !== 12) {
console.log('reject') console.log('reject')
throw new Error('mnemonic must contain 12 words') throw new Error('mnemonic must contain 12 words')
}
} else {
throw new Error('12 word mnemonic is required')
} }
} catch (error) { } else {
throw error throw new Error('12 word mnemonic is required')
} }
} }
} }
ImportWallet.propTypes = { ImportWallet.propTypes = {
walletInfo: PropTypes.object.isRequired, walletInfo: PropTypes.object.isRequired,
setWalletInfo: PropTypes.func.isRequired, setWalletInfo: PropTypes.func.isRequired,
updateBalance: PropTypes.func.isRequired, updateBalance: PropTypes.func.isRequired,
setBchWallet: PropTypes.func.isRequired setBchWallet: PropTypes.func.isRequired
} }
export default ImportWallet export default ImportWallet
+4 -2
View File
@@ -1,3 +1,5 @@
/* eslint-disable */
import React from 'react' import React from 'react'
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
import { Content } from 'adminlte-2-react' import { Content } from 'adminlte-2-react'
@@ -27,7 +29,7 @@ class Wallet extends React.Component {
{_this.props.walletInfo.mnemonic && {_this.props.walletInfo.mnemonic &&
_this.props.walletInfo.from === 'created' && ( _this.props.walletInfo.from === 'created' && (
<WalletInfo walletInfo={_this.props.walletInfo} /> <WalletInfo walletInfo={_this.props.walletInfo} />
)} )}
<ImportWallet <ImportWallet
@@ -39,7 +41,7 @@ class Wallet extends React.Component {
{_this.props.walletInfo.mnemonic && {_this.props.walletInfo.mnemonic &&
_this.props.walletInfo.from === 'imported' && ( _this.props.walletInfo.from === 'imported' && (
<WalletInfo walletInfo={_this.props.walletInfo} /> <WalletInfo walletInfo={_this.props.walletInfo} />
)} )}
<InfoWallets /> <InfoWallets />
+11 -11
View File
@@ -1,30 +1,30 @@
import React from "react" import React from 'react'
import { Row, Col, Box } from "adminlte-2-react" import { Row, Col, Box } from 'adminlte-2-react'
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome" import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
class InfoWallets extends React.Component { class InfoWallets extends React.Component {
state = {} // state = {}
render() { render () {
return ( return (
<Row> <Row>
<Col sm={2} /> <Col sm={2} />
<Col sm={8}> <Col sm={8}>
<Box className="hover-shadow border-none mt-2"> <Box className='hover-shadow border-none mt-2'>
<Row> <Row>
<Col sm={12} className="text-center"> <Col sm={12} className='text-center'>
<h1> <h1>
<FontAwesomeIcon <FontAwesomeIcon
className="title-icon" className='title-icon'
size="xs" size='xs'
icon={"exclamation-triangle"} icon='exclamation-triangle'
/> />
<span>Webs Wallets</span> <span>Webs Wallets</span>
</h1> </h1>
</Col> </Col>
<Col sm={12} className="text-center mt-2 mb-2"> <Col sm={12} className='text-center mt-2 mb-2'>
<p> <p>
Bitcoin.com Mint is an open source, non-custodial web wallet Bitcoin.com Mint is an open source, non-custodial web wallet
supporting SLP and BCH. Web wallets offer user convenience, supporting SLP and BCH. Web wallets offer user convenience,
+2 -2
View File
@@ -17,7 +17,7 @@ class Footer extends React.Component {
<a <a
href='https://psfoundation.cash/' href='https://psfoundation.cash/'
target='_blank' target='_blank'
rel='noreferrer' rel='noopener noreferrer'
> >
Permissionless Software Foundation Permissionless Software Foundation
</a> </a>
@@ -28,7 +28,7 @@ class Footer extends React.Component {
<a <a
href='https://github.com/Permissionless-Software-Foundation/gatsby-ipfs-web-wallet' href='https://github.com/Permissionless-Software-Foundation/gatsby-ipfs-web-wallet'
target='_blank' target='_blank'
rel='noreferrer' rel='noopener noreferrer'
> >
Github Github
</a> </a>
+20 -18
View File
@@ -1,40 +1,42 @@
import React, { Component } from "react" import React, { Component } from 'react'
import PropTypes from "prop-types" import PropTypes from 'prop-types'
import { Content, Button } from "adminlte-2-react" import { Content, Button } from 'adminlte-2-react'
import QScanner from "./qr-scanner" import QScanner from './qr-scanner'
let _this let _this
class ScannerModal extends Component { class ScannerModal extends Component {
constructor(props) { constructor (props) {
super(props) super(props)
_this = this _this = this
this.state = {} this.state = {}
this.modalFooter = (
<>
<Button text='Close' pullLeft onClick={this.props.handleOnHide} />
</>
)
} }
modalFooter = ( render () {
<React.Fragment>
<Button text="Close" pullLeft onClick={this.props.onHide} />
</React.Fragment>
)
render() {
return ( return (
<Content <Content
title="Qr Scanner" title='Qr Scanner'
modal modal
modalFooter={this.modalFooter} modalFooter={this.modalFooter}
show={_this.props.show} show={_this.props.show}
modalCloseButton={true} modalCloseButton
onHide={_this.props.onHide} onHide={_this.props.handleOnHide}
> >
<QScanner onError={_this.props.onError} onScan={_this.props.onScan} /> <QScanner onError={_this.props.handleOnError} onScan={_this.props.handleOnScan} />
</Content> </Content>
) )
} }
} }
ScannerModal.propTypes = { ScannerModal.propTypes = {
show: PropTypes.bool.isRequired, show: PropTypes.bool.isRequired,
onHide: PropTypes.func.isRequired, OnHide: PropTypes.func.isRequired,
onError: PropTypes.func, onError: PropTypes.func,
onScan: PropTypes.func, onScan: PropTypes.func
} }
export default ScannerModal export default ScannerModal
+30 -27
View File
@@ -1,37 +1,39 @@
import React, { Component } from "react" import React, { Component } from 'react'
import PropTypes from "prop-types" import PropTypes from 'prop-types'
import "./qr-scanner.css" import './qr-scanner.css'
import QrReader from "react-qr-reader" import QrReader from 'react-qr-reader'
let _this let _this
class QScanner extends Component { class QScanner extends Component {
constructor(props) { constructor (props) {
super(props) super(props)
_this = this _this = this
this.state = { this.state = {
result: "No Result", result: 'No Result',
facingMode: "environment", facingMode: 'environment'
}
this.handleScan = data => {
if (data) {
this.setState({
result: data
})
_this.props.onScan && _this.props.onScan(data)
}
}
this.handleError = err => {
console.error(err)
_this.props.onError ? _this.props.onError(err) : console.error(err)
} }
} }
handleScan = data => { render () {
if (data) {
this.setState({
result: data,
})
_this.props.onScan && _this.props.onScan(data)
}
}
handleError = err => {
console.error(err)
_this.props.onError ? _this.props.onError(err) : alert(err)
}
render() {
return ( return (
<div className="QRScanner-container"> <div className='QRScanner-container'>
<h4>Facing Mode: {_this.state.facingMode}</h4> <h4>Facing Mode: {_this.state.facingMode}</h4>
<button className="change-button" onClick={_this.changeMode}> <button className='change-button' onClick={_this.handleChangeMode}>
Change Change
</button> </button>
<QrReader <QrReader
@@ -41,21 +43,22 @@ class QScanner extends Component {
facingMode={_this.state.facingMode} facingMode={_this.state.facingMode}
/> />
<b> <b>
<p className="qr-result">{this.state.result}</p> <p className='qr-result'>{this.state.result}</p>
</b> </b>
</div> </div>
) )
} }
changeMode() {
let mode = _this.state.facingMode === "user" ? "environment" : "user" handleChangeMode () {
const mode = _this.state.facingMode === 'user' ? 'environment' : 'user'
console.log(`changing to ${mode} mode`) console.log(`changing to ${mode} mode`)
_this.setState({ _this.setState({
facingMode: mode, facingMode: mode
}) })
} }
} }
QScanner.propTypes = { QScanner.propTypes = {
onError: PropTypes.func, onError: PropTypes.func,
onScan: PropTypes.func, onScan: PropTypes.func
} }
export default QScanner export default QScanner
+2 -2
View File
@@ -1,11 +1,11 @@
import React from 'react' import React from 'react'
import Layout from '../components/layout' import Layout from '../components/layout'
import SEO from '../components/seo' import Seo from '../components/seo'
const NotFoundPage = () => ( const NotFoundPage = () => (
<Layout> <Layout>
<SEO title='404: Not found' /> <Seo title='404: Not found' />
<h1>NOT FOUND</h1> <h1>NOT FOUND</h1>
<p>You just hit a route that doesn&#39;t exist... the sadness.</p> <p>You just hit a route that doesn&#39;t exist... the sadness.</p>
</Layout> </Layout>
+2 -2
View File
@@ -2,11 +2,11 @@ import React from 'react'
import { Link } from 'gatsby' import { Link } from 'gatsby'
import Layout from '../components/layout' import Layout from '../components/layout'
import SEO from '../components/seo' import Seo from '../components/seo'
const SecondPage = () => ( const SecondPage = () => (
<Layout> <Layout>
<SEO title='Page two' /> <Seo title='Page two' />
<h1>Hi from the second page</h1> <h1>Hi from the second page</h1>
<p>Welcome to page 2</p> <p>Welcome to page 2</p>
<Link to='/'>Go back to the homepage</Link> <Link to='/'>Go back to the homepage</Link>