Skip to content

Commit

Permalink
Merge pull request #53 from jonaskello/rule-rename
Browse files Browse the repository at this point in the history
Rename Rules
  • Loading branch information
Rebecca Stevens authored Jul 30, 2019
2 parents 7ccb03f + 24cde61 commit 20aedea
Show file tree
Hide file tree
Showing 20 changed files with 54 additions and 42 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ See [@typescript-eslint/parser's README.md](https://github.com/typescript-eslint

| Name | Description | <span title="No Object-Orientation">:see_no_evil:</span> | <span title="Lite">:hear_no_evil:</span> | <span title="Recommended">:speak_no_evil:</span> | :wrench: | :blue_heart: |
| ------------------------------------------------------------ | ------------------------------------------------------------------------ | :------------------------------------------------------: | :--------------------------------------: | :----------------------------------------------: | :------: | :---------------: |
| [`no-this`](./docs/rules/no-this.md) | Disallow `this` access | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | | |
| [`no-this-expression`](./docs/rules/no-this-expression.md) | Disallow `this` access | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | | |
| [`no-class`](./docs/rules/no-class.md) | Disallow classes | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | | |
| [`no-mixed-type`](./docs/rules/no-mixed-type.md) | Restrict types so that only members of the same kind are allowed in them | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | | :thought_balloon: |
| [`prefer-type-literal`](./docs/rules/prefer-type-literal.md) | Use type literals over interfaces | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | | :thought_balloon: |
Expand All @@ -157,11 +157,11 @@ See [@typescript-eslint/parser's README.md](https://github.com/typescript-eslint

:see_no_evil: = `no-exceptions` Ruleset.

| Name | Description | <span title="No Exceptions">:see_no_evil:</span> | <span title="Lite">:hear_no_evil:</span> | <span title="Recommended">:speak_no_evil:</span> | :wrench: | :blue_heart: |
| ---------------------------------------- | ----------------------------------------------------- | :----------------------------------------------: | :--------------------------------------: | :----------------------------------------------: | :------: | :----------: |
| [`no-throw`](./docs/rules/no-throw.md) | Disallow throwing exceptions | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | | |
| [`no-try`](./docs/rules/no-try.md) | Disallow try-catch[-finally] and try-finally patterns | :heavy_check_mark: | | :heavy_check_mark: | | |
| [`no-reject`](./docs/rules/no-reject.md) | Disallow rejecting Promises | | | | | |
| Name | Description | <span title="No Exceptions">:see_no_evil:</span> | <span title="Lite">:hear_no_evil:</span> | <span title="Recommended">:speak_no_evil:</span> | :wrench: | :blue_heart: |
| ---------------------------------------------------------- | ----------------------------------------------------- | :----------------------------------------------: | :--------------------------------------: | :----------------------------------------------: | :------: | :----------: |
| [`no-throw-statement`](./docs/rules/no-throw-statement.md) | Disallow throwing exceptions | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | | |
| [`no-try-statement`](./docs/rules/no-try-statement.md) | Disallow try-catch[-finally] and try-finally patterns | :heavy_check_mark: | | :heavy_check_mark: | | |
| [`no-promise-reject`](./docs/rules/no-promise-reject.md) | Disallow rejecting Promises | | | | | |

### Currying Rules

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/no-class.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Disallow use of the `class` keyword.

## Rule Details

Thanks to libraries like [recompose](https://github.com/acdlite/recompose) and Redux's [React Container components](http://redux.js.org/docs/basics/UsageWithReact.html), there's not much reason to build Components using `React.createClass` or ES6 classes anymore. The `no-this` rule makes this explicit.
Thanks to libraries like [recompose](https://github.com/acdlite/recompose) and Redux's [React Container components](http://redux.js.org/docs/basics/UsageWithReact.html), there's not much reason to build Components using `React.createClass` or ES6 classes anymore. The `no-this-expression` rule makes this explicit.

```typescript
const Message = React.createClass({
Expand Down
4 changes: 2 additions & 2 deletions docs/rules/no-reject.md → docs/rules/no-promise-reject.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Disallow try-catch[-finally] and try-finally patterns (no-reject)
# Disallow try-catch[-finally] and try-finally patterns (no-promise-reject)

This rule disallows `Promise.reject()`.

## Rule Details

You can view a `Promise` as a result object with built-in error (something like `{ value: number } | { error: Error }`) in which case a rejected `Promise` can be viewed as a returned result and thus fits with functional programming. You can also view a rejected promise as something similar to an exception and as such something that does not fit with functional programming. If your view is the latter you can use the `no-reject` rule to disallow rejected promises.
You can view a `Promise` as a result object with built-in error (something like `{ value: T } | { error: Error }`) in which case a rejected `Promise` can be viewed as a returned result and thus fits with functional programming. You can also view a rejected promise as something similar to an exception and as such something that does not fit with functional programming. If your view is the latter you can use the `no-promise-reject` rule to disallow rejected promises.

```typescript
async function divide(
Expand Down
2 changes: 1 addition & 1 deletion docs/rules/no-this.md → docs/rules/no-this-expression.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Disallow this access (no-this)
# Disallow this access (no-this-expression)

See the [no-class](./no-class.md) rule for more info.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Disallow throwing exceptions (no-throw)
# Disallow throwing exceptions (no-throw-statement)

This rule disallows the `throw` keyword.

Expand Down
4 changes: 2 additions & 2 deletions docs/rules/no-try.md → docs/rules/no-try-statement.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Disallow try-catch[-finally] and try-finally patterns (no-try)
# Disallow try-catch[-finally] and try-finally patterns (no-try-statement)

This rule disallows the `try` keyword.

## Rule Details

Try statements are not part of functional programming. See [no-throw](./no-throw.md) for more information.
Try statements are not part of functional programming. See [no-throw-statement](./no-throw-statement.md) for more information.

## Options

Expand Down
8 changes: 4 additions & 4 deletions src/configs/all.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ const config = {
"functional/no-expression-statement": "error",
"functional/no-let": "error",
"functional/no-loop-statement": "error",
"functional/no-reject": "error",
"functional/no-this": "error",
"functional/no-throw": "error",
"functional/no-try": "error"
"functional/no-promise-reject": "error",
"functional/no-this-expression": "error",
"functional/no-throw-statement": "error",
"functional/no-try-statement": "error"
},
overrides: [
{
Expand Down
2 changes: 1 addition & 1 deletion src/configs/functional-lite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const config = deepMerge(functional, {
rules: {
"functional/no-conditional-statement": "off",
"functional/no-expression-statement": "off",
"functional/no-try": "off"
"functional/no-try-statement": "off"
}
});

Expand Down
4 changes: 2 additions & 2 deletions src/configs/no-exceptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import recommended from "./external-recommended";

const config = deepMerge(recommended, {
rules: {
"functional/no-throw": "error",
"functional/no-try": "error"
"functional/no-throw-statement": "error",
"functional/no-try-statement": "error"
}
});

Expand Down
2 changes: 1 addition & 1 deletion src/configs/no-object-orientation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import recommended from "./external-recommended";

const config = deepMerge(recommended, {
rules: {
"functional/no-this": "error",
"functional/no-this-expression": "error",
"functional/no-class": "error"
},
overrides: [
Expand Down
28 changes: 20 additions & 8 deletions src/rules/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,26 @@ import {
name as noMixedInterfaceRuleName,
rule as noMixedInterfaceRule
} from "./no-mixed-type";
import { name as noRejectRuleName, rule as noRejectRule } from "./no-reject";
import {
name as noPromiseRejectRuleName,
rule as noPromiseRejectRule
} from "./no-promise-reject";
import {
name as noReturnVoidName,
rule as noReturnVoid
} from "./no-return-void";
import { name as noThisRuleName, rule as noThisRule } from "./no-this";
import { name as noThrowRuleName, rule as noThrowRule } from "./no-throw";
import { name as noTryRuleName, rule as noTryRule } from "./no-try";
import {
name as noThisExpressionRuleName,
rule as noThisExpressionRule
} from "./no-this-expression";
import {
name as noThrowStatementRuleName,
rule as noThrowStatementRule
} from "./no-throw-statement";
import {
name as noTryStatementRuleName,
rule as noTryStatementRule
} from "./no-try-statement";
import {
name as preferReadonlyTypesRuleName,
rule as preferReadonlyTypesRule
Expand All @@ -58,11 +70,11 @@ export const rules = {
[noLoopRuleName]: noLoopRule,
[noMethodSignatureRuleName]: noMethodSignatureRule,
[noMixedInterfaceRuleName]: noMixedInterfaceRule,
[noRejectRuleName]: noRejectRule,
[noPromiseRejectRuleName]: noPromiseRejectRule,
[noReturnVoidName]: noReturnVoid,
[noThisRuleName]: noThisRule,
[noThrowRuleName]: noThrowRule,
[noTryRuleName]: noTryRule,
[noThisExpressionRuleName]: noThisExpressionRule,
[noThrowStatementRuleName]: noThrowStatementRule,
[noTryStatementRuleName]: noTryStatementRule,
[preferReadonlyTypesRuleName]: preferReadonlyTypesRule,
[preferTypeRuleName]: preferTypeRule
};
2 changes: 1 addition & 1 deletion src/rules/no-reject.ts → src/rules/no-promise-reject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
import { isIdentifier, isMemberExpression } from "../util/typeguard";

// The name of this rule.
export const name = "no-reject" as const;
export const name = "no-promise-reject" as const;

// The options this rule can take.
type Options = {};
Expand Down
2 changes: 1 addition & 1 deletion src/rules/no-this.ts → src/rules/no-this-expression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
} from "../util/rule";

// The name of this rule.
export const name = "no-this" as const;
export const name = "no-this-expression" as const;

// The options this rule can take.
type Options = {};
Expand Down
2 changes: 1 addition & 1 deletion src/rules/no-throw.ts → src/rules/no-throw-statement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
} from "../util/rule";

// The name of this rule.
export const name = "no-throw" as const;
export const name = "no-throw-statement" as const;

// The options this rule can take.
type Options = {};
Expand Down
2 changes: 1 addition & 1 deletion src/rules/no-try.ts → src/rules/no-try-statement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
} from "../util/rule";

// The name of this rule.
export const name = "no-try" as const;
export const name = "no-try-statement" as const;

// The options this rule can take.
type Options = {
Expand Down
2 changes: 1 addition & 1 deletion src/util/conditional-imports/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"rules": {
"@typescript-eslint/no-require-imports": "off",
"functional/functional-parameters": "off",
"functional/no-try": "off"
"functional/no-try-statement": "off"
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/**
* @file Tests for no-reject.
* @file Tests for no-promise-reject.
*/

import dedent from "dedent";
import { RuleTester } from "eslint";

import { name, rule } from "../../src/rules/no-reject";
import { name, rule } from "../../src/rules/no-promise-reject";

import { es6, typescript } from "../helpers/configs";
import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/**
* @file Tests for no-this.
* @file Tests for no-this-expression.
*/

import { RuleTester } from "eslint";

import { name, rule } from "../../src/rules/no-this";
import { name, rule } from "../../src/rules/no-this-expression";

import { es3, typescript } from "../helpers/configs";
import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/**
* @file Tests for no-throw.
* @file Tests for no-throw-statement.
*/

import dedent from "dedent";
import { RuleTester } from "eslint";

import { name, rule } from "../../src/rules/no-throw";
import { name, rule } from "../../src/rules/no-throw-statement";

import { es3, typescript } from "../helpers/configs";
import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/**
* @file Tests for no-try.
* @file Tests for no-try-statement.
*/

import { RuleTester } from "eslint";

import { name, rule } from "../../src/rules/no-try";
import { name, rule } from "../../src/rules/no-try-statement";

import { es3, typescript } from "../helpers/configs";
import {
Expand Down

0 comments on commit 20aedea

Please sign in to comment.