diff --git a/Composer/.eslintrc.js b/Composer/.eslintrc.js
index 34cee152d8..ec1cd1aff8 100644
--- a/Composer/.eslintrc.js
+++ b/Composer/.eslintrc.js
@@ -40,6 +40,7 @@ module.exports = {
'no-console': 'warn',
'dot-notation': 'error',
yoda: 'error',
+ 'no-bitwise': 'error',
// eqeqeq: 'error',
// plugin: import
diff --git a/Composer/packages/client/src/Onboarding/WelcomeModal/Expanded/index.tsx b/Composer/packages/client/src/Onboarding/WelcomeModal/Expanded/index.tsx
index f71d4f492b..394aae21f3 100644
--- a/Composer/packages/client/src/Onboarding/WelcomeModal/Expanded/index.tsx
+++ b/Composer/packages/client/src/Onboarding/WelcomeModal/Expanded/index.tsx
@@ -57,14 +57,14 @@ const WelcomeModal = () => {
{stepSets.map(({ steps: { length }, title }, index) => (
))}
- {!~currentStep && (
+ {currentStep === -1 && (
{currentSet + 1 < stepSets.length && (
diff --git a/Composer/packages/client/src/Onboarding/index.tsx b/Composer/packages/client/src/Onboarding/index.tsx
index a583b733c6..6ac26e25d7 100644
--- a/Composer/packages/client/src/Onboarding/index.tsx
+++ b/Composer/packages/client/src/Onboarding/index.tsx
@@ -72,7 +72,7 @@ const Onboarding: React.FC = () => {
!complete && projectId && navigateTo && navigate(navigateTo);
setTeachingBubble({ currentStep, id, location, setLength: steps.length, targetId });
- setMinimized(!!~currentStep);
+ setMinimized(currentStep >= 0);
if (currentSet > -1 && currentSet < stepSets.length) {
onboardingState.setCurrentSet(stepSets[currentSet].id);
diff --git a/Composer/packages/client/src/pages/design/exportSkillModal/index.tsx b/Composer/packages/client/src/pages/design/exportSkillModal/index.tsx
index 275588cb9e..f1f36651ba 100644
--- a/Composer/packages/client/src/pages/design/exportSkillModal/index.tsx
+++ b/Composer/packages/client/src/pages/design/exportSkillModal/index.tsx
@@ -42,7 +42,7 @@ const ExportSkillModal: React.FC
= ({ onSubmit, onDismiss
const handleEditJson = () => {
const step = order.findIndex((step) => step === ManifestEditorSteps.MANIFEST_REVIEW);
- if (~step) {
+ if (step >= 0) {
setCurrentStep(step);
setErrors({});
}
diff --git a/Composer/packages/client/src/utils/luUtil.ts b/Composer/packages/client/src/utils/luUtil.ts
index ba8be1f60e..6a4c4b1fc4 100644
--- a/Composer/packages/client/src/utils/luUtil.ts
+++ b/Composer/packages/client/src/utils/luUtil.ts
@@ -17,7 +17,7 @@ export * from '@bfc/indexers/lib/utils/luUtil';
export function getReferredFiles(luFiles: LuFile[], dialogs: DialogInfo[]) {
return luFiles.filter((file) => {
const idWithOutLocale = getBaseName(file.id);
- return !!~dialogs.findIndex((dialog) => dialog.luFile === idWithOutLocale);
+ return dialogs.some((dialog) => dialog.luFile === idWithOutLocale);
});
}
diff --git a/Composer/packages/lib/code-editor/src/LuEditor.tsx b/Composer/packages/lib/code-editor/src/LuEditor.tsx
index a50b437440..a9ca4cd239 100644
--- a/Composer/packages/lib/code-editor/src/LuEditor.tsx
+++ b/Composer/packages/lib/code-editor/src/LuEditor.tsx
@@ -96,6 +96,8 @@ const LuEditor: React.FC = (props) => {
const m = monacoRef.current;
if (m) {
+ // this is the correct way to combine keycodes in Monaco
+ // eslint-disable-next-line no-bitwise
editor.addCommand(m.KeyMod.Shift | m.KeyCode.Enter, function () {
const position = editor.getPosition();
SendRequestWithRetry(languageClient, 'labelingExperienceRequest', { uri, position });
diff --git a/Composer/packages/lib/indexers/src/dialogUtils/dialogChecker.ts b/Composer/packages/lib/indexers/src/dialogUtils/dialogChecker.ts
index 05623cf66d..d3295618fb 100644
--- a/Composer/packages/lib/indexers/src/dialogUtils/dialogChecker.ts
+++ b/Composer/packages/lib/indexers/src/dialogUtils/dialogChecker.ts
@@ -16,7 +16,7 @@ export const createPath = (path: string, type: string): string => {
if (/\[|\]/.test(x)) {
const reg = /\[.*\]/;
x = x.replace(reg, '');
- return ~values(FieldNames).indexOf(x);
+ return values(FieldNames).includes(x);
}
});
diff --git a/Composer/packages/lib/indexers/src/dialogUtils/validation.ts b/Composer/packages/lib/indexers/src/dialogUtils/validation.ts
index 618c74abd3..be66900cae 100644
--- a/Composer/packages/lib/indexers/src/dialogUtils/validation.ts
+++ b/Composer/packages/lib/indexers/src/dialogUtils/validation.ts
@@ -29,10 +29,10 @@ const isExpression = (value: string | boolean | number, types: string[]): boolea
//TODO: returnType is number, schem type is string, need map or unify
const checkReturnType = (returnType: ReturnType, types: string[]): string => {
return returnType === ReturnType.Object ||
- ~types.indexOf(ExpressionTypeMapString[returnType]) ||
- (returnType === ReturnType.Number && ~types.indexOf(ExpressionType.integer))
+ types.includes(ExpressionTypeMapString[returnType]) ||
+ (returnType === ReturnType.Number && types.includes(ExpressionType.integer))
? ''
- : formatMessage('the expression type is not match');
+ : formatMessage('the return type does not match');
};
export const checkExpression = (exp: string | boolean | number, required: boolean, types: string[]): string => {
diff --git a/Composer/packages/server/src/models/bot/botProject.ts b/Composer/packages/server/src/models/bot/botProject.ts
index dcf46da7db..3bf33c0955 100644
--- a/Composer/packages/server/src/models/bot/botProject.ts
+++ b/Composer/packages/server/src/models/bot/botProject.ts
@@ -389,7 +389,7 @@ export class BotProject {
private getLocale(id: string): string {
const index = id.lastIndexOf('.');
- if (~index) return '';
+ if (index >= 0) return '';
return id.substring(index + 1);
}
diff --git a/Composer/packages/server/src/models/bot/luPublisher.ts b/Composer/packages/server/src/models/bot/luPublisher.ts
index a68638d6b9..1536d27f2b 100644
--- a/Composer/packages/server/src/models/bot/luPublisher.ts
+++ b/Composer/packages/server/src/models/bot/luPublisher.ts
@@ -39,7 +39,7 @@ export class LuPublisher {
public botDir: string;
public dialogsDir: string;
public generatedFolderPath: string;
- public interuptionFolderPath: string;
+ public interruptionFolderPath: string;
public storage: IFileStorage;
public config: ILuisConfig | null = null;
public downSamplingConfig: IDownSamplingConfig = { maxImbalanceRatio: 0, maxUtteranceAllowed: 0 };
@@ -60,7 +60,7 @@ export class LuPublisher {
this.botDir = path;
this.dialogsDir = this.botDir;
this.generatedFolderPath = Path.join(this.dialogsDir, GENERATEDFOLDER);
- this.interuptionFolderPath = Path.join(this.generatedFolderPath, INTERUPTION);
+ this.interruptionFolderPath = Path.join(this.generatedFolderPath, INTERUPTION);
this.storage = storage;
this._locale = locale;
}
@@ -135,7 +135,7 @@ export class LuPublisher {
return luObject;
}
- private async _downSizeUtterances(luContents: any) {
+ private async _downsizeUtterances(luContents: any) {
return await Promise.all(
luContents.map(async (luContent) => {
const result = await LuisBuilder.fromLUAsync(luContent.content);
@@ -147,12 +147,12 @@ export class LuPublisher {
}
private async _writeFiles(crossTrainResult) {
- if (!(await this.storage.exists(this.interuptionFolderPath))) {
- await this.storage.mkDir(this.interuptionFolderPath);
+ if (!(await this.storage.exists(this.interruptionFolderPath))) {
+ await this.storage.mkDir(this.interruptionFolderPath);
}
for (const key of crossTrainResult.keys()) {
const fileName = Path.basename(key);
- const newFileId = Path.join(this.interuptionFolderPath, fileName);
+ const newFileId = Path.join(this.interruptionFolderPath, fileName);
await this.storage.writeFile(newFileId, crossTrainResult.get(key).Content);
}
}
@@ -160,14 +160,13 @@ export class LuPublisher {
private async _runBuild(files: FileInfo[]) {
const config = await this._getConfig(files);
if (config.models.length === 0) {
- throw new Error('No luis file exist');
- }
- const loadResult = await this._loadLuConatents(config.models);
- loadResult.luContents = await this._downSizeUtterances(loadResult.luContents);
- let authoringEndpoint = config.authoringEndpoint;
- if (!authoringEndpoint) {
- authoringEndpoint = `https://${config.region}.api.cognitive.microsoft.com`;
+ throw new Error('No LUIS files exist');
}
+
+ const loadResult = await this._loadLuContents(config.models);
+ loadResult.luContents = await this._downsizeUtterances(loadResult.luContents);
+ const authoringEndpoint = config.endpoint ?? `https://${config.region}.api.cognitive.microsoft.com`;
+
const buildResult = await this.builder.build(
loadResult.luContents,
loadResult.recognizers,
@@ -201,35 +200,38 @@ export class LuPublisher {
private _getConfig = async (files: FileInfo[]) => {
if (!this.config) {
- throw new Error('Please complete your Luis settings');
+ throw new Error('Please complete your LUIS settings');
}
- const luConfig: any = {
+ const luConfig = {
authoringKey: this.config.authoringKey || '',
region: this.config.authoringRegion || '',
botName: this.config.name || '',
suffix: this.config.environment || '',
fallbackLocal: this.config.defaultLanguage || 'en-us',
+ endpoint: this.config.endpoint || null,
+ models: [] as string[],
};
- luConfig.models = [];
//add all lu file after cross train
let paths: string[] = [];
if (this._needCrossTrain()) {
- paths = await this.storage.glob('**/*.lu', this.interuptionFolderPath);
- luConfig.models = paths.map((filePath) => Path.join(this.interuptionFolderPath, filePath));
+ paths = await this.storage.glob('**/*.lu', this.interruptionFolderPath);
+ luConfig.models = paths.map((filePath) => Path.join(this.interruptionFolderPath, filePath));
}
- //add the lu file that are not in interuption folder.
+ const pathSet = new Set(paths);
+
+ //add the lu file that are not in interruption folder.
files.forEach((file) => {
- if (!~paths.indexOf(file.name)) {
+ if (!pathSet.has(file.name)) {
luConfig.models.push(Path.resolve(this.botDir, file.relativePath));
}
});
return luConfig;
};
- private _loadLuConatents = async (paths: string[]) => {
+ private _loadLuContents = async (paths: string[]) => {
return await this.builder.loadContents(
paths,
this._locale,
@@ -240,6 +242,6 @@ export class LuPublisher {
private async _cleanCrossTrain() {
if (!this._needCrossTrain()) return;
- await this._deleteDir(this.interuptionFolderPath);
+ await this._deleteDir(this.interruptionFolderPath);
}
}