Skip to content

Commit

Permalink
Lint fixes: Enable Automatic formatting fixes (#1788)
Browse files Browse the repository at this point in the history
  • Loading branch information
MSNev committed Mar 22, 2022
1 parent 31fc481 commit d047267
Show file tree
Hide file tree
Showing 61 changed files with 566 additions and 494 deletions.
4 changes: 3 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
"plugin:security/recommended"
],
"rules": {
//"indent": ["error", 4], // Re-Enable for auto fixing after merging ChromeDebugExtension Branch
"indent": ["error"], // Enabling for auto fixing
"quotes": ["warn", "double"], // Enabled for auto fixing
"curly": [ "error" ], // Enabling for auto fixing
"brace-style": [ "error" ], // Enabling for auto fixing
"prefer-const": "off",
"prefer-spread": "off",
"no-var": "off",
Expand Down
2 changes: 1 addition & 1 deletion AISKU/src/ApplicationInsightsDeprecated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export class AppInsightsDeprecated implements IAppInsightsDeprecated {
this.context = { addTelemetryInitializer: this.addTelemetryInitializers.bind(this) }
}

/**
/**
* The array of telemetry initializers to call before sending each telemetry item.
*/

Expand Down
2 changes: 1 addition & 1 deletion AISKULight/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export class ApplicationInsights {

public stopPollingInternalLogs(): void {
this.core.stopPollingInternalLogs();
}
}

private getSKUDefaults() {
this.config.diagnosticLogInterval =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ export function PageViewEnvelopeCreator(logger: IDiagnosticLogger, telemetryItem

const bd = telemetryItem[strBaseData] as IPageViewTelemetryInternal;

// special case: pageview.id is grabbed from current operation id. Analytics plugin is decoupled from properties plugin, so this is done here instead. This can be made a default telemetry intializer instead if needed to be decoupled from channel
// special case: pageview.id is grabbed from current operation id. Analytics plugin is decoupled from properties plugin, so this is done here instead. This can be made a default telemetry intializer instead if needed to be decoupled from channel
let currentContextId;
if (((telemetryItem.ext || {}).trace || {}).traceID) {
currentContextId = telemetryItem.ext.trace.traceID;
Expand Down
18 changes: 9 additions & 9 deletions channels/applicationinsights-channel-js/src/Sender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -588,9 +588,9 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {

function _checkAndUpdateEndPointUrl(responseUrl: string) {
// Maximum stamp specific redirects allowed(uncomment this when breeze is ready with not allowing redirects feature)
if(_stamp_specific_redirects >= 10) {
// _self._senderConfig.endpointUrl = () => Sender._getDefaultAppInsightsChannelConfig().endpointUrl()+"/?redirect=false";
// _stamp_specific_redirects = 0;
if(_stamp_specific_redirects >= 10) {
// _self._senderConfig.endpointUrl = () => Sender._getDefaultAppInsightsChannelConfig().endpointUrl()+"/?redirect=false";
// _stamp_specific_redirects = 0;
return false;
}
if(!isNullOrUndefined(responseUrl) && responseUrl !== "") {
Expand Down Expand Up @@ -724,16 +724,16 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {
* @param payload {string} - The data payload to be sent.
* @param isAsync {boolean} - not used
*/
function _fetchSender(payload: string[], isAsync: boolean) {
_doFetchSender(payload, true);
}
function _fetchSender(payload: string[], isAsync: boolean) {
_doFetchSender(payload, true);
}

/**
* Send fetch API request
* @param payload {string} - The data payload to be sent.
* @param isAsync {boolean} - For fetch this identifies whether we are "unloading" (false) or a normal request
*/
function _doFetchSender(payload: string[], isAsync: boolean) {
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" });
Expand Down Expand Up @@ -964,7 +964,7 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {
_InternalMessageId.TransmissionFailed, ". " +
"Cannot send XDomain request. The endpoint URL protocol doesn't match the hosting page protocol.");

buffer.clear();
buffer.clear();
return;
}

Expand Down Expand Up @@ -1142,7 +1142,7 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {
* @param name - Header name.
* @param value - Header value.
*/
public addHeader(name: string, value: string) {
public addHeader(name: string, value: string) {
// @DynamicProtoStub - DO NOT add any code as this will be removed during packaging
}
}
12 changes: 4 additions & 8 deletions channels/applicationinsights-channel-js/src/Serializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,10 @@ export class Serializer {
output[field] = "null";
} else if (!value.toString) {
output[field] = "invalid field: toString() is not defined.";
}
else {
} else {
output[field] = value.toString();
}
}
else if (expectedType === "number") {
} else if (expectedType === "number") {
if (value === undefined) {
output[field] = "undefined";
} else if (value === null) {
Expand All @@ -153,13 +151,11 @@ export class Serializer {
const num = parseFloat(value);
if (isNaN(num)) {
output[field] = "NaN";
}
else {
} else {
output[field] = num;
}
}
}
else {
} else {
output[field] = "invalid field: " + name + " is of unknown type.";
logger.throwInternal(LoggingSeverity.CRITICAL, output[field], null, true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class Sample implements ISample {
this.samplingScoreGenerator = new SamplingScoreGenerator();
}

/**
/**
* Determines if an envelope is sampled in (i.e. will be sent) or not (i.e. will be dropped).
*/
public isSampledIn(envelope: ITelemetryItem): boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ export class HashCodeScoreGenerator {
}

public getHashCode(input: string): number {
if (input === "") { return 0; }
if (input === "") {
return 0;
}

while (input.length < MIN_INPUT_LENGTH) {
input = input.concat(input);
Expand Down
78 changes: 41 additions & 37 deletions common/Tests/Framework/src/AITestClass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export class AITestClass {
*/
public assertNoEvents: boolean = false;

/**
/**
* Automatically assert that all hooks have been removed
*/
public assertNoHooks: boolean = false;
Expand Down Expand Up @@ -471,8 +471,7 @@ export class AITestClass {
} else {
_testFinished();
}
}
catch (ex) {
} catch (ex) {
console.error("Failed: Unexpected Exception: " + ex);
Assert.ok(false, "Unexpected Exception: " + ex);
_testFinished(true);
Expand All @@ -489,18 +488,24 @@ export class AITestClass {
public spy(funcToWrap: Function): SinonSpy;
/** Creates a spy for object.methodName and replaces the original method with the spy. The spy acts exactly like the original method in all cases. The original method can be restored by calling object.methodName.restore(). The returned spy is the function object which replaced the original method. spy === object.method. */
public spy(object: any, methodName: string, func?: Function): SinonSpy;
public spy(..._args: any[]): SinonSpy { return null; }
public spy(..._args: any[]): SinonSpy {
return null;
}

/** Creates an anonymous stub function. */
public stub(): SinonStub;
/** Stubs all the object's methods. */
public stub(object: any): SinonStub;
/** Replaces object.methodName with a func, wrapped in a spy. As usual, object.methodName.restore(); can be used to restore the original method. */
public stub(object: any, methodName: string, func?: Function): SinonStub;
public stub(..._args: any[]): SinonStub { return null; }
public stub(..._args: any[]): SinonStub {
return null;
}

/** Creates a mock for the provided object.Does not change the object, but returns a mock object to set expectations on the object's methods. */
public mock(_object: any): SinonMock { return null; }
public mock(_object: any): SinonMock {
return null;
}

/**** end: Sinon methods and properties ***/

Expand Down Expand Up @@ -562,12 +567,12 @@ export class AITestClass {

try {
AITestClass.orgObjectDefineProperty(window.navigator, "userAgent",
{
configurable: true,
get () {
return userAgent;
}
});
{
configurable: true,
get () {
return userAgent;
}
});
} catch (e) {
QUnit.assert.ok(false, "Failed to set the userAgent - " + e);
throw e;
Expand Down Expand Up @@ -604,12 +609,12 @@ export class AITestClass {
if (!newNavigator.hasOwnProperty(name)) {
// if it couldn't be set directly try and pretend
AITestClass.orgObjectDefineProperty(newNavigator, name,
{
configurable: true,
get: function () {
return navigator[name];
}
});
{
configurable: true,
get: function () {
return navigator[name];
}
});
}
}
}
Expand All @@ -627,12 +632,12 @@ export class AITestClass {
protected setNavigator(newNavigator: any) {
try {
AITestClass.orgObjectDefineProperty(window, "navigator",
{
configurable: true,
get: function () {
return newNavigator;
}
});
{
configurable: true,
get: function () {
return newNavigator;
}
});
} catch (e) {
QUnit.assert.ok(true, "Set Navigator failed - " + e);
sinon.stub(window, "navigator").returns(newNavigator);
Expand Down Expand Up @@ -733,12 +738,12 @@ export class AITestClass {
if (!newLocation.hasOwnProperty(name)) {
// if it couldn't be set directly try and pretend
AITestClass.orgObjectDefineProperty(newLocation, name,
{
configurable: true,
get: function () {
return this._orgLocation[name];
}
});
{
configurable: true,
get: function () {
return this._orgLocation[name];
}
});
}
}
}
Expand All @@ -760,11 +765,11 @@ export class AITestClass {
try {
if (newLocation) {
AITestClass.orgObjectDefineProperty(window, "__mockLocation",
{
configurable: true,
enumerable: true,
value: newLocation
});
{
configurable: true,
enumerable: true,
value: newLocation
});
} else {
delete (window as any).__mockLocation;
}
Expand Down Expand Up @@ -932,8 +937,7 @@ export class AITestClass {
if (failed) {
// Just cleanup the sandbox since the test has already failed.
this.sandbox.restore();
}
else {
} else {
// Verify the sandbox and restore.
(this.sandbox as any).verifyAndRestore();
}
Expand Down
18 changes: 9 additions & 9 deletions common/Tests/Framework/src/Assert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { expectedToString, stateToString } from "./DebugHelpers";
* - Make them consistent with XUnit assertions in the order of the actual and expected parameter values.
*/
export class Assert {
/**
/**
* A deep recursive comparison assertion, working on primitive types, arrays, objects,
* regular expressions, dates and functions.
*
Expand All @@ -24,7 +24,7 @@ export class Assert {
return QUnit.assert.deepEqual(actual, expected, message || expectedToString(expected));
}

/**
/**
* A non-strict comparison assertion, roughly equivalent to JUnit assertEquals.
*
* The equal assertion uses the simple comparison operator (==) to compare the actual
Expand All @@ -40,7 +40,7 @@ export class Assert {
return QUnit.assert.equal(actual, expected, message || expectedToString(expected));
}

/**
/**
* An inverted deep recursive comparison assertion, working on primitive types,
* arrays, objects, regular expressions, dates and functions.
*
Expand All @@ -56,7 +56,7 @@ export class Assert {
return QUnit.assert.notDeepEqual(actual, expected, message || expectedToString(expected));
}

/**
/**
* A non-strict comparison assertion, checking for inequality.
*
* The notEqual assertion uses the simple inverted comparison operator (!=) to compare
Expand All @@ -80,7 +80,7 @@ export class Assert {
return QUnit.assert.propEqual(actual, expected, message || expectedToString(expected));
}

/**
/**
* A non-strict comparison assertion, checking for inequality.
*
* The notStrictEqual assertion uses the strict inverted comparison operator (!==)
Expand All @@ -96,7 +96,7 @@ export class Assert {
return QUnit.assert.notStrictEqual(actual, expected, message || expectedToString(expected));
}

/**
/**
* A boolean assertion, equivalent to CommonJS's assert.ok() and JUnit's assertTrue().
* Passes if the first argument is truthy.
*
Expand All @@ -111,7 +111,7 @@ export class Assert {
return QUnit.assert.ok(state, message || stateToString(state));
}

/**
/**
* A strict type and value comparison assertion.
*
* The strictEqual() assertion provides the most rigid comparison of type and value with
Expand All @@ -125,7 +125,7 @@ export class Assert {
return QUnit.assert.strictEqual(actual, expected, message || expectedToString(expected));
}

/**
/**
* Assertion to test if a callback throws an exception when run.
*
* When testing code that is expected to throw an exception based on a specific set of
Expand All @@ -137,7 +137,7 @@ export class Assert {
*/
public static throws(block: () => any, expected: any, message?: string): any;

/**
/**
* @param block Function to execute
* @param message A short description of the assertion
*/
Expand Down
2 changes: 1 addition & 1 deletion common/Tests/Framework/src/PollingAssert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Assert } from "./Assert";
import { AITestClass } from "./AITestClass";

export class PollingAssert {
/**
/**
* Starts polling assertion function for a period of time after which it's considered failed.
* @param {() => boolean} assertionFunctionReturnsBoolean - funciton returning true if condition passes and false if condition fails. Assertion will be done on this function's result.
* @param {string} assertDescription - message shown with the assertion
Expand Down
Loading

0 comments on commit d047267

Please sign in to comment.