3

Is it possible to use phplint and phpcs with Visual Studio Code editor?
It seems that it's possible with Visual Studio Code tasks, is it right? If yes, how?
Visual Studio Code Tasks

1 Answer 1

2

This is a very basic example of a PHPLint task for Visual Studio Code. It isn't very sophisticated, but you will see that it gets things working.

A more sophisticated Regular Expression is needed to properly identify which lines are errors, which are warnings, and which don't matter at all.

{
    "command": "C:\\phplint\\phpl.bat",
    "version": "0.1.0",
    "args": [
        "C:\\Code\\index.php"
    ],
    "problemMatcher": {
        "fileLocation": ["relative", "${workspaceRoot}"],
        "pattern": {
            "regexp": "^(.*):(.*)$",
            "message": 1
        }
    }
}

I am using a custom problem matcher to parse the output of PHPLint. The pattern has a regexp, which parses the output of PHPLint, followed by a list of what is in each position (in this case, I am just treating the whole line as a "message" - a bit too basic, but you get the idea).

This is essentially how you would create a task for anything you can access on the command line.

Sign up to request clarification or add additional context in comments.

2 Comments

Is it possible use lint in current file instead of value for args that you used?
A more sophisticated regex and task: github.com/ikappas/vscode-phpcs/issues/… ( I couldn't get it to work, but maybe someone else can )

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.