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

chore: estlint quotes rule #3850

Merged
merged 2 commits into from
Jul 7, 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
9 changes: 8 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,18 @@
"jsdoc/require-param-type": "off",
"jsdoc/require-returns": "error",
"jsdoc/require-returns-type": "off",
"lodash/import-scope": [2],
"lodash/import-scope": ["error"],
"no-unused-vars": "off",
"no-var": "error",
"prefer-const": "error",
"prettier/prettier": "error",
"quotes": [
"error",
"single",
{
"avoidEscape": true
}
],
"security/detect-object-injection": "off"
},
"overrides": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,11 +353,11 @@ export class OrchestratorRecognizer extends AdaptiveRecognizer implements Orches
}

if (!modelFolder) {
throw new Error(`Missing "ModelFolder" information.`);
throw new Error('Missing "ModelFolder" information.');
}

if (!snapshotFile) {
throw new Error(`Missing "ShapshotFile" information.`);
throw new Error('Missing "ShapshotFile" information.');
}

// Create orchestrator core
Expand Down
2 changes: 1 addition & 1 deletion libraries/botbuilder-ai/src/luisAdaptiveRecognizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export class LuisAdaptiveRecognizer extends Recognizer implements LuisAdaptiveRe
!activity || (context.activity.type === activity.type && context.activity.text === activity.text);

if (!utteranceMatches) {
throw new Error(`TurnContext is different than text`);
throw new Error('TurnContext is different than text');
}

