Skip to content

Per project xml rulesets must be linked in *.sublime-project? #197

@Brugman

Description

@Brugman

Thanks for making this. I got the basic linting working really fast after failing with SublimeLinter-phpcs.

I'm confused by something. I've read about per project rulesets using a phpcs.xml, and I work in a team, on a few different kinds of PHP projects, so that sounds great.

To test I made the following minimal ruleset:

<?xml version="1.0"?>
<ruleset name="PHP_CodeSniffer">
    <description>Ruleset for this project.</description>
    <rule ref="Generic.ControlStructures.InlineControlStructure.NotAllowed"/>
</ruleset>

Now I have the following files:

/webdev/project1/app.php
/webdev/project1/phpcs.xml
/webdev/project1/project1.sublime-project
/webdev/project1/project1.sublime-workspace

When I go to the command line, cd to /webdev/project1/, and run phpcs app.php, I see the xml ruleset in action. The only errors I get are Inline control structures are not allowed.

But when I open the project in Sublime and run Sniff this file, I get all kinds of PSR2 errors. The default ruleset.

From other peoples issues and Googling I found that people add..

    "settings":
    {
        "phpcs":
        {
            "phpcs_additional_args": {
                "--standard": "./phpcs.xml",
                "-n": ""
            },
        }
    }

..to their project1.sublime-project files. So I tried it, and sure enough, now it works.

But *.sublime-project files are not really meant to be committed to repos. And if it's not committed, then every developer has to edit that file manually. Doesn't that defeat the purpose of distributing a per project settings file?

Why can't Sublime check for a phpcs.xml in the current directory, and then its parent, and then its parent, and then its parent, and use it, without me explicitly stating its location? I thought it would.

And lastly, from the command line it does work automatically. Is the command line smarter than Sublime?

I'm confused. I am I doing it wrong? I am missing something?

Thanks for your time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions