diff --git a/.overcommit.yml b/.overcommit.yml index 3e4647d..59e8b70 100644 --- a/.overcommit.yml +++ b/.overcommit.yml @@ -41,7 +41,7 @@ PreCommit: Pep257: enabled: true - flags: ['--ignore=D202'] + flags: ['--ignore=D202,D203'] PythonFlake8: enabled: true diff --git a/.travis.yml b/.travis.yml index ab757ff..ceb5775 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,4 +8,4 @@ install: # command to run tests script: - flake8 . --max-line-length=120 - - pep257 . --ignore=D202 + - pep257 . --ignore=D202,D203 diff --git a/CHANGELOG.md b/CHANGELOG.md index 201247d..872d063 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # SublimeLinter-slim-lint Changelog +## 3.0.0 (3/7/2018) + +#### Fixed + +* Fixed compatibility with SublimeLinter 4 ([PR #4](https://github.com/elstgav/SublimeLinter-slim-lint/pull/4) — thanks [@rpbaptist!](https://github.com/rpbaptist)) + +#### Changed + +* Added new configuration options; [see README](README.md#settings) for details + ## 2.0.0 (5/31/2015) #### Changed diff --git a/README.md b/README.md index 2bd99b7..f66dec2 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ SublimeLinter-slim-lint This linter plugin for [SublimeLinter][docs] provides an interface to [slim-lint]. It will be used with files that have the “Ruby Slim” syntax. ## Installation -SublimeLinter 3 must be installed in order to use this plugin. If SublimeLinter 3 is not installed, please follow the instructions [here][installation]. +SublimeLinter 4 must be installed in order to use this plugin. If SublimeLinter 4 is not installed, please follow the instructions [here][installation]. ### Linter installation Before using this plugin, you must ensure that `slim-lint` is installed on your system. To install `slim-lint`, do the following: @@ -40,6 +40,30 @@ For general information on how SublimeLinter works with settings, please see [Se You can configure `slim-lint` options in the way you would from the command line, with `.slim-lint.yml` files. If a `.slim-lint.yml` file is not found in the file hierarchy starting with the linted file, your home directory will also be searched. For more information, see the [slim-lint page][slim-lint]. Default configuration file can be found [here](https://github.com/sds/slim-lint/blob/master/config/default.yml). +To override the config file path, you would add this to the Sublime Linter User Settings: + +```json +"slimlint": { + "args": ["--config", "path/to/config.yml"] +} +``` + +If you are using Bundler and would like to use the locked slim_lint version, you must set `use_bundle_exec` to true: + +```json +"slimlint": { + "use_bundle_exec": true +} +``` + +You can configure the rubocop config file location: + +```json +"slimlint": { + "rubocop_config": "path/to/config.yml" +} +``` + ## Release History [See the CHANGELOG](CHANGELOG.md) diff --git a/linter.py b/linter.py index 0f05321..e970799 100644 --- a/linter.py +++ b/linter.py @@ -1,8 +1,9 @@ # # linter.py -# Linter for SublimeLinter3, a code checking framework for Sublime Text 3 +# Linter for SublimeLinter4, a code checking framework for Sublime Text 3 # # Written by Gavin Elster +# Contributors: Richard Baptist # Copyright (c) 2015 Gavin Elster # # License: MIT @@ -10,18 +11,15 @@ """This module exports the SlimLint plugin class.""" -import os -from SublimeLinter.lint import RubyLinter, util +from SublimeLinter.lint import RubyLinter class SlimLint(RubyLinter): - """Provides an interface to slim-lint.""" syntax = 'ruby slim' - cmd = 'ruby -S slim-lint' + cmd = None tempfile_suffix = '.slim' - config_file = ('--config', '.slim-lint.yml', '~') version_args = '-S slim-lint --version' version_re = r'(?P\d+\.\d+\.\d+)' @@ -33,21 +31,20 @@ class SlimLint(RubyLinter): r'(?P[^`]*(?:`(?P.+?)`)?.*)' ) - def build_args(self, settings): - """ - Return a list of args to add to cls.cmd. + def cmd(self): + """Build the command to run slim-lint.""" + settings = self.get_view_settings() + + rubocop_config_file = settings.get('rubocop_config', False) + + if rubocop_config_file: + self.env["SLIM_LINT_RUBOCOP_CONF"] = rubocop_config_file + + command = ['ruby', '-S'] - We hook into this method to find the rubocop config and set it as an - environment variable for the rubocop linter to pick up. - """ + if settings.get('use_bundle_exec', False): + command.extend(['bundle', 'exec']) - if self.filename: - config = util.find_file( - os.path.dirname(self.filename), - '.rubocop.yml', - aux_dirs='~' - ) - if config: - self.env["SLIM_LINT_RUBOCOP_CONF"] = config + command.extend(['slim-lint']) - return super().build_args(settings) + return command diff --git a/messages.json b/messages.json index 97e0356..f5ee626 100644 --- a/messages.json +++ b/messages.json @@ -1,4 +1,5 @@ { "install": "messages/install.txt", - "2.0.0": "messages/2.0.0.txt" + "2.0.0": "messages/2.0.0.txt", + "3.0.0": "messages/3.0.0.txt" } diff --git a/messages/3.0.0.txt b/messages/3.0.0.txt new file mode 100644 index 0000000..391a4ea --- /dev/null +++ b/messages/3.0.0.txt @@ -0,0 +1,33 @@ +SublimeLinter-slim-lint 3.0.0 +----------------------------- + +* Fixes compatibility with SublimeLinter 4 + + +** IMPORTANT! ** + +This update removes autodetection of .rubocop.yml files (in order to support SublimeLinter 4); +instead you can manually set the rubocop file location using the new config options below. + + +** New Configuration Options ** + +To override the config file path, you would add this to the Sublime Linter User Settings: + +"slimlint": { + "args": ["--config", "path/to/config.yml"] +} + +If you are using Bundler and would like to use the locked slim_lint version, you must set `use_bundle_exec` to true: + +"slimlint": { + "use_bundle_exec": true +} + +You can configure the rubocop config file location: + +"slimlint": { + "rubocop_config": "path/to/config.yml" +} + +See https://github.com/elstgav/SublimeLinter-slim-lint/blob/master/README.md for more details