sindresorhus/eslint-plugin-unicorn

no-null: false positive when null is used as function argument

Chiusa

#1842 aperta il 15 giu 2022

 (2 commenti) (1 reazione) (0 assegnatari)JavaScript (468 fork)user submission
enhancementhelp wanted

Metriche repository

Star
 (5022 stelle)
Metriche merge PR
 (Merge medio 4h 30m) (26 PR mergiate in 30 g)

Descrizione

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?

Guida contributor