From 4881ca805d2da6b7bec87981e1f67c5cea017f56 Mon Sep 17 00:00:00 2001 From: Koen Lageveen Date: Sat, 6 Jun 2020 22:49:45 +0200 Subject: [PATCH 1/3] add -s flag to include error code and capture it in the regex --- linter.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/linter.py b/linter.py index 1bcabea..84cb372 100644 --- a/linter.py +++ b/linter.py @@ -2,8 +2,8 @@ class Phpcs(ComposerLinter): - cmd = ('phpcs', '--report=emacs', '${args}', '-') - regex = r'^.*:(?P[0-9]+):(?P[0-9]+): (?:(?Perror)|(?Pwarning)) - (?P.+)' + cmd = ('phpcs', '-s', '--report=emacs', '${args}', '-') + regex = r'^.*:(?P[0-9]+):(?P[0-9]+): (?:(?Perror)|(?Pwarning)) - (?P.+) \((?P.*)\)' defaults = { 'selector': 'source.php - text.blade, text.html.basic', # we want auto-substitution of the filename, but `cmd` does not support that yet From dad2cae31ddb1b4ed7e554a75836eb3ab6d5ea9a Mon Sep 17 00:00:00 2001 From: Koen Lageveen Date: Sat, 6 Jun 2020 22:55:16 +0200 Subject: [PATCH 2/3] =?UTF-8?q?fix=20lint=20=F0=9F=99=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- linter.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/linter.py b/linter.py index 84cb372..d026565 100644 --- a/linter.py +++ b/linter.py @@ -3,9 +3,10 @@ class Phpcs(ComposerLinter): cmd = ('phpcs', '-s', '--report=emacs', '${args}', '-') - regex = r'^.*:(?P[0-9]+):(?P[0-9]+): (?:(?Perror)|(?Pwarning)) - (?P.+) \((?P.*)\)' + regex = r'^.*:(?P[0-9]+):(?P[0-9]+): (?:(?Perror)|(?Pwarning)) - (?P.+) \((?P.*)\)' # noqa: E501 defaults = { 'selector': 'source.php - text.blade, text.html.basic', - # we want auto-substitution of the filename, but `cmd` does not support that yet + # we want auto-substitution of the filename, + # but `cmd` does not support that yet '--stdin-path=': '${file}' } From 1a6041d195e1ffae20a1a9dd964dede02182c183 Mon Sep 17 00:00:00 2001 From: Koen Lageveen Date: Sun, 7 Jun 2020 13:52:18 +0200 Subject: [PATCH 3/3] capture error code if the -s arg is used --- README.md | 11 +++++++++++ linter.py | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f58d5d6..387f3fa 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,17 @@ Before using this plugin, ensure that `phpcs` is installed on your system, prefe - SublimeLinter settings: http://sublimelinter.com/en/latest/settings.html - Linter settings: http://sublimelinter.com/en/latest/linter_settings.html +Use the `"args"` setting to configure the coding standard, and/or to display the sniff codes for each error: + +```json +{ + "args": [ + "--standard=PEAR", // code standard + "-s" // display sniff codes + ] +} +``` + ### Per-project Standards You can set up your project settings to use a specific standard using the following: diff --git a/linter.py b/linter.py index d026565..6748c2c 100644 --- a/linter.py +++ b/linter.py @@ -2,8 +2,8 @@ class Phpcs(ComposerLinter): - cmd = ('phpcs', '-s', '--report=emacs', '${args}', '-') - regex = r'^.*:(?P[0-9]+):(?P[0-9]+): (?:(?Perror)|(?Pwarning)) - (?P.+) \((?P.*)\)' # noqa: E501 + cmd = ('phpcs', '--report=emacs', '${args}', '-') + regex = r'^.*:(?P[0-9]+):(?P[0-9]+): (?:(?Perror)|(?Pwarning)) - (?P(.(?!\(\S+\)$))+)( \((?P\S+)\)$)?' # noqa: E501 defaults = { 'selector': 'source.php - text.blade, text.html.basic', # we want auto-substitution of the filename,