[no-var-requires] False negative if require result is passed to a function #665
Labels
enhancement: plugin rule option
New rule option for an existing eslint-plugin rule
good first issue
Good for newcomers
has pr
there is a PR raised to close this
package: eslint-plugin
Issues related to @typescript-eslint/eslint-plugin
Repro
The provided code can also be found in the minimal reproduction repo at https://github.com/theneva/no-var-requires-trick.
I use the @typescript-eslint/recommended plugin with no configuration (and disable @typescript-eslint/no-unused-vars to reduce noise for the repro):
I can then trick the rule by passing the result of the
require('fs')
call into a function:Expected Result
The rule should report this as an error, as I am using the returned value of a
require(…)
call.Actual Result
The rule does not consider this to be an error.
Additional Info
When my TS code looks like this (with the same eslint config), the rule reports one assignment and ignores the other:
The output looks as follows (reporting
fs2
but notfs
):Versions
@typescript-eslint/eslint-plugin
1.11.0
@typescript-eslint/parser
1.11.0
TypeScript
3.5.2
ESLint
6.0.1
node
11.10.1
npm
N/A
(yarn
version1.17.0
)The text was updated successfully, but these errors were encountered: