Disallow assigning values to variables used for imports.
Why is this an issue?
Assigning a new value to an import variable is a poor practice that affects code readability.
What is the potential impact?
Bad practices can cause bugs. When using the reassigned variable, if you are expecting to access the imported value, but are in fact using
something else can lead to unexpected behaviour that is hard to debug.
More importantly, it will cause a runtime error when using ES modules. With TypeScript, it will raise a compilation error.
How to fix it
You should use a separate variable to store your other values and make constant the import variable.
Code examples
Noncompliant code example
let { readFile } = require('fs');
readFile = 'hello world!';
Compliant solution
const { readFile } = require('fs');
const text = 'hello world!';