From a11ac9ba51150586f01ad30cc8459b632e627233 Mon Sep 17 00:00:00 2001 From: Evyatar Date: Fri, 4 Oct 2024 22:34:40 -0400 Subject: [PATCH] lint: no-unused --- .eslintrc.js | 17 ++++++++++++----- .../__tests__/hasRemainingTests.test.ts | 3 --- packages/vest/src/core/test/test.memo.ts | 2 +- packages/vest/src/testUtils/TVestMock.ts | 2 +- packages/vest/src/testUtils/partition.ts | 2 +- packages/vest/src/testUtils/testPromise.ts | 2 +- vx/commands/init/prompt/index.js | 2 +- vx/commands/test/test.js | 1 - .../lib/rules/use-use.js | 4 ++-- vx/packageNames.js | 6 ------ vx/scripts/genTsConfig.js | 2 -- vx/scripts/genVitestConfig.js | 2 +- vx/scripts/release/depsTree.js | 1 - vx/scripts/release/steps/publishPackage.js | 7 +------ vx/scripts/release/steps/setNextVersion.js | 8 +------- 15 files changed, 22 insertions(+), 39 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index c786e5384..f11a8803f 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -51,7 +51,7 @@ module.exports = { '@typescript-eslint/no-explicit-any': 'off', '@typescript-eslint/explicit-module-boundary-types': 'off', '@typescript-eslint/no-unused-vars': [ - 1, + 2, { argsIgnorePattern: '^_', varsIgnorePattern: '^_', @@ -113,9 +113,6 @@ module.exports = { ], }, ], - 'vitest/expect-expect': 0, - 'vitest/no-identical-title': 0, - 'vitest/no-standalone-expect': 0, 'max-params': [1, { max: 4 }], 'no-console': 2, 'no-else-return': 1, @@ -127,7 +124,14 @@ module.exports = { 'no-undef': 2, 'no-unneeded-ternary': 2, 'no-unused-expressions': 2, - 'no-unused-vars': 0, + 'no-unused-vars': [ + 2, + { + args: 'after-used', + argsIgnorePattern: '^_', + varsIgnorePattern: '^_', + }, + ], 'no-useless-catch': 2, 'no-useless-computed-key': 2, 'no-useless-return': 2, @@ -144,6 +148,9 @@ module.exports = { minKeys: 4, }, ], + 'vitest/expect-expect': 0, + 'vitest/no-identical-title': 0, + 'vitest/no-standalone-expect': 0, }, settings: { 'import/parsers': { diff --git a/packages/vest/src/core/isolate/IsolateTest/__tests__/hasRemainingTests.test.ts b/packages/vest/src/core/isolate/IsolateTest/__tests__/hasRemainingTests.test.ts index 40a1cc4de..b2c6672ed 100644 --- a/packages/vest/src/core/isolate/IsolateTest/__tests__/hasRemainingTests.test.ts +++ b/packages/vest/src/core/isolate/IsolateTest/__tests__/hasRemainingTests.test.ts @@ -1,15 +1,12 @@ -import { SuiteWalker } from 'SuiteWalker'; import { describe, it, expect, beforeEach } from 'vitest'; import wait from 'wait'; import * as vest from 'vest'; describe('SuiteWalker.useHasRemainingWithTestNameMatching', () => { - let hasRemaining: boolean | null = null; let count = 0; beforeEach(() => { - hasRemaining = null; count = 0; }); describe('When no field specified', () => { diff --git a/packages/vest/src/core/test/test.memo.ts b/packages/vest/src/core/test/test.memo.ts index a6808f00a..65a07bebf 100644 --- a/packages/vest/src/core/test/test.memo.ts +++ b/packages/vest/src/core/test/test.memo.ts @@ -66,7 +66,7 @@ function useGetTestFromCache( return cache(dependencies, cacheAction); } - // FIXME(@ealush 2024-08-12): This is some kind of a hack. Instead organically letting Vest set the next + // FIXME:(@ealush 2024-08-12): This is some kind of a hack. Instead organically letting Vest set the next // child of the isolate, we're forcing it from the outside. // Instead, an ideal solution would probably be to have test.memo be its own isolate // that just injects a historic output from a previous test run. diff --git a/packages/vest/src/testUtils/TVestMock.ts b/packages/vest/src/testUtils/TVestMock.ts index 9d7770654..91c0edf4e 100644 --- a/packages/vest/src/testUtils/TVestMock.ts +++ b/packages/vest/src/testUtils/TVestMock.ts @@ -3,5 +3,5 @@ import * as vest from 'vest'; export type TVestMock = typeof vest; -export type TTestSuiteCallback = (...args: any[]) => void; +export type TTestSuiteCallback = (..._args: any[]) => void; export type TTestSuite = vest.Suite; diff --git a/packages/vest/src/testUtils/partition.ts b/packages/vest/src/testUtils/partition.ts index 8dbbcbaed..598de6405 100644 --- a/packages/vest/src/testUtils/partition.ts +++ b/packages/vest/src/testUtils/partition.ts @@ -1,6 +1,6 @@ export default function partition( array: T[], - predicate: (value: T, _index: number, array: T[]) => boolean, + predicate: (_value: T, _index: number, _array: T[]) => boolean, ): [T[], T[]] { return array.reduce( (partitions: [T[], T[]], value, number) => { diff --git a/packages/vest/src/testUtils/testPromise.ts b/packages/vest/src/testUtils/testPromise.ts index 6887a49d9..916209513 100644 --- a/packages/vest/src/testUtils/testPromise.ts +++ b/packages/vest/src/testUtils/testPromise.ts @@ -1,3 +1,3 @@ -export function TestPromise(cb: (done: () => void) => void): Promise { +export function TestPromise(cb: (_done: () => void) => void): Promise { return new Promise(done => cb(done)); } diff --git a/vx/commands/init/prompt/index.js b/vx/commands/init/prompt/index.js index a74dccbea..b01d3452c 100644 --- a/vx/commands/init/prompt/index.js +++ b/vx/commands/init/prompt/index.js @@ -103,7 +103,7 @@ function updateValues(packagePath, config) { }); } -function removeTemplateExtensionFromFile(packagePath, packageName) { +function removeTemplateExtensionFromFile(packagePath, _packageName) { glob.sync(packagePath + '/**/*.tmpl').forEach(file => { fsExtra.moveSync(file, file.replace('.tmpl', '')); }); diff --git a/vx/commands/test/test.js b/vx/commands/test/test.js index 764cad6ca..0f2e297c2 100644 --- a/vx/commands/test/test.js +++ b/vx/commands/test/test.js @@ -1,7 +1,6 @@ const path = require('path'); const exec = require('vx/exec'); -const opts = require('vx/opts'); const { usePackage } = require('vx/vxContext'); const vxPath = require('vx/vxPath'); diff --git a/vx/eslint-plugin-vest-internal/lib/rules/use-use.js b/vx/eslint-plugin-vest-internal/lib/rules/use-use.js index 3721d4b63..476693318 100644 --- a/vx/eslint-plugin-vest-internal/lib/rules/use-use.js +++ b/vx/eslint-plugin-vest-internal/lib/rules/use-use.js @@ -20,14 +20,14 @@ module.exports = { }, create(context) { return { - [matcher(FUNC_DEC)](node) { + [matcher(FUNC_DEC)]() { const parentFunction = findAncestor(context, FUNC_DEC); if (parentFunction && !parentFunction.id.name.match(USE_MATCHER)) { report(context, parentFunction, parentFunction.id); } }, - [matcher(VAR_DEC)](node) { + [matcher(VAR_DEC)]() { const parentFunction = findAncestor(context, 'ArrowFunctionExpression'); if (parentFunction) { diff --git a/vx/packageNames.js b/vx/packageNames.js index 8d7516a33..b37eff3bf 100644 --- a/vx/packageNames.js +++ b/vx/packageNames.js @@ -1,13 +1,7 @@ -const path = require('path'); - -const glob = require('glob'); - const { sortDependencies } = require('./scripts/release/depsTree'); -const packageJson = require('vx/util/packageJson'); const packageList = require('vx/util/packageList'); const { usePackage } = require('vx/vxContext'); -const vxPath = require('vx/vxPath'); module.exports = Object.defineProperty( { paths: {}, list: [], names: {} }, diff --git a/vx/scripts/genTsConfig.js b/vx/scripts/genTsConfig.js index 777f74ab0..4eaf9354f 100644 --- a/vx/scripts/genTsConfig.js +++ b/vx/scripts/genTsConfig.js @@ -1,5 +1,3 @@ -const path = require('path'); - const { writeJSONSync } = require('fs-extra'); const lodash = require('lodash'); diff --git a/vx/scripts/genVitestConfig.js b/vx/scripts/genVitestConfig.js index f7a8af40d..6071e2bd8 100644 --- a/vx/scripts/genVitestConfig.js +++ b/vx/scripts/genVitestConfig.js @@ -5,7 +5,7 @@ const logger = require('vx/logger'); const opts = require('vx/opts'); const packageNames = require('vx/packageNames'); const packageList = require('vx/util/packageList'); -const { genPathsPerPackage, packages } = require('vx/util/pathsPerPackage'); +const { genPathsPerPackage } = require('vx/util/pathsPerPackage'); const vxPath = require('vx/vxPath'); const VITEST_CONFIG_PATH = 'vx/config/vitest/customMatchers.ts'; diff --git a/vx/scripts/release/depsTree.js b/vx/scripts/release/depsTree.js index af8501c6a..a197ad324 100644 --- a/vx/scripts/release/depsTree.js +++ b/vx/scripts/release/depsTree.js @@ -1,4 +1,3 @@ -const { glob } = require('glob'); const { memoize } = require('lodash'); const packageJson = require('vx/util/packageJson'); diff --git a/vx/scripts/release/steps/publishPackage.js b/vx/scripts/release/steps/publishPackage.js index a2b1ad503..947d344c6 100644 --- a/vx/scripts/release/steps/publishPackage.js +++ b/vx/scripts/release/steps/publishPackage.js @@ -1,13 +1,8 @@ -const { TAG_NEXT, TAG_DEV } = require('../releaseKeywords'); - const exec = require('vx/exec'); const logger = require('vx/logger'); -const opts = require('vx/opts'); const joinTruthy = require('vx/util/joinTruthy'); const taggedBranch = require('vx/util/taggedBranch'); -const { isReleaseBranch } = require('vx/util/taggedBranch'); const { usePackage } = require('vx/vxContext'); -const vxPath = require('vx/vxPath'); function publishPackage({ tag, tagId, versionToPublish }) { logger.info(`🚀 Publishing package ${usePackage()}. @@ -56,6 +51,6 @@ function genPublishCommand(tag) { return [`yarn workspace ${usePackage()} npm publish`, tag && `--tag ${tag}`]; } -function shouldRelease(versionToUse) { +function shouldRelease(_versionToUse) { return taggedBranch.branchAllowsRelease; } diff --git a/vx/scripts/release/steps/setNextVersion.js b/vx/scripts/release/steps/setNextVersion.js index 028cbe434..104cd52d0 100644 --- a/vx/scripts/release/steps/setNextVersion.js +++ b/vx/scripts/release/steps/setNextVersion.js @@ -7,13 +7,7 @@ const packageJson = require('vx/util/packageJson'); const { usePackage } = require('vx/vxContext'); const vxPath = require('vx/vxPath'); -function setNextVersion({ - tagId, - tag, - nextVersion, - versionToPublish, - changeLevel, -}) { +function setNextVersion({ tagId, tag, versionToPublish, changeLevel }) { const packageName = usePackage(); const existingPkgJson = packageJson(packageName);