Skip to content
This repository has been archived by the owner on Feb 10, 2024. It is now read-only.

Commit

Permalink
Merge branch 'sublime-linter-4-compatibility'
Browse files Browse the repository at this point in the history
  • Loading branch information
elstgav committed Mar 7, 2018
2 parents 64e1acb + 675dd69 commit 43bd6d7
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .overcommit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ PreCommit:

Pep257:
enabled: true
flags: ['--ignore=D202']
flags: ['--ignore=D202,D203']

PythonFlake8:
enabled: true
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ install:
# command to run tests
script:
- flake8 . --max-line-length=120
- pep257 . --ignore=D202
- pep257 . --ignore=D202,D203
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
26 changes: 25 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down
39 changes: 18 additions & 21 deletions linter.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
#
# 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
#

"""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<version>\d+\.\d+\.\d+)'
Expand All @@ -33,21 +31,20 @@ class SlimLint(RubyLinter):
r'(?P<message>[^`]*(?:`(?P<near>.+?)`)?.*)'
)

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
3 changes: 2 additions & 1 deletion messages.json
Original file line number Diff line number Diff line change
@@ -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"
}
33 changes: 33 additions & 0 deletions messages/3.0.0.txt
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 43bd6d7

Please sign in to comment.