duaraghav8 / solium-plugin-security

The Official Security Plugin for Ethlint (formerly Solium)
http://npmjs.com/package/solium-plugin-security
MIT License
44 stars 12 forks source link

Added utils for checking nodes #24

Closed Cisplatin closed 6 years ago

Cisplatin commented 7 years ago

Some of them (the utils) might not be too useful, I'm not sure - let me know if this is a good idea or not!

duaraghav8 commented 7 years ago

@Cisplatin this is MUCH cleaner(I'd like to hear you if you have any opinion on below points)

Cisplatin commented 7 years ago

@duaraghav8 Yeah, the first point is why I asked you about this PR on discord - devs might just resort to checking type, like you said, in which case this PR will probably do more harm than good. I agree this should be an experimental PR.

With regards to putting them in the core solium repo, that's also a good point - would you like me to move the utils file to there and then change this PR to use that file instead?

duaraghav8 commented 7 years ago

@Cisplatin Yes, that's the best way to move forward! Please move the utils to solium, expose them & use in this plugin.

feel free to use ES6 features at ALL the places

This should expose all util methods to the rules like

create(context) {
    if (context.getSourceCode().isExpression(node)) {
        // blah
    }
}

Tests for above go into https://github.com/duaraghav8/Solium/blob/master/test/lib/utils/ast-utils.js and https://github.com/duaraghav8/Solium/blob/master/test/lib/utils/source-code-utils.js (and any other relevant files)

If you feel there's a more intuitive/cleaner way to do this, I'd like to hear it

Cisplatin commented 6 years ago

@duaraghav8 Sounds like a clean solution - I'll get working on it!

Cisplatin commented 6 years ago

@duaraghav8 Going to close this PR and make a new one that uses Solium's utils to clean-up the rules since this PR has quite a few conflicts now due to refactors and such.