Skip to content

Commit 37ac82c

Browse files
committed
add microsoft-typescript/only-arrow-functions
1 parent 09eac67 commit 37ac82c

File tree

6 files changed

+13
-9
lines changed

6 files changed

+13
-9
lines changed

.eslintrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@
5858
"microsoft-typescript/object-literal-surrounding-space": "error",
5959
"microsoft-typescript/no-type-assertion-whitespace": "error",
6060
"microsoft-typescript/type-operator-spacing": "error",
61+
"microsoft-typescript/only-arrow-functions": ["error", {
62+
"allowNamedFunctions": true ,
63+
"allowDeclarations": true
64+
}],
6165
"microsoft-typescript/no-double-space": "error",
6266
"microsoft-typescript/boolean-trivia": "error",
6367
"microsoft-typescript/no-in-operator": "error",

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
@@ -115,7 +115,7 @@ function importDefinitelyTypedTests(tscPath: string, rwcTestPath: string, defini
115115
.filter(i => fs.statSync(path.join(definitelyTypedRoot, i)).isDirectory())
116116
.forEach(d => {
117117
const directoryPath = path.join(definitelyTypedRoot, d);
118-
fs.readdir(directoryPath, function (err, files) {
118+
fs.readdir(directoryPath, (err, files) => {
119119
if (err) {
120120
throw err;
121121
}

scripts/word2md.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ module Word { // eslint-disable-line @typescript-eslint/prefer-namespace-keyword
131131
}
132132
}
133133

134-
const sys = (function () {
134+
const sys = (function () { // eslint-disable-line microsoft-typescript/only-arrow-functions
135135
const fileStream = new ActiveXObject("ADODB.Stream");
136136
fileStream.Type = 2 /*text*/;
137137
const binaryStream = new ActiveXObject("ADODB.Stream");

src/harness/harnessLanguageService.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ namespace Harness.LanguageService {
44
const proxy = Object.create(/*prototype*/ null); // eslint-disable-line no-null/no-null
55
const langSvc: any = info.languageService;
66
for (const k of Object.keys(langSvc)) {
7-
proxy[k] = function () {
7+
proxy[k] = function () { // eslint-disable-line microsoft-typescript/only-arrow-functions
88
return langSvc[k].apply(langSvc, arguments);
99
};
1010
}
@@ -796,7 +796,7 @@ namespace Harness.LanguageService {
796796
create(info: ts.server.PluginCreateInfo) {
797797
const proxy = makeDefaultProxy(info);
798798
const langSvc: any = info.languageService;
799-
proxy.getQuickInfoAtPosition = function () {
799+
proxy.getQuickInfoAtPosition = function () { // eslint-disable-line microsoft-typescript/only-arrow-functions
800800
const parts = langSvc.getQuickInfoAtPosition.apply(langSvc, arguments);
801801
if (parts.displayParts.length > 0) {
802802
parts.displayParts[0].text = "Proxied";

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-
return <any>(function () {
366+
return <any>(function () { // eslint-disable-line microsoft-typescript/only-arrow-functions
367367
if (replayLog !== undefined) {
368368
return replay.apply(undefined, arguments);
369369
}

0 commit comments

Comments
 (0)