-
Notifications
You must be signed in to change notification settings - Fork 464
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
Allow loading config file from plugin directory #878
Allow loading config file from plugin directory #878
Conversation
`plugin_directories` property can be used in `.scss-linter.yml` to load additional linters from a directory. However it does not allow loading custom `.scss-linter.yml` for such directory. This commit allows loading a custom `.scss-linter.yml` from any directory specified in `plugin_directories` and merge it with your existing configuration.
80f6fff
to
787c381
Compare
# | ||
# @return [String] | ||
def plugin_config_file | ||
File.join(@dir, Config::FILE_NAME) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To reduce indirection, this line could probably be inlined directly in the plugin_config
method (since you don't use it elsewhere).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to keep as close a PluginGem structure (https://github.com/brigade/scss-lint/blob/master/lib/scss_lint/plugins/linter_gem.rb#L44) but yes it can be inlined; unless we want to test it (which we don't). I can remove it ;)
# Returns the {SCSSLint::Config} for this directory. | ||
# | ||
# This is intended to be merged with the configuration that loaded this | ||
# plugin. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment confuses me a little since we use merge_with_default: false
below. What is indented to merge, and where does that happen? I don't have a lot of context on how scss-lint configuration works, so excuse me if I'm missing something obvious.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Plugins are loaded in Config.rb (see https://github.com/brigade/scss-lint/blob/master/lib/scss_lint/config.rb#L235 and https://github.com/brigade/scss-lint/blob/master/lib/scss_lint/plugins.rb). Basically each plugin is loaded and brings its own configuration. Then all those configs are merged into one config and eventually (unless specified otherwise in the main .scss-lint.yml or cli option) merge with the default.yml config. Therefore, each plugin should avoid merging its config from default as it is done at the end of the process.
I borrowed the comment from https://github.com/brigade/scss-lint/blob/master/lib/scss_lint/plugins/linter_gem.rb#L25 for consistency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the explanation, that makes sense.
Hi @trotzig thanks for taking time to review this PR 👍 |
Thanks @barraq! I'm waiting to hear back from a person with more context on the setup. I'll get back soon. |
Thanks for the contribution @barraq! I'm going to include this in a 0.52.0 release which will be published as soon as I have permissions to push to rubygems.org. |
Awesome :D thanks |
Okay, it's been released now. |
Description
plugin_directories
property can be used in.scss-lint.yml
to load additional linters from a directory. However it does not allow loading custom.scss-lint.yml
for such directory.This PR allows loading a custom
.scss-lint.yml
from any directory specified inplugin_directories
and merge it with your existing configuration. This is pretty handy to allow extending your existing configuration from other configuration coming from other non-gem package, e.g. npm, bower, etc.What was done
linter_dir.rb
to add loading custom.scss-lint.yml
functionality (based onlinter_gem
)Note
While
scss-linter
allows loading.scss-lint.yml
file from othergems
it sometimes happen that you need to extend your project config from another.scss-lint.yml
that is not coming from agem
but from another directory or another non-gem package, like npm, bower, etc.Might be related to #516