diff --git a/.eslintrc b/.eslintrc index df091ac4297b1..39bec1a73cdd4 100644 --- a/.eslintrc +++ b/.eslintrc @@ -58,6 +58,10 @@ "microsoft-typescript/object-literal-surrounding-space": "error", "microsoft-typescript/no-type-assertion-whitespace": "error", "microsoft-typescript/type-operator-spacing": "error", + "microsoft-typescript/only-arrow-functions": ["error", { + "allowNamedFunctions": true , + "allowDeclarations": true + }], "microsoft-typescript/no-double-space": "error", "microsoft-typescript/boolean-trivia": "error", "microsoft-typescript/no-in-operator": "error", diff --git a/scripts/authors.ts b/scripts/authors.ts index 8f771df89569b..66233d9651094 100644 --- a/scripts/authors.ts +++ b/scripts/authors.ts @@ -100,18 +100,18 @@ function sortAuthors(a: string, b: string) { } namespace Commands { - export const writeAuthors: Command = function () { + export const writeAuthors: Command = () => { const output = deduplicate(getKnownAuthors().map(getAuthorName).filter(a => !!a)).sort(sortAuthors).join("\r\n* "); fs.writeFileSync(authorsPath, "TypeScript is authored by:\r\n* " + output); }; writeAuthors.description = "Write known authors to AUTHORS.md file."; - export const listKnownAuthors: Command = function () { + export const listKnownAuthors: Command = () => { deduplicate(getKnownAuthors().map(getAuthorName)).filter(a => !!a).sort(sortAuthors).forEach(log); }; listKnownAuthors.description = "List known authors as listed in .mailmap file."; - export const listAuthors: Command = function (...specs: string[]) { + export const listAuthors: Command = (...specs: string[]) => { const cmd = "git shortlog -se " + specs.join(" "); console.log(cmd); const outputRegExp = /\d+\s+([^<]+)<([^>]+)>/; @@ -137,7 +137,7 @@ namespace Commands { const maps = getKnownAuthorMaps(); - const lookupAuthor = function ({name, email}: { name: string, email: string }) { + const lookupAuthor = ({name, email}: { name: string, email: string }) => { return maps.authorsByEmail[email.toLocaleLowerCase()] || maps.authorsByName[name]; }; diff --git a/scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.ts b/scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.ts index f7625f411498d..ae7b1b4acb725 100644 --- a/scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.ts +++ b/scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.ts @@ -115,7 +115,7 @@ function importDefinitelyTypedTests(tscPath: string, rwcTestPath: string, defini .filter(i => fs.statSync(path.join(definitelyTypedRoot, i)).isDirectory()) .forEach(d => { const directoryPath = path.join(definitelyTypedRoot, d); - fs.readdir(directoryPath, function (err, files) { + fs.readdir(directoryPath, (err, files) => { if (err) { throw err; } diff --git a/scripts/word2md.ts b/scripts/word2md.ts index 21ad578bab386..281ffc6215481 100644 --- a/scripts/word2md.ts +++ b/scripts/word2md.ts @@ -131,7 +131,7 @@ module Word { // eslint-disable-line @typescript-eslint/prefer-namespace-keyword } } -const sys = (function () { +const sys = (function () { // eslint-disable-line microsoft-typescript/only-arrow-functions const fileStream = new ActiveXObject("ADODB.Stream"); fileStream.Type = 2 /*text*/; const binaryStream = new ActiveXObject("ADODB.Stream"); diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index 692bd73c67d71..949ac5dda7aba 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -4,7 +4,7 @@ namespace Harness.LanguageService { const proxy = Object.create(/*prototype*/ null); // eslint-disable-line no-null/no-null const langSvc: any = info.languageService; for (const k of Object.keys(langSvc)) { - proxy[k] = function () { + proxy[k] = function () { // eslint-disable-line microsoft-typescript/only-arrow-functions return langSvc[k].apply(langSvc, arguments); }; } @@ -796,7 +796,7 @@ namespace Harness.LanguageService { create(info: ts.server.PluginCreateInfo) { const proxy = makeDefaultProxy(info); const langSvc: any = info.languageService; - proxy.getQuickInfoAtPosition = function () { + proxy.getQuickInfoAtPosition = function () { // eslint-disable-line microsoft-typescript/only-arrow-functions const parts = langSvc.getQuickInfoAtPosition.apply(langSvc, arguments); if (parts.displayParts.length > 0) { parts.displayParts[0].text = "Proxied"; diff --git a/src/harness/loggedIO.ts b/src/harness/loggedIO.ts index 480efb6d4bbdc..57fa8097e523f 100644 --- a/src/harness/loggedIO.ts +++ b/src/harness/loggedIO.ts @@ -363,7 +363,7 @@ namespace Playback { function recordReplay(original: T, underlying: any) { function createWrapper(record: T, replay: T): T { - return (function () { + return (function () { // eslint-disable-line microsoft-typescript/only-arrow-functions if (replayLog !== undefined) { return replay.apply(undefined, arguments); }