Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate why guard-for-in doesn't work for all cases #8100

Open
lilleyse opened this issue Aug 22, 2019 · 0 comments
Open

Investigate why guard-for-in doesn't work for all cases #8100

lilleyse opened this issue Aug 22, 2019 · 0 comments

Comments

@lilleyse
Copy link
Contributor

We have the eslint rule

'guard-for-in': 'error'

but it doesn't error on cases like

        for (var subMaterialId in materials) {
            if (shaderComponent.indexOf(subMaterialId) > -1) {
                return true;
            }
        }

which should actually look like:

        var materials = material._template.materials;
        for (var subMaterialId in materials) {
            if (materials.hasOwnProperty(subMaterialId)) {
                if (shaderComponent.indexOf(subMaterialId) > -1) {
                    return true;
                }
            }
        }

It seems like guard-for-in is happy as long as there's an if statement after the for loop but it doesn't actually check with whether hasOwnProperty is called.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant