Skip to content

Commit

Permalink
Use Glob Patterns For Exclusions Instead Of Regular Expressions (#51)
Browse files Browse the repository at this point in the history
This adds a new `phpCodeSniffer.exclude` option that replaces the `phpCodeSniffer.ignorePatterns` option. The new option uses glob patterns instead of regular expressions, making it consistent with other extensions.
  • Loading branch information
ObliviousHarmony authored Jul 29, 2022
1 parent 92342f8 commit 8c24d30
Show file tree
Hide file tree
Showing 9 changed files with 211 additions and 136 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,16 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Added
- Use glob patterns to exclude files and folders from linting using the `phpCodeSniffer.exclude` option.

### Fixed
- Document formatting with no changes clears diagnostics.
- Document selection formatting only works on the first character of the diagnostic.

### Deprecated
- `phpCodeSniffer.ignorePatterns` has been deprecated in favor of using glob patterns over regular expressions.

## [1.6.0] - 2022-05-06
### Fixed
- `phpCodeSniffer.executable` options with spaces throwing errors.
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ VS Code's available features.

## Configuration

Out of the box this extension will do nothing and must be configured prior to use.
_**Until you configure it, this extension will not lint any files.**_

### Standard (`phpCodeSniffer.standard`)

Expand All @@ -25,3 +25,7 @@ the `phpCodeSniffer.autoExecutable` option if you'd like for the extension to au
executable. This works by looking for a `{vendor-dir}/bin/phpcs` file in the document's directory and then
traversing up to the workspace folder if it does not find one. When it fails to find one automatically it
will fall back to the explicit option.

### File and Folder Exclusions (`phpCodeSniffer.exclude`)

This array of glob patterns allows you to exclude files and folders from linting. While the extension **does** respect any file rules in your coding standard, this option allows you to define additional rules.
180 changes: 75 additions & 105 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"phpCodeSniffer.ignorePatterns": {
"type": "array",
"description": "An array of regular expressions for paths that should be ignored by the extension.",
"markdownDeprecationMessage": "File and folder exclusions should use glob patterns in `#phpCodeSniffer.exclude#` instead.",
"default": [
".*/vendor/.*"
],
Expand All @@ -56,6 +57,17 @@
},
"scope": "window"
},
"phpCodeSniffer.exclude": {
"type": "array",
"description": "Glob patterns for files and folders that should be ignored by the extension.",
"default": [
"**/vendor/**"
],
"items": {
"type": "string"
},
"scope": "window"
},
"phpCodeSniffer.lintAction": {
"type": "string",
"description": "The editor action that will cause the linter to run.",
Expand Down Expand Up @@ -111,10 +123,14 @@
}
]
},
"dependencies": {
"minimatch": "^3.0.4"
},
"devDependencies": {
"@types/jest": "^26.0.23",
"@types/node": "^12.20.37",
"@types/vscode": "~1.53.0",
"@types/minimatch": "^3.0.4",
"@typescript-eslint/eslint-plugin": "^4.33.0",
"@typescript-eslint/parser": "^4.33.0",
"eslint": "^7.27.0",
Expand Down
Loading

0 comments on commit 8c24d30

Please sign in to comment.