Skip to content

Commit

Permalink
Upgrade to ESLint 5
Browse files Browse the repository at this point in the history
  • Loading branch information
malept committed Oct 25, 2018
1 parent 20d9462 commit 8ea94db
Show file tree
Hide file tree
Showing 15 changed files with 59 additions and 59 deletions.
4 changes: 2 additions & 2 deletions common.js
Expand Up @@ -35,7 +35,7 @@ function parseCLIArgs (argv) {

if (protocolSchemes && protocolNames && protocolNames.length === protocolSchemes.length) {
args.protocols = protocolSchemes.map(function (scheme, i) {
return {schemes: [scheme], name: protocolNames[i]}
return { schemes: [scheme], name: protocolNames[i] }
})
}

Expand Down Expand Up @@ -68,7 +68,7 @@ function parseCLIArgs (argv) {
}

function sanitizeAppName (name) {
return sanitize(name, {replacement: '-'})
return sanitize(name, { replacement: '-' })
}

function generateFinalBasename (opts) {
Expand Down
2 changes: 1 addition & 1 deletion mac.js
Expand Up @@ -324,7 +324,7 @@ function filterCFBundleIdentifier (identifier) {

function createSignOpts (properties, platform, app, version, quiet) {
// use default sign opts if osx-sign is true, otherwise clone osx-sign object
let signOpts = properties === true ? {identity: null} : Object.assign({}, properties)
let signOpts = properties === true ? { identity: null } : Object.assign({}, properties)

// osx-sign options are handed off to sign module, but
// with a few additions from the main options
Expand Down
12 changes: 6 additions & 6 deletions package.json
Expand Up @@ -39,13 +39,13 @@
"ava": "^0.25.0",
"buffer-equal": "^1.0.0",
"codecov": "^3.0.0",
"eslint": "^4.18.0",
"eslint-config-standard": "^11.0.0",
"eslint-plugin-ava": "^4.3.0",
"eslint": "^5.5.0",
"eslint-config-standard": "^12.0.0",
"eslint-plugin-ava": "^5.1.1",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-node": "^6.0.0",
"eslint-plugin-promise": "^3.5.0",
"eslint-plugin-standard": "^3.0.0",
"eslint-plugin-node": "^7.0.1",
"eslint-plugin-promise": "^4.0.1",
"eslint-plugin-standard": "^4.0.0",
"mz": "^2.6.0",
"nyc": "^13.0.1",
"pkg-up": "^2.0.0",
Expand Down
2 changes: 1 addition & 1 deletion platform.js
Expand Up @@ -192,7 +192,7 @@ class App {
}

debug(`Copying asar: ${src} to ${this.appAsarPath}`)
return fs.copy(src, this.appAsarPath, {overwrite: false, errorOnExist: true})
return fs.copy(src, this.appAsarPath, { overwrite: false, errorOnExist: true })
})
}

Expand Down
2 changes: 1 addition & 1 deletion targets.js
Expand Up @@ -86,7 +86,7 @@ module.exports = {
const archs = officialPlatformArchCombos[platform]
if (platform === 'linux') {
const excludedArchs = Object.keys(linuxArchBuildVersions)
.filter(arch => !officialLinuxBuildExists({electronVersion: electronVersion}, linuxArchBuildVersions[arch]))
.filter(arch => !officialLinuxBuildExists({ electronVersion: electronVersion }, linuxArchBuildVersions[arch]))
return archs.filter(arch => !excludedArchs.includes(arch))
}

Expand Down
4 changes: 2 additions & 2 deletions test/_setup.js
Expand Up @@ -23,7 +23,7 @@ function skipDownloadingMacZips (platform, arch) {

function downloadAll (version) {
console.log(`Calling electron-download for ${version} before running tests...`)
const combinations = download.createDownloadCombos({electronVersion: config.version, all: true}, targets.officialPlatforms, targets.officialArchs, skipDownloadingMacZips)
const combinations = download.createDownloadCombos({ electronVersion: config.version, all: true }, targets.officialPlatforms, targets.officialArchs, skipDownloadingMacZips)

return Promise.all(combinations.map(combination => downloadElectronZip(version, combination)))
}
Expand Down Expand Up @@ -67,7 +67,7 @@ function npmInstallForFixture (fixture) {
return true
} else {
console.log(`Running npm install in fixtures/${fixture}...`)
return exec('npm install --no-bin-links', {cwd: fixtureDir})
return exec('npm install --no-bin-links', { cwd: fixtureDir })
}
})
}
Expand Down
4 changes: 2 additions & 2 deletions test/asar.js
Expand Up @@ -12,11 +12,11 @@ test('asar argument test: asar is not set', t => {
})

