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

Enable some more automatic eslint fixes #1690

Merged
merged 1 commit into from
Oct 13, 2021
Merged
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
8 changes: 4 additions & 4 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"plugin:security/recommended"
],
"rules": {
"quotes": ["off", "double"], // Re-enable for auto fixing
"quotes": ["warn", "double"], // Enabled for auto fixing
"prefer-const": "off",
"prefer-spread": "off",
"no-var": "off",
Expand All @@ -23,18 +23,18 @@
"no-useless-escape": "off", // Suppressing Error -- need to Review Later
"no-trailing-spaces": [ "warn", { "skipBlankLines": true }],// Enabled for auto fixing
"no-const-assign": "error",
"comma-dangle": [ "warn", "never" ], // Enabled for auto fixing
"comma-dangle": [ "error", "never" ], // Enabled for auto fixing
"security/detect-object-injection": "off", // Suppress Warning -- need to Review Later
"@typescript-eslint/ban-types": "off",
"@typescript-eslint/no-unused-vars": "off", // Re-enable for auto fixing
"@typescript-eslint/no-unused-vars": [ "warn", { "vars": "all", "args": "none", "argsIgnorePattern": "^_", "ignoreRestSiblings": true } ],
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Attempted setting this to error, but there are several fixes required -- only manually updated a few (in the tools folder) before rolling back to warning.

"@typescript-eslint/triple-slash-reference": "off",
"@typescript-eslint/no-inferrable-types": "off",
"@typescript-eslint/no-this-alias": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-empty-interface": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-extra-semi": "warn", // Enabled for auto fixing
"@typescript-eslint/no-extra-semi": "error", // Enabled for auto fixing
"@typescript-eslint/no-non-null-assertion": "error"
}
}
2 changes: 1 addition & 1 deletion AISKU/src/Init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function _logWarn(aiName:string, message:string) {
// TODO: Find better place to warn to console when SDK initialization fails
var _console = typeof console !== Undefined ? console : null;
if (_console && _console.warn) {
_console.warn('Failed to initialize AppInsights JS SDK for instance ' + (aiName || '<unknown>') + ' - ' + message);
_console.warn("Failed to initialize AppInsights JS SDK for instance " + (aiName || "<unknown>") + " - " + message);
}
}

