Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: examples with arrow functions in no-return-assign (fixes #13135) #13138

Merged
merged 3 commits into from
Apr 4, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/rules/no-return-assign.md
Expand Up @@ -40,6 +40,10 @@ function doSomething() {
function doSomething() {
return foo += 2;
}

const foo = (a,b) => a = b
anikethsaha marked this conversation as resolved.
Show resolved Hide resolved

const bar = (a, b, c) => (a = b, c == b)
```

Examples of **correct** code for the default `"except-parens"` option:
Expand All @@ -58,6 +62,10 @@ function doSomething() {
function doSomething() {
return (foo = bar + 2);
}

const foo = (a, b) => (a = b)

const bar = (a, b, c) => ((a = b), c == b)
```

### always
Expand Down
10 changes: 8 additions & 2 deletions tests/lib/rules/no-return-assign.js
Expand Up @@ -52,7 +52,8 @@ ruleTester.run("no-return-assign", rule, {
{
code: "() => (result = a * b)",
options: ["except-parens"]
}
},
"const foo = (a,b,c) => ((a = b), c)"
],
invalid: [
{
Expand All @@ -79,7 +80,12 @@ ruleTester.run("no-return-assign", rule, {
},
{
code: "() => result = a * b",
errors: [{ messageId: "arrowAssignment", type: "ArrowFunctionExpression" }]
errors: [
{
messageId: "arrowAssignment",
type: "ArrowFunctionExpression"
}
]
},
{
code: "function x() { return result = a * b; };",
Expand Down