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

Consolidate JS apply and check whitelists #20

Closed
amcgee opened this issue Mar 5, 2019 · 5 comments
Closed

Consolidate JS apply and check whitelists #20

amcgee opened this issue Mar 5, 2019 · 5 comments
Labels

Comments

@amcgee
Copy link
Member

amcgee commented Mar 5, 2019

Currently there are two implementations of whitelisting, one in files.js which includes css and json files and one in check.js which does not. As such, the behavior of d2-style js check doesn't match d2-style js apply.

These should probably both use the shared whitelist, likely excluding css and json files for now (though I think we should look into @ismay's stylelint suggestion in #17 - it can also support styled-jsx I believe).

@amcgee
Copy link
Member Author

amcgee commented Mar 5, 2019

Oops, It looks like @varl changed the code under me while I was sleeping :-D

I think this is still relevant though - the --all flag now has a confusing double-meaning because it toggles staged file checking as well as non-js file checking I believe?

@varl
Copy link
Contributor

varl commented Mar 5, 2019

Haha, yeah I'm a sneak sometimes. 🐍 I saw the same thing...

I think the --all check should be fine, but please verify my claims. I tested it in different places and looked good to me.

The staged_files and --all should be filtered using the same whitelists (only the whitelists.js one):

    if (all) {
        codeFiles = collectJsFiles(root_dir)

https://github.com/dhis2/cli-style/blob/master/src/files.js#L19-L22

    } else if (files) {
        codeFiles = files

This is unfiltered because a user has manually passed in a list of files on the commandline... On the other hand ... Maybe we should filter this one as well.

    } else {
        const whitelist = whitelisted(whitelists.js)
        codeFiles = staged_files(root_dir).filter(whitelist)
    }

This could be written a bit more cleverly so less of the internals of files.js needs to be exported:
https://github.com/dhis2/cli-style/blob/master/src/files.js#L8-L17

@varl
Copy link
Contributor

varl commented Mar 5, 2019

I've cleaned up the implementation a bit, it's more clear now.

@amcgee amcgee closed this as completed in #21 Mar 5, 2019
@amcgee
Copy link
Member Author

amcgee commented Mar 5, 2019 via email

@dhis2-bot
Copy link
Contributor

🎉 This issue has been resolved in version 2.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

No branches or pull requests

3 participants