Php_codesniffer: Configuration options - eslint?

Created on 11 Nov 2016  路  11Comments  路  Source: squizlabs/PHP_CodeSniffer

I used JSHint for my linting so far, but the more I read I can see that ESLint is becoming more and more popular. In the config wiki I only see that the mentioned several linters (CSSLint, JSHint, JSLint...), but no mention of ESLint.

Does this means that you do not support ESLint, or can I simply do

phpcs --config-set eslint_path ... path to linter ...

and it will work, or should I just stick with JSHint when sniffing php files?

Enhancement

Most helpful comment

It may be a good idea to document this

Thanks. I obviously missed that sniff while documenting sniff properties. It is now documented here: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Customisable-Sniff-Properties#genericdebugeslint

All 11 comments

The other linters have config setting because there are sniffs within PHPCS that use those linters (the JSHint one is here: https://github.com/squizlabs/PHP_CodeSniffer/blob/master/CodeSniffer/Standards/Generic/Sniffs/Debug/JSHintSniff.php).

There is no sniff included with PHPCS that uses ESLint, so there is no config option for it. That means you can't currently use PHPCS with ESLint.

I'll leave this as a feature request to add a sniff to support ESLint.

Thanks for clearing it up :)

I wrote a sniff for ESLint for our coding standards, happy to contribute it as a PR if you want one?

I would like to use the Sniff for ESLint.

@gsherwood Could you give a confirmation that you would like a PR otherwise I will ask @rmccue to make a PR to the WordPress coding standards. Thanks :)

Could you give a confirmation that you would like a PR

If the sniff was changed to drop the constant, and @rmccue was ok with using the copyright and licence from PHPCS, then I'd be happy to look at a PR for an ESLint sniff.

Happy to clean up and submit a PR, will try and do that this week 馃憤

@rmccue Looking forward to the PR. Any idea on when it can be expected ?

PR is up at #1374. :)

so how to actually pass CLI config options to ESLint itself? Or at least a path to .eslintrc.json?

@alexdesignworks There is a line of code that tries to work out where you have included the config file.

If that does not work for you could you extend the ESLintSniff Class and override the $configFile property.

Or define the following in your phpcs.xml config file.

<rule ref="Generic.Debug.ESLint">
    <properties>
        <property name="configFile" value="your/lint/.eslintrc.jsonl"/>
    </properties>
</rule>

@gsherwood It may be a good idea to document this here: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Configuration-Options#generic-coding-standard-configuration-options

It may be a good idea to document this

Thanks. I obviously missed that sniff while documenting sniff properties. It is now documented here: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Customisable-Sniff-Properties#genericdebugeslint

Was this page helpful?
0 / 5 - 0 ratings

Related issues

LPodolski picture LPodolski  路  3Comments

lquessenberry picture lquessenberry  路  3Comments

wowcut picture wowcut  路  3Comments

slawkens picture slawkens  路  3Comments

petegore picture petegore  路  3Comments