eslint-plugin-unicorn
eslint-plugin-unicorn copied to clipboard
no-null: false positive when null is used as function argument
eslint unicorn v42.0.0
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-null.md
Fails when null is used as function argument, even though this should pass. In fact this is even an example given in the "Pass" section: https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-null.md#pass
This works (no error):
const foo = Object.create(null);
but this fails:
drawingManager.setMap( null );
markers[ index ].setMap( null );
I think this shouldn't fail? I can't choose what argument types a function accepts in many cases (libraries). And if we want to have this error for functions we can control, it's better to give an error for no null arg when function is declared?
I guess we can add an option for this.
Running into the same issue making MSW mocks with HttpResponse
, since the first parameter to HttpResponse
's constructor is typed as body?: BodyInit | null
and I need to mock a null
case.