Sublime Forum

How to setup Sublimelinter 4 with phpcs properly

#1

Hi,
I’m getting confused with the new SublimeLinter version. As sublimelinter phpcs is now depreceated, how can we setup SL to properly use wpcs linter. The doc talks about a per project, in the plugin settings? If someone have a clue or an exemple to link to, you’re most welcome.

0 Likes

#2

Where did you see that the phpcs plugin was deprecated?

0 Likes

#3

Here: https://github.com/benmatselby/sublime-phpcs

0 Likes

#4

Ok, I misunderstood what you were referring to.

The SublimeLinter-phpcs plugin has instructions for setting the path to the phpcs executable and standards files.

0 Likes

#5

Hi,

I work with Sublime Linter and several addons: phpcs, phpcbf, phpcsfixer, phpmd, …

Here’s a config sample:

"linters": {
        "php": {
            "@disable": false,
            "args": [],
            "excludes": []
        },
        "phpcbf": {
            "@disable": false,
            "args": [],
            "cmd": "C:/Users/[USER]/AppData/Roaming/Composer/vendor/bin/phpcbf.bat",
            "excludes": []
        },
        "phpcs": {
            "@disable": false,
            "args": [],
            "excludes": [],
            "ignore_match": [
                "Line exceeds",
                "A file should declare"
            ],
            "standard": "PSR2"
        },
        "phpcsfixer": {
            "@disable": false,
            "args": [],
            "excludes": []
        },
        "phpmd": {
            "@disable": false,
            "args": [
                "--minimumpriority",
                "2"
            ],
            "excludes": [],
            "rulesets": "cleancode,codesize,controversial,design,naming,unusedcode"
        }
    },
    "paths": {
        "linux": [],
        "osx": [],
        "windows": [
            "C:/Ampps/php-7.1",
            "C:/Users/[USER]/AppData/Roaming/Composer/vendor/bin/"
        ]
    }

If you install phpcs globally with Composer and adapt the paths to yours it should work fine.

The other tools (phpcsfixer, …) can be installed the same way.

0 Likes

#6

Lovely, exactly what I was looking for. Thanks

0 Likes

#7

@migli How do you run phpcbf from sublime BTW, you added a keybinding to SL?

0 Likes

#8

I’m just using Siblime Linter settings: “lint_mode”: “load_save”

0 Likes