test('asar argument test: asar is true', t => {
t.deepEqual(common.createAsarOpts({asar: true}), {})
t.deepEqual(common.createAsarOpts({ asar: true }), {})
})

test('asar argument test: asar is not an Object or a bool', t => {
t.false(common.createAsarOpts({asar: 'string'}), 'createAsarOpts returns false')
t.false(common.createAsarOpts({ asar: 'string' }), 'createAsarOpts returns false')
})

util.testSinglePlatform('default_app.asar removal test', (t, opts) => {
Expand Down
2 changes: 1 addition & 1 deletion test/basic.js
Expand Up @@ -47,7 +47,7 @@ test('download argument test: download.{arch,platform,version} does not overwrit
}

const downloadOpts = download.createDownloadOpts(opts, 'linux', 'x64')
t.deepEqual(downloadOpts, {arch: 'x64', platform: 'linux', version: '0.36.0'})
t.deepEqual(downloadOpts, { arch: 'x64', platform: 'linux', version: '0.36.0' })
})

test('sanitize app name for use in file/directory names', t => {
Expand Down
4 changes: 2 additions & 2 deletions test/cli.js
Expand Up @@ -54,7 +54,7 @@ test('CLI argument test: --out without a value is the same as not passing --out'

test('CLI argument test: --protocol with a corresponding --protocol-name', t => {
const args = common.parseCLIArgs(['--protocol=foo', '--protocol-name=Foo'])
t.deepEqual(args.protocols, [{schemes: ['foo'], name: 'Foo'}])
t.deepEqual(args.protocols, [{ schemes: ['foo'], name: 'Foo' }])
})

test('CLI argument test: --protocol without a corresponding --protocol-name', t => {
Expand All @@ -64,5 +64,5 @@ test('CLI argument test: --protocol without a corresponding --protocol-name', t

test('CLI argument test: multiple --protocol/--protocol-name argument pairs', t => {
const args = common.parseCLIArgs(['--protocol=foo', '--protocol-name=Foo', '--protocol=bar', '--protocol-name=Bar'])
t.deepEqual(args.protocols, [{schemes: ['foo'], name: 'Foo'}, {schemes: ['bar'], name: 'Bar'}])
t.deepEqual(args.protocols, [{ schemes: ['foo'], name: 'Foo' }, { schemes: ['bar'], name: 'Bar' }])
})
34 changes: 17 additions & 17 deletions test/darwin.js
Expand Up @@ -222,7 +222,7 @@ function appHelpersBundleTest (t, opts, helperBundleId, appBundleId) {

if (!(process.env.CI && process.platform === 'win32')) {
darwinTest('helper app paths test', helperAppPathsTest)
darwinTest('helper app paths test with app name needing sanitization', helperAppPathsTest, {name: '@username/package-name'}, '@username-package-name')
darwinTest('helper app paths test with app name needing sanitization', helperAppPathsTest, { name: '@username/package-name' }, '@username-package-name')

const iconBase = path.join(__dirname, 'fixtures', 'monochrome')
const icnsPath = `${iconBase}.icns`
Expand Down Expand Up @@ -267,41 +267,41 @@ if (!(process.env.CI && process.platform === 'win32')) {
test('osxSign argument test: default args', t => {
const args = true
const signOpts = mac.createSignOpts(args, 'darwin', 'out', 'version')
t.deepEqual(signOpts, {identity: null, app: 'out', platform: 'darwin', version: 'version'})
t.deepEqual(signOpts, { identity: null, app: 'out', platform: 'darwin', version: 'version' })
})

test('osxSign argument test: identity=true sets autodiscovery mode', t => {
const args = {identity: true}
const args = { identity: true }
const signOpts = mac.createSignOpts(args, 'darwin', 'out', 'version')
t.deepEqual(signOpts, {identity: null, app: 'out', platform: 'darwin', version: 'version'})
t.deepEqual(signOpts, { identity: null, app: 'out', platform: 'darwin', version: 'version' })
})

test('osxSign argument test: entitlements passed to electron-osx-sign', t => {
const args = {entitlements: 'path-to-entitlements'}
const args = { entitlements: 'path-to-entitlements' }
const signOpts = mac.createSignOpts(args, 'darwin', 'out', 'version')
t.deepEqual(signOpts, {app: 'out', platform: 'darwin', version: 'version', entitlements: args.entitlements})
t.deepEqual(signOpts, { app: 'out', platform: 'darwin', version: 'version', entitlements: args.entitlements })
})

test('osxSign argument test: app not overwritten', t => {
const args = {app: 'some-other-path'}
const args = { app: 'some-other-path' }
const signOpts = mac.createSignOpts(args, 'darwin', 'out', 'version')
t.deepEqual(signOpts, {app: 'out', platform: 'darwin', version: 'version'})
t.deepEqual(signOpts, { app: 'out', platform: 'darwin', version: 'version' })
})

test('osxSign argument test: platform not overwritten', t => {
const args = {platform: 'mas'}
const args = { platform: 'mas' }
const signOpts = mac.createSignOpts(args, 'darwin', 'out', 'version')
t.deepEqual(signOpts, {app: 'out', platform: 'darwin', version: 'version'})
t.deepEqual(signOpts, { app: 'out', platform: 'darwin', version: 'version' })
})

test('osxSign argument test: binaries not set', t => {
const args = {binaries: ['binary1', 'binary2']}
const args = { binaries: ['binary1', 'binary2'] }
const signOpts = mac.createSignOpts(args, 'darwin', 'out', 'version')
t.deepEqual(signOpts, {app: 'out', platform: 'darwin', version: 'version'})
t.deepEqual(signOpts, { app: 'out', platform: 'darwin', version: 'version' })
})

darwinTest('codesign test', (t, opts) => {
opts.osxSign = {identity: 'Developer CodeCert'}
opts.osxSign = { identity: 'Developer CodeCert' }

let appPath

Expand All @@ -325,8 +325,8 @@ if (!(process.env.CI && process.platform === 'win32')) {
})

darwinTest('binary naming test', binaryNameTest)
darwinTest('sanitized binary naming test', binaryNameTest, {name: '@username/package-name'}, '@username-package-name')
darwinTest('executableName test', binaryNameTest, {executableName: 'app-name', name: 'MyAppName'}, 'app-name', 'MyAppName')
darwinTest('sanitized binary naming test', binaryNameTest, { name: '@username/package-name' }, '@username-package-name')
darwinTest('executableName test', binaryNameTest, { executableName: 'app-name', name: 'MyAppName' }, 'app-name', 'MyAppName')

darwinTest('CFBundleName is the sanitized app name and CFBundleDisplayName is the non-sanitized app name', (t, opts) => {
const appBundleIdentifier = 'com.electron.username-package-name'
Expand Down Expand Up @@ -402,14 +402,14 @@ if (!(process.env.CI && process.platform === 'win32')) {

darwinTest('appCopyright/NSHumanReadableCopyright test', (t, baseOpts) => {
const copyright = 'Copyright © 2003–2015 Organization. All rights reserved.'
const opts = Object.assign({}, baseOpts, {appCopyright: copyright})
const opts = Object.assign({}, baseOpts, { appCopyright: copyright })

return packageAndParseInfoPlist(t, opts)
.then(info => t.is(info.NSHumanReadableCopyright, copyright, 'NSHumanReadableCopyright should reflect opts.appCopyright'))
})

darwinTest('app named Electron packaged successfully', (t, baseOpts) => {
const opts = Object.assign({}, baseOpts, {name: 'Electron'})
const opts = Object.assign({}, baseOpts, { name: 'Electron' })
let appPath

return packager(opts)
Expand Down
4 changes: 2 additions & 2 deletions test/ignore.js
Expand Up @@ -60,7 +60,7 @@ function ignoreImplicitOutDirTest (t, opts) {
test('generateIgnores ignores the generated temporary directory only on Linux', t => {
const tmpdir = '/foo/bar'
const expected = path.join(tmpdir, 'electron-packager')
let opts = {tmpdir}
let opts = { tmpdir }

ignore.generateIgnores(opts)

Expand All @@ -72,7 +72,7 @@ test('generateIgnores ignores the generated temporary directory only on Linux',
})

test('generateOutIgnores ignores all possible platform/arch permutations', (t) => {
const ignores = ignore.generateOutIgnores({name: 'test'})
const ignores = ignore.generateOutIgnores({ name: 'test' })
t.is(ignores.length, util.allPlatformArchCombosCount)
})

Expand Down
6 changes: 3 additions & 3 deletions test/infer.js
Expand Up @@ -88,12 +88,12 @@ util.testSinglePlatformParallel('infer using `electron-prebuilt-compile` package
util.testSinglePlatformParallel('infer using `electron` package only', inferMissingVersionTest)
util.testSinglePlatformParallel('infer where `electron` version is preferred over `electron-prebuilt`', inferElectronVersionTest, 'basic-renamed-to-electron', 'electron')
util.testSinglePlatformParallel('infer win32metadata', (t, opts) => {
const expected = {CompanyName: 'Foo Bar'}
const expected = { CompanyName: 'Foo Bar' }

return testInferWin32metadata(t, opts, expected, 'win32metadata matches package.json values')
})
util.testSinglePlatformParallel('do not infer win32metadata if it already exists', (t, opts) => {
opts.win32metadata = {CompanyName: 'Existing'}
opts.win32metadata = { CompanyName: 'Existing' }
const expected = Object.assign({}, opts.win32metadata)

return testInferWin32metadata(t, opts, expected, 'win32metadata did not update with package.json values')
Expand All @@ -103,7 +103,7 @@ util.testSinglePlatformParallel('infer win32metadata when author is an object',
name: 'Foo Bar Object',
email: 'foobar@example.com'
}
const expected = {CompanyName: 'Foo Bar Object'}
const expected = { CompanyName: 'Foo Bar Object' }

return testInferWin32metadataAuthorObject(t, opts, author, expected, 'win32metadata did not update with package.json values')
})
Expand Down
30 changes: 15 additions & 15 deletions test/targets.js
Expand Up @@ -26,7 +26,7 @@ function testMultiTarget (testcaseDescription, extraOpts, expectedPackageCount,
}

function testCombinations (testcaseDescription, arch, platform) {
testMultiTarget(testcaseDescription, {arch: arch, platform: platform}, 4,
testMultiTarget(testcaseDescription, { arch: arch, platform: platform }, 4,
'Packages should be generated for all combinations of specified archs and platforms')
}

Expand Down Expand Up @@ -54,30 +54,30 @@ test('allOfficialArchsForPlatformAndVersion returns mips64el when the correct ve

test('validateListFromOptions does not take non-Array/String values', t => {
targets.supported.digits = new Set(['64', '65'])
t.false(targets.validateListFromOptions({digits: 64}, 'digits') instanceof Array,
t.false(targets.validateListFromOptions({ digits: 64 }, 'digits') instanceof Array,
'should not be an Array')
delete targets.supported.digits
})

test('validateListFromOptions works for armv7l host and target arch', t => {
sinon.stub(process, 'arch').value('arm')
sinon.stub(process, 'config').value({variables: {arm_version: '7'}})
sinon.stub(process, 'config').value({ variables: { arm_version: '7' } })

t.deepEqual(targets.validateListFromOptions({}, 'arch'), ['armv7l'])

sinon.restore()
})

testMultiTarget('build for all available official targets', {all: true, electronVersion: '1.8.2'},
testMultiTarget('build for all available official targets', { all: true, electronVersion: '1.8.2' },
util.allPlatformArchCombosCount,
'Packages should be generated for all possible platforms')
testMultiTarget('build for all available official targets for a version without arm64 or mips64el support',
{all: true},
{ all: true },
util.allPlatformArchCombosCount - 2,
'Packages should be generated for all possible platforms (except arm64 and mips64el)')
testMultiTarget('platform=all (one arch)', {arch: 'ia32', platform: 'all'}, 2,
testMultiTarget('platform=all (one arch)', { arch: 'ia32', platform: 'all' }, 2,
'Packages should be generated for both 32-bit platforms')
testMultiTarget('arch=all test (one platform)', {arch: 'all', platform: 'linux'}, 3,
testMultiTarget('arch=all test (one platform)', { arch: 'all', platform: 'linux' }, 3,
'Packages should be generated for all expected architectures')

testCombinations('multi-platform / multi-arch test, from arrays', ['ia32', 'x64'], ['linux', 'win32'])
Expand All @@ -93,13 +93,13 @@ test('fails with invalid platform', util.invalidOptionTest({
platform: 'dos'
}))

testMultiTarget('invalid official combination', {arch: 'ia32', platform: 'darwin'}, 0, 'Package should not be generated for invalid official combination')
testMultiTarget('platform=linux and arch=arm64 with a supported official Electron version', {arch: 'arm64', platform: 'linux', electronVersion: '1.8.0'}, 1, 'Package should be generated for arm64')
testMultiTarget('platform=linux and arch=arm64 with an unsupported official Electron version', {arch: 'arm64', platform: 'linux'}, 0, 'Package should not be generated for arm64')
testMultiTarget('platform=linux and arch=mips64el with a supported official Electron version', {arch: 'mips64el', platform: 'linux', electronVersion: '1.8.2-beta.5'}, 1, 'Package should be generated for mips64el')
testMultiTarget('platform=linux and arch=mips64el with an unsupported official Electron version', {arch: 'mips64el', platform: 'linux'}, 0, 'Package should not be generated for mips64el')
testMultiTarget('platform=linux and arch=mips64el with an unsupported official Electron version (2.0.0)', {arch: 'mips64el', platform: 'linux', electronVersion: '2.0.0'}, 0, 'Package should not be generated for mips64el')
testMultiTarget('unofficial arch', {arch: 'z80', platform: 'linux', download: {mirror: 'mirror'}}, 1,
testMultiTarget('invalid official combination', { arch: 'ia32', platform: 'darwin' }, 0, 'Package should not be generated for invalid official combination')
testMultiTarget('platform=linux and arch=arm64 with a supported official Electron version', { arch: 'arm64', platform: 'linux', electronVersion: '1.8.0' }, 1, 'Package should be generated for arm64')
testMultiTarget('platform=linux and arch=arm64 with an unsupported official Electron version', { arch: 'arm64', platform: 'linux' }, 0, 'Package should not be generated for arm64')
testMultiTarget('platform=linux and arch=mips64el with a supported official Electron version', { arch: 'mips64el', platform: 'linux', electronVersion: '1.8.2-beta.5' }, 1, 'Package should be generated for mips64el')
testMultiTarget('platform=linux and arch=mips64el with an unsupported official Electron version', { arch: 'mips64el', platform: 'linux' }, 0, 'Package should not be generated for mips64el')
testMultiTarget('platform=linux and arch=mips64el with an unsupported official Electron version (2.0.0)', { arch: 'mips64el', platform: 'linux', electronVersion: '2.0.0' }, 0, 'Package should not be generated for mips64el')
testMultiTarget('unofficial arch', { arch: 'z80', platform: 'linux', download: { mirror: 'mirror' } }, 1,
'Package should be generated for non-standard arch from non-official mirror')
testMultiTarget('unofficial platform', {arch: 'ia32', platform: 'minix', download: {mirror: 'mirror'}}, 1,
testMultiTarget('unofficial platform', { arch: 'ia32', platform: 'minix', download: { mirror: 'mirror' } }, 1,
'Package should be generated for non-standard platform from non-official mirror')
6 changes: 3 additions & 3 deletions test/win32.js
Expand Up @@ -72,7 +72,7 @@ function setCopyrightTest (appCopyright) {
appCopyright: appCopyright
}

return generateVersionStringTest('version-string', opts, {LegalCopyright: appCopyright}, 'Legal copyright should match app copyright')
return generateVersionStringTest('version-string', opts, { LegalCopyright: appCopyright }, 'Legal copyright should match app copyright')
}

function setCopyrightAndCompanyNameTest (appCopyright, companyName) {
Expand All @@ -86,7 +86,7 @@ function setCopyrightAndCompanyNameTest (appCopyright, companyName) {
return generateVersionStringTest(
'version-string',
opts,
{LegalCopyright: appCopyright, CompanyName: companyName},
{ LegalCopyright: appCopyright, CompanyName: companyName },
'Legal copyright should match app copyright and Company name should match win32metadata value'
)
}
Expand Down Expand Up @@ -130,7 +130,7 @@ function setCompanyNameTest (companyName) {

return generateVersionStringTest('version-string',
opts,
{CompanyName: companyName},
{ CompanyName: companyName },
`Company name should match win32metadata value`)
}

Expand Down
2 changes: 1 addition & 1 deletion win32.js
Expand Up @@ -40,7 +40,7 @@ class WindowsApp extends App {
ProductName: this.opts.name
}, this.opts.win32metadata)

let rcOpts = {'version-string': win32metadata}
let rcOpts = { 'version-string': win32metadata }

if (this.opts.appVersion) {
rcOpts['product-version'] = rcOpts['file-version'] = this.opts.appVersion
Expand Down

0 comments on commit 8ea94db

Please sign in to comment.