Skip to content
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

feat: new rule prefer-catch #525

Merged
merged 3 commits into from
Oct 26, 2024
Merged

Conversation

brettz9
Copy link
Member

@brettz9 brettz9 commented Aug 1, 2024

What is the purpose of this pull request?

  • New rule

What changes did you make? (Give an overview)

Adds new rule prefer-catch to prefer catch over then(a, b) or then(null, b).

Closes #217.

Copy link

codecov bot commented Aug 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (bbcfcbf) to head (0b43d92).
Report is 67 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##              main      #525    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files           25        29     +4     
  Lines          649       774   +125     
  Branches       250       291    +41     
==========================================
+ Hits           649       774   +125     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@brettz9 brettz9 requested a review from a team August 1, 2024 08:15
rules/lib/parentheses.js Show resolved Hide resolved
rules/prefer-catch.js Outdated Show resolved Hide resolved
@brettz9 brettz9 requested a review from a team October 16, 2024 18:59
@brettz9 brettz9 requested a review from a team October 16, 2024 22:27
Copy link
Member

@ota-meshi ota-meshi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@brettz9 brettz9 merged commit 05c8a93 into eslint-community:main Oct 26, 2024
11 checks passed
@brettz9 brettz9 deleted the prefer-catch branch October 26, 2024 03:21
renovate bot added a commit to mmkal/eslint-plugin-mmkal that referenced this pull request Nov 25, 2024
##### [v7.2.0](https://github.com/eslint-community/eslint-plugin-promise/blob/HEAD/CHANGELOG.md#720-2024-11-25)

##### 🌟 Features

