diff --git a/Composer/.eslintrc.js b/Composer/.eslintrc.js index 6ce39182a3..b0e4f3bd7f 100644 --- a/Composer/.eslintrc.js +++ b/Composer/.eslintrc.js @@ -52,6 +52,7 @@ module.exports = { enforceInMethodNames: true, }, ], + 'prefer-arrow-callback': 'error', // plugin: import 'import/first': 'error', diff --git a/Composer/packages/electron-server/src/main.ts b/Composer/packages/electron-server/src/main.ts index 4e71ec2042..79374bb772 100644 --- a/Composer/packages/electron-server/src/main.ts +++ b/Composer/packages/electron-server/src/main.ts @@ -145,7 +145,7 @@ async function main() { mainWindow.show(); - mainWindow.on('closed', function () { + mainWindow.on('closed', () => { ElectronWindow.destroy(); }); log('Rendered application.'); @@ -188,7 +188,7 @@ async function run() { }); // Quit when all windows are closed. - app.on('window-all-closed', function () { + app.on('window-all-closed', () => { // On OS X it is common for applications and their menu bar // to stay active until the user quits explicitly with Cmd + Q if (!isMac()) { @@ -196,7 +196,7 @@ async function run() { } }); - app.on('activate', function () { + app.on('activate', () => { // On OS X it's common to re-create a window in the app when the // dock icon is clicked and there are no other windows open. if (!ElectronWindow.isBrowserWindowCreated) { @@ -204,7 +204,7 @@ async function run() { } }); - app.on('will-finish-launching', function () { + app.on('will-finish-launching', () => { // Protocol handler for osx app.on('open-url', (event, url) => { event.preventDefault(); diff --git a/Composer/packages/lib/code-editor/src/LuEditor.tsx b/Composer/packages/lib/code-editor/src/LuEditor.tsx index a9ca4cd239..6b67877f6c 100644 --- a/Composer/packages/lib/code-editor/src/LuEditor.tsx +++ b/Composer/packages/lib/code-editor/src/LuEditor.tsx @@ -98,7 +98,7 @@ const LuEditor: React.FC = (props) => { 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 () { + editor.addCommand(m.KeyMod.Shift | m.KeyCode.Enter, () => { const position = editor.getPosition(); SendRequestWithRetry(languageClient, 'labelingExperienceRequest', { uri, position }); }); diff --git a/Composer/packages/server/__tests__/models/bot/botProject.test.ts b/Composer/packages/server/__tests__/models/bot/botProject.test.ts index 05e259590d..f3426c026b 100644 --- a/Composer/packages/server/__tests__/models/bot/botProject.test.ts +++ b/Composer/packages/server/__tests__/models/bot/botProject.test.ts @@ -84,7 +84,7 @@ describe('copyTo', () => { let files: string[] = []; if (fs.existsSync(path)) { files = fs.readdirSync(path); - files.forEach(function (file) { + files.forEach((file) => { const curPath = path + '/' + file; if (fs.statSync(curPath).isDirectory()) { // recurse diff --git a/Composer/packages/server/src/server.ts b/Composer/packages/server/src/server.ts index d51af95295..5bf66d2c84 100644 --- a/Composer/packages/server/src/server.ts +++ b/Composer/packages/server/src/server.ts @@ -64,7 +64,7 @@ export async function start(pluginDir?: string): Promise { 'upgrade-insecure-requests;', ]; - app.all('*', function (req: Request, res: Response, next: NextFunction) { + app.all('*', (req: Request, res: Response, next: NextFunction) => { res.header('Access-Control-Allow-Origin', '*'); res.header('Access-Control-Allow-Methods', 'GET,HEAD,OPTIONS,POST,PUT,DELETE'); res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept, Authorization'); @@ -103,14 +103,14 @@ export async function start(pluginDir?: string): Promise { // next needs to be an arg in order for express to recognize this as the error handler // eslint-disable-next-line @typescript-eslint/no-unused-vars - app.use(function (err: Error, req: Request, res: Response, _next: NextFunction) { + app.use((err: Error, req: Request, res: Response, _next: NextFunction) => { if (err) { log(err); res.status(500).json({ message: err.message }); } }); - app.get('*', function (req, res) { + app.get('*', (req, res) => { res.render(path.resolve(clientDirectory, 'index.ejs'), { __nonce__: req.__nonce__ }); }); diff --git a/Composer/packages/tools/language-servers/language-generation/__tests__/unitTest/util.test.ts b/Composer/packages/tools/language-servers/language-generation/__tests__/unitTest/util.test.ts index 2c0ad5aa42..2601bce4cf 100644 --- a/Composer/packages/tools/language-servers/language-generation/__tests__/unitTest/util.test.ts +++ b/Composer/packages/tools/language-servers/language-generation/__tests__/unitTest/util.test.ts @@ -4,7 +4,7 @@ import { textFromTemplate, checkTemplate, updateTemplate } from '../../src/utils'; describe('LG LSP server util function test', () => { - it('text from template', function () { + it('text from template', () => { const template = { name: 'Greeting', body: '-hi', @@ -13,7 +13,7 @@ describe('LG LSP server util function test', () => { expect(templateText).toContain('# Greeting'); }); - it('check a valid template', function () { + it('check a valid template', () => { const template = { name: 'Greeting', body: '-hi', @@ -22,7 +22,7 @@ describe('LG LSP server util function test', () => { expect(diags).toHaveLength(0); }); - it('check an invalid template', function () { + it('check an invalid template', () => { const template = { name: 'Greeting', body: 'hi ${ ', @@ -31,7 +31,7 @@ describe('LG LSP server util function test', () => { expect(diags).toHaveLength(1); }); - it('update template', function () { + it('update template', () => { const content = ` # Greeting - hello diff --git a/Composer/packages/tools/language-servers/language-understanding/__tests__/unitTest/serverUtil.test.ts b/Composer/packages/tools/language-servers/language-understanding/__tests__/unitTest/serverUtil.test.ts index 20af0d73ce..9c550a7cfd 100644 --- a/Composer/packages/tools/language-servers/language-understanding/__tests__/unitTest/serverUtil.test.ts +++ b/Composer/packages/tools/language-servers/language-understanding/__tests__/unitTest/serverUtil.test.ts @@ -12,8 +12,8 @@ const text = `@ml location hasRoles homeaddress @ regex zipcode = /[0-9]{5}/ @ ml mail usesFeature address #checktemperature --it is sunny and the temperature is -- the temperature is 35 +-it is sunny and the temperature is +- the temperature is 35 - address is {address=[beijing,100080]} `; @@ -37,33 +37,33 @@ const luisObject = { prebuiltEntities: [], }; -describe('LU LSP Server Function Unit Tests', function () { - it('Test Get ML Entities', function () { +describe('LU LSP Server Function Unit Tests', () => { + it('Test Get ML Entities', () => { const result = util.getMLEntities(text); assert.deepStrictEqual(result, ['location', 'mail']); }); - it('Test Get Composites Entities', function () { + it('Test Get Composites Entities', () => { const result = util.getCompositesEntities(luisObject); assert.deepStrictEqual(result, ['geoInfo']); }); - it('Test Get RegExp Entities', function () { + it('Test Get RegExp Entities', () => { const result = util.getRegexEntities(luisObject); assert.deepStrictEqual(result, ['zipcode']); }); - it('Test Get All Parsed Entities', function () { + it('Test Get All Parsed Entities', () => { const result = util.getSuggestionEntities(luisObject, util.suggestionAllEntityTypes); assert.deepStrictEqual(result, ['address', 'zipcode', 'city', 'geoInfo']); }); - it('Test Get All Parsed Roles', function () { + it('Test Get All Parsed Roles', () => { const result = util.getSuggestionRoles(luisObject, util.suggestionAllEntityTypes); assert.deepStrictEqual(result, ['role1', 'role2']); }); - it('Test Entity Can UsesFeature', function () { + it('Test Entity Can UsesFeature', () => { let lineContent = '@ geoInfo usesFeature '; let result = util.matchedEntityCanUsesFeature(lineContent, text, luisObject); assert.equal(result, true); @@ -81,7 +81,7 @@ describe('LU LSP Server Function Unit Tests', function () { assert.equal(result, false); }); - it('Test Intent Can UsesFeature', function () { + it('Test Intent Can UsesFeature', () => { let text = '@ intent mockIntent usesFeature '; let result = util.matchIntentUsesFeatures(text); assert.equal(result, true); @@ -91,7 +91,7 @@ describe('LU LSP Server Function Unit Tests', function () { assert.equal(result, false); }); - it('Test Intent In a Entity Definiton', function () { + it('Test Intent In a Entity Definiton', () => { let text = '@ intent mockIntent'; let result = util.matchIntentInEntityDef(text); assert.equal(result, true); @@ -101,7 +101,7 @@ describe('LU LSP Server Function Unit Tests', function () { assert.equal(result, false); }); - it('Test Entity Definition', function () { + it('Test Entity Definition', () => { let text = '@ '; let result = util.isEntityType(text); assert.equal(result, true); @@ -111,7 +111,7 @@ describe('LU LSP Server Function Unit Tests', function () { assert.equal(result, false); }); - it('Test Prebuilt Entity Definition', function () { + it('Test Prebuilt Entity Definition', () => { let text = '@ prebuilt '; let result = util.isPrebuiltEntity(text); assert.equal(result, true); @@ -121,7 +121,7 @@ describe('LU LSP Server Function Unit Tests', function () { assert.equal(result, false); }); - it('Test RegExp Entity Definition', function () { + it('Test RegExp Entity Definition', () => { let text = '@ regex zipcode ='; let result = util.isRegexEntity(text); assert.equal(result, true); @@ -131,7 +131,7 @@ describe('LU LSP Server Function Unit Tests', function () { assert.equal(result, false); }); - it('Test Seperated Line Entity', function () { + it('Test Seperated Line Entity', () => { let text = '@ zipcode ='; let result = util.isSeperatedEntityDef(text); assert.equal(result, true); @@ -141,7 +141,7 @@ describe('LU LSP Server Function Unit Tests', function () { assert.equal(result, false); }); - it('Test Entity Name ', function () { + it('Test Entity Name ', () => { let text = '@ ml location'; let result = util.isEntityName(text); assert.equal(result, true); @@ -155,7 +155,7 @@ describe('LU LSP Server Function Unit Tests', function () { assert.equal(result, false); }); - it('Test Composite Entity ', function () { + it('Test Composite Entity ', () => { let text = '@ composite location = ['; let result = util.isCompositeEntity(text); assert.equal(result, true); @@ -169,7 +169,7 @@ describe('LU LSP Server Function Unit Tests', function () { assert.equal(result, false); }); - it('Test Entering Pattern ', function () { + it('Test Entering Pattern ', () => { let text = '- The weather in Seattle is { '; let result = util.matchedEnterPattern(text); assert.equal(result, true); @@ -183,7 +183,7 @@ describe('LU LSP Server Function Unit Tests', function () { assert.equal(result, false); }); - it('Test Entering Roles ', function () { + it('Test Entering Roles ', () => { let text = '- The weather in Seattle is {morning: '; let result = util.matchedRolesPattern(text); assert.equal(result, true); @@ -197,7 +197,7 @@ describe('LU LSP Server Function Unit Tests', function () { assert.equal(result, false); }); - it('Test Entering Entity ', function () { + it('Test Entering Entity ', () => { let text = '- The weather in Seattle is {@ '; let result = util.matchedEntityPattern(text); assert.equal(result, true); @@ -211,7 +211,7 @@ describe('LU LSP Server Function Unit Tests', function () { assert.equal(result, false); }); - it('Test Remove Labeled Utterance', function () { + it('Test Remove Labeled Utterance', () => { let text = '- this is a {type = Audio} message from {device = PC}'; let result = util.removeLabelsInUtterance(text); assert.equal(result, '- this is a Audio message from PC');