eslint-plugin-angular icon indicating copy to clipboard operation
eslint-plugin-angular copied to clipboard

False positive for: use $document instead of document

Open danielolszewski opened this issue 9 years ago • 2 comments

I'm using eslint-plugin-angular version 1.3.0. In one of my Angular services I have a function that accepts a JS object parameter which name is document, e.g.:

function sampleFunc(document) {
    if (document.enabled) {
        // ...
    }
    // ...
}

The plugin treats the document parameters as the global reference to the document object and raises the error.

danielolszewski avatar Jul 15 '16 10:07 danielolszewski

How do you think we can detect the use of global variable versus your document function parameter ?

EmmanuelDemey avatar Jul 24 '16 14:07 EmmanuelDemey

@Gillespie59 Actually I think that could be possible. I remember that I had to distinguish between parameters and global variables for another rule.

BUT I don't think that it is a good thing to shadow global variables with. This can be very confusing for others to read your code. There is even a ESLint role to prevent this for own variables (http://eslint.org/docs/rules/no-shadow).

tilmanschweitzer avatar Jul 24 '16 20:07 tilmanschweitzer