build: update eslint + eslint plugins (#22777)

* build: run eslint --fix

* chore: manually fix all hasOwnProperty errors

* chore: manually fix all void 0 vs undefined errors

* chore: manually fix all async-in-promise errors

* chore: manually fix lexical declaration in case block
This commit is contained in:
Samuel Attard 2020-03-20 08:12:18 -07:00 committed by GitHub
parent 42f138282f
commit b87b501161
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
62 changed files with 280 additions and 280 deletions

View file

@ -38,7 +38,7 @@ async function downloadArtifact (name, buildNum, dest) {
url: circleArtifactUrl,
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
Accept: 'application/json'
}
}, true).catch(err => {
if (args.verbose) {

View file

@ -15,7 +15,7 @@ const DEPOT_TOOLS = path.resolve(SOURCE_ROOT, '..', 'third_party', 'depot_tools'
const OUT_DIR = getOutDir({ outDir: args.outDir })
if (!OUT_DIR) {
throw new Error(`No viable out dir: one of Debug, Testing, or Release must exist.`)
throw new Error('No viable out dir: one of Debug, Testing, or Release must exist.')
}
const env = Object.assign({

View file

@ -57,7 +57,7 @@ function isObjCHeader (filename) {
return /\/(mac|cocoa)\//.test(filename)
}
const LINTERS = [ {
const LINTERS = [{
key: 'c++',
roots: ['shell'],
test: filename => filename.endsWith('.cc') || (filename.endsWith('.h') && !isObjCHeader(filename)),
@ -104,7 +104,7 @@ const LINTERS = [ {
test: filename => filename.endsWith('.js') || filename.endsWith('.ts'),
run: (opts, filenames) => {
const cmd = path.join(SOURCE_ROOT, 'node_modules', '.bin', 'eslint')
const args = [ '--cache', '--ext', '.js,.ts', ...filenames ]
const args = ['--cache', '--ext', '.js,.ts', ...filenames]
if (opts.fix) args.unshift('--fix')
spawnAndCheckExitCode(cmd, args, { cwd: SOURCE_ROOT })
}
@ -202,7 +202,7 @@ const LINTERS = [ {
function parseCommandLine () {
let help
const opts = minimist(process.argv.slice(2), {
boolean: [ 'c++', 'objc', 'javascript', 'python', 'gn', 'patches', 'help', 'changed', 'fix', 'verbose', 'only' ],
boolean: ['c++', 'objc', 'javascript', 'python', 'gn', 'patches', 'help', 'changed', 'fix', 'verbose', 'only'],
alias: { 'c++': ['cc', 'cpp', 'cxx'], javascript: ['js', 'es'], python: 'py', changed: 'c', help: 'h', verbose: 'v' },
unknown: arg => { help = true }
})

View file

@ -66,8 +66,8 @@ async function makeRequest (requestOptions, parseResponse) {
async function circleCIcall (targetBranch, job, options) {
console.log(`Triggering CircleCI to run build job: ${job} on branch: ${targetBranch} with release flag.`)
const buildRequest = {
'branch': targetBranch,
'parameters': {
branch: targetBranch,
parameters: {
'run-lint': false,
'run-build-linux': false,
'run-build-mac': false
@ -185,7 +185,7 @@ async function circleCIRequest (url, method, requestBody) {
url,
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
Accept: 'application/json'
},
body: requestBody ? JSON.stringify(requestBody) : null
}, true).catch(err => {

View file

@ -144,8 +144,8 @@ async function getReleaseNotes (range, newVersion, explicitLinks) {
async function main () {
const opts = minimist(process.argv.slice(2), {
boolean: [ 'explicit-links', 'help' ],
string: [ 'version' ]
boolean: ['explicit-links', 'help'],
string: ['version']
})
opts.range = opts._.shift()
if (opts.help || !opts.range) {

View file

@ -18,7 +18,7 @@ const CHECK_INTERVAL = 5000
const CACHE_DIR = path.resolve(__dirname, '.cache')
const NO_NOTES = 'No notes'
const FOLLOW_REPOS = [ 'electron/electron', 'electron/node' ]
const FOLLOW_REPOS = ['electron/electron', 'electron/node']
const breakTypes = new Set(['breaking-change'])
const docTypes = new Set(['doc', 'docs'])
@ -222,7 +222,7 @@ const parseCommitMessage = (commitMessage, owner, repo, commit = {}) => {
// Edge case: manual backport where commit has `owner/repo#pull` notation
if (commitMessage.toLowerCase().includes('backport') &&
((match = commitMessage.match(/\b(\w+)\/(\w+)#(\d+)\b/)))) {
const [ , owner, repo, number ] = match
const [, owner, repo, number] = match
if (FOLLOW_REPOS.includes(`${owner}/${repo}`)) {
setPullRequest(commit, owner, repo, number)
}
@ -231,7 +231,7 @@ const parseCommitMessage = (commitMessage, owner, repo, commit = {}) => {
// Edge case: manual backport where commit has a link to the backport PR
if (commitMessage.includes('ackport') &&
((match = commitMessage.match(/https:\/\/github\.com\/(\w+)\/(\w+)\/pull\/(\d+)/)))) {
const [ , owner, repo, number ] = match
const [, owner, repo, number] = match
if (FOLLOW_REPOS.includes(`${owner}/${repo}`)) {
setPullRequest(commit, owner, repo, number)
}
@ -257,8 +257,8 @@ const parseCommitMessage = (commitMessage, owner, repo, commit = {}) => {
}
const getLocalCommitHashes = async (dir, ref) => {
const args = ['log', '-z', `--format=%H`, ref]
return (await runGit(dir, args)).split(`\0`).map(hash => hash.trim())
const args = ['log', '-z', '--format=%H', ref]
return (await runGit(dir, args)).split('\0').map(hash => hash.trim())
}
/*
@ -272,13 +272,13 @@ const getLocalCommitDetails = async (module, point1, point2) => {
const fieldSep = '||'
const format = ['%H', '%P', '%aE', '%B'].join(fieldSep)
const args = ['log', '-z', '--cherry-pick', '--right-only', '--first-parent', `--format=${format}`, `${point1}..${point2}`]
const commits = (await runGit(dir, args)).split(`\0`).map(field => field.trim())
const commits = (await runGit(dir, args)).split('\0').map(field => field.trim())
const details = []
for (const commit of commits) {
if (!commit) {
continue
}
const [ hash, parentHashes, email, commitMessage ] = commit.split(fieldSep, 4).map(field => field.trim())
const [hash, parentHashes, email, commitMessage] = commit.split(fieldSep, 4).map(field => field.trim())
details.push(parseCommitMessage(commitMessage, owner, repo, {
email,
hash,
@ -496,7 +496,7 @@ const getNotes = async (fromRef, toRef, newVersion) => {
if (!shouldIncludeMultibranchChanges(newVersion)) {
// load all the prDatas
await Promise.all(
pool.commits.map(commit => new Promise(async (resolve) => {
pool.commits.map(commit => (async () => {
const { pr } = commit
if (typeof pr === 'object') {
const prData = await getPullRequest(pr.number, pr.owner, pr.repo)
@ -504,8 +504,7 @@ const getNotes = async (fromRef, toRef, newVersion) => {
commit.prData = prData
}
}
resolve()
}))
})())
)
// remove items that already landed in a previous major/minor series
@ -616,22 +615,22 @@ const renderCommit = (commit, explicitLinks) => {
}
const commonVerbs = {
'Added': [ 'Add' ],
'Backported': [ 'Backport' ],
'Cleaned': [ 'Clean' ],
'Disabled': [ 'Disable' ],
'Ensured': [ 'Ensure' ],
'Exported': [ 'Export' ],
'Fixed': [ 'Fix', 'Fixes' ],
'Handled': [ 'Handle' ],
'Improved': [ 'Improve' ],
'Made': [ 'Make' ],
'Removed': [ 'Remove' ],
'Repaired': [ 'Repair' ],
'Reverted': [ 'Revert' ],
'Stopped': [ 'Stop' ],
'Updated': [ 'Update' ],
'Upgraded': [ 'Upgrade' ]
Added: ['Add'],
Backported: ['Backport'],
Cleaned: ['Clean'],
Disabled: ['Disable'],
Ensured: ['Ensure'],
Exported: ['Export'],
Fixed: ['Fix', 'Fixes'],
Handled: ['Handle'],
Improved: ['Improve'],
Made: ['Make'],
Removed: ['Remove'],
Repaired: ['Repair'],
Reverted: ['Revert'],
Stopped: ['Stop'],
Updated: ['Update'],
Upgraded: ['Upgrade']
}
for (const [key, values] of Object.entries(commonVerbs)) {
for (const value of values) {
@ -649,7 +648,7 @@ const renderCommit = (commit, explicitLinks) => {
}
const renderNotes = (notes, explicitLinks) => {
const rendered = [ `# Release Notes for ${notes.name}\n\n` ]
const rendered = [`# Release Notes for ${notes.name}\n\n`]
const renderSection = (title, commits) => {
if (commits.length === 0) {

View file

@ -23,8 +23,8 @@ const pass = '✓'.green
const fail = '✗'.red
if (!bumpType && !args.notesOnly) {
console.log(`Usage: prepare-release [stable | minor | beta | nightly]` +
` (--stable) (--notesOnly) (--automaticRelease) (--branch)`)
console.log('Usage: prepare-release [stable | minor | beta | nightly]' +
' (--stable) (--notesOnly) (--automaticRelease) (--branch)')
process.exit(1)
}
@ -66,7 +66,7 @@ async function createRelease (branchToTarget, isBeta) {
const releaseNotes = await getReleaseNotes(branchToTarget, newVersion)
await tagRelease(newVersion)
console.log(`Checking for existing draft release.`)
console.log('Checking for existing draft release.')
const releases = await octokit.repos.listReleases({
owner: 'electron',
repo: targetRepo
@ -87,14 +87,14 @@ async function createRelease (branchToTarget, isBeta) {
let releaseIsPrelease = false
if (isBeta) {
if (newVersion.indexOf('nightly') > 0) {
releaseBody = `Note: This is a nightly release. Please file new issues ` +
`for any bugs you find in it.\n \n This release is published to npm ` +
`under the nightly tag and can be installed via npm install electron@nightly, ` +
releaseBody = 'Note: This is a nightly release. Please file new issues ' +
'for any bugs you find in it.\n \n This release is published to npm ' +
'under the nightly tag and can be installed via npm install electron@nightly, ' +
`or npm i electron-nightly@${newVersion.substr(1)}.\n \n ${releaseNotes.text}`
} else {
releaseBody = `Note: This is a beta release. Please file new issues ` +
`for any bugs you find in it.\n \n This release is published to npm ` +
`under the beta tag and can be installed via npm install electron@beta, ` +
releaseBody = 'Note: This is a beta release. Please file new issues ' +
'for any bugs you find in it.\n \n This release is published to npm ' +
'under the beta tag and can be installed via npm install electron@beta, ' +
`or npm i electron@${newVersion.substr(1)}.\n \n ${releaseNotes.text}`
}
releaseIsPrelease = true
@ -124,7 +124,7 @@ async function pushRelease (branch) {
const pushDetails = await GitProcess.exec(['push', 'origin', `HEAD:${branch}`, '--follow-tags'], ELECTRON_DIR)
if (pushDetails.exitCode === 0) {
console.log(`${pass} Successfully pushed the release. Wait for ` +
`release builds to finish before running "npm run release".`)
'release builds to finish before running "npm run release".')
} else {
console.log(`${fail} Error pushing the release: ${pushDetails.stderr}`)
process.exit(1)
@ -140,7 +140,7 @@ async function runReleaseBuilds (branch) {
async function tagRelease (version) {
console.log(`Tagging release ${version}.`)
const checkoutDetails = await GitProcess.exec([ 'tag', '-a', '-m', version, version ], ELECTRON_DIR)
const checkoutDetails = await GitProcess.exec(['tag', '-a', '-m', version, version], ELECTRON_DIR)
if (checkoutDetails.exitCode === 0) {
console.log(`${pass} Successfully tagged ${version}.`)
} else {
@ -181,8 +181,8 @@ async function promptForVersion (version) {
// function to determine if there have been commits to master since the last release
async function changesToRelease () {
const lastCommitWasRelease = new RegExp(`^Bump v[0-9.]*(-beta[0-9.]*)?(-nightly[0-9.]*)?$`, 'g')
const lastCommit = await GitProcess.exec(['log', '-n', '1', `--pretty=format:'%s'`], ELECTRON_DIR)
const lastCommitWasRelease = new RegExp('^Bump v[0-9.]*(-beta[0-9.]*)?(-nightly[0-9.]*)?$', 'g')
const lastCommit = await GitProcess.exec(['log', '-n', '1', '--pretty=format:\'%s\''], ELECTRON_DIR)
return !lastCommitWasRelease.test(lastCommit.stdout)
}
@ -204,7 +204,7 @@ async function prepareRelease (isBeta, notesOnly) {
await pushRelease(currentBranch)
await runReleaseBuilds(currentBranch)
} else {
console.log(`There are no new changes to this branch since the last release, aborting release.`)
console.log('There are no new changes to this branch since the last release, aborting release.')
process.exit(1)
}
}

View file

@ -92,7 +92,7 @@ new Promise((resolve, reject) => {
request.get({
url: tsdAsset.url,
headers: {
'accept': 'application/octet-stream',
accept: 'application/octet-stream',
'user-agent': 'electron-npm-publisher'
}
}, (err, response, body) => {

View file

@ -9,7 +9,7 @@ const args = require('minimist')(process.argv.slice(2), {
'automaticRelease',
'verboseNugget'
],
default: { 'verboseNugget': false }
default: { verboseNugget: false }
})
const fs = require('fs')
const { execSync } = require('child_process')
@ -54,7 +54,7 @@ async function getDraftRelease (version, skipValidation) {
check(draft.prerelease, 'draft is a prerelease')
}
check(draft.body.length > 50 && !draft.body.includes('(placeholder)'), 'draft has release notes')
check((failureCount === 0), `Draft release looks good to go.`, true)
check((failureCount === 0), 'Draft release looks good to go.', true)
}
return draft
}
@ -68,7 +68,7 @@ async function validateReleaseAssets (release, validatingRelease) {
requiredAssets.forEach(asset => {
check(extantAssets.includes(asset), asset)
})
check((failureCount === 0), `All required GitHub assets exist for release`, true)
check((failureCount === 0), 'All required GitHub assets exist for release', true)
if (!validatingRelease || !release.draft) {
if (release.draft) {
@ -129,9 +129,9 @@ function assetsForVersion (version, validatingRelease) {
`electron-${version}-win32-arm64-pdb.zip`,
`electron-${version}-win32-arm64-symbols.zip`,
`electron-${version}-win32-arm64.zip`,
`electron-api.json`,
`electron.d.ts`,
`hunspell_dictionaries.zip`,
'electron-api.json',
'electron.d.ts',
'hunspell_dictionaries.zip',
`ffmpeg-${version}-darwin-x64.zip`,
`ffmpeg-${version}-linux-arm64.zip`,
`ffmpeg-${version}-linux-armv7l.zip`,
@ -161,7 +161,7 @@ function assetsForVersion (version, validatingRelease) {
}
function s3UrlsForVersion (version) {
const bucket = `https://gh-contractor-zcbenz.s3.amazonaws.com/`
const bucket = 'https://gh-contractor-zcbenz.s3.amazonaws.com/'
const patterns = [
`${bucket}atom-shell/dist/${version}/iojs-${version}-headers.tar.gz`,
`${bucket}atom-shell/dist/${version}/iojs-${version}.tar.gz`,
@ -302,7 +302,7 @@ async function makeRelease (releaseToValidate) {
await validateReleaseAssets(draftRelease)
await publishRelease(draftRelease)
console.log(`${pass} SUCCESS!!! Release has been published. Please run ` +
`"npm run publish-to-npm" to publish release to npm.`)
'"npm run publish-to-npm" to publish release to npm.')
}
}
@ -321,7 +321,7 @@ async function makeTempDir () {
async function verifyAssets (release) {
const downloadDir = await makeTempDir()
console.log(`Downloading files from GitHub to verify shasums`)
console.log('Downloading files from GitHub to verify shasums')
const shaSumFile = 'SHASUMS256.txt'
let filesToCheck = await Promise.all(release.assets.map(async asset => {

View file

@ -20,10 +20,10 @@ const getHeaders = (filePath, fileName) => {
const extension = fileName.split('.').pop()
const size = fs.statSync(filePath).size
const options = {
'json': 'text/json',
'zip': 'application/zip',
'txt': 'text/plain',
'ts': 'application/typescript'
json: 'text/json',
zip: 'application/zip',
txt: 'text/plain',
ts: 'application/typescript'
}
return {
@ -74,7 +74,7 @@ function uploadToGitHub () {
uploadToGitHub()
}
}).catch((getReleaseErr) => {
console.log(`Fatal: Unable to get current release assets via getRelease! Error was:`, getReleaseErr)
console.log('Fatal: Unable to get current release assets via getRelease! Error was:', getReleaseErr)
})
} else {
console.log(`Error retrying uploading ${fileName} to GitHub:`, err)

View file

@ -16,9 +16,9 @@ const readFile = promisify(fs.readFile)
function parseCommandLine () {
let help
const opts = minimist(process.argv.slice(2), {
string: [ 'bump', 'version' ],
boolean: [ 'dryRun', 'help' ],
alias: { 'version': ['v'] },
string: ['bump', 'version'],
boolean: ['dryRun', 'help'],
alias: { version: ['v'] },
unknown: arg => { help = true }
})
if (help || opts.help || !opts.bump) {