Skip to content

4.0 | Wiki: update for removed sniffs running external tooling #28

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions wiki/Annotated-Ruleset.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ The following sample file documents the `ruleset.xml` format and shows you the c
such as show_warnings and report_format.

The following tag is equivalent to the command line argument:
--runtime-set zend_ca_path /path/to/ZendCodeAnalyzer
--runtime-set php_version 80100
-->
<config name="zend_ca_path" value="/path/to/ZendCodeAnalyzer"/>
<config name="php_version" value="80100"/>

<!--
If no files or directories are specified on the command line
Expand Down Expand Up @@ -453,10 +453,10 @@ The following sample file shows a `ruleset.xml` file that makes use of selective
<ruleset name="Selective Standard">

<!--
Use an external tool only when checking coding standards
Use the php_version setting only when checking coding standards
and not while fixing a file.
-->
<config phpcs-only="true" name="zend_ca_path" value="/path/to/ZendCodeAnalyzer"/>
<config phpcs-only="true" name="php_version" value="70400"/>

<!--
Exclude some files from being fixed.
Expand Down
38 changes: 14 additions & 24 deletions wiki/Configuration-Options.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,33 +229,33 @@ $ phpcs --config-set ignore_non_auto_fixable_on_exit 1
<p align="right"><a href="#table-of-contents">back to top</a></p>


## Generic Coding Standard Configuration Options
## Setting tool paths

### Setting the path to CSSLint
### Setting the path to PHP

