Skip to content

Commit

Permalink
chore: eslint standardization clean-up (#2325)
Browse files Browse the repository at this point in the history
* chore: turn on linting for several packages

* chore: turn on linting and fix erros for certs-v5

* chore: turn on linting and fix errors for orgs-v5

* chore: yarn.lock updates

* chore: eslint clean up in certs-v5

* chore: eslint clean up in ci-v5

* chore: eslint clean up in container-registry-v5

* chore: eslint clean up in oauth-v5

* chore: eslint clean up in orgs-v5

* chore: addons-v5 eslint cleanup

* chore: apps eslint cleanup

* chore: buildpacks eslint cleanup

* chore: certs and certs-v5 eslint cleanup

* chore: ci eslint cleanup

* chore: ci-v5 eslint cleanup

* chore: cli eslint cleanup

* chore: config eslint cleanup

* chore: git and local eslint cleanup

* chore: pipelines eslint cleanup

* chore: ps run and status eslint cleanup
  • Loading branch information
k80bowman authored Apr 26, 2023
1 parent dd85b41 commit 2b22b16
Show file tree
Hide file tree
Showing 127 changed files with 230 additions and 239 deletions.
19 changes: 19 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,41 @@
],
"rules": {
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-unused-vars": "warn", // TODO: fix issues and turn this back on
"camelcase":"off",
"import/no-unresolved": "error",
"func-names":"warn", // TODO: fix issues and turn this back on
"no-await-in-loop": "warn", // TODO: fix issues and turn this back on
"no-constant-condition": ["error", {"checkLoops": false }],
"no-else-return": "warn", // TODO: fix issues and turn this back on
"no-negated-condition":"warn", // TODO: fix issues and turn this back on
"no-process-exit": "off",
"no-promise-executor-return": "warn", // TODO: fix issues and turn this back on
"no-prototype-builtins": "warn", // TODO: fix issues and turn this back on
"no-return-await":"warn", // TODO: fix issues and turn this back on
"node/no-deprecated-api": "warn", // TODO: fix issues and turn this back on
"node/no-missing-import": "off", // using import/no-unresolved instead
"radix":"warn", // TODO: fix issues and turn this back on
"wrap-iife": "warn", // TODO: fix issues and turn this back on
"unicorn/better-regex": "off", // TODO: fix issues and turn this back on
"unicorn/consistent-function-scoping": "off", // TODO: fix issues and turn this back on
"unicorn/filename-case": "off",
"unicorn/import-style": "off",
"unicorn/no-abusive-eslint-disable": "off",
"unicorn/no-array-for-each": "off",
"unicorn/no-array-reduce": "warn", // TODO: fix issues and turn this back on
"unicorn/no-lonely-if":"off",
"unicorn/no-process-exit": "off",
"unicorn/no-useless-undefined": "warn", // TODO: fix issues and turn this back on
"unicorn/numeric-separators-style":"off",
"unicorn/prefer-array-some": "warn", // TODO: fix issues and turn this back on
"unicorn/prefer-module": "off",
"unicorn/prefer-node-protocol": "off",
"unicorn/prefer-object-from-entries": "warn", // TODO: fix issues and turn this back on
"unicorn/prefer-regexp-test": "off",
"unicorn/prefer-spread": "off", // TODO: fix issues and turn this back on
"unicorn/prefer-string-slice": "warn", // TODO: fix issues and turn this back on
"unicorn/prefer-ternary": "off" // TODO: fix issues and turn this back on
},

