diff --git a/eslint.config.cjs b/eslint.config.cjs index 644791d452..72ec919f30 100644 --- a/eslint.config.cjs +++ b/eslint.config.cjs @@ -13,8 +13,9 @@ const lodashPlugin = require('eslint-plugin-lodash'); const mochaPlugin = require('eslint-plugin-mocha'); const prettierPluginRecommended = require('eslint-plugin-prettier/recommended'); const securityPlugin = require('eslint-plugin-security'); +const path = require('path'); -module.exports = [ +module.exports = config = [ // Base configurations. eslint.configs.recommended, ...tseslint.configs.recommended, @@ -193,3 +194,18 @@ module.exports = [ }, }, ]; + +// Apply only to repository tools. +if ( + ['testing', 'tools', 'tsup', 'botbuilder-vendors', 'botbuilder-repo-utils'].some((tool) => + process.cwd().includes(`${path.sep}${tool}`), + ) +) { + config.push({ + rules: { + 'security/detect-non-literal-fs-filename': 'off', + 'mocha/no-exports': 'off', + 'mocha/no-top-level-hooks': 'off', + }, + }); +} diff --git a/testing/bot-integration/eslint.config.cjs b/testing/bot-integration/eslint.config.cjs deleted file mode 100644 index 63647b52cc..0000000000 --- a/testing/bot-integration/eslint.config.cjs +++ /dev/null @@ -1,10 +0,0 @@ -const onlyWarn = require("eslint-plugin-only-warn"); -const sharedConfig = require("../../eslint.config.cjs") - -module.exports = [ - ...sharedConfig, - { - plugins: { - "only-warn": onlyWarn, - }, - }]; diff --git a/testing/bot-integration/package.json b/testing/bot-integration/package.json index ca6145f0df..14d8cda9a3 100644 --- a/testing/bot-integration/package.json +++ b/testing/bot-integration/package.json @@ -6,15 +6,14 @@ "scripts": { "build": "tsc -b", "clean": "rimraf lib tsconfig.tsbuildinfo", - "lint": "eslint .", + "lint": "eslint . --config ../../eslint.config.cjs", "test": "yarn build && mocha **/*.test.js" }, "author": "Microsoft Corp.", "license": "MIT", "dependencies": { "botbuilder": "4.1.6", - "botframework-connector": "4.1.6", - "eslint-plugin-only-warn": "^1.1.0" + "botframework-connector": "4.1.6" }, "devDependencies": { "@types/express": "^4.17.21", diff --git a/testing/bot-integration/src/channelServiceRoutes.test.ts b/testing/bot-integration/src/channelServiceRoutes.test.ts index 7bf367d5c6..2ed505b127 100644 --- a/testing/bot-integration/src/channelServiceRoutes.test.ts +++ b/testing/bot-integration/src/channelServiceRoutes.test.ts @@ -10,13 +10,12 @@ describe('ChannelServiceRoutes - Integration Tests', function () { const app = express(); const handler = new ChannelServiceHandler( new SimpleCredentialProvider('', ''), - new AuthenticationConfiguration() + new AuthenticationConfiguration(), ); const routes = new ChannelServiceRoutes(handler); routes.register(app); - // eslint-disable-next-line @typescript-eslint/no-explicit-any const bfRoutes = (app._router.stack as Array).filter((layer) => { const route: express.IRoute = layer.route; if (route) { @@ -31,13 +30,12 @@ describe('ChannelServiceRoutes - Integration Tests', function () { const app = express(); const handler = new ChannelServiceHandler( new SimpleCredentialProvider('', ''), - new AuthenticationConfiguration() + new AuthenticationConfiguration(), ); const routes = new ChannelServiceRoutes(handler); routes.register(app, '/test'); - // eslint-disable-next-line @typescript-eslint/no-explicit-any const bfRoutes = (app._router.stack as Array).filter((layer) => { const route: express.IRoute = layer.route; if (route) { @@ -52,7 +50,7 @@ describe('ChannelServiceRoutes - Integration Tests', function () { const server = createServer(); const handler = new ChannelServiceHandler( new SimpleCredentialProvider('', ''), - new AuthenticationConfiguration() + new AuthenticationConfiguration(), ); const routes = new ChannelServiceRoutes(handler); @@ -76,7 +74,7 @@ describe('ChannelServiceRoutes - Integration Tests', function () { const server = createServer(); const handler = new ChannelServiceHandler( new SimpleCredentialProvider('', ''), - new AuthenticationConfiguration() + new AuthenticationConfiguration(), ); const routes = new ChannelServiceRoutes(handler); diff --git a/testing/botbuilder-test-utils/eslint.config.cjs b/testing/botbuilder-test-utils/eslint.config.cjs deleted file mode 100644 index 63647b52cc..0000000000 --- a/testing/botbuilder-test-utils/eslint.config.cjs +++ /dev/null @@ -1,10 +0,0 @@ -const onlyWarn = require("eslint-plugin-only-warn"); -const sharedConfig = require("../../eslint.config.cjs") - -module.exports = [ - ...sharedConfig, - { - plugins: { - "only-warn": onlyWarn, - }, - }]; diff --git a/testing/botbuilder-test-utils/package.json b/testing/botbuilder-test-utils/package.json index a916d59af8..f4c0c5772d 100644 --- a/testing/botbuilder-test-utils/package.json +++ b/testing/botbuilder-test-utils/package.json @@ -7,7 +7,7 @@ "scripts": { "build": "tsc -b", "clean": "rimraf lib tsconfig.tsbuildinfo", - "lint": "eslint ." + "lint": "eslint . --config ../../eslint.config.cjs" }, "peerDependencies": { "jsonwebtoken": "*", @@ -19,7 +19,6 @@ "@types/node-forge": "^1.3.11" }, "dependencies": { - "eslint-plugin-only-warn": "^1.1.0", "node-forge": "^1.3.1", "zod": "^3.23.8" } diff --git a/testing/botbuilder-test-utils/src/jwt.ts b/testing/botbuilder-test-utils/src/jwt.ts index 9f05a82019..bf2c3919ff 100644 --- a/testing/botbuilder-test-utils/src/jwt.ts +++ b/testing/botbuilder-test-utils/src/jwt.ts @@ -13,10 +13,18 @@ import { randomUUID } from 'crypto'; * Registers mocha hooks for proper usage */ export function mocha(): void { - before(() => nock.disableNetConnect()); - beforeEach(() => nock.cleanAll()); - after(() => nock.enableNetConnect()); - afterEach(() => nock.cleanAll()); + before(function () { + nock.disableNetConnect(); + }); + beforeEach(function () { + nock.cleanAll(); + }); + after(function () { + nock.enableNetConnect(); + }); + afterEach(function () { + nock.cleanAll(); + }); } export type Options = { @@ -44,7 +52,6 @@ export type Result = { // encodes a forge big int as a base64 string const encodeBigInt = (bigInt: forge.jsbn.BigInteger): string => // Note: the @types declarations for forge are wrong, `toString` does take a base. - // eslint-disable-next-line @typescript-eslint/no-explicit-any forge.util.encode64(forge.util.hexToBytes((bigInt as any).toString(16))); const formatHost = (url: url.Url): string => `${url.protocol}//${url.host}`; diff --git a/testing/botbuilder-test-utils/src/oauth.ts b/testing/botbuilder-test-utils/src/oauth.ts index 2a87e26e7e..f9508ac864 100644 --- a/testing/botbuilder-test-utils/src/oauth.ts +++ b/testing/botbuilder-test-utils/src/oauth.ts @@ -8,10 +8,18 @@ import nock from 'nock'; // eslint-disable-line import/no-extraneous-dependencie * Registers mocha hooks for proper usage */ export function mocha(): void { - before(() => nock.disableNetConnect()); - beforeEach(() => nock.cleanAll()); - after(() => nock.enableNetConnect()); - afterEach(() => nock.cleanAll()); + before(function () { + nock.disableNetConnect(); + }); + beforeEach(function () { + nock.cleanAll(); + }); + after(function () { + nock.enableNetConnect(); + }); + afterEach(function () { + nock.cleanAll(); + }); } export type Options = { diff --git a/testing/consumer-test/eslint.config.cjs b/testing/consumer-test/eslint.config.cjs deleted file mode 100644 index 63647b52cc..0000000000 --- a/testing/consumer-test/eslint.config.cjs +++ /dev/null @@ -1,10 +0,0 @@ -const onlyWarn = require("eslint-plugin-only-warn"); -const sharedConfig = require("../../eslint.config.cjs") - -module.exports = [ - ...sharedConfig, - { - plugins: { - "only-warn": onlyWarn, - }, - }]; diff --git a/testing/consumer-test/package.json b/testing/consumer-test/package.json index 70023e1613..43bb9cba28 100644 --- a/testing/consumer-test/package.json +++ b/testing/consumer-test/package.json @@ -3,7 +3,7 @@ "private": true, "version": "1.0.0", "scripts": { - "lint": "eslint .", + "lint": "eslint . --config ../../eslint.config.cjs", "test": "npm-run-all test:gen test:mocha", "test:gen": "ts-node ./generateTests.ts", "test:mocha": "mocha ./tests/generated/*.test.js --parallel" @@ -36,8 +36,7 @@ "botframework-config": "4.1.6", "botframework-connector": "4.1.6", "botframework-schema": "4.1.6", - "botframework-streaming": "4.1.6", - "eslint-plugin-only-warn": "^1.1.0" + "botframework-streaming": "4.1.6" }, "devDependencies": { "mocha": "^10.7.3" diff --git a/yarn.lock b/yarn.lock index 59d35d3abe..53233fc3f6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8061,11 +8061,6 @@ eslint-plugin-mocha@^10.5.0: globals "^13.24.0" rambda "^7.4.0" -eslint-plugin-only-warn@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/eslint-plugin-only-warn/-/eslint-plugin-only-warn-1.1.0.tgz#c6ddc37ddc4e72c121f07be565fcb7b6671fe78a" - integrity sha512-2tktqUAT+Q3hCAU0iSf4xAN1k9zOpjK5WO8104mB0rT/dGhOa09582HN5HlbxNbPRZ0THV7nLGvzugcNOSjzfA== - eslint-plugin-prettier@^5.2.1: version "5.2.1" resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-5.2.1.tgz#d1c8f972d8f60e414c25465c163d16f209411f95"