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

Add no-object-as-default-parameter rule #633

Merged
merged 13 commits into from Jun 30, 2020
2 changes: 2 additions & 0 deletions rules/no-object-as-default-parameter.js
Expand Up @@ -4,6 +4,8 @@ const getDocumentationUrl = require('./utils/get-documentation-url');
const MESSAGE_ID = 'noObjectAsDefaultParameter';

const objectParameterSelector = [
':matches(FunctionDeclaration, ArrowFunctionExpression)',
medusalix marked this conversation as resolved.
Show resolved Hide resolved
'>',
'AssignmentPattern',
medusalix marked this conversation as resolved.
Show resolved Hide resolved
'[left.type="Identifier"]',
'[right.type="ObjectExpression"]',
Expand Down
5 changes: 4 additions & 1 deletion test/no-object-as-default-parameter.js
Expand Up @@ -34,7 +34,10 @@ ruleTester.run('no-object-as-default-parameter', rule, {
'const abc = (foo = \'bar\') => {};',
'const abc = (foo = 123, bar = \'foo\') => {};',
'const abc = (foo = {}) => {};',
'const abc = ({a = true, b = \'foo\'}) => {};'
'const abc = ({a = true, b = \'foo\'}) => {};',
'const {abc = {foo: 1}} = bar;',
'const {abc = {null: \'baz\'}} = bar;',
'const {abc = {foo: undefined}} = undefined;'
],
invalid: [
{
Expand Down