Skip to content

Commit

Permalink
Merge pull request #11 from ajmichels/per-project-executable
Browse files Browse the repository at this point in the history
add support for defining cmd on a per-project level
  • Loading branch information
ajmichels committed Mar 18, 2016
2 parents eae35fc + 296a402 commit e6f4c2b
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 2 deletions.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,22 @@ To install via Package Control, do the following:
## Settings
For general information on how SublimeLinter works with settings, please see [Settings](http://sublimelinter.readthedocs.org/en/latest/settings.html). For information on generic linter settings, please see [Linter Settings](http://sublimelinter.readthedocs.org/en/latest/linter_settings.html).

### Project Specific Executable
It is possible to specify the `phpcs` executable that should be used to lint your code on a per-project level.

**Example:**
```json
{
"SublimeLinter": {
"linters": {
"phpcs": {
"cmd": "${project}/vendor/bin/phpcs"
}
}
}
}
```

## Contributing
If you would like to contribute enhancements or fixes, please do the following:

Expand Down
14 changes: 13 additions & 1 deletion linter.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,21 @@ class Phpcs(Linter):
r'message="(?P<message>.*)" source'
)
executable = 'phpcs'
cmd = 'phpcs --report=checkstyle'
defaults = {
'--standard=': 'PSR2',
}
inline_overrides = ('standard')
tempfile_suffix = 'php'

def cmd(self):
"""Read cmd from inline settings."""
settings = Linter.get_view_settings(self)

if 'cmd' in settings:
command = [settings.get('cmd')]
else:
command = [self.executable_path]

command.append('--report=checkstyle')

return command
3 changes: 2 additions & 1 deletion messages.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"install": "messages/install.txt"
"install": "messages/install.txt",
"1.1.0": "messages/1.1.0.txt"
}
15 changes: 15 additions & 0 deletions messages/1.1.0.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
SublimeLinter-phpcs 1.1.0
---------------------------

This version adds support for declaring per-project linter executable files.

Example (*.sublime-project):
{
"SublimeLinter": {
"linters": {
"phpcs": {
"cmd": "${project}/vendor/bin/phpcs"
}
}
}
}

0 comments on commit e6f4c2b

Please sign in to comment.