diff options
| author | Andrej Mihajlov <and@mullvad.net> | 2018-06-29 12:04:52 +0200 |
|---|---|---|
| committer | Andrej Mihajlov <and@mullvad.net> | 2018-07-02 18:32:23 +0200 |
| commit | 00e3c4464a001cd3b170fba071bd4a19f0147d0b (patch) | |
| tree | 36d448da77e111e4641eb5771ea17b9ff3ccfbf3 | |
| parent | a2258433e93804117397624ecaea22d970d7e2b9 (diff) | |
| download | mullvadvpn-00e3c4464a001cd3b170fba071bd4a19f0147d0b.tar.xz mullvadvpn-00e3c4464a001cd3b170fba071bd4a19f0147d0b.zip | |
Add option to prefer const over let for immutable variables
| -rw-r--r-- | .eslintrc | 1 | ||||
| -rw-r--r-- | app/components/Connect.js | 2 | ||||
| -rw-r--r-- | app/components/HeaderBar.js | 2 | ||||
| -rw-r--r-- | app/components/Settings.js | 4 | ||||
| -rw-r--r-- | app/lib/backend.js | 2 | ||||
| -rw-r--r-- | app/lib/keyframe-animation.js | 4 | ||||
| -rw-r--r-- | app/main.js | 8 | ||||
| -rw-r--r-- | test/components/Login.spec.js | 2 | ||||
| -rw-r--r-- | test/components/Settings.spec.js | 2 | ||||
| -rw-r--r-- | test/keyframe-animation.spec.js | 26 |
10 files changed, 27 insertions, 26 deletions
@@ -13,6 +13,7 @@ }, "plugins": [ "react", "flowtype" ], "rules": { + "prefer-const": "warn", "no-console": "off", "no-loop-func": "warn", "new-cap": "off", diff --git a/app/components/Connect.js b/app/components/Connect.js index fbb743854d..d14b768d44 100644 --- a/app/components/Connect.js +++ b/app/components/Connect.js @@ -316,7 +316,7 @@ export default class Connect extends Component<ConnectProps, ConnectState> { } networkSecurityStyle(): Types.Style { - let classes = [styles.status_security]; + const classes = [styles.status_security]; if (this.props.connection.status === 'connected') { classes.push(styles.status_security__secure); } else if (this.props.connection.status === 'disconnected') { diff --git a/app/components/HeaderBar.js b/app/components/HeaderBar.js index 69578bacfa..fcd7d40733 100644 --- a/app/components/HeaderBar.js +++ b/app/components/HeaderBar.js @@ -24,7 +24,7 @@ export default class HeaderBar extends Component<HeaderBarProps> { }; render() { - let containerClass = [ + const containerClass = [ styles['headerbar'], platformStyles[process.platform], styles['style_' + this.props.style], diff --git a/app/components/Settings.js b/app/components/Settings.js index 33fc371faa..ad90e034c4 100644 --- a/app/components/Settings.js +++ b/app/components/Settings.js @@ -67,10 +67,10 @@ export default class Settings extends Component<SettingsProps> { let isOutOfTime = false, formattedExpiry = ''; - let expiryIso = this.props.account.expiry; + const expiryIso = this.props.account.expiry; if (isLoggedIn && expiryIso) { - let expiry = moment(this.props.account.expiry); + const expiry = moment(this.props.account.expiry); isOutOfTime = expiry.isSameOrBefore(moment()); formattedExpiry = (expiry.fromNow(true) + ' left').toUpperCase(); } diff --git a/app/lib/backend.js b/app/lib/backend.js index c7b4ca53ec..b24b495449 100644 --- a/app/lib/backend.js +++ b/app/lib/backend.js @@ -264,7 +264,7 @@ export class Backend { async connect() { try { - let currentState = await this._ipc.getState(); + const currentState = await this._ipc.getState(); if (currentState.state === 'secured') { log.debug('Refusing to connect as connection is already secured'); this._store.dispatch(connectionActions.connected()); diff --git a/app/lib/keyframe-animation.js b/app/lib/keyframe-animation.js index 7a8968eb35..2961412230 100644 --- a/app/lib/keyframe-animation.js +++ b/app/lib/keyframe-animation.js @@ -124,7 +124,7 @@ export default class KeyframeAnimation { } play(options: KeyframeAnimationOptions = {}) { - let { startFrame, endFrame, beginFromCurrentState, advanceTo } = options; + const { startFrame, endFrame, beginFromCurrentState, advanceTo } = options; if (startFrame !== undefined && endFrame !== undefined) { if (startFrame < 0 || startFrame >= this._numFrames) { @@ -216,7 +216,7 @@ export default class KeyframeAnimation { return; } - let lastFrame = this._frameRange[this._reverse ? 0 : 1]; + const lastFrame = this._frameRange[this._reverse ? 0 : 1]; if (this._currentFrame === lastFrame) { // mark animation as finished if it's not repeating if (!this._repeat) { diff --git a/app/main.js b/app/main.js index c6bade7719..64c341dc60 100644 --- a/app/main.js +++ b/app/main.js @@ -255,9 +255,9 @@ const ApplicationMain = { switch (process.platform) { case 'win32': { // Windows: %ALLUSERSPROFILE%\{appname} - let programDataDirectory = process.env.ALLUSERSPROFILE; + const programDataDirectory = process.env.ALLUSERSPROFILE; if (programDataDirectory) { - let appDataDirectory = path.join(programDataDirectory, appDirectoryName); + const appDataDirectory = path.join(programDataDirectory, appDirectoryName); return path.join(appDataDirectory, rpcAddressFileName); } else { throw new Error('Missing %ALLUSERSPROFILE% environment variable'); @@ -413,7 +413,7 @@ const ApplicationMain = { }, _addContextMenu(window: BrowserWindow) { - let menuTemplate = [ + const menuTemplate = [ { role: 'cut' }, { role: 'copy' }, { role: 'paste' }, @@ -425,7 +425,7 @@ const ApplicationMain = { window.webContents.on( 'context-menu', (_e: Event, props: { x: number, y: number, isEditable: boolean }) => { - let inspectTemplate = [ + const inspectTemplate = [ { label: 'Inspect element', click() { diff --git a/test/components/Login.spec.js b/test/components/Login.spec.js index 90bb70f4b3..ce7f347acf 100644 --- a/test/components/Login.spec.js +++ b/test/components/Login.spec.js @@ -8,7 +8,7 @@ import AccountInput from '../../app/components/AccountInput'; describe('components/Login', () => { it('notifies on the first change after failure', () => { - let onFirstChange = spy(); + const onFirstChange = spy(); const props = { account: Object.assign({}, defaultAccount, { status: 'failed', diff --git a/test/components/Settings.spec.js b/test/components/Settings.spec.js index f564902c2a..ffdf0bf545 100644 --- a/test/components/Settings.spec.js +++ b/test/components/Settings.spec.js @@ -168,7 +168,7 @@ describe('components/Settings', () => { }); it('should call external links callback', () => { - let collectedExternalLinkTypes: Array<string> = []; + const collectedExternalLinkTypes: Array<string> = []; const props = makeProps(loggedOutAccountState, settingsState, { onExternalLink: (type) => { collectedExternalLinkTypes.push(type); diff --git a/test/keyframe-animation.spec.js b/test/keyframe-animation.spec.js index 926bb79625..08a177ea79 100644 --- a/test/keyframe-animation.spec.js +++ b/test/keyframe-animation.spec.js @@ -14,7 +14,7 @@ describe('lib/keyframe-animation', function() { }; it('should play sequence', (done) => { - let seq = []; + const seq = []; const animation = newAnimation(); animation.onFrame = () => { seq.push(animation._currentFrame); @@ -29,7 +29,7 @@ describe('lib/keyframe-animation', function() { }); it('should play one frame', (done) => { - let seq = []; + const seq = []; const animation = newAnimation(); animation.onFrame = () => { seq.push(animation._currentFrame); @@ -44,7 +44,7 @@ describe('lib/keyframe-animation', function() { }); it('should play sequence with custom frames', (done) => { - let seq = []; + const seq = []; const animation = newAnimation(); animation.onFrame = () => { seq.push(animation._currentFrame); @@ -62,7 +62,7 @@ describe('lib/keyframe-animation', function() { }); it('should play sequence with custom frames in reverse', (done) => { - let seq = []; + const seq = []; const animation = newAnimation(); animation.onFrame = () => { seq.push(animation._currentFrame); @@ -81,7 +81,7 @@ describe('lib/keyframe-animation', function() { }); it('should begin from current state starting below range', (done) => { - let seq = []; + const seq = []; const animation = newAnimation(); animation.onFrame = () => { seq.push(animation._currentFrame); @@ -103,7 +103,7 @@ describe('lib/keyframe-animation', function() { }); it('should begin from current state starting below range reverse', (done) => { - let seq = []; + const seq = []; const animation = newAnimation(); animation.onFrame = () => { seq.push(animation._currentFrame); @@ -126,7 +126,7 @@ describe('lib/keyframe-animation', function() { }); it('should begin from current state starting above range', (done) => { - let seq = []; + const seq = []; const animation = newAnimation(); animation.onFrame = () => { seq.push(animation._currentFrame); @@ -148,7 +148,7 @@ describe('lib/keyframe-animation', function() { }); it('should begin from current state starting above range reverse', (done) => { - let seq = []; + const seq = []; const animation = newAnimation(); animation.onFrame = () => { seq.push(animation._currentFrame); @@ -171,7 +171,7 @@ describe('lib/keyframe-animation', function() { }); it('should play sequence in reverse', (done) => { - let seq = []; + const seq = []; const animation = newAnimation(); animation.onFrame = () => { seq.push(animation._currentFrame); @@ -187,7 +187,7 @@ describe('lib/keyframe-animation', function() { }); it('should play sequence on repeat', (done) => { - let seq = []; + const seq = []; const animation = newAnimation(); const expectedFrames = [0, 1, 2, 3, 4, 0, 1, 2, 3, 4]; @@ -206,7 +206,7 @@ describe('lib/keyframe-animation', function() { }); it('should play sequence on repeat in reverse', (done) => { - let seq = []; + const seq = []; const animation = newAnimation(); const expectedFrames = [4, 3, 2, 1, 0, 4, 3, 2, 1, 0]; @@ -226,7 +226,7 @@ describe('lib/keyframe-animation', function() { }); it('should alternate sequence', (done) => { - let seq = []; + const seq = []; const animation = newAnimation(); const expectedFrames = [0, 1, 2, 3, 4, 3, 2, 1, 0]; @@ -246,7 +246,7 @@ describe('lib/keyframe-animation', function() { }); it('should alternate reverse sequence', (done) => { - let seq = []; + const seq = []; const animation = newAnimation(); const expectedFrames = [4, 3, 2, 1, 0, 1, 2, 3, 4]; |
