Skip to content

Commit 6b2a880

Browse files
committed
(format): update standard to latest v13
- v13 requires const instead of let usage - v13 requires line in b/t class members - v12 requires spacing in curly braces - the last two I'm not a huge fan of, but they make sense matching behavior elsewhere more or else. also it's standard so that's just what it is, no bikeshedding - the **very old** webpack.production.config.js also had a lint error from v6+ on using __dirname without path.join
1 parent 8538985 commit 6b2a880

File tree

4 files changed

+22
-16
lines changed

4 files changed

+22
-16
lines changed

example/app.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,24 @@ import SignaturePad from '../src/index.js'
66
import styles from './styles.cssm'
77

88
class App extends Component {
9-
state = {trimmedDataURL: null}
9+
state = { trimmedDataURL: null }
10+
1011
sigPad = {}
12+
1113
clear = () => {
1214
this.sigPad.clear()
1315
}
16+
1417
trim = () => {
15-
this.setState({trimmedDataURL: this.sigPad.getTrimmedCanvas()
16-
.toDataURL('image/png')})
18+
this.setState({ trimmedDataURL: this.sigPad.getTrimmedCanvas()
19+
.toDataURL('image/png') })
1720
}
21+
1822
render () {
19-
let {trimmedDataURL} = this.state
23+
const { trimmedDataURL } = this.state
2024
return <div className={styles.container}>
2125
<div className={styles.sigContainer}>
22-
<SignaturePad canvasProps={{className: styles.sigPad}}
26+
<SignaturePad canvasProps={{ className: styles.sigPad }}
2327
ref={(ref) => { this.sigPad = ref }} />
2428
</div>
2529
<div>

src/index.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export default class SignatureCanvas extends Component {
2727
_sigPad = null
2828

2929
_excludeOurProps = () => {
30-
let {canvasProps, clearOnResize, ...sigPadProps} = this.props
30+
const { canvasProps, clearOnResize, ...sigPadProps } = this.props
3131
return sigPadProps
3232
}
3333

@@ -54,7 +54,7 @@ export default class SignatureCanvas extends Component {
5454
// return a trimmed copy of the canvas
5555
getTrimmedCanvas = () => {
5656
// copy the canvas
57-
let copy = document.createElement('canvas')
57+
const copy = document.createElement('canvas')
5858
copy.width = this._canvas.width
5959
copy.height = this._canvas.height
6060
copy.getContext('2d').drawImage(this._canvas, 0, 0)
@@ -75,18 +75,18 @@ export default class SignatureCanvas extends Component {
7575
}
7676

7777
_resizeCanvas = () => {
78-
let canvasProps = this.props.canvasProps || {}
79-
let {width, height} = canvasProps
78+
const canvasProps = this.props.canvasProps || {}
79+
const { width, height } = canvasProps
8080
// don't resize if the canvas has fixed width and height
8181
if (width && height) {
8282
return
8383
}
8484

85-
let canvas = this._canvas
85+
const canvas = this._canvas
8686
/* When zoomed out to less than 100%, for some very strange reason,
8787
some browsers report devicePixelRatio as less than 1
8888
and only part of the canvas is cleared then. */
89-
let ratio = Math.max(window.devicePixelRatio || 1, 1)
89+
const ratio = Math.max(window.devicePixelRatio || 1, 1)
9090

9191
if (!width) {
9292
canvas.width = canvas.offsetWidth * ratio
@@ -99,7 +99,7 @@ export default class SignatureCanvas extends Component {
9999
}
100100

101101
render () {
102-
let {canvasProps} = this.props
102+
const { canvasProps } = this.props
103103
return <canvas ref={(ref) => { this._canvas = ref }} {...canvasProps} />
104104
}
105105

webpack.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ module.exports = {
1616
exclude: /node_modules/,
1717
loaders: [
1818
'react-hot',
19-
query('babel-loader', {presets: ['es2015', 'react', 'stage-2']})
19+
query('babel-loader', { presets: ['es2015', 'react', 'stage-2'] })
2020
]
2121
}, {
2222
test: /\.cssm$/, loader: 'style-loader!css-loader?modules'

webpack.production.config.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
const path = require('path')
2+
13
module.exports = {
24
entry: './src/index.js',
35
output: {
4-
path: __dirname + '/build',
6+
path: path.join(__dirname, '/build'),
57
filename: 'index.js',
68
library: 'SignatureCanvas',
7-
libraryTarget: 'umd',
9+
libraryTarget: 'umd'
810
},
911
// don't bundle non-relative packages
1012
externals: /^[^.]/,
@@ -13,7 +15,7 @@ module.exports = {
1315
test: /\.js$/,
1416
exclude: /node_modules/,
1517
loader: 'babel-loader',
16-
query: {presets: ['es2015', 'react', 'stage-2']}
18+
query: { presets: ['es2015', 'react', 'stage-2'] }
1719
}]
1820
}
1921
}

0 commit comments

Comments
 (0)