From 3a25b01da16b1ad3afe4d12e709d4ebc4c6a7cde Mon Sep 17 00:00:00 2001 From: Richard Baptist Date: Tue, 6 Mar 2018 19:04:30 +0200 Subject: [PATCH 1/6] Make linter compatible with Sublime Linter 4 --- linter.py | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) 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 From eeeb74be7a576365b9e6824ec43f39bcc5b2a3b1 Mon Sep 17 00:00:00 2001 From: Richard Baptist Date: Tue, 6 Mar 2018 19:04:35 +0200 Subject: [PATCH 2/6] Update README.md --- README.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/README.md b/README.md index 2bd99b7..a34c32b 100644 --- a/README.md +++ b/README.md @@ -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 rubocop version (which will also allow you to use `inherit_gem` in `rubocop.yml`, in case you are inheriting from another gem in the project), 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) From d6e23589d43d4324e96f233aabc2f99d17f0d9db Mon Sep 17 00:00:00 2001 From: Richard Baptist Date: Wed, 7 Mar 2018 11:40:26 +0200 Subject: [PATCH 3/6] Fix README It was a copy/paste from Rubocop linter --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a34c32b..d2cef1e 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ To override the config file path, you would add this to the Sublime Linter User } ``` -If you are using Bundler and would like to use the locked rubocop version (which will also allow you to use `inherit_gem` in `rubocop.yml`, in case you are inheriting from another gem in the project), you must set `use_bundle_exec` to true: +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": { From e766a685cec32ee7c88b712f4f0415022f39c089 Mon Sep 17 00:00:00 2001 From: Gavin Elster Date: Wed, 7 Mar 2018 11:08:55 -0800 Subject: [PATCH 4/6] Fix linter issues --- .overcommit.yml | 2 +- .travis.yml | 2 +- linter.py | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) 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/linter.py b/linter.py index 0f05321..f24b492 100644 --- a/linter.py +++ b/linter.py @@ -15,7 +15,6 @@ class SlimLint(RubyLinter): - """Provides an interface to slim-lint.""" syntax = 'ruby slim' From b3eab787606451f14aa92a1427f8123149d58fde Mon Sep 17 00:00:00 2001 From: Gavin Elster Date: Wed, 7 Mar 2018 11:35:13 -0800 Subject: [PATCH 5/6] Bump version --- CHANGELOG.md | 10 ++++++++++ README.md | 2 +- messages.json | 3 ++- messages/3.0.0.txt | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 messages/3.0.0.txt diff --git a/CHANGELOG.md b/CHANGELOG.md index 201247d..286962f 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 (Thanks @rpbaptist! PR #4) + +#### 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 d2cef1e..0ffe175 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ You can configure the rubocop config file location: ```json "slimlint": { - "rubocop_config": "path/to/config.yml" + "rubocop_config": "path/to/config.yml" } ``` 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 From 675dd6922b89940b998e33a72370b3220ead050c Mon Sep 17 00:00:00 2001 From: Gavin Elster Date: Wed, 7 Mar 2018 11:41:15 -0800 Subject: [PATCH 6/6] Fix documentation --- CHANGELOG.md | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 286962f..872d063 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ #### Fixed -* Fixed compatibility with SublimeLinter 4 (Thanks @rpbaptist! PR #4) +* Fixed compatibility with SublimeLinter 4 ([PR #4](https://github.com/elstgav/SublimeLinter-slim-lint/pull/4) — thanks [@rpbaptist!](https://github.com/rpbaptist)) #### Changed diff --git a/README.md b/README.md index 0ffe175..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: