-
Notifications
You must be signed in to change notification settings - Fork 76
Filename matching for linting, Fixes #5 #79
base: master
Are you sure you want to change the base?
Conversation
Thanks @MyklClason for start working on this. Instead of reusing the extension field and picking the best extension I would an extra field called I think this is more general and does not abuse the |
As for the extension abuse. I completely agree it's abuse. I wasn't sure on what to call it offhand. I'll use these names instead.
My regex is weak so I was unable to create a regex that could duplicate the functionality of Note: |
Regex worked out rather well, but ended up having to write a priority function to get the expected results. I'm also not sure the regex is efficient. Edit: I'm not sure why this is failing. Seems like |
Also out of curiosity, why are you using I ask because I end up commenting out that line whenever I'm testing this. Here is what I'm using (rather simple approach). Before when I was working with Python, I normally don't use the terminal, but using Cloud9 as my IDE these days.
|
I meant something different. Instead of reutilizing the extension field in the configuration, I would add an extra field called path_matches, which is a regex. Then when parsing the config instead of returning a dict that maps from extension to linter you return a Config object, which has a method called Then in the lint function instead of For example if you want to run a linter for travis.yml files you would have: travis:
path_matches: "/\\.travis\\.yml$"
... |
Ah yes. I had similar thoughts while I was working on it, in terms of how to adjust the config. I was actually thinking of using something exactly like As a potential issue, it brings up the question of things like, "What if there's say a config.js file that uses a specialized version of javascript? That method results in using both config.js and .js, which may not be good." Prioritization of the results of the regexes seems to solve that, perhaps with a command to switch between best match linter and all matches linter. That and to do it right, I'd have to make a number of changes that break tests, which I may or may not be able to fix. Such as changing the below error message to something like
For backwards compatibility and perhaps simplification, it might be good to still use extensions. Essentially, if path_matches isn't provided, then an extension matching regex will be generated from the extensions. Still though, seems good to move the |
Incomplete. I've done most of the work to setup complete filename matching for linting. Figured I'd put it up here for discussion before I finish it. Only a single line of the original code is changed. Though the final version should be more integrated. Code should be fully backwards compatible, just a little slower.
Filenames are now broken into a list of possible keys for which linters may be assigned rather than being limited to only extensions. A best match search is done from left to right to determine which linter to use.
To do: