Skip to content

Commit

Permalink
chore(deps-dev): bump @tophat/eslint-config from 0.7.0 to 0.9.0 (toph…
Browse files Browse the repository at this point in the history
…at#989)

* chore(deps-dev): bump @tophat/eslint-config from 0.7.0 to 0.9.0

Bumps [@tophat/eslint-config](https://github.com/tophat/eslint-config) from 0.7.0 to 0.9.0.
- [Release notes](https://github.com/tophat/eslint-config/releases)
- [Changelog](https://github.com/tophat/eslint-config/blob/master/CHANGELOG.md)
- [Commits](https://github.com/tophat/eslint-config/compare/v0.7.0...@tophat/[email protected])

Signed-off-by: dependabot-preview[bot] <[email protected]>

* chore: run make lint fix

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Co-authored-by: Emmanuel Ogbizi-Ugbe <[email protected]>
  • Loading branch information
dependabot-preview[bot] and iamogbz authored Jun 3, 2021
1 parent 053b96e commit 791fc2d
Show file tree
Hide file tree
Showing 27 changed files with 116 additions and 212 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"devDependencies": {
"@babel/core": "^7.13.10",
"@babel/preset-env": "^7.14.1",
"@tophat/eslint-config": "^0.7.0",
"@tophat/eslint-config": "^0.9.0",
"all-contributors-cli": "^6.20.0",
"babel-eslint": "^10.1.0",
"babel-loader": "^8.2.2",
Expand Down
18 changes: 9 additions & 9 deletions scripts/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ function httpResponseIsRedirect({ headers: { location } }) {
* @param {string} destination
*/
async function httpResponseToFile(response, destination) {
return new Promise(resolve => {
return new Promise((resolve) => {
const file = fs.createWriteStream(destination)
response.pipe(file)
file.on('finish', () => file.close(resolve))
Expand All @@ -109,10 +109,10 @@ async function httpResponseToFile(response, destination) {
* @param {http.ServerResponse} response
*/
async function httpResponseToString(response) {
return new Promise(resolve => {
return new Promise((resolve) => {
let output = ''
response.setEncoding('utf8')
response.on('data', chunk => (output += chunk))
response.on('data', (chunk) => (output += chunk))
response.on('end', () => resolve(output))
})
}
Expand Down Expand Up @@ -151,7 +151,7 @@ async function downloadFile({ source, destination }) {
),
)

return https.get(httpRequest(source), response => {
return https.get(httpRequest(source), (response) => {
const { statusCode, headers } = response
if (statusCode >= 400)
return reject(
Expand All @@ -178,7 +178,7 @@ async function downloadFile({ source, destination }) {
async function removeFile(maybeDir, recurse = false) {
if (!fs.existsSync(maybeDir)) return
if (fs.lstatSync(maybeDir).isDirectory() && recurse) {
fs.readdirSync(maybeDir).forEach(file => {
fs.readdirSync(maybeDir).forEach((file) => {
const maybeFile = path.join(maybeDir, file)
removeFile(maybeFile, recurse)
})
Expand All @@ -192,9 +192,9 @@ async function cleanYvmDir(yvmPath) {
const filesNotToRemove = new Set(['versions'])
const filesToRemove = fs
.readdirSync(yvmPath)
.filter(f => !filesNotToRemove.has(f))
.filter((f) => !filesNotToRemove.has(f))
await Promise.all(
filesToRemove.map(file =>
filesToRemove.map((file) =>
removeFile(path.join(yvmPath, file), true).catch(log),
),
)
Expand All @@ -220,7 +220,7 @@ async function compatInstall({ paths, version }) {
)
.toString()
.split('\n')
.forEach(l => log(l))
.forEach((l) => log(l))
return fs.unlinkSync(yvmCompatInstallScript)
} catch (e) {
continue
Expand Down Expand Up @@ -295,7 +295,7 @@ Open another terminal window to start using, or "${sourceCommand}"`)
}

if (!module.parent) {
run().catch(error => {
run().catch((error) => {
log('yvm installation failed')
log(error.message)
})
Expand Down
4 changes: 2 additions & 2 deletions src/commands/alias.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { getFormatter, resolveMatchingAliases, setAlias } from 'util/alias'
import { getVersionInUse, getYarnVersions, resolveVersion } from 'util/version'
import { getVersionsFromTags } from 'util/utils'

const safeResolveVersion = async versionString =>
resolveVersion({ versionString }).catch(e => log.info(e.message))
const safeResolveVersion = async (versionString) =>
resolveVersion({ versionString }).catch((e) => log.info(e.message))

const setAliasCommand = async ({ name, version }) => {
const [allVersions, installedVersions, currentVersion] = await Promise.all([
Expand Down
10 changes: 5 additions & 5 deletions src/commands/configureShell.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const yvmDirVarName = 'YVM_DIR'
export async function ensureConfig(configFile, configLines) {
if (!fs.existsSync(configFile)) return false
let contents = fs.readFileSync(configFile, 'utf8')
const linesAppended = configLines.map(string => {
const linesAppended = configLines.map((string) => {
const finalString = `\n${string}`
if (contents.includes(string)) {
const matchString = new RegExp(`\n.*${escapeRegExp(string)}.*`)
Expand All @@ -43,7 +43,7 @@ export async function ensureConfig(configFile, configLines) {
contents += finalString
return true
})
if (linesAppended.some(a => a)) {
if (linesAppended.some((a) => a)) {
contents += '\n'
}
fs.writeFileSync(configFile, contents)
Expand Down Expand Up @@ -126,13 +126,13 @@ export const configureShell = async ({
fish: configureFish,
zsh: configureZsh,
}
const configHandler = sh => configHandlers[sh](config)
const configHandler = (sh) => configHandlers[sh](config)
const configShells = Object.keys(configHandlers)
const supportedShells = configShells.filter(sh => sh.includes(shell))
const supportedShells = configShells.filter((sh) => sh.includes(shell))
const updatingShellConfigs = [].concat(
profile && !shell
? supportedShells.reduce(
(conf, sh) => conf.then(r => r || configHandler(sh)),
(conf, sh) => conf.then((r) => r || configHandler(sh)),
Promise.resolve(false),
)
: supportedShells.map(configHandler),
Expand Down
4 changes: 2 additions & 2 deletions src/commands/getOldPath.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import log from 'util/log'
import { getNonYvmPathEntries, toPathString } from 'util/path'

export const buildOldPath = shell =>
export const buildOldPath = (shell) =>
toPathString({ shell, paths: [...new Set(getNonYvmPathEntries(shell))] })

export const getOldPath = async shell => {
export const getOldPath = async (shell) => {
try {
log.capturable(buildOldPath(shell))
return 0
Expand Down
4 changes: 2 additions & 2 deletions src/commands/getShimPath.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import log from 'util/log'
import { shimRootPath } from 'util/utils'
import { getNonYvmShimPathEntries, toPathString, yvmPath } from 'util/path'

export const buildShimPath = shell => {
export const buildShimPath = (shell) => {
const updatedPath = [
shimRootPath(yvmPath),
...new Set(getNonYvmShimPathEntries(shell)),
]
return toPathString({ shell, paths: updatedPath })
}

export const getShimPath = async shell => {
export const getShimPath = async (shell) => {
try {
log.capturable(buildShimPath(shell))
return 0
Expand Down
4 changes: 2 additions & 2 deletions src/commands/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ const extractYarn = async (version, rootPath) => {
return destPath
}

const logVerifyNotice = extraMessage => {
const logVerifyNotice = (extraMessage) => {
log.notice(`Unable to verify GPG signature.
Note, this may happen on older yarn versions if the public key used to sign those versions has expired.`)
extraMessage && log(extraMessage)
}

const logHelpful = error => {
const logHelpful = (error) => {
if (error instanceof VerificationError) {
return logVerifyNotice(
"If you would like to proceed anyway, re-run 'yvm install' without the '--verify' flag",
Expand Down
2 changes: 1 addition & 1 deletion src/commands/list.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import log from 'util/log'
import { getVersionInUse, getYarnVersions, printVersions } from 'util/version'

export const listVersions = async rootPath => {
export const listVersions = async (rootPath) => {
const installedVersions = getYarnVersions(rootPath)
if (installedVersions.length) {
const versionInUse = await getVersionInUse()
Expand Down
2 changes: 1 addition & 1 deletion src/commands/setDefault.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import log from 'util/log'
import { setDefaultVersion } from 'util/version'

export const setDefault = async version => {
export const setDefault = async (version) => {
try {
if (!(await setDefaultVersion({ version }))) {
return 1
Expand Down
13 changes: 7 additions & 6 deletions src/util/alias.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import { YARN_STABLE_VERSION_URL } from 'util/constants'

const filterAliasesByName = (pattern, aliases) => {
return Object.keys(aliases)
.filter(name => new RegExp(pattern).test(name))
.map(name => ({ name, value: aliases[name] }))
.filter((name) => new RegExp(pattern).test(name))
.map((name) => ({ name, value: aliases[name] }))
}

const getAllDependants = ({ name, aliases }) => {
Expand All @@ -26,7 +26,7 @@ const getAllDependants = ({ name, aliases }) => {
continue
}
visited.push(aliasName)
dependants.push(...aliasNames.filter(d => aliases[d] === aliasName))
dependants.push(...aliasNames.filter((d) => aliases[d] === aliasName))
}
return visited
}
Expand Down Expand Up @@ -64,7 +64,7 @@ export const resolveSystem = memoize(async ({ shell } = {}) => {
return NOT_AVAILABLE
})

export const isReserved = name => RESERVED_NAMES.includes(name)
export const isReserved = (name) => RESERVED_NAMES.includes(name)

export const resolveReserved = memoize(async (name, args = {}) => {
const resolver =
Expand Down Expand Up @@ -130,7 +130,7 @@ export const unsetAlias = async ({
let deleted = false
const aliases = await getUserAliases(yvmPath)
const aliasNameList = Object.keys(aliases)
const dependants = aliasNameList.filter(d => aliases[d] === name)
const dependants = aliasNameList.filter((d) => aliases[d] === name)
if (dependants.length && !force && !recursive) {
log.notice(`The following aliases will be orphaned: ${dependants}
Rerun with '--force' to remove just this alias
Expand Down Expand Up @@ -167,7 +167,8 @@ export const resolveAlias = memoize(
yvmPath = defaultYvmPath,
}) => {
const chain = visitedAliases.join(', ')
const resolveErrorMessage = msg => `${msg}: '${versionString}' ${chain}`
const resolveErrorMessage = (msg) =>
`${msg}: '${versionString}' ${chain}`
if (visitedAliases.includes(versionString)) {
throw new Error(resolveErrorMessage`Cyclic chain detected`)
}
Expand Down
6 changes: 3 additions & 3 deletions src/util/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ import request from 'request'

import { USER_AGENT } from 'util/constants'

const isErrorCode = httpStatusCode => httpStatusCode >= 400
const isErrorCode = (httpStatusCode) => httpStatusCode >= 400

export const downloadFile = (url, filePath) =>
new Promise((resolve, reject) => {
fs.ensureFileSync(filePath)
const handleError = err => reject(err)
const handleError = (err) => reject(err)
request
.get(url, { headers: { 'user-agent': USER_AGENT } })
.on('error', handleError)
.on('response', r => {
.on('response', (r) => {
const msg = `HTTP ${r.statusCode} - ${r.statusMessage} (${url})`
if (isErrorCode(r.statusCode)) handleError(msg)
})
Expand Down
24 changes: 12 additions & 12 deletions src/util/path.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import { negate } from 'lodash'

import { shimRootPath, versionRootPath } from 'util/utils'

const isFishShell = shell => shell === 'fish'
const isFishShell = (shell) => shell === 'fish'

const isYvmVersionPath = ({ p, rootPath = yvmPath }) =>
p.startsWith(versionRootPath(rootPath))

const isShimPath = p => p && p.endsWith(shimRootPath(yvmPath))
const isShimPath = (p) => p && p.endsWith(shimRootPath(yvmPath))

export const getPathDelimiter = shell => {
export const getPathDelimiter = (shell) => {
if (isFishShell(shell)) {
return ' '
}
Expand All @@ -23,7 +23,7 @@ export const getPathDelimiter = shell => {
export const toPathString = ({ shell, paths }) =>
paths.join(getPathDelimiter(shell)).trim()

export const getCurrentPath = shell => {
export const getCurrentPath = (shell) => {
if (isFishShell(shell)) {
return process.env.fish_user_paths || ''
}
Expand All @@ -32,24 +32,24 @@ export const getCurrentPath = shell => {

export const yvmPath = process.env.YVM_DIR || path.resolve(os.homedir(), '.yvm')

export const isYvmPath = p => p && p.startsWith(yvmPath)
export const isYvmPath = (p) => p && p.startsWith(yvmPath)

export const getPathEntries = shell =>
export const getPathEntries = (shell) =>
getCurrentPath(shell).split(getPathDelimiter(shell))

export const getNonYvmPathEntries = shell =>
export const getNonYvmPathEntries = (shell) =>
getPathEntries(shell).filter(negate(isYvmPath))

export const getNonYvmVersionPathEntries = ({ shell, rootPath = yvmPath }) =>
getPathEntries(shell).filter(p => !isYvmVersionPath({ p, rootPath }))
getPathEntries(shell).filter((p) => !isYvmVersionPath({ p, rootPath }))

export const getNonYvmShimPathEntries = shell =>
export const getNonYvmShimPathEntries = (shell) =>
getPathEntries(shell).filter(negate(isShimPath))

export const getYarnPathEntries = shell =>
export const getYarnPathEntries = (shell) =>
getPathEntries(shell)
.map(p => path.join(p, 'yarn'))
.map((p) => path.join(p, 'yarn'))
.filter(fs.existsSync)

export const getNonYvmYarnPathEntries = shell =>
export const getNonYvmYarnPathEntries = (shell) =>
getYarnPathEntries(shell).filter(negate(isYvmPath))
12 changes: 6 additions & 6 deletions src/util/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ import {
} from 'util/constants'
import log from 'util/log'

export const shimRootPath = rootPath => path.resolve(rootPath, 'shim')
export const versionRootPath = rootPath => path.resolve(rootPath, 'versions')
export const shimRootPath = (rootPath) => path.resolve(rootPath, 'shim')
export const versionRootPath = (rootPath) => path.resolve(rootPath, 'versions')

export const getExtractionPath = (version, rootPath) =>
path.resolve(rootPath, 'versions', `v${version}`)

export const stripVersionPrefix = tagName =>
export const stripVersionPrefix = (tagName) =>
tagName[0] === 'v' ? tagName.substring(1) : tagName

export const getRequest = memoize(async url => {
export const getRequest = memoize(async (url) => {
const options = {
url,
gzip: true,
Expand All @@ -44,11 +44,11 @@ export const getRequest = memoize(async url => {
})
})

export const getVersionDownloadUrl = version =>
export const getVersionDownloadUrl = (version) =>
`${YARN_DOWNLOAD_URL}/${version}/yarn-v${version}.tar.gz`

export const getReleasesFromTags = memoize(async () => {
return getRequest(YARN_RELEASES_API_URL).then(body => {
return getRequest(YARN_RELEASES_API_URL).then((body) => {
return JSON.parse(body).reduce((accumulator, tag) => {
const version = stripVersionPrefix(tag.name)
const [major] = version.split('.')
Expand Down
9 changes: 5 additions & 4 deletions src/util/verification.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { YARN_PUBLIC_KEY_URL } from './constants'
import { downloadFile, getDownloadPath } from './download'
import { getVersionDownloadUrl } from './utils'

const getSignatureUrl = version => `${getVersionDownloadUrl(version)}.asc`
const getSignatureUrl = (version) => `${getVersionDownloadUrl(version)}.asc`

const getSignatureDownloadPath = (version, rootPath) =>
`${getDownloadPath(version, rootPath)}.asc`
Expand All @@ -19,7 +19,7 @@ const downloadSignature = (version, rootPath) => {
return downloadFile(url, filePath)
}

const getPublicKey = async rootPath => {
const getPublicKey = async (rootPath) => {
const publicKeyPath = getPublicKeyPath(rootPath)

if (fs.existsSync(publicKeyPath)) {
Expand All @@ -34,7 +34,8 @@ const getPublicKey = async rootPath => {
export class VerificationError extends Error {}
export class PublicKeyImportError extends Error {}

export const getPublicKeyPath = rootPath => path.resolve(rootPath, 'pubkey.gpg')
export const getPublicKeyPath = (rootPath) =>
path.resolve(rootPath, 'pubkey.gpg')

export const verifySignature = async (version, rootPath) => {
await downloadSignature(version, rootPath)
Expand Down Expand Up @@ -65,7 +66,7 @@ export const verifySignature = async (version, rootPath) => {
armored: detachedSig,
data: file,
},
err => (err ? reject(new VerificationError(err)) : resolve(true)),
(err) => (err ? reject(new VerificationError(err)) : resolve(true)),
)
})
}
Loading

0 comments on commit 791fc2d

Please sign in to comment.