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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update: Allow regex in no-param-reassign ignore option array #11275
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,6 +39,11 @@ ruleTester.run("no-param-reassign", rule, { | |
{ code: "function foo(a) { delete a.b; }", options: [{ props: true, ignorePropertyModificationsFor: ["a"] }] }, | ||
{ code: "function foo(a, z) { a.b = 0; x.y = 0; }", options: [{ props: true, ignorePropertyModificationsFor: ["a", "x"] }] }, | ||
{ code: "function foo(a) { a.b.c = 0;}", options: [{ props: true, ignorePropertyModificationsFor: ["a"] }] }, | ||
{ code: "function foo(aFoo) { aFoo.b = 0; }", options: [{ props: true, ignorePropertyModificationsForRegex: ["^a.*$"] }] }, | ||
{ code: "function foo(aFoo) { ++aFoo.b; }", options: [{ props: true, ignorePropertyModificationsForRegex: ["^a.*$"] }] }, | ||
{ code: "function foo(aFoo) { delete aFoo.b; }", options: [{ props: true, ignorePropertyModificationsForRegex: ["^a.*$"] }] }, | ||
{ code: "function foo(a, z) { aFoo.b = 0; x.y = 0; }", options: [{ props: true, ignorePropertyModificationsForRegex: ["^a.*$", "^x.*$"] }] }, | ||
{ code: "function foo(aFoo) { aFoo.b.c = 0;}", options: [{ props: true, ignorePropertyModificationsForRegex: ["^a.*$"] }] }, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be good to have an additional For example, a test where props from two different params are modified, one modification is allowed because of |
||
{ | ||
code: "function foo(a) { ({ [a]: variable } = value) }", | ||
options: [{ props: true }], | ||
|
@@ -106,6 +111,18 @@ ruleTester.run("no-param-reassign", rule, { | |
parserOptions: { ecmaVersion: 6 }, | ||
errors: [{ message: "Assignment to property of function parameter 'bar'." }] | ||
}, | ||
{ | ||
code: "function foo(bar) { [bar.a] = []; }", | ||
options: [{ props: true, ignorePropertyModificationsForRegex: ["^a.*$"] }], | ||
parserOptions: { ecmaVersion: 6 }, | ||
errors: [{ message: "Assignment to property of function parameter 'bar'." }] | ||
}, | ||
{ | ||
code: "function foo(bar) { [bar.a] = []; }", | ||
options: [{ props: true, ignorePropertyModificationsForRegex: ["^B.*$"] }], | ||
parserOptions: { ecmaVersion: 6 }, | ||
errors: [{ message: "Assignment to property of function parameter 'bar'." }] | ||
}, | ||
{ | ||
code: "function foo(bar) { ({foo: bar.a} = {}); }", | ||
options: [{ props: true }], | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we please also add
for-in
andfor-of
examples? Just to make this example consistent with other examples from the actual version.