Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

Commit

Permalink
Rename to arrow-return-shorthand and fix metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
andy-hanson committed Jan 7, 2017
1 parent f7ca02f commit ff252e2
Show file tree
Hide file tree
Showing 15 changed files with 69 additions and 32 deletions.
32 changes: 19 additions & 13 deletions docs/_data/rules.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"description": "Requires parentheses around the parameters of arrow function definitions.",
"hasFix": true,
"rationale": "Maintains stylistic consistency with other arrow function definitions.",
"optionsDescription": "\nif `ban-single-arg-parens` is specified, then arrow functions with one parameter\nmust not have parentheses if removing them is allowed by TypeScript.",
"optionsDescription": "\nIf `ban-single-arg-parens` is specified, then arrow functions with one parameter\nmust not have parentheses if removing them is allowed by TypeScript.",
"options": {
"type": "string",
"enum": [
Expand All @@ -75,6 +75,24 @@
"type": "style",
"typescriptOnly": false
},
{
"ruleName": "arrow-return-shorthand",
"description": "Suggests to convert `() => { return x; }` to `() => x`.",
"hasFix": true,
"optionsDescription": "\nIf `multiline` is specified, then this will warn even if the function spans multiple lines.",
"options": {
"type": "string",
"enum": [
"multiline"
]
},
"optionExamples": [
"[true]",
"[true, \"multiline\"]"
],
"type": "style",
"typescriptOnly": false
},
{
"ruleName": "ban",
"description": "Bans the use of specific functions or global methods.",
Expand Down Expand Up @@ -1189,18 +1207,6 @@
"type": "style",
"typescriptOnly": false
},
{
"ruleName": "prefer-arrow-shorthand-return",
"description": "Suggests to convert `() => { return x; }` to `() => x`.",
"optionsDescription": "Not configurable.",
"options": null,
"optionExamples": [
"[true]",
"[true, \"multiline\"]"
],
"type": "functionality",
"typescriptOnly": false
},
{
"ruleName": "prefer-const",
"description": "Requires that variable declarations use `const` instead of `let` if possible.",
Expand Down
2 changes: 1 addition & 1 deletion docs/rules/arrow-parens/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
rationale: Maintains stylistic consistency with other arrow function definitions.
optionsDescription: |-

if `ban-single-arg-parens` is specified, then arrow functions with one parameter
If `ban-single-arg-parens` is specified, then arrow functions with one parameter
must not have parentheses if removing them is allowed by TypeScript.
options:
type: string
Expand Down
26 changes: 26 additions & 0 deletions docs/rules/arrow-return-shorthand/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
ruleName: arrow-return-shorthand
description: 'Suggests to convert `() => { return x; }` to `() => x`.'
hasFix: true
optionsDescription: |-

If `multiline` is specified, then this will warn even if the function spans multiple lines.
options:
type: string
enum:
- multiline
optionExamples:
- '[true]'
- '[true, "multiline"]'
type: style
typescriptOnly: false
layout: rule
title: 'Rule: arrow-return-shorthand'
optionsJSON: |-
{
"type": "string",
"enum": [
"multiline"
]
}
---
2 changes: 1 addition & 1 deletion src/rules/arrowParensRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class Rule extends Lint.Rules.AbstractRule {
hasFix: true,
rationale: "Maintains stylistic consistency with other arrow function definitions.",
optionsDescription: Lint.Utils.dedent`
if \`${BAN_SINGLE_ARG_PARENS}\` is specified, then arrow functions with one parameter
If \`${BAN_SINGLE_ARG_PARENS}\` is specified, then arrow functions with one parameter
must not have parentheses if removing them is allowed by TypeScript.`,
options: {
type: "string",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,20 @@ const OPTION_MULTILINE = "multiline";
export class Rule extends Lint.Rules.AbstractRule {
/* tslint:disable:object-literal-sort-keys */
public static metadata: Lint.IRuleMetadata = {
ruleName: "prefer-arrow-shorthand-return",
ruleName: "arrow-return-shorthand",
description: "Suggests to convert `() => { return x; }` to `() => x`.",
optionsDescription: "Not configurable.",
options: null,
hasFix: true,
optionsDescription: Lint.Utils.dedent`
If \`${OPTION_MULTILINE}\` is specified, then this will warn even if the function spans multiple lines.`,
options: {
type: "string",
enum: [OPTION_MULTILINE],
},
optionExamples: [
`[true]`,
`[true, "${OPTION_MULTILINE}"]`,
],
type: "functionality",
type: "style",
typescriptOnly: false,
};
/* tslint:enable:object-literal-sort-keys */
Expand Down
8 changes: 8 additions & 0 deletions test/rules/arrow-return-shorthand/default/tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"rules": {
"arrow-return-shorthand": true
},
"jsRules": {
"arrow-return-shorthand": true
}
}
5 changes: 5 additions & 0 deletions test/rules/arrow-return-shorthand/multiline/tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"rules": {
"arrow-return-shorthand": [true, "multiline"]
}
}
8 changes: 0 additions & 8 deletions test/rules/prefer-arrow-shorthand-return/default/tslint.json

This file was deleted.

This file was deleted.

0 comments on commit ff252e2

Please sign in to comment.