Expand Down
1 change: 0 additions & 1 deletion packages/addons-v5/commands/addons/attach.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ async function run(context, heroku) {
await cli.action(
`Setting ${cli.color.attachment(attachment.name)} config vars and restarting ${cli.color.app(app)}`,
{success: false},
// eslint-disable-next-line wrap-iife
async function () {
let releases = await heroku.get(`/apps/${app}/releases`, {
partial: true,
Expand Down
4 changes: 2 additions & 2 deletions packages/addons-v5/commands/addons/destroy.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ async function run(context, heroku) {
for (let app of toPairs(groupBy(addons, 'app.name'))) {
addons = app[1]
app = app[0]
await cli.confirmApp(app, context.flags.confirm) // eslint-disable-line no-await-in-loop
await cli.confirmApp(app, context.flags.confirm)
for (let addon of addons) {
let msg = `Destroying ${cli.color.addon(addon.name)} on ${cli.color.app(addon.app.name)}`
await cli.action(msg, heroku.request({ // eslint-disable-line no-await-in-loop
await cli.action(msg, heroku.request({
method: 'DELETE',
path: `/apps/${addon.app.id}/addons/${addon.id}`,
headers: {'Accept-Expansion': 'plan'},
Expand Down
2 changes: 1 addition & 1 deletion packages/addons-v5/commands/addons/detach.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ async function run(context, heroku) {
await cli.action(
`Unsetting ${cli.color.attachment(attachment.name)} config vars and restarting ${cli.color.app(app)}`,
{success: false},
async function () { // eslint-disable-line wrap-iife
async function () {
let releases = await heroku.request({
path: `/apps/${app}/releases`,
partial: true,
Expand Down
2 changes: 1 addition & 1 deletion packages/addons-v5/commands/addons/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ async function run(ctx, api) {
format: function (addon) {
if (addon.app.name === app) {
return formatPrice(addon.plan.price)
} else { // eslint-disable-line no-else-return
} else {
return style('dim', printf('(billed to %s app)', style('app', addon.app.name)))
}
},
Expand Down
2 changes: 1 addition & 1 deletion packages/addons-v5/commands/addons/info.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ let style = require('../../lib/util').style

let run = cli.command({preauth: true}, function (ctx, api) {
const resolve = require('../../lib/resolve')
return async function () { // eslint-disable-line wrap-iife
return async function () {
let addon = await resolve.addon(api, ctx.app, ctx.args.addon)
let attachments = await api.request({
method: 'GET',
Expand Down
2 changes: 1 addition & 1 deletion packages/addons-v5/commands/addons/rename.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
let cli = require('heroku-cli-util')

let run = cli.command({preauth: true}, function (ctx, api) {
return async function () { // eslint-disable-line wrap-iife
return async function () {
let addon = await api.get(`/addons/${ctx.args.addon}`)
let addonUrl = `/apps/${addon.app.id}/addons/${addon.id}`

Expand Down
3 changes: 1 addition & 2 deletions packages/addons-v5/commands/addons/upgrade.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ It is not clear which add-on's plan you are trying to change.
Specify the add-on name instead of the name of the add-on service.
For example, instead of: ${cli.color.blue('heroku addons:upgrade ' + context.args.addon + ' ' + (context.args.plan || ''))}
Run this: ${cli.color.blue('heroku addons:upgrade ' + example + ' ' + name + ':' + plan)}
${// eslint-disable-next-line no-negated-condition
${
!app ? 'Alternatively, specify an app to filter by with ' + cli.color.blue('--app') : ''
}
${cli.color.cyan('https://devcenter.heroku.com/articles/managing-add-ons')}`)
Expand Down Expand Up @@ -86,7 +86,6 @@ async function run(c, h) {
service = addon.addon_service.name
app = addon.app.name
plan = `${service}:${plan}`
// eslint-disable-next-line wrap-iife
await cli.action(`Changing ${cli.color.magenta(addon.name)} on ${cli.color.cyan(app)} from ${cli.color.blue(addon.plan.name)} to ${cli.color.blue(plan)}`, {success: false}, async function () {
addon = await heroku.request({
path: `/apps/${app}/addons/${addon.name}`,
Expand Down
4 changes: 2 additions & 2 deletions packages/addons-v5/commands/addons/wait.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ async function run(ctx, api) {

addons = addons.filter(addon => addon.state === 'provisioning')

let interval = Number.parseInt(ctx.flags['wait-interval']) // eslint-disable-line radix
let interval = Number.parseInt(ctx.flags['wait-interval'])
if (!interval || interval < 0) {
interval = 5
}

for (let addon of addons) {
const startTime = new Date()
try {
addon = await waitForAddonProvisioning(api, addon, interval) // eslint-disable-line no-await-in-loop
addon = await waitForAddonProvisioning(api, addon, interval)
} catch (error) {
notify(`heroku addons:wait ${addon.name}`, 'Add-on failed to provision', false)
throw error
Expand Down
3 changes: 0 additions & 3 deletions packages/addons-v5/lib/addons_wait.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@ module.exports = async function (api, addon, interval) {
const app = addon.app.name
const addonName = addon.name

// eslint-disable-next-line wrap-iife
await cli.action(`Creating ${cli.color.addon(addon.name)}`, async function () {
while (addon.state === 'provisioning') {
// eslint-disable-next-line no-await-in-loop, no-promise-executor-return
await new Promise(resolve => setTimeout(resolve, interval * 1000))

// eslint-disable-next-line no-await-in-loop
addon = await api.request({
method: 'GET',
path: `/apps/${app}/addons/${addonName}`,
Expand Down
1 change: 0 additions & 1 deletion packages/addons-v5/lib/create_addon.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ function formatConfigVarsMessage(addon) {
if (configVars.length > 0) {
configVars = configVars.map(c => cli.color.configVar(c)).join(', ')
return `Created ${cli.color.addon(addon.name)} as ${configVars}`
// eslint-disable-next-line no-else-return
} else {
return `Created ${cli.color.addon(addon.name)}`
}
Expand Down
3 changes: 0 additions & 3 deletions packages/addons-v5/lib/resolve.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ const appAddon = function (heroku, app, id, options = {}) {
const handleNotFound = function (err, resource) {
if (err.statusCode === 404 && err.body && err.body.resource === resource) {
return true
// eslint-disable-next-line no-else-return
} else {
throw err
}
Expand Down Expand Up @@ -110,7 +109,6 @@ const singularize = function (type, namespace) {
matches = matches.filter(m => m.namespace === namespace)
} else if (matches.length > 1) {
// In cases that aren't specific enough, filter by namespace
// eslint-disable-next-line no-prototype-builtins
matches = matches.filter(m => !m.hasOwnProperty('namespace') || m.namespace === null)
}

Expand Down Expand Up @@ -170,7 +168,6 @@ exports.attachment = function (heroku, app, id, options = {}) {
// If we were passed an add-on slug, there still could be an attachment
// to the context app. Try to find and use it so `context_app` is set
// correctly in the SSO payload.
// eslint-disable-next-line no-else-return
else if (app) {
return exports.addon(heroku, app, id, options)
.then(addon => getAppAddonAttachment(addon, app))
Expand Down
1 change: 0 additions & 1 deletion packages/addons-v5/lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ module.exports = {
},

trapConfirmationRequired: async function (app, confirm, fn) {
// eslint-disable-next-line no-return-await
return await fn(confirm)
.catch(error => {
if (!error.body || error.body.id !== 'confirmation_required') throw error
Expand Down
1 change: 1 addition & 0 deletions packages/addons-v5/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"scripts": {
"lint": "eslint . --ext .js --config ../../.eslintrc --ignore-path ../../.eslintignore",
"postpublish": "rm oclif.manifest.json",
"posttest": "yarn lint",
"prepack": "oclif manifest",
"release": "np",
"test": "nyc mocha",
Expand Down
1 change: 0 additions & 1 deletion packages/addons-v5/test/commands/addons/docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
let cli = require('heroku-cli-util')
let proxyquire = require('proxyquire')
const sinon = require('sinon')
// eslint-disable-next-line @typescript-eslint/no-empty-function
let openStub = sinon.stub(cli, 'open').callsFake(() => {})
let cmd = commands.find(c => c.topic === 'addons' && c.command === 'docs')
let docs
Expand Down
1 change: 0 additions & 1 deletion packages/addons-v5/test/lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ describe('util.formatPrice', function () {
})

it('returns undefined when no pricing information given', function () {
// eslint-disable-next-line unicorn/no-useless-undefined
expect(util.formatPrice(null)).to.eq(undefined)
})
})
1 change: 0 additions & 1 deletion packages/addons-v5/test/opn.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

let opn = function (url) {
opn.url = url
// eslint-disable-next-line no-promise-executor-return
return new Promise(resolve => resolve())
}

Expand Down
1 change: 0 additions & 1 deletion packages/apps/src/commands/domains/clear.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export default class DomainsClear extends Command {
let {body: domains} = await this.heroku.get<Array<Heroku.Domain>>(`/apps/${flags.app}/domains`)
domains = domains.filter((d: Heroku.Domain) => d.kind === 'custom')
for (const domain of domains) {
// eslint-disable-next-line no-await-in-loop
await this.heroku.delete(`/apps/${flags.app}/domains/${domain.hostname}`)
}

Expand Down
1 change: 0 additions & 1 deletion packages/apps/src/commands/domains/wait.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export default class DomainsWait extends Command {
}

for (const domain of domains) {
// eslint-disable-next-line no-await-in-loop
await waitForDomain(flags.app, this.heroku, domain)
}
}
Expand Down
3 changes: 1 addition & 2 deletions packages/apps/src/lib/wait-for-domain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ export default async function waitForDomain(app: string, heroku: APIClient, doma

action.start(`Waiting for ${color.green(domain.hostname || 'domain')}`)
while (domain.status === 'pending') {
// eslint-disable-next-line no-await-in-loop
await CliUx.ux.wait(5000)
// eslint-disable-next-line no-await-in-loop
const {body: updatedDomain} = await heroku.get<Heroku.Domain>(`/apps/${app}/domains/${domain.id}`)
domain = updatedDomain
}

action.stop()
if (domain.status === 'succeeded' || domain.status === 'none') return
throw new Error(`The domain creation finished with status ${domain.status}`)
Expand Down
1 change: 0 additions & 1 deletion packages/buildpacks/src/buildpacks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ export class BuildpackCommand {
}

Result.match({
// eslint-disable-next-line @typescript-eslint/no-empty-function
Ok: _ => {},
Err: err => {
CliUx.ux.error(`Could not find the buildpack: ${buildpack}. ${err}`, {exit: 1})
Expand Down
1 change: 0 additions & 1 deletion packages/buildpacks/src/commands/buildpacks/info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export default class Info extends Command {
const registry = new BuildpackRegistry()

Result.match({
// eslint-disable-next-line @typescript-eslint/no-empty-function
Ok: _ => {},
Err: err => {
this.error(`Could not publish the buildpack.\n${err}`)
Expand Down
2 changes: 0 additions & 2 deletions packages/buildpacks/src/commands/buildpacks/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ export default class Search extends Command {

if (args.term) {
const uniqueBuildpacks = new Map<string, BuildpackBody>()
// eslint-disable-next-line unicorn/no-useless-undefined
const array = ((await registry.search(args.term, undefined, undefined)).unwrapOr([]))
// eslint-disable-next-line unicorn/no-useless-undefined
.concat((await registry.search(undefined, args.term, undefined)).unwrapOr([]))
.concat((await registry.search(undefined, undefined, args.term)).unwrapOr([]))
array
Expand Down
1 change: 0 additions & 1 deletion packages/buildpacks/src/commands/buildpacks/versions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ export default class Versions extends Command {
const registry = new BuildpackRegistry()

Result.match({
// eslint-disable-next-line @typescript-eslint/no-empty-function
Ok: _ => {},
Err: err => {
this.error(`Could not find the buildpack.\n${err}`)
Expand Down
1 change: 0 additions & 1 deletion packages/certs-v5/commands/certs/auto/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ async function run(context, heroku) {
{label: 'Domain', key: 'hostname'},
{label: 'Status', key: 'acm_status', format: humanize},
]
// eslint-disable-next-line unicorn/prefer-array-some
if (domains.find(d => d.acm_status_reason)) {
columns.push({
label: 'Reason',
Expand Down
1 change: 0 additions & 1 deletion packages/certs-v5/commands/certs/chain.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ let cli = require('heroku-cli-util')
// let error = require('../../lib/error.js')
// let readFile = require('../../lib/read_file.js')

// eslint-disable-next-line @typescript-eslint/no-unused-vars
async function run(context) {
// TODO: Fix chain command

Expand Down
5 changes: 0 additions & 5 deletions packages/certs-v5/commands/certs/generate.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable require-atomic-updates */
'use strict'

let cli = require('heroku-cli-util')
Expand All @@ -9,7 +8,6 @@ let endpoints = require('../../lib/endpoints.js').all
function valueEmpty(value) {
if (value) {
return value.length === 0
// eslint-disable-next-line no-else-return
} else {
return true
}
Expand Down Expand Up @@ -51,7 +49,6 @@ function getSubject(context) {

function requiresPrompt(context) {
if (valueEmpty(context.flags.subject)) {
// eslint-disable-next-line unicorn/prevent-abbreviations
let args = [context.flags.owner, context.flags.country, context.flags.area, context.flags.city]
if (!context.flags.now && args.every(function (v) {
return valueEmpty(v)
Expand All @@ -64,14 +61,12 @@ function requiresPrompt(context) {
}

function getCommand(certs, domain) {
// eslint-disable-next-line unicorn/prefer-array-some
if (certs.find(function (f) {
return f.ssl_cert.cert_domains.find(function (d) {
return d === domain
})
})) {
return 'update'
// eslint-disable-next-line no-else-return
} else {
return 'add'
}
Expand Down
1 change: 0 additions & 1 deletion packages/certs-v5/commands/certs/key.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ let cli = require('heroku-cli-util')
// let error = require('../../lib/error.js')
// let readFile = require('../../lib/read_file.js')

// eslint-disable-next-line @typescript-eslint/no-unused-vars
async function run(context) {
// TODO: Fix key command

Expand Down
1 change: 0 additions & 1 deletion packages/certs-v5/commands/certs/remove.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ async function run(context, heroku) {

await cli.confirmApp(context.app, context.flags.confirm, `WARNING: Destructive Action - you cannot rollback this change\nThis command will remove the endpoint ${formattedEndpoint} from ${cli.color.app(context.app)}.`)

// eslint-disable-next-line @typescript-eslint/no-unused-vars
let _ = await cli.action(`Removing SSL certificate ${formattedEndpoint} from ${cli.color.app(context.app)}`, {}, heroku.request({
path: endpoint._meta.path,
method: 'DELETE',
Expand Down
2 changes: 0 additions & 2 deletions packages/certs-v5/lib/display_table.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ let _ = require('lodash')
function type(f) {
if (f.ssl_cert && f.ssl_cert.acm) {
return 'ACM'
// eslint-disable-next-line no-else-return
} else {
return 'SNI'
}
Expand Down Expand Up @@ -44,7 +43,6 @@ module.exports = function (certs) {
columns.push({label: 'Display Name', key: 'display_name'})
}

// eslint-disable-next-line unicorn/prefer-array-some
if (_.find(mapped, row => row.cname)) {
columns = columns.concat([{label: 'Endpoint', key: 'cname', format: function (f) {
return f || '(Not applicable for SNI)'
Expand Down
1 change: 0 additions & 1 deletion packages/certs-v5/lib/display_warnings.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ module.exports = function (endpoint) {
let warnings = endpoint.warnings
if (warnings) {
for (var field in warnings) {
// eslint-disable-next-line no-prototype-builtins
if (warnings.hasOwnProperty(field) && endpoint.warnings[field].length > 0) {
cli.warn(`WARNING: ${field} ${endpoint.warnings[field]}`)
}
Expand Down
Loading

0 comments on commit 2b22b16

Please sign in to comment.