Skip to content

Commit

Permalink
fix: eslint settings, lint errors (#3348)
Browse files Browse the repository at this point in the history
* fix: eslint config

* fix: adaptive-expressions-ie11 lint errors

* fix: botbuilder-ai-orchestrator lint errors

* fix: bot-integration-tests lint errors

* fix: botbuilder-applicationinsights lint errors

* fix: botbuilder-azure lint errors

* fix: botbuilder-dialogs-adaptive-teams lint errors

* fix: botbuilder-testing lint errors

Co-authored-by: Steven Gum <14935595+stevengum@users.noreply.github.com>
  • Loading branch information
joshgummersall and stevengum authored Mar 5, 2021
1 parent 95e48f2 commit 866b662
Show file tree
Hide file tree
Showing 35 changed files with 1,131 additions and 834 deletions.
57 changes: 34 additions & 23 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,6 @@
"env": {
"es6": true
},
"extends": [
"eslint:recommended",
"plugin:security/recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/eslint-recommended",
"prettier",
"plugin:prettier/recommended",
"prettier/@typescript-eslint",
"plugin:jsdoc/recommended"
],
"ignorePatterns": [
"_ts3.4/",
"dist/",
Expand All @@ -28,15 +18,27 @@
},
"plugins": [
"@typescript-eslint",
"prettier",
"import",
"jsdoc",
"security",
"import"
"lodash",
"prettier",
"security"
],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:jsdoc/recommended",
"plugin:security/recommended",
"plugin:prettier/recommended"
],
"settings": {
"jsdoc": {
"ignoreInternal": true,
"ignorePrivate": true
"ignorePrivate": true,
"tagNamePreference": {
"augments": "extends"
}
}
},
"rules": {
Expand All @@ -60,6 +62,13 @@
"peerDependencies": false
}
],
"jsdoc/check-tag-names": [
"error",
{
"definedTags": ["remarks"]
}
],
"jsdoc/empty-tags": "off",
"jsdoc/require-jsdoc": [
"error",
{
Expand All @@ -71,6 +80,7 @@
"jsdoc/require-param-type": "off",
"jsdoc/require-returns": "error",
"jsdoc/require-returns-type": "off",
"lodash/import-scope": [2],
"no-unused-vars": "off",
"no-var": "error",
"prettier/prettier": "error",
Expand All @@ -79,8 +89,9 @@
"overrides": [
{
"files": [
"*.test.js",
"*.test.ts"
"*.test.*",
"test/**/*",
"tests/**/*"
],
"env": {
"mocha": true,
Expand All @@ -89,22 +100,22 @@
"rules": {
"@typescript-eslint/no-var-requires": "off",
"import/no-extraneous-dependencies": "off",
"jsdoc/require-jsdoc": "off",
"jsdoc/require-param": "off",
"jsdoc/require-returns": "off",
"security/detect-non-literal-fs-filename": "off"
}
},
{
"files": [
"babel.config.js",
"webpack.config.js"
"*.config.js"
],
"globals": {
"__dirname": true,
"module": true,
"require": true
"env": {
"node": true
},
"rules": {
"@typescript-eslint/no-var-requires": "off"
}
}
]
}
}
3 changes: 1 addition & 2 deletions libraries/adaptive-expressions-ie11/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{
"extends": "../../.eslintrc.json",
"plugins": ["only-warn"]
"extends": "../../.eslintrc.json"
}
6 changes: 3 additions & 3 deletions libraries/adaptive-expressions-ie11/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
"types": "./dist/index.d.ts",
"dependencies": {
"adaptive-expressions": "4.1.6",
"core-js": "^3.3.2"
"clean-webpack-plugin": "^3.0.0",
"core-js": "^3.3.2",
"terser-webpack-plugin": "^4.2.3"
},
"devDependencies": {
"@babel/core": "^7.6.4",
Expand All @@ -31,8 +33,6 @@
"@babel/preset-typescript": "^7.6.0",
"@babel/runtime": "^7.6.3",
"babel-loader": "^8.0.6",
"clean-webpack-plugin": "^3.0.0",
"terser-webpack-plugin": "^4.2.3",
"ts-loader": "^7.0.5",
"typescript": "3.5.3",
"webpack": "^4.43.0",
Expand Down
3 changes: 1 addition & 2 deletions libraries/bot-integration-tests/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{
"extends": "../../.eslintrc.json",
"plugins": ["only-warn"]
"extends": "../../.eslintrc.json"
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ describe('ChannelServiceRoutes - Integration Tests', function () {

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 @@ -36,6 +37,7 @@ describe('ChannelServiceRoutes - Integration Tests', function () {

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 Down
3 changes: 1 addition & 2 deletions libraries/botbuilder-ai-orchestrator/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{
"extends": "../../.eslintrc.json",
"plugins": ["only-warn"]
"extends": "../../.eslintrc.json"
}
1 change: 1 addition & 0 deletions libraries/botbuilder-ai-orchestrator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"adaptive-expressions": "4.1.6",
"botbuilder-core": "4.1.6",
"botbuilder-dialogs": "4.1.6",
"botbuilder-dialogs-declarative": "4.1.6",
"orchestrator-core": "4.12.0-preview",
"uuid": "^8.3.2"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
import { Activity, RecognizerResult } from 'botbuilder-core';
import { Converter, ConverterFactory, DialogContext, Recognizer, RecognizerConfiguration } from 'botbuilder-dialogs';

// eslint-disable-next-line @typescript-eslint/no-var-requires
const oc = require('orchestrator-core');

export interface OrchestratorAdaptiveRecognizerConfiguration extends RecognizerConfiguration {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
* Licensed under the MIT License.
*/

import { ComponentRegistration } from 'botbuilder-core';
import { ComponentDeclarativeTypes, DeclarativeType } from 'botbuilder-dialogs-declarative';
import { OrchestratorAdaptiveRecognizer } from './orchestratorAdaptiveRecognizer';

export class OrchestratorComponentRegistration extends ComponentRegistration {
public getDeclarativeTypes(_resourceExplorer: unknown) {
export class OrchestratorComponentRegistration implements ComponentDeclarativeTypes {
public getDeclarativeTypes(_resourceExplorer: unknown): DeclarativeType[] {
return [
{
kind: OrchestratorAdaptiveRecognizer.$kind,
Expand Down
7 changes: 5 additions & 2 deletions libraries/botbuilder-ai-orchestrator/tests/mockResolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/

/* eslint-disable @typescript-eslint/explicit-module-boundary-types */

class MockResolver {
constructor(score) {
this._score = score;
}

score(text) {
score(_text) {
return this._score;
}
}
Expand All @@ -19,4 +22,4 @@ class TestAdapterSettings {
}
}

module.exports = { MockResolver, TestAdapterSettings };
module.exports = { MockResolver, TestAdapterSettings };
2 changes: 1 addition & 1 deletion libraries/botbuilder-ai-orchestrator/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"outDir": "lib",
"rootDir": "src",
"skipLibCheck": true
},
},
"include": [
"src/**/*"
]
Expand Down
3 changes: 1 addition & 2 deletions libraries/botbuilder-applicationinsights/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{
"extends": "../../.eslintrc.json",
"plugins": ["only-warn"]
"extends": "../../.eslintrc.json"
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/**
* @module botbuilder-applicationinsights
*/
Expand All @@ -6,6 +7,9 @@
* Licensed under the MIT License.
*/
import * as appInsights from 'applicationinsights';
import * as cls from 'cls-hooked';
import * as crypto from 'crypto';

import {
Activity,
BotTelemetryClient,
Expand All @@ -16,22 +20,19 @@ import {
TelemetryTrace,
TelemetryPageView,
} from 'botbuilder-core';
import * as cls from 'cls-hooked';
import * as crypto from 'crypto';
const ns: any = cls.createNamespace('my.request');

// This is the currently recommended work-around for using Application Insights with async/await
// https://github.com/Microsoft/ApplicationInsights-node.js/issues/296
// This allows AppInsights to automatically apply the appropriate context objects deep inside the async/await chain.
// tslint:disable-next-line:no-submodule-imports
import {
CorrelationContext,
CorrelationContextManager,
} from 'applicationinsights/out/AutoCollection/CorrelationContextManager';
const origGetCurrentContext: any = CorrelationContextManager.getCurrentContext;

function getCurrentContext(): any {
// tslint:disable-next-line:no-backbone-get-set-outside-model
const origGetCurrentContext = CorrelationContextManager.getCurrentContext;
const ns = cls.createNamespace('my.request');

function getCurrentContext(): CorrelationContext {
return ns.get('ctx') || origGetCurrentContext();
}

Expand All @@ -44,15 +45,12 @@ export const ApplicationInsightsWebserverMiddleware: any = (req: any, res: any,
const activity: Partial<Activity> = req.body;
if (activity && activity.id) {
const context: CorrelationContext = appInsights.getCorrelationContext();

// tslint:disable-next-line:no-string-literal
context['activity'] = req.body;
}

ns.bindEmitter(req);
ns.bindEmitter(res);
ns.run((): void => {
// tslint:disable-next-line:no-backbone-get-set-outside-model
ns.set('ctx', origGetCurrentContext());
next();
});
Expand All @@ -77,6 +75,7 @@ export class ApplicationInsightsTelemetryClient implements BotTelemetryClient, B

/**
* Creates a new instance of the [ApplicationInsightsTelemetryClient](xref:botbuilder-applicationinsights.ApplicationInsightsTelemetryClient) class.
*
* @param instrumentationKey The ApplicationInsights instrumentation key.
* @remarks The settings parameter is passed directly into appInsights.setup().
* https://www.npmjs.com/package/applicationinsights#basic-usage
Expand All @@ -101,20 +100,25 @@ export class ApplicationInsightsTelemetryClient implements BotTelemetryClient, B
* Provides access to the Application Insights configuration that is running here.
* Allows developers to adjust the options, for example:
* `appInsightsClient.configuration.setAutoCollectDependencies(false)`
*
* @returns app insights configuration
*/
get configuration(): appInsights.Configuration {
return this.config;
}

/**
* Provides direct access to the telemetry client object, which might be necessary for some operations.
*
* @returns app insights telemetry client
*/
get defaultClient(): appInsights.TelemetryClient {
return this.client;
}

/**
* Sends information about an external dependency (outgoing call) in the application.
*
* @param telemetry The [TelemetryDependency](xref:botbuilder-core.TelemetryDependency) to track.
*/
public trackDependency(telemetry: TelemetryDependency): void {
Expand All @@ -123,6 +127,7 @@ export class ApplicationInsightsTelemetryClient implements BotTelemetryClient, B

/**
* Logs custom events with extensible named fields.
*
* @param telemetry The [TelemetryEvent](xref:botbuilder-core.TelemetryEvent) to track.
*/
public trackEvent(telemetry: TelemetryEvent): void {
Expand All @@ -131,6 +136,7 @@ export class ApplicationInsightsTelemetryClient implements BotTelemetryClient, B

/**
* Logs a system exception.
*
* @param telemetry The [TelemetryException](xref:botbuilder-core.TelemetryException) to track.
*/
public trackException(telemetry: TelemetryException): void {
Expand All @@ -139,6 +145,7 @@ export class ApplicationInsightsTelemetryClient implements BotTelemetryClient, B

/**
* Sends a trace message.
*
* @param telemetry The [TelemetryTrace](xref:botbuilder-core.TelemetryTrace) to track.
*/
public trackTrace(telemetry: TelemetryTrace): void {
Expand All @@ -147,6 +154,7 @@ export class ApplicationInsightsTelemetryClient implements BotTelemetryClient, B

/**
* Logs a dialog entry as an Application Insights page view.
*
* @param telemetry The [TelemetryPageView](xref:botbuilder-core.TelemetryPageView) to track.
*/
public trackPageView(telemetry: TelemetryPageView): void {
Expand All @@ -167,7 +175,6 @@ export class ApplicationInsightsTelemetryClient implements BotTelemetryClient, B
function addBotIdentifiers(envelope: appInsights.Contracts.Envelope, context: { [name: string]: any }): boolean {
if (context.correlationContext && context.correlationContext.activity) {
const activity: Partial<Activity> = context.correlationContext.activity;
// tslint:disable-next-line:no-string-literal
const telemetryItem: any = envelope.data['baseData']; // TODO: update when envelope ts definition includes baseData
const userId: string = activity.from ? activity.from.id : '';
const channelId: string = activity.channelId || '';
Expand Down
Loading

0 comments on commit 866b662

Please sign in to comment.