The `Generic.Debug.CSSLint` sniff will check each CSS file using [CSS Lint](http://csslint.net/). Use the `csslint_path` configuration option to tell the CSSLint sniff where to find the tool.
The `Generic.PHP.Syntax` sniff will check the syntax of each PHP file using [the built-in PHP linter](http://php.net/manual/en/features.commandline.options.php). Use the `php_path` configuration option to tell the Syntax sniff where to find the PHP binary.

```bash
$ phpcs --config-set csslint_path /path/to/csslint
$ phpcs --config-set php_path /path/to/php
```

### Setting the path to the Google Closure Linter
### Setting the path to CSSLint (PHP_CodeSniffer < 4.0.0)

The `Generic.Debug.ClosureLinter` sniff will check each file using the [Google Closure Linter](https://github.com/google/closure-linter), an open source JavaScript style checker from Google. Use the `gjslint_path` configuration option to tell the Google Closure Linter sniff where to find the tool.
The `Generic.Debug.CSSLint` sniff will check each CSS file using [CSS Lint](http://csslint.net/). Use the `csslint_path` configuration option to tell the CSSLint sniff where to find the tool.

```bash
$ phpcs --config-set gjslint_path /path/to/gjslint
$ phpcs --config-set csslint_path /path/to/csslint
```

### Setting the path to PHP
### Setting the path to the Google Closure Linter (PHP_CodeSniffer < 4.0.0)

The `Generic.PHP.Syntax` sniff will check the syntax of each PHP file using [the built-in PHP linter](http://php.net/manual/en/features.commandline.options.php). Use the `php_path` configuration option to tell the Syntax sniff where to find the PHP binary.
The `Generic.Debug.ClosureLinter` sniff will check each file using the [Google Closure Linter](https://github.com/google/closure-linter), an open source JavaScript style checker from Google. Use the `gjslint_path` configuration option to tell the Google Closure Linter sniff where to find the tool.

```bash
$ phpcs --config-set php_path /path/to/php
$ phpcs --config-set gjslint_path /path/to/gjslint
```

### Setting the path to JSHint
### Setting the path to JSHint (PHP_CodeSniffer < 4.0.0)

The `Generic.Debug.JSHint` sniff will check each JavaScript file using [JSHint](http://www.jshint.com/), a tool to detect errors and potential problems in JavaScript code. Use the `jshint_path` configuration option to tell the JSHint sniff where to find the tool.

Expand All @@ -269,12 +269,7 @@ As JSHint is just JavaScript code, you may also need to install [Rhino](https://
$ phpcs --config-set rhino_path /path/to/rhino
```

<p align="right"><a href="#table-of-contents">back to top</a></p>


## Squiz Coding Standard Configuration Options

### Setting the path to JSLint
### Setting the path to JSLint (PHP_CodeSniffer < 4.0.0)

The `Squiz.Debug.JSLint` sniff will check each JavaScript file using [JSLint](http://www.jslint.com/), a JavaScript program that looks for problems in JavaScript programs. Use the `jslint_path` configuration option to tell the JSLint sniff where to find the tool.

Expand All @@ -288,20 +283,15 @@ As JSLint is just JavaScript code, you may also need to install [Rhino](https://
$ phpcs --config-set rhino_path /path/to/rhino
```

### Setting the path to JavaScript Lint
### Setting the path to JavaScript Lint (PHP_CodeSniffer < 4.0.0)

The `Squiz.Debug.JavascriptLint` sniff will check each JavaScript file using [JavaScript Lint](http://www.javascriptlint.com/), a tool that checks all your JavaScript source code for common mistakes without actually running the script or opening the web page. Use the `jsl_path` configuration option to tell the JavaScript Lint sniff where to find the tool.

```bash
$ phpcs --config-set jsl_path /path/to/jsl
```

<p align="right"><a href="#table-of-contents">back to top</a></p>


## Zend Coding Standard Configuration Options

### Setting the path to the Zend Code Analyzer
### Setting the path to the Zend Code Analyzer (PHP_CodeSniffer < 4.0.0)

The `Zend.Debug.CodeAnalyzer` sniff will check each file using the Zend Code Analyzer, a tool that comes with Zend Studio. Use the `zend_ca_path` configuration option to tell the Zend Code Analyzer sniff where to find the tool.

Expand Down
189 changes: 96 additions & 93 deletions wiki/Customisable-Sniff-Properties.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,61 +79,6 @@ If the `error` property is set to `false`, a warning will be thrown for violatio
<p align="right"><a href="#table-of-contents">back to top</a></p>


### Generic.Debug.ClosureLinter

| Property Name | Type | Default | Available Since |
| ------------- | ----- | ------- | --------------- |
| errorCodes | array | [] | - |
| ignoreCodes | array | [] | - |

The `Generic.Debug.ClosureLinter` sniff runs the [Google Closure Linter](https://github.com/google/closure-linter) tool over JavaScript files and reports errors that the tool finds. All found errors are reported as PHP_CodeSniffer warnings by default.

There are two configurable options:
* `errorCodes` : a list of error codes that should show as errors instead of warnings
* `ignoreCodes` : a list of error codes that should be ignored

> [!NOTE]
> The error codes accepted by this sniff are the 4-digit codes generated by the `gjslint` tool and displayed in the warning messages produced by this sniff.

```xml
<rule ref="Generic.Debug.ClosureLinter">
<properties>
<property name="errorCodes" type="array">
<element value="0210"/>
</property>
<property name="ignoreCodes" type="array">
<element value="0001"/>
<element value="0110"/>
<element value="0240"/>
</property>
</properties>
</rule>
```

<p align="right"><a href="#table-of-contents">back to top</a></p>


### Generic.Debug.ESLint

| Property Name | Type | Default | Available Since |
| ------------- | ------ | ------- | --------------- |
| configFile | string | - | 2.9.0 |

The `Generic.Debug.ESLint` sniff runs the [ESLint](https://eslint.org/) tool over JavaScript files and reports errors that the tool finds. All found violations are reported as either PHP_CodeSniffer errors or warnings based on the severity level that the ESLint tool provides.

The sniff will attempt to auto-discover an ESLint config file in the current directory, but a config file path can also be specified by setting the `configFile` property.

```xml
<rule ref="Generic.Debug.ESLint">
<properties>
<property name="configFile" value="/path/to/.eslintrc.json"/>
</properties>
</rule>
```

<p align="right"><a href="#table-of-contents">back to top</a></p>


### Generic.Files.LineEndings

| Property Name | Type | Default | Available Since |
Expand Down Expand Up @@ -1421,44 +1366,6 @@ Two of the rules that this sniff enforces are the indent of `case` and `default`
<p align="right"><a href="#table-of-contents">back to top</a></p>


### Squiz.CSS.ForbiddenStyles

| Property Name | Type | Default | Available Since |
| ------------- | ---- | ------- | --------------- |
| error | bool | true | 1.4.6 |

If the `error` property is set to `false`, a warning will be thrown for violations instead of an error.

```xml
<rule ref="Squiz.CSS.ForbiddenStyles">
<properties>
<property name="error" value="false" />
</properties>
</rule>
```

<p align="right"><a href="#table-of-contents">back to top</a></p>


### Squiz.CSS.Indentation

| Property Name | Type | Default | Available Since |
| ------------- | ---- | ------- | --------------- |
| indent | int | 4 | 1.4.7 |

This sniff checks the indentation of CSS class definitions. By default, this sniff ensures that style statements are indented using 4 spaces, but you can change the size of the indent by setting the `indent` property.

```xml
<rule ref="Squiz.CSS.Indentation">
<properties>
<property name="indent" value="2" />
</properties>
</rule>
```

<p align="right"><a href="#table-of-contents">back to top</a></p>


### Squiz.Functions.FunctionDeclaration

| Property Name | Type | Default | Available Since |
Expand Down Expand Up @@ -1783,3 +1690,99 @@ Some of the rules this sniff enforces are that there should not be whitespace at
```

<p align="right"><a href="#table-of-contents">back to top</a></p>


## Deprecated/Removed Sniffs

### Generic.Debug.ClosureLinter (PHP_CodeSniffer < 4.0.0)

| Property Name | Type | Default | Available Since | Deprecated | Removed |
| ------------- | ----- | ------- | --------------- | ---------- | ------- |
| errorCodes | array | [] | - | 3.9.0 | 4.0.0 |
| ignoreCodes | array | [] | - | 3.9.0 | 4.0.0 |

The `Generic.Debug.ClosureLinter` sniff runs the [Google Closure Linter](https://github.com/google/closure-linter) tool over JavaScript files and reports errors that the tool finds. All found errors are reported as PHP_CodeSniffer warnings by default.

There are two configurable options:
* `errorCodes` : a list of error codes that should show as errors instead of warnings
* `ignoreCodes` : a list of error codes that should be ignored

> [!NOTE]
> The error codes accepted by this sniff are the 4-digit codes generated by the `gjslint` tool and displayed in the warning messages produced by this sniff.

```xml
<rule ref="Generic.Debug.ClosureLinter">
<properties>
<property name="errorCodes" type="array">
<element value="0210"/>
</property>
<property name="ignoreCodes" type="array">
<element value="0001"/>
<element value="0110"/>
<element value="0240"/>
</property>
</properties>
</rule>
```

<p align="right"><a href="#table-of-contents">back to top</a></p>


### Generic.Debug.ESLint (PHP_CodeSniffer < 4.0.0)

| Property Name | Type | Default | Available Since | Deprecated | Removed |
| ------------- | ------ | ------- | --------------- | ---------- | ------- |
| configFile | string | - | 2.9.0 | 3.9.0 | 4.0.0 |


The `Generic.Debug.ESLint` sniff runs the [ESLint](https://eslint.org/) tool over JavaScript files and reports errors that the tool finds. All found violations are reported as either PHP_CodeSniffer errors or warnings based on the severity level that the ESLint tool provides.

The sniff will attempt to auto-discover an ESLint config file in the current directory, but a config file path can also be specified by setting the `configFile` property.

```xml
<rule ref="Generic.Debug.ESLint">
<properties>
<property name="configFile" value="/path/to/.eslintrc.json"/>
</properties>
</rule>
```

<p align="right"><a href="#table-of-contents">back to top</a></p>


### Squiz.CSS.ForbiddenStyles (PHP_CodeSniffer < 4.0.0)

| Property Name | Type | Default | Available Since | Deprecated | Removed |
| ------------- | ---- | ------- | --------------- | ---------- | ------- |
| error | bool | true | 1.4.6 | 3.9.0 | 4.0.0 |

If the `error` property is set to `false`, a warning will be thrown for violations instead of an error.

```xml
<rule ref="Squiz.CSS.ForbiddenStyles">
<properties>
<property name="error" value="false" />
</properties>
</rule>
```

<p align="right"><a href="#table-of-contents">back to top</a></p>


### Squiz.CSS.Indentation (PHP_CodeSniffer < 4.0.0)

| Property Name | Type | Default | Available Since | Deprecated | Removed |
| ------------- | ---- | ------- | --------------- | ---------- | ------- |
| indent | int | 4 | 1.4.7 | 3.9.0 | 4.0.0 |

This sniff checks the indentation of CSS class definitions. By default, this sniff ensures that style statements are indented using 4 spaces, but you can change the size of the indent by setting the `indent` property.

```xml
<rule ref="Squiz.CSS.Indentation">
<properties>
<property name="indent" value="2" />
</properties>
</rule>
```

<p align="right"><a href="#table-of-contents">back to top</a></p>
Loading