From def54e1aeeae8e2b8414df50f0defb38b835341d Mon Sep 17 00:00:00 2001 From: continuous-deployment Date: Fri, 24 Feb 2017 08:34:39 +0000 Subject: [PATCH] docs: update documentation --- README.md | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 72 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5bc02f84..5f248fe7 100644 --- a/README.md +++ b/README.md @@ -1416,7 +1416,7 @@ Requires that functions have return type annotation. You can skip all arrow functions by providing the `excludeArrowFunctions` option with `true`. -Alternatively, you can want to exclude only concise arrow function (e.g. `() => 2`). Provide `excludeArrowFunctions` with `expressionsOnly` for this. +Alternatively, you can exclude a concise arrow function (e.g. `() => 2`). Provide `excludeArrowFunctions` with `expressionsOnly` for this. ```js { @@ -1444,6 +1444,43 @@ Alternatively, you can want to exclude only concise arrow function (e.g. `() => } ``` +You can exclude or include specific tests with the `includeOnlyMatching` and `excludeMatching` rules. + +```js +{ + "rules": { + "flowtype/require-return-type": [ + 2, + "always", + { + "includeOnlyMatching": [ + "^F.*", + "Ba(r|z)" + ] + } + ] + } +} + +{ + "rules": { + "flowtype/require-return-type": [ + 2, + "always", + { + "excludeMatching": [ + "^F.*", + "Ba(r|z)" + ] + } + ] + } +} + +``` + +Both rules take an array that can contain either strings or valid RegExp statements. + The following patterns are considered problems: ```js @@ -1533,11 +1570,23 @@ function* x() {} // Options: ["always",{"excludeArrowFunctions":"expressionsOnly"}] async () => { return 4; } // Message: Missing return type annotation. + +// Options: ["always",{"includeOnlyMatching":["bar"]}] +function foo() { return 42; } +function bar() { return 42; } +// Message: Missing return type annotation. + +// Options: ["always",{"includeOnlyMatching":["bar"]}] +const foo = () => { return 42; }; +const bar = () => { return 42; } +// Message: Missing return type annotation. ``` The following patterns are not considered problems: ```js +return; + (foo): string => {} // Options: ["always"] @@ -1606,6 +1655,28 @@ async (foo): Promise => { return 3; } // Options: ["always",{"excludeArrowFunctions":"expressionsOnly"}] async () => 3 + +// Options: ["always",{"excludeMatching":["foo"]}] +function foo() { return 42; } + +// Options: ["always",{"includeOnlyMatching":["bar"]}] +function foo() { return 42; } + +// Options: ["always",{"excludeMatching":["bar"]}] +function foo(): number { return 42; } +function bar() { return 42; } + +// Options: ["always",{"includeOnlyMatching":["foo","baz"]}] +function foo(): number { return 42; } +function bar() { return 42; } + +// Options: ["always",{"excludeMatching":["^b.*","qux"]}] +function foo(): number { return 42; } +function bar() { return 42; } + +// Options: ["always",{"includeOnlyMatching":["^f.*"]}] +function foo(): number { return 42; } +function bar() { return 42; } ```