Skip to content

Commit

Permalink
Fully enabled the arrow-return-shorthand rule internally (palantir#2888)
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Goldberg authored and adidahiya committed Aug 7, 2017
1 parent 07065bc commit eb047b7
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 16 deletions.
5 changes: 2 additions & 3 deletions src/formatters/checkstyleFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,8 @@ export class Formatter extends AbstractFormatter {
let output = '<?xml version="1.0" encoding="utf-8"?><checkstyle version="4.3">';

if (failures.length !== 0) {
const failuresSorted = failures.sort((a, b) => {
return a.getFileName().localeCompare(b.getFileName());
});
const failuresSorted = failures.sort(
(a, b) => a.getFileName().localeCompare(b.getFileName()));
let previousFilename: string | null = null;
for (const failure of failuresSorted) {
const severity = failure.getRuleSeverity();
Expand Down
5 changes: 2 additions & 3 deletions src/language/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,8 @@ export function hasModifier(modifiers: ts.ModifiersArray | undefined, ...modifie
return false;
}

return modifiers.some((m) => {
return modifierKinds.some((k) => m.kind === k);
});
return modifiers.some(
(m) => modifierKinds.some((k) => m.kind === k));
}

/**
Expand Down
5 changes: 2 additions & 3 deletions src/linter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,9 @@ class Linter {
}

// add rule severity to failures
const ruleSeverityMap = new Map(enabledRules.map((rule) => {
const ruleSeverityMap = new Map(enabledRules.map(
// tslint:disable-next-line no-unnecessary-type-assertion
return [rule.getOptions().ruleName, rule.getOptions().ruleSeverity] as [string, RuleSeverity];
}));
(rule) => [rule.getOptions().ruleName, rule.getOptions().ruleSeverity] as [string, RuleSeverity]));

for (const failure of fileFailures) {
const severity = ruleSeverityMap.get(failure.getRuleName());
Expand Down
7 changes: 4 additions & 3 deletions src/rules/fileHeaderRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ export class Rule extends Lint.Rules.AbstractRule {
// ignore shebang if it exists
let offset = text.startsWith("#!") ? text.indexOf("\n") : 0;
// returns the text of the first comment or undefined
const commentText = ts.forEachLeadingCommentRange(text, offset, (pos, end, kind) => {
return text.substring(pos + 2, kind === ts.SyntaxKind.SingleLineCommentTrivia ? end : end - 2);
});
const commentText = ts.forEachLeadingCommentRange(
text,
offset,
(pos, end, kind) => text.substring(pos + 2, kind === ts.SyntaxKind.SingleLineCommentTrivia ? end : end - 2));
if (commentText === undefined || !new RegExp(this.ruleArguments[0] as string).test(commentText)) {
if (offset !== 0) {
++offset; // show warning in next line after shebang
Expand Down
5 changes: 2 additions & 3 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,8 @@ export function isLowerCase(str: string): boolean {
* Removes leading indents from a template string without removing all leading whitespace
*/
export function dedent(strings: TemplateStringsArray, ...values: any[]) {
let fullString = strings.reduce((accumulator, str, i) => {
return `${accumulator}${values[i - 1]}${str}`;
});
let fullString = strings.reduce(
(accumulator, str, i) => `${accumulator}${values[i - 1]}${str}`);

// match all leading spaces/tabs at the start of each line
const match = fullString.match(/^[ \t]*(?=\S)/gm);
Expand Down
1 change: 0 additions & 1 deletion tslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"elements"
]
},
"arrow-return-shorthand": true,
"comment-format": [
true,
"check-space"
Expand Down

0 comments on commit eb047b7

Please sign in to comment.