Skip to content

Commit

Permalink
Chore: Add extra test, improve docs (#12492)
Browse files Browse the repository at this point in the history
* Chore: Add extra test, improve docs

* Chore: Update test options
  • Loading branch information
platinumazure committed Dec 22, 2019
1 parent 827259e commit b340304
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
14 changes: 11 additions & 3 deletions docs/rules/no-param-reassign.md
Expand Up @@ -129,17 +129,25 @@ Examples of **correct** code for the `{ "props": true }` option with `"ignorePro
```js
/*eslint no-param-reassign: ["error", { "props": true, "ignorePropertyModificationsForRegex": ["^bar"] }]*/

function foo(bar) {
function foo(barVar) {
barVar.prop = "value";
}

function foo(bar) {
function foo(barrito) {
delete barrito.aaa;
}

function foo(bar) {
function foo(bar_) {
bar_.aaa++;
}

function foo(barBaz) {
for (barBaz.aaa in baz) {}
}

function foo(barBaz) {
for (barBaz.aaa of baz) {}
}
```


Expand Down
8 changes: 8 additions & 0 deletions tests/lib/rules/no-param-reassign.js
Expand Up @@ -91,6 +91,14 @@ ruleTester.run("no-param-reassign", rule, {
code: "function foo(a) { for (bar of baz) a.b; }",
options: [{ props: true }],
parserOptions: { ecmaVersion: 6 }
},
{
code: "function foo(bar, baz) { bar.a = true; baz.b = false; }",
options: [{
props: true,
ignorePropertyModificationsForRegex: ["^(foo|bar)$"],
ignorePropertyModificationsFor: ["baz"]
}]
}
],

Expand Down

0 comments on commit b340304

Please sign in to comment.