Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Remaining ESLint issues #4846

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion eslint.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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',
},
});
}
10 changes: 0 additions & 10 deletions testing/bot-integration/eslint.config.cjs

This file was deleted.

5 changes: 2 additions & 3 deletions testing/bot-integration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
10 changes: 4 additions & 6 deletions testing/bot-integration/src/channelServiceRoutes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<any>).filter((layer) => {
const route: express.IRoute = layer.route;
if (route) {
Expand All @@ -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<any>).filter((layer) => {
const route: express.IRoute = layer.route;
if (route) {
Expand All @@ -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);

Expand All @@ -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);

Expand Down
10 changes: 0 additions & 10 deletions testing/botbuilder-test-utils/eslint.config.cjs

This file was deleted.

3 changes: 1 addition & 2 deletions testing/botbuilder-test-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"scripts": {
"build": "tsc -b",
"clean": "rimraf lib tsconfig.tsbuildinfo",
"lint": "eslint ."
"lint": "eslint . --config ../../eslint.config.cjs"
},
"peerDependencies": {
"jsonwebtoken": "*",
Expand All @@ -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"
}
Expand Down
17 changes: 12 additions & 5 deletions testing/botbuilder-test-utils/src/jwt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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}`;
Expand Down
16 changes: 12 additions & 4 deletions testing/botbuilder-test-utils/src/oauth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
10 changes: 0 additions & 10 deletions testing/consumer-test/eslint.config.cjs

This file was deleted.

5 changes: 2 additions & 3 deletions testing/consumer-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
5 changes: 0 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading