Skip to content

Commit

Permalink
add microsoft-typescript/only-arrow-functions
Browse files Browse the repository at this point in the history
  • Loading branch information
a-tarasyuk committed Jun 6, 2019
1 parent 09eac67 commit 5995ca2
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 10 deletions.
4 changes: 4 additions & 0 deletions .eslintrc
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -65,7 +65,7 @@
"del": "latest",
"eslint": "latest",
"eslint-formatter-autolinkable-stylish": "latest",
"eslint-plugin-microsoft-typescript": "latest",
"eslint-plugin-microsoft-typescript": "0.1.10",
"eslint-plugin-no-null": "latest",
"fancy-log": "latest",
"fs-extra": "^6.0.1",
Expand Down
8 changes: 4 additions & 4 deletions scripts/authors.ts
Expand Up @@ -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+([^<]+)<([^>]+)>/;
Expand All @@ -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];
};

Expand Down
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion scripts/word2md.ts
Expand Up @@ -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");
Expand Down
4 changes: 2 additions & 2 deletions src/harness/harnessLanguageService.ts
Expand Up @@ -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);
};
}
Expand Down Expand Up @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion src/harness/loggedIO.ts
Expand Up @@ -363,7 +363,7 @@ namespace Playback {

function recordReplay<T extends ts.AnyFunction>(original: T, underlying: any) {
function createWrapper(record: T, replay: T): T {
return <any>(function () {
return <any>(function () { // eslint-disable-line microsoft-typescript/only-arrow-functions
if (replayLog !== undefined) {
return replay.apply(undefined, arguments);
}
Expand Down

0 comments on commit 5995ca2

Please sign in to comment.