// Initialize application info
Expand Down
20 changes: 11 additions & 9 deletions libraries/botbuilder-ai/src/luisRecognizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -612,32 +612,34 @@ export class LuisRecognizer implements LuisRecognizerTelemetryClient {
switch (response.status) {
case 400:
error.message = [
`Response 400: The request's body or parameters are incorrect,`,
`meaning they are missing, malformed, or too large.`,
"Response 400: The request's body or parameters are incorrect,",
'meaning they are missing, malformed, or too large.',
].join(' ');
break;
case 401:
error.message = `Response 401: The key used is invalid, malformed, empty, or doesn't match the region.`;
error.message =
"Response 401: The key used is invalid, malformed, empty, or doesn't match the region.";
break;
case 403:
error.message = `Response 403: Total monthly key quota limit exceeded.`;
error.message = 'Response 403: Total monthly key quota limit exceeded.';
break;
case 409:
error.message = `Response 409: Application loading in progress, please try again.`;
error.message = 'Response 409: Application loading in progress, please try again.';
break;
case 410:
error.message = `Response 410: Please retrain and republish your application.`;
error.message = 'Response 410: Please retrain and republish your application.';
break;
case 414:
error.message = `Response 414: The query is too long. Please reduce the query length to 500 or less characters.`;
error.message =
'Response 414: The query is too long. Please reduce the query length to 500 or less characters.';
break;
case 429:
error.message = `Response 429: Too many requests.`;
error.message = 'Response 429: Too many requests.';
break;
default:
error.message = [
`Response ${response.status}: Unexpected status code received.`,
`Please verify that your LUIS application is properly setup.`,
'Please verify that your LUIS application is properly setup.',
].join(' ');
}
}
Expand Down
10 changes: 5 additions & 5 deletions libraries/botbuilder-ai/tests/qnaMaker.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ describe('QnAMaker', function () {
const qna = new QnAMaker(endpoint, { top: 1 });
const answer = 'BaseCamp: You can use a damp rag to clean around the Power Pack';

let results = await qna.generateAnswer(`how do I clean the stove?`);
let results = await qna.generateAnswer('how do I clean the stove?');

assert(results);
assert.strictEqual(results.length, 1);
Expand All @@ -617,7 +617,7 @@ describe('QnAMaker', function () {
const qna = new QnAMaker(endpoint, { top: 1 });
const answer = 'BaseCamp: You can use a damp rag to clean around the Power Pack';

let results = await qna.generateAnswer(`how do I clean the stove?`);
let results = await qna.generateAnswer('how do I clean the stove?');

assert(results);
assert.strictEqual(results.length, 1);
Expand All @@ -644,13 +644,13 @@ describe('QnAMaker', function () {

it('returns 0 answers for questions without an answer', async function () {
const qna = new QnAMaker(endpoint, { top: 1 });
const results = await qna.generateAnswer(`foo`);
const results = await qna.generateAnswer('foo');

assert.deepStrictEqual(results, []);
});

it('emits trace info once per call to Answer', async function () {
const context = new TestContext({ text: `how do I clean the stove?`, type: 'message' });
const context = new TestContext({ text: 'how do I clean the stove?', type: 'message' });
const qna = new QnAMaker(endpoint, { top: 1 });

const found = await qna.answer(context);
Expand Down Expand Up @@ -678,7 +678,7 @@ describe('QnAMaker', function () {
});

it('returns false from answer if no good answers found', async function () {
const context = new TestContext({ text: `foo`, type: 'message' });
const context = new TestContext({ text: 'foo', type: 'message' });
const qna = new QnAMaker(endpoint, { top: 1 });

assert.strictEqual(await qna.answer(context), false);
Expand Down
2 changes: 1 addition & 1 deletion libraries/botbuilder-ai/tests/qnaMakerDialog.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const ENDPOINT_KEY = process.env.QNAENDPOINTKEY;
const HOSTNAME = process.env.QNAHOSTNAME || 'test-qna-app';
const isMockQna = false || !(KB_ID && ENDPOINT_KEY);

const beginMessage = { text: `begin`, type: 'message' };
const beginMessage = { text: 'begin', type: 'message' };

describe('QnAMakerDialog', function () {
this.timeout(3000);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class TestInitializerMiddleware extends TelemetryInitializerMiddleware {
}
}

describe(`TelemetryInitializerMiddleware`, function () {
describe('TelemetryInitializerMiddleware', function () {
this.timeout(5000);

afterEach(function () {
Expand Down
4 changes: 2 additions & 2 deletions libraries/botbuilder-azure-queues/src/azureQueueStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ export class AzureQueueStorage extends QueueStorage {
constructor(queuesStorageConnectionString: string, queueName: string) {
super();
if (!queuesStorageConnectionString) {
throw new Error(`queuesStorageConnectionString cannot be empty`);
throw new Error('queuesStorageConnectionString cannot be empty');
}

if (!queueName) {
throw new Error(`queueName cannot be empty`);
throw new Error('queueName cannot be empty');
}

this._queueClient = new QueueClient(queuesStorageConnectionString, queueName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ function addComposerConfiguration(configuration: Configuration): void {
const qnaRegion = configuration.string(['qna', 'qnaRegion']) || 'westus';
configuration.file(path.join(botRoot, 'generated', `qnamaker.settings.${environment}.${qnaRegion}.json`), true);

configuration.file(path.join(botRoot, 'generated', `orchestrator.settings.json`), true);
configuration.file(path.join(botRoot, 'generated', 'orchestrator.settings.json'), true);
}

async function normalizeConfiguration(configuration: Configuration, applicationRoot: string): Promise<void> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class AuthenticationError extends Error implements IStatusCodeError {
public static determineStatusCodeAndBuildMessage(err: any): string {
const errMessage: string = err && err.message ? err.message : 'Internal Server Error';
const code: number = AuthenticationError.determineStatusCode(errMessage);
const connectionHeader = `Connection: 'close'\r\n`;
const connectionHeader = "Connection: 'close'\r\n";

return `HTTP/1.1 ${code} ${StatusCodes[code]}\r\n${errMessage}\r\n${connectionHeader}\r\n`;
}
Expand All @@ -54,7 +54,7 @@ export class AuthenticationError extends Error implements IStatusCodeError {
if (typeof message === 'string') {
if (message.toLowerCase().startsWith('unauthorized')) {
return StatusCodes.UNAUTHORIZED;
} else if (message.toLowerCase().startsWith(`'authheader'`)) {
} else if (message.toLowerCase().startsWith("'authheader'")) {
return StatusCodes.BAD_REQUEST;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ export namespace JwtTokenValidation {
*/
export function getAppIdFromClaims(claims: Claim[]): string {
if (!claims) {
throw new TypeError(`JwtTokenValidation.getAppIdFromClaims(): missing claims.`);
throw new TypeError('JwtTokenValidation.getAppIdFromClaims(): missing claims.');
}

let appId: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export namespace SkillValidation {
*/
export function isSkillClaim(claims: Claim[]): boolean {
if (!claims) {
throw new TypeError(`SkillValidation.isSkillClaim(): missing claims.`);
throw new TypeError('SkillValidation.isSkillClaim(): missing claims.');
}

// Group claims by type for fast lookup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ describe('AuthenticationError', function () {
});

it('should return false if it is not an error that implements IStatusCodeError', function () {
const nonStatusCodeError = new Error(`I'm just a vanilla Error`);
const nonStatusCodeError = new Error("I'm just a vanilla Error");
const isStatusCodeErr = AuthenticationError.isStatusCodeError(nonStatusCodeError);

assert.strictEqual(isStatusCodeErr, false);
});

it('should be able to assign a 400 statusCode if none was provided and build correct error message', function () {
const errMessage = `'authHeader' is required.`;
const errMessage = "'authHeader' is required.";
const code = StatusCodes.BAD_REQUEST;
const expectedMessage = `HTTP/1.1 ${code} ${StatusCodes[code]}\r\n${errMessage}\r\nConnection: 'close'\r\n\r\n`;

Expand Down
4 changes: 2 additions & 2 deletions libraries/botframework-connector/tests/connector.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,15 +193,15 @@ describe('Bot Framework Connector SDK', function () {
activity.entities = [
{
type: 'mention',
text: `<at>User1</at>`,
text: '<at>User1</at>',
mentioned: {
name: 'User1',
id: `${user.id}_1`,
},
},
{
type: 'mention',
text: `<at>User2</at>`,
text: '<at>User2</at>',
mentioned: {
name: 'User2',
id: `${user.id}_2`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ describe('SimpleCredentialProvider', function () {
it('isValidAppId() should resolve true if appId matches appId from construction', async function () {
const credentials = new SimpleCredentialProvider(APP_ID, APP_PASSWORD);
const isValidAppId = await credentials.isValidAppId(APP_ID);
assert(isValidAppId, `should have validated provided appId`);
assert(isValidAppId, 'should have validated provided appId');
});

it(`isValidAppId() should resolve false if appId doesn't match appId from construction`, async function () {
it("isValidAppId() should resolve false if appId doesn't match appId from construction", async function () {
const credentials = new SimpleCredentialProvider(APP_ID, APP_PASSWORD);
const isValidAppId = await credentials.isValidAppId(NOT_APP_ID);
assert(!isValidAppId, `should have validated provided appId`);
assert(!isValidAppId, 'should have validated provided appId');
});

it('getAppPassword() should resolve appPassword if appId matches appId from construction', async function () {
Expand All @@ -30,7 +30,7 @@ describe('SimpleCredentialProvider', function () {
strictEqual(appPassword, APP_PASSWORD);
});

it(`getAppPassword() should resolve null if appId doesn't matches appId from construction`, async function () {
it("getAppPassword() should resolve null if appId doesn't matches appId from construction", async function () {
const credentials = new SimpleCredentialProvider(APP_ID, APP_PASSWORD);
const appPassword = await credentials.getAppPassword(NOT_APP_ID);
strictEqual(appPassword, null);
Expand All @@ -42,7 +42,7 @@ describe('SimpleCredentialProvider', function () {
strictEqual(isAuthDisabled, false);
});

it(`isAuthenticationDisabled() should resolve false if appId wasn't passed in during construction`, async function () {
it("isAuthenticationDisabled() should resolve false if appId wasn't passed in during construction", async function () {
const credentials = new SimpleCredentialProvider();
strictEqual(credentials.appId, undefined);
const isAuthDisabled = await credentials.isAuthenticationDisabled();
Expand Down
1 change: 1 addition & 0 deletions libraries/botframework-schema/src/activityEx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ export namespace ActivityEx {

/**
* Creates a ConversationReference based on the source activity.
*
* @param source The source activity.
* @returns A conversation reference for the conversation that contains the activity.
*/
Expand Down
2 changes: 1 addition & 1 deletion libraries/botframework-schema/tests/activityEx.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
const { strictEqual } = require('assert');
const { ActivityEx, ActivityTypes, Channels } = require('../');

describe(`activityValidator`, function () {
describe('activityValidator', function () {
it('should create a Message Activity', function () {
const activity = ActivityEx.createMessageActivity();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe('SpeechConstants', function () {
// Expected value derived from https://github.com/microsoft/botframework-obi/blame/5c2542115b110a1dae8e597473271abc8e67c30d/protocols/botframework-activity/botframework-activity.md#L353
strictEqual(
SpeechConstants.EmptySpeakTag,
`<speak version="1.0" xmlns="https://www.w3.org/2001/10/synthesis" xml:lang="en-US" />`
'<speak version="1.0" xmlns="https://www.w3.org/2001/10/synthesis" xml:lang="en-US" />'
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export function getServerFactory(): (callback?: ConnectionListener) => INodeServ
}

throw TypeError(
`require is undefined. Must be in a Node module to require 'net' dynamically in order to fetch Server factory.`
"require is undefined. Must be in a Node module to require 'net' dynamically in order to fetch Server factory."
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export class WebSocketClient implements IStreamingTransportClient {
this._sender.connect(transport);
this._receiver.connect(transport);
} catch (_error) {
throw new Error(`Unable to connect client to Node transport.`);
throw new Error('Unable to connect client to Node transport.');
}
}

Expand Down