-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
fix!: no-unused-vars varsIgnorePattern
behavior with catch arguments
#17932
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
6fbbd3f
feat: fix varsIgnorePattern behavior
Tanujkanti4441 96e79c3
update docs and catchClause ignore error message
Tanujkanti4441 92298dc
update docs and tests
Tanujkanti4441 1e72d73
docs: add entry to v9 migrate page
Tanujkanti4441 741cfb6
update migrate guide wordings
Tanujkanti4441 File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -28,6 +28,7 @@ The lists below are ordered roughly by the number of users each change is expect | |||||||||
* [Case-sensitive flags in `no-invalid-regexp`](#no-invalid-regexp) | ||||||||||
* [Stricter `/* exported */` parsing](#exported-parsing) | ||||||||||
* [`"eslint:recommended"` and `"eslint:all"` strings no longer accepted in flat config](#string-config) | ||||||||||
* [Behavior of `varsIgnorePattern` option of `no-unused-vars` rule with catch arguments](#vars-ignore-pattern) | ||||||||||
|
||||||||||
### Breaking changes for plugin developers | ||||||||||
|
||||||||||
|
@@ -236,6 +237,25 @@ export default [ | |||||||||
|
||||||||||
**Related issue(s):** [#17488](https://github.com/eslint/eslint/issues/17488) | ||||||||||
|
||||||||||
## <a name="vars-ignore-pattern"></a> Behavior of `varsIgnorePattern` option of `no-unused-vars` rule with catch arguments | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
||||||||||
In previous versions of ESLint, `varsIgnorePattern` option of `no-unused-vars`, that is used to restrict some specified variable to be reported, used to ignore all variables that machtes the specified pattern except `function` arguments because there is a seperate option to ignore them called `argsIgnorePattern` and same was expected for `caughtErrorsIgnorePattern` option but `varsIgnorePattern` was also ignoring `catch` block arguments. | ||||||||||
|
||||||||||
This behavior has been fixed in ESLint v9.0.0, that means `varsIgnorePattern` option don't get applied to both `function` and `catch` block arguments. | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
||||||||||
```js | ||||||||||
/*eslint no-unused-vars: ["error", { "caughtErrors": "all", "varsIgnorePattern": "^err" }]*/ | ||||||||||
|
||||||||||
try { | ||||||||||
//... | ||||||||||
} catch (err) { // 'err' will be reported. | ||||||||||
console.error("errors"); | ||||||||||
} | ||||||||||
|
||||||||||
``` | ||||||||||
|
||||||||||
**Related issue(s):** [#17540](https://github.com/eslint/eslint/issues/17540) | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
||||||||||
## <a name="removed-context-methods"></a> Removed multiple `context` methods | ||||||||||
|
||||||||||
ESLint v9.0.0 removes multiple deprecated methods from the `context` object and moves them onto the `SourceCode` object: | ||||||||||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.