-   **`no-callback-in-promise`:** add `timeoutsErr` option ([#514](eslint-community/eslint-plugin-promise#514)) ([907753f](eslint-community/eslint-plugin-promise@907753f))
-   **`valid-params`:** add `exclude` option ([#515](eslint-community/eslint-plugin-promise#515)) ([7ff2cb9](eslint-community/eslint-plugin-promise@7ff2cb9))
-   **always-return:** add `ignoreAssignmentVariable` option ([#518](eslint-community/eslint-plugin-promise#518)) ([701279c](eslint-community/eslint-plugin-promise@701279c))
-   **catch-or-return:** add `allowThenStrict` option ([#522](eslint-community/eslint-plugin-promise#522)) ([53be970](eslint-community/eslint-plugin-promise@53be970))
-   new rule `prefer-catch` ([#525](eslint-community/eslint-plugin-promise#525)) ([05c8a93](eslint-community/eslint-plugin-promise@05c8a93))

##### 🩹 Fixes

-   permit appropriate computed member expressions and prototype access ([#535](eslint-community/eslint-plugin-promise#535)) ([4de9d43](eslint-community/eslint-plugin-promise@4de9d43))

##### 🧹 Chores

-   **deps-dev:** bump eslint-plugin-jest from 28.6.0 to 28.8.0 ([#536](eslint-community/eslint-plugin-promise#536)) ([80741f8](eslint-community/eslint-plugin-promise@80741f8))
-   **deps-dev:** bump eslint-plugin-n from 17.9.0 to 17.10.2 ([#529](eslint-community/eslint-plugin-promise#529)) ([a646010](eslint-community/eslint-plugin-promise@a646010))
-   **deps-dev:** bump globals from 15.8.0 to 15.9.0 ([#527](eslint-community/eslint-plugin-promise#527)) ([b8afe92](eslint-community/eslint-plugin-promise@b8afe92))
-   **deps-dev:** bump husky from 9.1.2 to 9.1.4 ([#524](eslint-community/eslint-plugin-promise#524)) ([b8fdb9f](eslint-community/eslint-plugin-promise@b8fdb9f))
-   **deps-dev:** bump lint-staged from 15.2.7 to 15.2.8 ([#539](eslint-community/eslint-plugin-promise#539)) ([9e2528f](eslint-community/eslint-plugin-promise@9e2528f))
-   **deps-dev:** update eslint-plugin-eslint-plugin to v6.3.0 ([#560](eslint-community/eslint-plugin-promise#560)) ([7459bd6](eslint-community/eslint-plugin-promise@7459bd6))
-   **deps-dev:** update eslint-plugin-eslint-plugin to v6.3.1 ([#561](eslint-community/eslint-plugin-promise#561)) ([434c6fa](eslint-community/eslint-plugin-promise@434c6fa))
-   **deps-dev:** update eslint-plugin-eslint-plugin to v6.3.2 ([#570](eslint-community/eslint-plugin-promise#570)) ([a849f64](eslint-community/eslint-plugin-promise@a849f64))
-   **deps-dev:** update eslint-plugin-jest to v28.9.0 ([#565](eslint-community/eslint-plugin-promise#565)) ([cf213fb](eslint-community/eslint-plugin-promise@cf213fb))
-   **deps-dev:** update eslint-plugin-n to v17.12.0 ([#563](eslint-community/eslint-plugin-promise#563)) ([d39e2f0](eslint-community/eslint-plugin-promise@d39e2f0))
-   **deps-dev:** update eslint-plugin-n to v17.13.0 ([#566](eslint-community/eslint-plugin-promise#566)) ([b62f234](eslint-community/eslint-plugin-promise@b62f234))
-   **deps-dev:** update eslint-plugin-n to v17.13.1 ([#567](eslint-community/eslint-plugin-promise#567)) ([266ddbb](eslint-community/eslint-plugin-promise@266ddbb))
-   **deps-dev:** update eslint-plugin-n to v17.13.2 ([#569](eslint-community/eslint-plugin-promise#569)) ([390f51f](eslint-community/eslint-plugin-promise@390f51f))
-   **deps-dev:** update npm-run-all2 to v6.2.4 ([#558](eslint-community/eslint-plugin-promise#558)) ([2cf1732](eslint-community/eslint-plugin-promise@2cf1732))
-   **deps-dev:** update npm-run-all2 to v6.2.6 ([#559](eslint-community/eslint-plugin-promise#559)) ([dc32933](eslint-community/eslint-plugin-promise@dc32933))
-   **deps:** switch from dependabot to renovate using shared eslint community configuration ([#537](eslint-community/eslint-plugin-promise#537)) ([30efed7](eslint-community/eslint-plugin-promise@30efed7))
-   **deps:** update [@eslint-community/eslint-utils](https://github.com/eslint-community/eslint-utils) to v4.4.1 ([#562](eslint-community/eslint-plugin-promise#562)) ([5c3628d](eslint-community/eslint-plugin-promise@5c3628d))
-   **deps:** update globals to v15.12.0 ([#564](eslint-community/eslint-plugin-promise#564)) ([c8632d1](eslint-community/eslint-plugin-promise@c8632d1))
-   update [@typescript-eslint/parser](https://github.com/typescript-eslint/parser) to v7.18.0 ([#545](eslint-community/eslint-plugin-promise#545)) ([5744e60](eslint-community/eslint-plugin-promise@5744e60))
-   update dependency eslint-plugin-n to v17.11.0 ([#556](eslint-community/eslint-plugin-promise#556)) ([bbd048b](eslint-community/eslint-plugin-promise@bbd048b))
-   update dependency eslint-plugin-n to v17.11.1 ([#557](eslint-community/eslint-plugin-promise#557)) ([e545254](eslint-community/eslint-plugin-promise@e545254))
-   update dependency globals to v15.11.0 ([#555](eslint-community/eslint-plugin-promise#555)) ([9151db8](eslint-community/eslint-plugin-promise@9151db8))
-   update dependency typescript to v5.6.3 ([#554](eslint-community/eslint-plugin-promise#554)) ([ab55120](eslint-community/eslint-plugin-promise@ab55120))
-   update eslint to v8.57.1 ([#551](eslint-community/eslint-plugin-promise#551)) ([38e2757](eslint-community/eslint-plugin-promise@38e2757))
-   update eslint-plugin-jest to v28.8.3 ([#548](eslint-community/eslint-plugin-promise#548)) ([89f2578](eslint-community/eslint-plugin-promise@89f2578))
-   update eslint-plugin-n to v17.10.3 ([#552](eslint-community/eslint-plugin-promise#552)) ([2d738fe](eslint-community/eslint-plugin-promise@2d738fe))
-   update globals to v15.10.0 ([#553](eslint-community/eslint-plugin-promise#553)) ([b871314](eslint-community/eslint-plugin-promise@b871314))
-   update husky to v9.1.6 ([#547](eslint-community/eslint-plugin-promise#547)) ([1e8d18f](eslint-community/eslint-plugin-promise@1e8d18f))
-   update lint-staged to v15.2.10 ([#544](eslint-community/eslint-plugin-promise#544)) ([7d46b3b](eslint-community/eslint-plugin-promise@7d46b3b))
-   update npm-run-all2 to v6.2.3 ([#550](eslint-community/eslint-plugin-promise#550)) ([14cd4c0](eslint-community/eslint-plugin-promise@14cd4c0))
-   update typescript to ~5.6.0 ([#549](eslint-community/eslint-plugin-promise#549)) ([ebcdd8b](eslint-community/eslint-plugin-promise@ebcdd8b))
renovate bot added a commit to mmkal/eslint-plugin-mmkal that referenced this pull request Nov 25, 2024
##### [v7.2.0](https://github.com/eslint-community/eslint-plugin-promise/blob/HEAD/CHANGELOG.md#720-2024-11-25)

##### 🌟 Features

-   **`no-callback-in-promise`:** add `timeoutsErr` option ([#514](eslint-community/eslint-plugin-promise#514)) ([907753f](eslint-community/eslint-plugin-promise@907753f))
-   **`valid-params`:** add `exclude` option ([#515](eslint-community/eslint-plugin-promise#515)) ([7ff2cb9](eslint-community/eslint-plugin-promise@7ff2cb9))
-   **always-return:** add `ignoreAssignmentVariable` option ([#518](eslint-community/eslint-plugin-promise#518)) ([701279c](eslint-community/eslint-plugin-promise@701279c))
-   **catch-or-return:** add `allowThenStrict` option ([#522](eslint-community/eslint-plugin-promise#522)) ([53be970](eslint-community/eslint-plugin-promise@53be970))
-   new rule `prefer-catch` ([#525](eslint-community/eslint-plugin-promise#525)) ([05c8a93](eslint-community/eslint-plugin-promise@05c8a93))

##### 🩹 Fixes

-   permit appropriate computed member expressions and prototype access ([#535](eslint-community/eslint-plugin-promise#535)) ([4de9d43](eslint-community/eslint-plugin-promise@4de9d43))

##### 🧹 Chores

-   **deps-dev:** bump eslint-plugin-jest from 28.6.0 to 28.8.0 ([#536](eslint-community/eslint-plugin-promise#536)) ([80741f8](eslint-community/eslint-plugin-promise@80741f8))
-   **deps-dev:** bump eslint-plugin-n from 17.9.0 to 17.10.2 ([#529](eslint-community/eslint-plugin-promise#529)) ([a646010](eslint-community/eslint-plugin-promise@a646010))
-   **deps-dev:** bump globals from 15.8.0 to 15.9.0 ([#527](eslint-community/eslint-plugin-promise#527)) ([b8afe92](eslint-community/eslint-plugin-promise@b8afe92))
-   **deps-dev:** bump husky from 9.1.2 to 9.1.4 ([#524](eslint-community/eslint-plugin-promise#524)) ([b8fdb9f](eslint-community/eslint-plugin-promise@b8fdb9f))
-   **deps-dev:** bump lint-staged from 15.2.7 to 15.2.8 ([#539](eslint-community/eslint-plugin-promise#539)) ([9e2528f](eslint-community/eslint-plugin-promise@9e2528f))
-   **deps-dev:** update eslint-plugin-eslint-plugin to v6.3.0 ([#560](eslint-community/eslint-plugin-promise#560)) ([7459bd6](eslint-community/eslint-plugin-promise@7459bd6))
-   **deps-dev:** update eslint-plugin-eslint-plugin to v6.3.1 ([#561](eslint-community/eslint-plugin-promise#561)) ([434c6fa](eslint-community/eslint-plugin-promise@434c6fa))
-   **deps-dev:** update eslint-plugin-eslint-plugin to v6.3.2 ([#570](eslint-community/eslint-plugin-promise#570)) ([a849f64](eslint-community/eslint-plugin-promise@a849f64))
-   **deps-dev:** update eslint-plugin-jest to v28.9.0 ([#565](eslint-community/eslint-plugin-promise#565)) ([cf213fb](eslint-community/eslint-plugin-promise@cf213fb))
-   **deps-dev:** update eslint-plugin-n to v17.12.0 ([#563](eslint-community/eslint-plugin-promise#563)) ([d39e2f0](eslint-community/eslint-plugin-promise@d39e2f0))
-   **deps-dev:** update eslint-plugin-n to v17.13.0 ([#566](eslint-community/eslint-plugin-promise#566)) ([b62f234](eslint-community/eslint-plugin-promise@b62f234))
-   **deps-dev:** update eslint-plugin-n to v17.13.1 ([#567](eslint-community/eslint-plugin-promise#567)) ([266ddbb](eslint-community/eslint-plugin-promise@266ddbb))
-   **deps-dev:** update eslint-plugin-n to v17.13.2 ([#569](eslint-community/eslint-plugin-promise#569)) ([390f51f](eslint-community/eslint-plugin-promise@390f51f))
-   **deps-dev:** update npm-run-all2 to v6.2.4 ([#558](eslint-community/eslint-plugin-promise#558)) ([2cf1732](eslint-community/eslint-plugin-promise@2cf1732))
-   **deps-dev:** update npm-run-all2 to v6.2.6 ([#559](eslint-community/eslint-plugin-promise#559)) ([dc32933](eslint-community/eslint-plugin-promise@dc32933))
-   **deps:** switch from dependabot to renovate using shared eslint community configuration ([#537](eslint-community/eslint-plugin-promise#537)) ([30efed7](eslint-community/eslint-plugin-promise@30efed7))
-   **deps:** update [@eslint-community/eslint-utils](https://github.com/eslint-community/eslint-utils) to v4.4.1 ([#562](eslint-community/eslint-plugin-promise#562)) ([5c3628d](eslint-community/eslint-plugin-promise@5c3628d))
-   **deps:** update globals to v15.12.0 ([#564](eslint-community/eslint-plugin-promise#564)) ([c8632d1](eslint-community/eslint-plugin-promise@c8632d1))
-   update [@typescript-eslint/parser](https://github.com/typescript-eslint/parser) to v7.18.0 ([#545](eslint-community/eslint-plugin-promise#545)) ([5744e60](eslint-community/eslint-plugin-promise@5744e60))
-   update dependency eslint-plugin-n to v17.11.0 ([#556](eslint-community/eslint-plugin-promise#556)) ([bbd048b](eslint-community/eslint-plugin-promise@bbd048b))
-   update dependency eslint-plugin-n to v17.11.1 ([#557](eslint-community/eslint-plugin-promise#557)) ([e545254](eslint-community/eslint-plugin-promise@e545254))
-   update dependency globals to v15.11.0 ([#555](eslint-community/eslint-plugin-promise#555)) ([9151db8](eslint-community/eslint-plugin-promise@9151db8))
-   update dependency typescript to v5.6.3 ([#554](eslint-community/eslint-plugin-promise#554)) ([ab55120](eslint-community/eslint-plugin-promise@ab55120))
-   update eslint to v8.57.1 ([#551](eslint-community/eslint-plugin-promise#551)) ([38e2757](eslint-community/eslint-plugin-promise@38e2757))
-   update eslint-plugin-jest to v28.8.3 ([#548](eslint-community/eslint-plugin-promise#548)) ([89f2578](eslint-community/eslint-plugin-promise@89f2578))
-   update eslint-plugin-n to v17.10.3 ([#552](eslint-community/eslint-plugin-promise#552)) ([2d738fe](eslint-community/eslint-plugin-promise@2d738fe))
-   update globals to v15.10.0 ([#553](eslint-community/eslint-plugin-promise#553)) ([b871314](eslint-community/eslint-plugin-promise@b871314))
-   update husky to v9.1.6 ([#547](eslint-community/eslint-plugin-promise#547)) ([1e8d18f](eslint-community/eslint-plugin-promise@1e8d18f))
-   update lint-staged to v15.2.10 ([#544](eslint-community/eslint-plugin-promise#544)) ([7d46b3b](eslint-community/eslint-plugin-promise@7d46b3b))
-   update npm-run-all2 to v6.2.3 ([#550](eslint-community/eslint-plugin-promise#550)) ([14cd4c0](eslint-community/eslint-plugin-promise@14cd4c0))
-   update typescript to ~5.6.0 ([#549](eslint-community/eslint-plugin-promise#549)) ([ebcdd8b](eslint-community/eslint-plugin-promise@ebcdd8b))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Prefer calling then and catch separately to combining them into a single then
3 participants