Expand Down
6 changes: 3 additions & 3 deletions AISKU/src/Initialization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
import { ApplicationInsights } from "@microsoft/applicationinsights-analytics-js";
import { Sender } from "@microsoft/applicationinsights-channel-js";
import { PropertiesPlugin } from "@microsoft/applicationinsights-properties-js";
import { AjaxPlugin as DependenciesPlugin, IDependenciesPlugin } from '@microsoft/applicationinsights-dependencies-js';
import { AjaxPlugin as DependenciesPlugin, IDependenciesPlugin } from "@microsoft/applicationinsights-dependencies-js";
import {
IUtil, Util, ICorrelationIdHelper, CorrelationIdHelper, IUrlHelper, UrlHelper, IDateTimeUtils, DateTimeUtils, ConnectionStringParser, FieldType,
IRequestHeaders, RequestHeaders, DisabledPropertyName, ProcessLegacy, SampleRate, HttpMethod, DEFAULT_BREEZE_ENDPOINT, AIData, AIBase,
Expand Down Expand Up @@ -487,7 +487,7 @@ export class Initialization implements IApplicationInsights {

// Back up the current session to local storage
// This lets us close expired sessions after the cookies themselves expire
arrForEach(appInsightsInstance.appInsights.core['_extensions'], (ext: any) => {
arrForEach(appInsightsInstance.appInsights.core["_extensions"], (ext: any) => {
if (ext.identifier === PropertiesPluginIdentifier) {
if (ext && ext.context && ext.context._sessionManager) {
ext.context._sessionManager.backup();
Expand All @@ -514,7 +514,7 @@ export class Initialization implements IApplicationInsights {
appInsightsInstance.appInsights.core.logger.throwInternal(
LoggingSeverity.CRITICAL,
_InternalMessageId.FailedToAddHandlerForOnBeforeUnload,
'Could not add handler for beforeunload and pagehide');
"Could not add handler for beforeunload and pagehide");
}
}

Expand Down
24 changes: 12 additions & 12 deletions channels/applicationinsights-channel-js/src/EnvelopeCreator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ import {
HttpMethod, IPageViewTelemetryInternal, IWeb,
IExceptionInternal,
SampleRate
} from '@microsoft/applicationinsights-common';
} from "@microsoft/applicationinsights-common";
import {
ITelemetryItem, IDiagnosticLogger, LoggingSeverity, _InternalMessageId, hasJSON, getJSON, objForEachKey,
isNullOrUndefined, isNumber, isString, toISOString, setValue, isTruthy, optimizeObject
} from '@microsoft/applicationinsights-core-js';
} from "@microsoft/applicationinsights-core-js";

// these two constants are used to filter out properties not needed when trying to extract custom properties and measurements from the incoming payload
const strBaseType = 'baseType';
const strBaseData = 'baseData';
const strProperties = 'properties';
const strTrue = 'true';
const strBaseType = "baseType";
const strBaseData = "baseData";
const strProperties = "properties";
const strTrue = "true";

function _setValueIf<T>(target:T, field:keyof T, value:any) {
return setValue(target, field, value, isTruthy);
Expand Down Expand Up @@ -61,10 +61,10 @@ function _extractPartAExtensions(item: ITelemetryItem, env: IEnvelope) {
let envBaseData = envData[strBaseData] = envData[strBaseData] || {};
let envProps = envBaseData[strProperties] = envBaseData[strProperties] || {};

_setValueIf(envProps, 'domain', web.domain);
_setValueIf(envProps, 'isManual', web.isManual ? strTrue : null);
_setValueIf(envProps, 'screenRes', web.screenRes);
_setValueIf(envProps, 'userConsent', web.userConsent ? strTrue : null);
_setValueIf(envProps, "domain", web.domain);
_setValueIf(envProps, "isManual", web.isManual ? strTrue : null);
_setValueIf(envProps, "screenRes", web.screenRes);
_setValueIf(envProps, "userConsent", web.userConsent ? strTrue : null);
}

let extOs = itmExt.os;
Expand Down Expand Up @@ -148,7 +148,7 @@ function _convertPropsUndefinedToCustomDefinedValue(properties: { [key: string]:
function _createEnvelope<T>(logger: IDiagnosticLogger, envelopeType: string, telemetryItem: ITelemetryItem, data: Data<T>): IEnvelope {
const envelope = new Envelope(logger, data, envelopeType);

_setValueIf(envelope, 'sampleRate', telemetryItem[SampleRate]);
_setValueIf(envelope, "sampleRate", telemetryItem[SampleRate]);
if ((telemetryItem[strBaseData] || {}).startTime) {
envelope.time = toISOString(telemetryItem[strBaseData].startTime);
}
Expand Down Expand Up @@ -204,7 +204,7 @@ export function EventEnvelopeCreator(logger: IDiagnosticLogger, telemetryItem: I
let customProperties = {};
let customMeasurements = {};
if (telemetryItem[strBaseType] !== Event.dataType) {
customProperties['baseTypeSource'] = telemetryItem[strBaseType]; // save the passed in base type as a property
customProperties["baseTypeSource"] = telemetryItem[strBaseType]; // save the passed in base type as a property
}

if (telemetryItem[strBaseType] === Event.dataType) { // take collection
Expand Down
8 changes: 4 additions & 4 deletions channels/applicationinsights-channel-js/src/Offline.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EventHelper, getWindow, getDocument, getNavigator, isUndefined, isNullOrUndefined, attachEvent } from '@microsoft/applicationinsights-core-js';
import dynamicProto from '@microsoft/dynamicproto-js';
import { EventHelper, getWindow, getDocument, getNavigator, isUndefined, isNullOrUndefined, attachEvent } from "@microsoft/applicationinsights-core-js";
import dynamicProto from "@microsoft/dynamicproto-js";

/**
* @description Monitors browser for offline events
Expand All @@ -19,8 +19,8 @@ export class OfflineListener {
dynamicProto(OfflineListener, this, (_self) => {
try {
if (_window) {
if (attachEvent(_window, 'online', _setOnline)) {
attachEvent(_window, 'offline', _setOffline);
if (attachEvent(_window, "online", _setOnline)) {
attachEvent(_window, "offline", _setOffline);
isListening = true;
}
}
Expand Down
8 changes: 4 additions & 4 deletions channels/applicationinsights-channel-js/src/SendBuffer.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { utlGetSessionStorage, utlSetSessionStorage } from '@microsoft/applicationinsights-common';
import { IDiagnosticLogger, LoggingSeverity, _InternalMessageId, getJSON, arrForEach, isFunction, arrIndexOf, isString, dumpObj, isArray, getExceptionName } from '@microsoft/applicationinsights-core-js';
import { ISenderConfig } from './Interfaces';
import dynamicProto from '@microsoft/dynamicproto-js';
import { utlGetSessionStorage, utlSetSessionStorage } from "@microsoft/applicationinsights-common";
import { IDiagnosticLogger, LoggingSeverity, _InternalMessageId, getJSON, arrForEach, isFunction, arrIndexOf, isString, dumpObj, isArray, getExceptionName } from "@microsoft/applicationinsights-core-js";
import { ISenderConfig } from "./Interfaces";
import dynamicProto from "@microsoft/dynamicproto-js";

export interface ISendBuffer {
/**
Expand Down
34 changes: 17 additions & 17 deletions channels/applicationinsights-channel-js/src/Sender.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
import { ISenderConfig, XDomainRequest as IXDomainRequest, IBackendResponse } from './Interfaces';
import { ISendBuffer, SessionStorageSendBuffer, ArraySendBuffer } from './SendBuffer';
import { ISenderConfig, XDomainRequest as IXDomainRequest, IBackendResponse } from "./Interfaces";
import { ISendBuffer, SessionStorageSendBuffer, ArraySendBuffer } from "./SendBuffer";
import {
DependencyEnvelopeCreator, EventEnvelopeCreator,
ExceptionEnvelopeCreator, MetricEnvelopeCreator, PageViewEnvelopeCreator,
PageViewPerformanceEnvelopeCreator, TraceEnvelopeCreator
} from './EnvelopeCreator';
import { Serializer } from './Serializer'; // todo move to channel
} from "./EnvelopeCreator";
import { Serializer } from "./Serializer"; // todo move to channel
import {
DisabledPropertyName, RequestHeaders, IEnvelope, PageView, Event,
Trace, Exception, Metric, PageViewPerformance, RemoteDependencyData,
IChannelControlsAI, IConfig, ProcessLegacy, BreezeChannelIdentifier,
SampleRate, isInternalApplicationInsightsEndpoint, utlCanUseSessionStorage,
ISample
} from '@microsoft/applicationinsights-common';
} from "@microsoft/applicationinsights-common";
import {
ITelemetryItem, IProcessTelemetryContext, IConfiguration,
_InternalMessageId, LoggingSeverity, IDiagnosticLogger, IAppInsightsCore, IPlugin,
getWindow, getNavigator, getJSON, BaseTelemetryPlugin, ITelemetryPluginChain, INotificationManager,
SendRequestReason, objForEachKey, isNullOrUndefined, arrForEach, dateNow, dumpObj, getExceptionName, getIEVersion, throwError, objKeys,
isBeaconsSupported, isFetchSupported, useXDomainRequest, isXhrSupported, isArray
} from '@microsoft/applicationinsights-core-js';
import { Offline } from './Offline';
import { Sample } from './TelemetryProcessors/Sample'
import dynamicProto from '@microsoft/dynamicproto-js';
} from "@microsoft/applicationinsights-core-js";
import { Offline } from "./Offline";
import { Sample } from "./TelemetryProcessors/Sample"
import dynamicProto from "@microsoft/dynamicproto-js";

const FetchSyncRequestSizeLimitBytes = 65000; // approx 64kb (the current Edge, Firefox and Chrome max limit)

Expand Down Expand Up @@ -504,7 +504,7 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {
}

if (failed.length > 0) {
_self._onError(failed, _formatErrorMessageXhr(null, ['partial success', results.itemsAccepted, 'of', results.itemsReceived].join(' ')));
_self._onError(failed, _formatErrorMessageXhr(null, ["partial success", results.itemsAccepted, "of", results.itemsReceived].join(" ")));
}

if (retry.length > 0) {
Expand Down Expand Up @@ -619,7 +619,7 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {
// _stamp_specific_redirects = 0;
return false;
}
if(!isNullOrUndefined(responseUrl) && responseUrl !== '') {
if(!isNullOrUndefined(responseUrl) && responseUrl !== "") {
if(responseUrl !== _self._senderConfig.endpointUrl()) {
_self._senderConfig.endpointUrl = () => responseUrl;
++_stamp_specific_redirects;
Expand Down Expand Up @@ -647,7 +647,7 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {

// Chrome only allows CORS-safelisted values for the sendBeacon data argument
// see: https://bugs.chromium.org/p/chromium/issues/detail?id=720283
const plainTextBatch = new Blob([batch], { type: 'text/plain;charset=UTF-8' });
const plainTextBatch = new Blob([batch], { type: "text/plain;charset=UTF-8" });

// The sendBeacon method returns true if the user agent is able to successfully queue the data for transfer. Otherwise it returns false.
const queued = nav.sendBeacon(url, plainTextBatch);
Expand Down Expand Up @@ -762,7 +762,7 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {
function _doFetchSender(payload: string[], isAsync: boolean) {
const endPointUrl = _self._senderConfig.endpointUrl();
const batch = _self._buffer.batchPayloads(payload);
const plainTextBatch = new Blob([batch], { type: 'application/json' });
const plainTextBatch = new Blob([batch], { type: "application/json" });
let requestHeaders = new Headers();
let batchLength = batch.length;

Expand Down Expand Up @@ -971,7 +971,7 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {
}

const endpointUrl = _self._senderConfig.endpointUrl().replace(/^(https?:)/, "");
xdr.open('POST', endpointUrl);
xdr.open("POST", endpointUrl);

// compose an array of payloads
const batch = buffer.batchPayloads(payload);
Expand All @@ -990,13 +990,13 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {

// Using function lookups for backward compatibility as the getNotifyMgr() did not exist until after v2.5.6
function _getNotifyMgr() : INotificationManager {
const func = 'getNotifyMgr';
const func = "getNotifyMgr";
if (_self.core[func]) {
return _self.core[func]();
}

// using _self.core['_notificationManager'] for backward compatibility
return _self.core['_notificationManager'];
return _self.core["_notificationManager"];
}

function _notifySendRequest(sendRequest: SendRequestReason, isAsync: boolean) {
Expand All @@ -1022,7 +1022,7 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {
if(disableIKeyValidationFlag) {
return true;
}
const UUID_Regex = '^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$';
const UUID_Regex = "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$";
const regexp = new RegExp(UUID_Regex);
return regexp.test(config.instrumentationKey);
}
Expand Down
6 changes: 3 additions & 3 deletions channels/applicationinsights-channel-js/src/Serializer.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { ISerializable, FieldType } from '@microsoft/applicationinsights-common';
import { ISerializable, FieldType } from "@microsoft/applicationinsights-common";
import {
IDiagnosticLogger, LoggingSeverity, _InternalMessageId, getJSON, objForEachKey, isFunction, isObject, isArray
} from '@microsoft/applicationinsights-core-js';
import dynamicProto from '@microsoft/dynamicproto-js'
} from "@microsoft/applicationinsights-core-js";
import dynamicProto from "@microsoft/dynamicproto-js"

export class Serializer {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

import { SamplingScoreGenerator } from './SamplingScoreGenerators/SamplingScoreGenerator';
import { ISample, Metric } from '@microsoft/applicationinsights-common';
import { ITelemetryItem, IDiagnosticLogger, _InternalMessageId, LoggingSeverity, safeGetLogger } from '@microsoft/applicationinsights-core-js';
import { SamplingScoreGenerator } from "./SamplingScoreGenerators/SamplingScoreGenerator";
import { ISample, Metric } from "@microsoft/applicationinsights-common";
import { ITelemetryItem, IDiagnosticLogger, _InternalMessageId, LoggingSeverity, safeGetLogger } from "@microsoft/applicationinsights-core-js";

export class Sample implements ISample {
public sampleRate: number;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

import { HashCodeScoreGenerator } from './HashCodeScoreGenerator';
import { ITelemetryItem } from '@microsoft/applicationinsights-core-js';
import { ContextTagKeys } from '@microsoft/applicationinsights-common';
import { HashCodeScoreGenerator } from "./HashCodeScoreGenerator";
import { ITelemetryItem } from "@microsoft/applicationinsights-core-js";
import { ContextTagKeys } from "@microsoft/applicationinsights-common";

export class SamplingScoreGenerator {

Expand Down
Loading