Skip to content

Commit 0e14b4e

Browse files
committed
microsoft-typescript/only-arrow-functions
1 parent 67e20fc commit 0e14b4e

6 files changed

Lines changed: 13 additions & 10 deletions

File tree

.eslintrc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,10 @@
5353
"microsoft-typescript/object-literal-surrounding-space": "error",
5454
"microsoft-typescript/no-type-assertion-whitespace": "error",
5555
"microsoft-typescript/type-operator-spacing": "error",
56-
"microsoft-typescript/only-arrow-functions": "off",
56+
"microsoft-typescript/only-arrow-functions": ["error", {
57+
"allowNamedFunctions": true ,
58+
"allowDeclarations": true
59+
}],
5760
"microsoft-typescript/no-double-space": "error",
5861
"microsoft-typescript/boolean-trivia": "error",
5962
"microsoft-typescript/no-in-operator": "off",

scripts/authors.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,18 +100,18 @@ function sortAuthors(a: string, b: string) {
100100
}
101101

102102
namespace Commands {
103-
export const writeAuthors: Command = function () {
103+
export const writeAuthors: Command = () => {
104104
const output = deduplicate(getKnownAuthors().map(getAuthorName).filter(a => !!a)).sort(sortAuthors).join("\r\n* ");
105105
fs.writeFileSync(authorsPath, "TypeScript is authored by:\r\n* " + output);
106106
};
107107
writeAuthors.description = "Write known authors to AUTHORS.md file.";
108108

109-
export const listKnownAuthors: Command = function () {
109+
export const listKnownAuthors: Command = () => {
110110
deduplicate(getKnownAuthors().map(getAuthorName)).filter(a => !!a).sort(sortAuthors).forEach(log);
111111
};
112112
listKnownAuthors.description = "List known authors as listed in .mailmap file.";
113113

114-
export const listAuthors: Command = function (...specs: string[]) {
114+
export const listAuthors: Command = (...specs: string[]) => {
115115
const cmd = "git shortlog -se " + specs.join(" ");
116116
console.log(cmd);
117117
const outputRegExp = /\d+\s+([^<]+)<([^>]+)>/;
@@ -137,7 +137,7 @@ namespace Commands {
137137

138138
const maps = getKnownAuthorMaps();
139139

140-
const lookupAuthor = function ({name, email}: { name: string, email: string }) {
140+
const lookupAuthor = ({name, email}: { name: string, email: string }) => {
141141
return maps.authorsByEmail[email.toLocaleLowerCase()] || maps.authorsByName[name];
142142
};
143143

scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ function importDefinitelyTypedTests(tscPath: string, rwcTestPath: string, defini
116116
.filter(i => fs.statSync(path.join(definitelyTypedRoot, i)).isDirectory())
117117
.forEach(d => {
118118
const directoryPath = path.join(definitelyTypedRoot, d);
119-
fs.readdir(directoryPath, function (err, files) {
119+
fs.readdir(directoryPath, (err, files) => {
120120
if (err) {
121121
throw err;
122122
}

scripts/word2md.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ namespace Word {
130130
}
131131
}
132132

133-
const sys = (function () {
133+
const sys = (() => {
134134
const fileStream = new ActiveXObject("ADODB.Stream");
135135
fileStream.Type = 2 /* text */;
136136
const binaryStream = new ActiveXObject("ADODB.Stream");

src/harness/harnessLanguageService.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace Harness.LanguageService {
55
const proxy = Object.create(/*prototype*/ null);
66
const langSvc: any = info.languageService;
77
for (const k of Object.keys(langSvc)) {
8-
// tslint:disable-next-line only-arrow-functions
8+
// eslint-disable-next-line microsoft-typescript/only-arrow-functions
99
proxy[k] = function () {
1010
return langSvc[k].apply(langSvc, arguments);
1111
};
@@ -800,7 +800,7 @@ namespace Harness.LanguageService {
800800
create(info: ts.server.PluginCreateInfo) {
801801
const proxy = makeDefaultProxy(info);
802802
const langSvc: any = info.languageService;
803-
// tslint:disable-next-line only-arrow-functions
803+
// eslint-disable-next-line microsoft-typescript/only-arrow-functions
804804
proxy.getQuickInfoAtPosition = function () {
805805
const parts = langSvc.getQuickInfoAtPosition.apply(langSvc, arguments);
806806
if (parts.displayParts.length > 0) {

src/harness/loggedIO.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ namespace Playback {
363363

364364
function recordReplay<T extends ts.AnyFunction>(original: T, underlying: any) {
365365
function createWrapper(record: T, replay: T): T {
366-
// tslint:disable-next-line only-arrow-functions
366+
// eslint-disable-next-line microsoft-typescript/only-arrow-functions
367367
return <any>(function () {
368368
if (replayLog !== undefined) {
369369
return replay.apply(undefined, arguments);

0 commit comments

Comments
 (0)