From 61fd5a44c75733f7ede8199dc8f4d77a160190d9 Mon Sep 17 00:00:00 2001 From: Ryan Manuel Date: Thu, 23 Mar 2023 11:19:32 -0500 Subject: [PATCH 1/3] chore: add linting to the scripts directory --- .eslintrc.js | 1 + package.json | 2 +- scripts/add-install-comment.js | 2 -- scripts/after-pack-hook.js | 1 - scripts/after-sign-hook.js | 2 -- scripts/binary.js | 1 - scripts/binary/binary-cleanup.js | 3 --- scripts/binary/index.js | 1 - scripts/binary/util/transform-requires.js | 3 --- scripts/check-node-version.js | 2 -- scripts/check-terminal.js | 1 - scripts/circle-cache.js | 1 - scripts/circle-env.js | 1 - scripts/cypress.js | 1 - scripts/get-next-version.js | 2 -- scripts/get-platform-key.js | 1 - scripts/github-actions/semantic-pull-request/index.js | 1 - scripts/github-actions/update-browser-versions.js | 2 -- scripts/gulp/tasks/gulpGraphql.ts | 4 +++- scripts/gulp/utils/childProcessUtils.ts | 3 --- scripts/import.js | 2 -- scripts/npm-release.js | 1 - scripts/prepare-release-artifacts.js | 1 - scripts/semantic-commits/get-binary-release-data.js | 1 - scripts/semantic-commits/get-current-release-data.js | 1 - scripts/semantic-commits/parse-changelog.js | 1 - scripts/semantic-commits/validate-binary-changelog.js | 1 - scripts/semantic-commits/validate-changelog.js | 1 - scripts/sync-exported-npm-with-cli.js | 1 - scripts/type_check.js | 1 - scripts/unit/github-actions/update-browser-version-spec.js | 1 - scripts/unit/npm-release-spec.js | 4 ---- scripts/unit/semantic-commits/validate-changelog-spec.js | 1 - scripts/utils.js | 2 -- scripts/verify-mocha-results.js | 2 -- scripts/wait-on-circle-jobs.js | 2 -- 36 files changed, 5 insertions(+), 53 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 12aa005137ac..5c469c301940 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -57,6 +57,7 @@ module.exports = { rules: { 'no-restricted-properties': 'off', 'no-restricted-syntax': 'off', + 'no-console': 'off', }, }, ], diff --git a/package.json b/package.json index b6f539808d92..05fdc95a4730 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "ensure-deps": "./scripts/ensure-dependencies.sh", "get-next-version": "node scripts/get-next-version.js", "postinstall": "node ./scripts/run-postInstall.js", - "lint": "lerna run lint --no-bail --concurrency 2", + "lint": "lerna run lint --no-bail --concurrency 2 && eslint --ext .js,.ts,.json, scripts", "prepare-release-artifacts": "node ./scripts/prepare-release-artifacts.js", "npm-release": "node scripts/npm-release.js", "prestart": "yarn ensure-deps", diff --git a/scripts/add-install-comment.js b/scripts/add-install-comment.js index 7a0d3c4e5d67..c90cc7a7f2d3 100644 --- a/scripts/add-install-comment.js +++ b/scripts/add-install-comment.js @@ -14,8 +14,6 @@ const { Octokit } = require('@octokit/core') const { createAppAuth } = require('@octokit/auth-app') const { stripIndent } = require('common-tags') -/* eslint-disable no-console */ - const { npm, binary } = getNameAndBinary(process.argv) la(is.unemptyString(npm), 'missing npm url') diff --git a/scripts/after-pack-hook.js b/scripts/after-pack-hook.js index fa28fe6d289e..cb1c776456ea 100644 --- a/scripts/after-pack-hook.js +++ b/scripts/after-pack-hook.js @@ -1,4 +1,3 @@ -/* eslint-disable no-console */ const fs = require('fs-extra') const { join } = require('path') const glob = require('glob') diff --git a/scripts/after-sign-hook.js b/scripts/after-sign-hook.js index 9280cccd2f0b..d40d11b6b2da 100644 --- a/scripts/after-sign-hook.js +++ b/scripts/after-sign-hook.js @@ -5,8 +5,6 @@ const fs = require('fs') const path = require('path') let electron_notarize = require('electron-notarize') -/* eslint-disable no-console */ - module.exports = async function (params) { // Only notarize the app on Mac OS. if (process.platform !== 'darwin') { diff --git a/scripts/binary.js b/scripts/binary.js index 6c83caca8cb8..be5a4925d53b 100644 --- a/scripts/binary.js +++ b/scripts/binary.js @@ -1,4 +1,3 @@ -/* eslint-disable no-console */ require('@packages/ts/register') const command = process.argv[2] diff --git a/scripts/binary/binary-cleanup.js b/scripts/binary/binary-cleanup.js index 507d35b6911d..73bcb11532f1 100644 --- a/scripts/binary/binary-cleanup.js +++ b/scripts/binary/binary-cleanup.js @@ -132,12 +132,10 @@ const createServerEntryPointBundle = async (buildAppDir) => { ], }) - // eslint-disable-next-line no-console console.log(`copying server entry point bundle from ${path.join(workingDir, 'index.js')} to ${path.join(buildAppDir, 'packages', 'server', 'index.js')}`) await fs.copy(path.join(workingDir, 'index.js'), path.join(buildAppDir, 'packages', 'server', 'index.js')) - // eslint-disable-next-line no-console console.log(`compiling server entry point bundle to ${path.join(buildAppDir, 'packages', 'server', 'index.jsc')}`) // Use bytenode to compile the entry point bundle. This will save time on the v8 compile step and ensure the integrity of the entry point @@ -171,7 +169,6 @@ const buildEntryPointAndCleanup = async (buildAppDir) => { ...serverEntryPointBundleDependencies, ] - // eslint-disable-next-line no-console console.log(`potentially removing ${potentiallyRemovedDependencies.length} dependencies`) // 4. Remove all dependencies that are in the snapshot but not in the list of kept dependencies from the binary diff --git a/scripts/binary/index.js b/scripts/binary/index.js index d90a5985c26a..04a34baa0bae 100644 --- a/scripts/binary/index.js +++ b/scripts/binary/index.js @@ -1,4 +1,3 @@ -/* eslint-disable no-console */ // store the cwd const cwd = process.cwd() diff --git a/scripts/binary/util/transform-requires.js b/scripts/binary/util/transform-requires.js index 1900cb2a7170..9259a86dbb60 100644 --- a/scripts/binary/util/transform-requires.js +++ b/scripts/binary/util/transform-requires.js @@ -22,11 +22,8 @@ const rewritePackageNames = (fileStr, buildRoot, filePath, onFound) => { const replaceString = `${match[1]}${replaceWith}${afterPkg}` - // eslint-disable-next-line no-console console.log() - // eslint-disable-next-line no-console console.log('resolve:', chalk.grey(pkgPath), '\nfrom:', chalk.grey(filePath)) - // eslint-disable-next-line no-console console.log(chalk.yellow(`@packages/${pkg}`), '->', chalk.green(replaceWith)) onFound && onFound(replaceString) diff --git a/scripts/check-node-version.js b/scripts/check-node-version.js index e0ca324b7ca1..d4537319733e 100644 --- a/scripts/check-node-version.js +++ b/scripts/check-node-version.js @@ -13,12 +13,10 @@ const nodeVersion = process.versions.node.split('.') // check just major version for now if (nodeVersionNeeded[0] !== nodeVersion[0]) { - /* eslint-disable no-console */ console.error('🛑 .node-version specified %s', nodeVersionNeededString) console.error('but current Node is %s', process.versions.node) /* eslint-enable no-console */ process.exit(1) } -// eslint-disable-next-line no-console console.log('✅ current Node version of %s matches the version specified in the .node-version file', process.versions.node) diff --git a/scripts/check-terminal.js b/scripts/check-terminal.js index 0a12b122d037..56468fe4b7b9 100644 --- a/scripts/check-terminal.js +++ b/scripts/check-terminal.js @@ -9,6 +9,5 @@ if (isMainLinux) { assert.ok(process.env.COLUMNS === '100', `process.env.COLUMNS=${process.env.COLUMNS} must be set to 100 for snapshots to pass`) -/* eslint-disable no-console */ console.log('stdout.isTTY?', process.stdout.isTTY) console.log('stderr.isTTY?', process.stderr.isTTY) diff --git a/scripts/circle-cache.js b/scripts/circle-cache.js index 47ce7276677d..5b3692c7ac1d 100644 --- a/scripts/circle-cache.js +++ b/scripts/circle-cache.js @@ -1,4 +1,3 @@ -/* eslint-disable no-console */ const glob = require('glob') const path = require('path') const fsExtra = require('fs-extra') diff --git a/scripts/circle-env.js b/scripts/circle-env.js index 57a64bbde5ee..09d650fb46f6 100644 --- a/scripts/circle-env.js +++ b/scripts/circle-env.js @@ -1,4 +1,3 @@ -/* eslint-disable no-console */ const fs = require('fs').promises async function loadInternalTaskData () { diff --git a/scripts/cypress.js b/scripts/cypress.js index 100a9142cc5c..e1562071c8bc 100644 --- a/scripts/cypress.js +++ b/scripts/cypress.js @@ -23,7 +23,6 @@ debug('starting the CLI in dev mode with args %o', { const exit = ({ exitCode }) => { if (typeof exitCode !== 'number') { - // eslint-disable-next-line no-console console.error(`missing exit code from execa (received ${exitCode})`) process.exit(1) } diff --git a/scripts/get-next-version.js b/scripts/get-next-version.js index 2f71f5c6f159..ffa5280757b2 100644 --- a/scripts/get-next-version.js +++ b/scripts/get-next-version.js @@ -1,5 +1,3 @@ -/* eslint-disable no-console */ - const path = require('path') const semver = require('semver') const bumpCb = require('conventional-recommended-bump') diff --git a/scripts/get-platform-key.js b/scripts/get-platform-key.js index be3f31b7afa2..b34090a7548a 100644 --- a/scripts/get-platform-key.js +++ b/scripts/get-platform-key.js @@ -1,3 +1,2 @@ // generate a unique key for each platform+arch combo in CI -// eslint-disable-next-line no-console console.log(`${process.platform}-${process.arch}`) diff --git a/scripts/github-actions/semantic-pull-request/index.js b/scripts/github-actions/semantic-pull-request/index.js index 36dc69102f45..cc980340c21f 100644 --- a/scripts/github-actions/semantic-pull-request/index.js +++ b/scripts/github-actions/semantic-pull-request/index.js @@ -1,4 +1,3 @@ -/* eslint-disable no-console */ const { validatePrTitle } = require('./validate-pr-title') const { validateChangelog } = require('../../semantic-commits/validate-changelog') const { getLinkedIssues } = require('../../semantic-commits/get-linked-issues') diff --git a/scripts/github-actions/update-browser-versions.js b/scripts/github-actions/update-browser-versions.js index 0ac53782b46c..641ecd594822 100644 --- a/scripts/github-actions/update-browser-versions.js +++ b/scripts/github-actions/update-browser-versions.js @@ -61,7 +61,6 @@ const getVersions = async ({ core }) => { core.setOutput('latest_beta_version', betaData.version) core.setOutput('description', description) } catch (err) { - // eslint-disable-next-line no-console console.log('Errored checking for new Chrome versions:', err.stack) core.setOutput('has_update', 'false') } @@ -96,7 +95,6 @@ const updatePRTitle = async ({ context, github, baseBranch, branchName, descript }) if (!data.length) { - // eslint-disable-next-line no-console console.log('Could not find PR for branch:', branchName) return diff --git a/scripts/gulp/tasks/gulpGraphql.ts b/scripts/gulp/tasks/gulpGraphql.ts index 06a784fc24cd..e40440499888 100644 --- a/scripts/gulp/tasks/gulpGraphql.ts +++ b/scripts/gulp/tasks/gulpGraphql.ts @@ -98,7 +98,9 @@ export async function syncRemoteGraphQL () { // TODO(tim): fix await fs.ensureDir(path.join(monorepoPaths.pkgGraphql, 'src/gen')) await fs.promises.writeFile(path.join(monorepoPaths.pkgGraphql, 'schemas/cloud.graphql'), body) - } catch {} + } catch (error) { + console.error('Could not sync remote GraphQL schema', error) + } } /** diff --git a/scripts/gulp/utils/childProcessUtils.ts b/scripts/gulp/utils/childProcessUtils.ts index 093b6a2f9935..c8df85c27449 100644 --- a/scripts/gulp/utils/childProcessUtils.ts +++ b/scripts/gulp/utils/childProcessUtils.ts @@ -173,19 +173,16 @@ export const execAsync = async ( const { silent } = options if (!silent) { - // eslint-disable-next-line no-console console.log(command) } const result = await execAsyncLocal(command, options) if (!silent && typeof result.stdout === 'string' && result.stdout.length) { - // eslint-disable-next-line no-console console.log(result.stdout) } if (!silent && typeof result.stderr === 'string' && result.stderr.length) { - // eslint-disable-next-line no-console console.error(result.stderr) } diff --git a/scripts/import.js b/scripts/import.js index 41cc2bfd01c0..76f893d431c1 100644 --- a/scripts/import.js +++ b/scripts/import.js @@ -1,5 +1,3 @@ -/* eslint-disable no-console */ - /* Usage - All arguments are required --from local path to repository to import diff --git a/scripts/npm-release.js b/scripts/npm-release.js index 70f4baf5de8b..8c2cb9213687 100644 --- a/scripts/npm-release.js +++ b/scripts/npm-release.js @@ -2,7 +2,6 @@ * To easily test if your release will apply locally, you can run: * yarn test-npm-package-release-script */ -/* eslint-disable no-console */ const execa = require('execa') const fs = require('fs') const semverSortNewestFirst = require('semver/functions/rcompare') diff --git a/scripts/prepare-release-artifacts.js b/scripts/prepare-release-artifacts.js index b82661b21542..1f213f890111 100644 --- a/scripts/prepare-release-artifacts.js +++ b/scripts/prepare-release-artifacts.js @@ -11,7 +11,6 @@ if (!/^\d+\.\d+\.\d+$/.test(args.version)) { throw new Error('A valid semantic version (X.Y.Z) must be passed in `--version`.') } -// eslint-disable-next-line no-console const log = (...args) => console.log('🏗', ...args) const exec = args['dry-run'] ? diff --git a/scripts/semantic-commits/get-binary-release-data.js b/scripts/semantic-commits/get-binary-release-data.js index a2a4dad8aad5..63281e88cbdc 100644 --- a/scripts/semantic-commits/get-binary-release-data.js +++ b/scripts/semantic-commits/get-binary-release-data.js @@ -1,4 +1,3 @@ -/* eslint-disable no-console */ const childProcess = require('child_process') const _ = require('lodash') const { Octokit } = require('@octokit/core') diff --git a/scripts/semantic-commits/get-current-release-data.js b/scripts/semantic-commits/get-current-release-data.js index ad35bf15b5cc..d7aef9342655 100644 --- a/scripts/semantic-commits/get-current-release-data.js +++ b/scripts/semantic-commits/get-current-release-data.js @@ -1,4 +1,3 @@ -/* eslint-disable no-console */ const childProcess = require('child_process') /** diff --git a/scripts/semantic-commits/parse-changelog.js b/scripts/semantic-commits/parse-changelog.js index f2bf54e90193..e9e3d7e84439 100644 --- a/scripts/semantic-commits/parse-changelog.js +++ b/scripts/semantic-commits/parse-changelog.js @@ -1,4 +1,3 @@ -/* eslint-disable no-console */ const fs = require('fs') const path = require('path') const { userFacingChanges } = require('./change-categories') diff --git a/scripts/semantic-commits/validate-binary-changelog.js b/scripts/semantic-commits/validate-binary-changelog.js index b24793e92128..094d8df20a50 100644 --- a/scripts/semantic-commits/validate-binary-changelog.js +++ b/scripts/semantic-commits/validate-binary-changelog.js @@ -1,4 +1,3 @@ -/* eslint-disable no-console */ const fs = require('fs') const path = require('path') const { validateChangelog } = require('./validate-changelog') diff --git a/scripts/semantic-commits/validate-changelog.js b/scripts/semantic-commits/validate-changelog.js index 845cd6f53a31..a232efc30513 100644 --- a/scripts/semantic-commits/validate-changelog.js +++ b/scripts/semantic-commits/validate-changelog.js @@ -1,4 +1,3 @@ -/* eslint-disable no-console */ const { userFacingChanges } = require('./change-categories') const { parseChangelog } = require('./parse-changelog') diff --git a/scripts/sync-exported-npm-with-cli.js b/scripts/sync-exported-npm-with-cli.js index 8a894317a5dd..42518dafab2d 100644 --- a/scripts/sync-exported-npm-with-cli.js +++ b/scripts/sync-exported-npm-with-cli.js @@ -75,7 +75,6 @@ packlist({ path: currentPackageDir }) const output = `${JSON.stringify(cliPackageConfig, null, 2) }\n` - // eslint-disable-next-line no-console console.log('Writing to CLI package.json for', exportName) fs.writeFileSync(path.join(cliPath, 'package.json'), output, 'utf-8') diff --git a/scripts/type_check.js b/scripts/type_check.js index 54bf027dd1ac..2cb84b834b2e 100644 --- a/scripts/type_check.js +++ b/scripts/type_check.js @@ -76,7 +76,6 @@ program }) const log = (msg) => { - // eslint-disable-next-line no-console console.log(msg) } diff --git a/scripts/unit/github-actions/update-browser-version-spec.js b/scripts/unit/github-actions/update-browser-version-spec.js index 376906c35f80..d9fc1352d14c 100644 --- a/scripts/unit/github-actions/update-browser-version-spec.js +++ b/scripts/unit/github-actions/update-browser-version-spec.js @@ -350,7 +350,6 @@ describe('update browser version github action', () => { }) expect(github.pulls.update).not.to.be.called - // eslint-disable-next-line no-console expect(console.log).to.be.calledWith('Could not find PR for branch:', 'some-branch-name') }) }) diff --git a/scripts/unit/npm-release-spec.js b/scripts/unit/npm-release-spec.js index cc0dd36c9348..73c5d69ad1a8 100644 --- a/scripts/unit/npm-release-spec.js +++ b/scripts/unit/npm-release-spec.js @@ -373,7 +373,6 @@ describe('semantic release', () => { execaStub.returns({ stdout: 'the stdout' }) await releasePackages(['package-1', 'package-2']) - /* eslint-disable no-console */ expect(console.log).to.be.calledWith('Released package-1 successfully:') expect(console.log).to.be.calledWith('Released package-2 successfully:') expect(console.log).to.be.calledWith('the stdout') @@ -408,7 +407,6 @@ describe('semantic release', () => { await releasePackages(['package-1', 'package-2']) - /* eslint-disable no-console */ expect(console.log).to.be.calledWith('Releasing package-1 failed:') expect(console.log).to.be.calledWith('could not release package-1') expect(console.log).to.be.calledWith('Released package-2 successfully:') @@ -422,7 +420,6 @@ describe('semantic release', () => { execaStub.returns({ stdout: 'the stdout' }) await releasePackages(['package-1', 'package-2']) - /* eslint-disable no-console */ expect(console.log).to.be.calledWith('\nAll packages released successfully') /* eslint-enable no-console */ }) @@ -443,7 +440,6 @@ describe('semantic release', () => { await releasePackages(['package-1', 'package-2', 'package-3']) - /* eslint-disable no-console */ expect(console.log).to.be.calledWith(` The following packages failed to release: - package-1 diff --git a/scripts/unit/semantic-commits/validate-changelog-spec.js b/scripts/unit/semantic-commits/validate-changelog-spec.js index ab9e9977a170..d00e175ecf5e 100644 --- a/scripts/unit/semantic-commits/validate-changelog-spec.js +++ b/scripts/unit/semantic-commits/validate-changelog-spec.js @@ -1,4 +1,3 @@ -/* eslint-disable no-console */ const { expect, use } = require('chai') const sinonChai = require('sinon-chai') const sinon = require('sinon') diff --git a/scripts/utils.js b/scripts/utils.js index 655d38d9b68c..753adaedf403 100644 --- a/scripts/utils.js +++ b/scripts/utils.js @@ -5,8 +5,6 @@ const path = require('path') const fs = require('fs') const execa = require('execa') -/* eslint-disable no-console */ - function getNameAndBinary (args = process.argv) { const options = minimist(args) diff --git a/scripts/verify-mocha-results.js b/scripts/verify-mocha-results.js index 3637bb796b3c..7fa5bdd4e833 100644 --- a/scripts/verify-mocha-results.js +++ b/scripts/verify-mocha-results.js @@ -1,5 +1,3 @@ -/* eslint-disable no-console */ - // this is a safety script to ensure that Mocha tests ran, by checking: // 1. that there are N test results in the reports dir (or at least 1, if N is not set) // 2. each of them contains 0 failures and >0 tests diff --git a/scripts/wait-on-circle-jobs.js b/scripts/wait-on-circle-jobs.js index 945b30f04280..3fa64497396f 100644 --- a/scripts/wait-on-circle-jobs.js +++ b/scripts/wait-on-circle-jobs.js @@ -1,5 +1,3 @@ -/* eslint-disable no-console */ - const _ = require('lodash') const minimist = require('minimist') const Promise = require('bluebird') From be4a9469f10c8860297c7b0bf317b43e9aa790a0 Mon Sep 17 00:00:00 2001 From: Ryan Manuel Date: Thu, 23 Mar 2023 11:23:59 -0500 Subject: [PATCH 2/3] chore: add linting to the scripts directory --- scripts/check-node-version.js | 1 - scripts/unit/npm-release-spec.js | 4 ---- 2 files changed, 5 deletions(-) diff --git a/scripts/check-node-version.js b/scripts/check-node-version.js index d4537319733e..e6de28eac4a1 100644 --- a/scripts/check-node-version.js +++ b/scripts/check-node-version.js @@ -15,7 +15,6 @@ const nodeVersion = process.versions.node.split('.') if (nodeVersionNeeded[0] !== nodeVersion[0]) { console.error('🛑 .node-version specified %s', nodeVersionNeededString) console.error('but current Node is %s', process.versions.node) - /* eslint-enable no-console */ process.exit(1) } diff --git a/scripts/unit/npm-release-spec.js b/scripts/unit/npm-release-spec.js index 73c5d69ad1a8..d71740b5a1d2 100644 --- a/scripts/unit/npm-release-spec.js +++ b/scripts/unit/npm-release-spec.js @@ -376,7 +376,6 @@ describe('semantic release', () => { expect(console.log).to.be.calledWith('Released package-1 successfully:') expect(console.log).to.be.calledWith('Released package-2 successfully:') expect(console.log).to.be.calledWith('the stdout') - /* eslint-enable no-console */ }) it('failures of one package release do not prevent subsequent package releases', async () => { @@ -411,7 +410,6 @@ describe('semantic release', () => { expect(console.log).to.be.calledWith('could not release package-1') expect(console.log).to.be.calledWith('Released package-2 successfully:') expect(console.log).to.be.calledWith('the stdout') - /* eslint-enable no-console */ }) it('logs success when all release succeed', async () => { @@ -421,7 +419,6 @@ describe('semantic release', () => { await releasePackages(['package-1', 'package-2']) expect(console.log).to.be.calledWith('\nAll packages released successfully') - /* eslint-enable no-console */ }) it('logs failure when one or more releases fail', async () => { @@ -444,7 +441,6 @@ describe('semantic release', () => { The following packages failed to release: - package-1 - package-3`) - /* eslint-enable no-console */ }) it('returns 0 when all releases succeed', async () => { From 4196669a427ca296bdb00c36718657343fa973b7 Mon Sep 17 00:00:00 2001 From: Ryan Manuel Date: Thu, 23 Mar 2023 11:27:27 -0500 Subject: [PATCH 3/3] remove last no-console --- scripts/get-browser-version.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/get-browser-version.js b/scripts/get-browser-version.js index 342dcf0b3f5e..08b5c08cc1d5 100644 --- a/scripts/get-browser-version.js +++ b/scripts/get-browser-version.js @@ -1,4 +1,4 @@ const versions = require('../browser-versions') const channel = process.argv[2] -process.stdout.write(versions[channel]) //eslint-disable-line no-console +process.stdout.write(versions[channel])