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: add allowEmptyCase option to no-fallthrough rule #15887

Merged
merged 8 commits into from Aug 26, 2022

Conversation

amareshsm
Copy link
Member

@amareshsm amareshsm commented May 18, 2022

Prerequisites checklist

What is the purpose of this pull request? (put an "X" next to an item)

[ ] Documentation update
[ ] Bug fix (template)
[ ] New rule (template)
[x] Changes an existing rule (template)
[ ] Add autofix to a rule
[ ] Add a CLI option
[ ] Add something to the core
[ ] Other, please explain:

Refs: #15703

What changes did you make? (Give an overview)

Change to the existing rule no-fallthrough.

Added an option to allow empty cases in the switch case.

Is there anything you'd like reviewers to focus on?

What rule do you want to change?

no-fallthrough

Does this change cause the rule to produce more or fewer warnings?
yes, if allowEmptyCase option is enabled will not show any error for empty cases.
How will the change be implemented? (New option, new default behavior, etc.)?
new option
Please provide some example code that this change will affect:

var foo = 2;
var a = function (){
    console.log('sample function');
}
switch(foo){
    case 1:
    /*
    Put a message here 
    */
    case 2: a();
}

What does the rule currently do for this code?

Throws error for the empty rule.
Error:

Expected a 'break' statement before 'case'. ([no-fallthrough](https://eslint.org/docs/rules/no-fallthrough)) 

What will the rule do after it's changed?

/* eslint no-fallthrough: ["error", { "allowEmptyCase": true }] */

If we set allowEmptyCase to true, won't show errors for empty cases regardless of blank lines and comments inside.

@eslint-github-bot eslint-github-bot bot added triage An ESLint team member will look at this issue soon feature This change adds a new feature to ESLint labels May 18, 2022
@netlify
Copy link

netlify bot commented May 18, 2022

Deploy Preview for docs-eslint ready!

Name Link
🔨 Latest commit aa88f11
🔍 Latest deploy log https://app.netlify.com/sites/docs-eslint/deploys/6303c8376a549c0009a3ad84
😎 Deploy Preview https://deploy-preview-15887--docs-eslint.netlify.app/rules/no-fallthrough
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@mdjermanovic mdjermanovic added enhancement This change enhances an existing feature of ESLint rule Relates to ESLint's core rules accepted There is consensus among the team that this change meets the criteria for inclusion and removed triage An ESLint team member will look at this issue soon labels May 18, 2022
Copy link
Member

@mdjermanovic mdjermanovic left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

Can you also update the documentation for this rule: docs/src/rules/no-fallthrough.md

@mdjermanovic mdjermanovic linked an issue May 18, 2022 that may be closed by this pull request
1 task
@amareshsm
Copy link
Member Author

Thanks for the PR!

Can you also update the documentation for this rule: docs/src/rules/no-fallthrough.md

updated the documentation.

docs/src/rules/no-fallthrough.md Outdated Show resolved Hide resolved
docs/src/rules/no-fallthrough.md Outdated Show resolved Hide resolved
tests/lib/rules/no-fallthrough.js Show resolved Hide resolved
@mdjermanovic
Copy link
Member

@amareshsm are you still working on this? Please feel free to let us know if you need any help or more information. It would be nice to finish this, and I think it's close.

@amareshsm
Copy link
Member Author

@amareshsm are you still working on this? Please feel free to let us know if you need any help or more information. It would be nice to finish this, and I think it's close.

Quite Held up this week. I will look into this soon. I will let you know if I need any help.

@nzakas
Copy link
Member

nzakas commented Jul 27, 2022

@amareshsm just checking back to see if you are still working on this?

@amareshsm amareshsm changed the title feat: allow empty case in switch feat: allow empty case in switch statement Aug 12, 2022
@amareshsm
Copy link
Member Author

Changes done. PR is ready for review

@mdjermanovic mdjermanovic changed the title feat: allow empty case in switch statement feat: add allowEmptyCase option to no-fallthrough rule Aug 17, 2022
docs/src/rules/no-fallthrough.md Outdated Show resolved Hide resolved
docs/src/rules/no-fallthrough.md Show resolved Hide resolved
docs/src/rules/no-fallthrough.md Outdated Show resolved Hide resolved
lib/rules/no-fallthrough.js Outdated Show resolved Hide resolved
lib/rules/no-fallthrough.js Outdated Show resolved Hide resolved
Copy link
Member

@mdjermanovic mdjermanovic left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

I'll leave this open for a few days in case someone else wants to review it before merging.

@mdjermanovic mdjermanovic merged commit 30b1a2d into eslint:main Aug 26, 2022
crapStone pushed a commit to Calciumdibromid/CaBr2 that referenced this pull request Sep 1, 2022
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [eslint](https://eslint.org) ([source](https://github.com/eslint/eslint)) | devDependencies | minor | [`8.22.0` -> `8.23.0`](https://renovatebot.com/diffs/npm/eslint/8.22.0/8.23.0) |

---

### Release Notes

<details>
<summary>eslint/eslint</summary>

### [`v8.23.0`](https://github.com/eslint/eslint/releases/tag/v8.23.0)

[Compare Source](eslint/eslint@v8.22.0...v8.23.0)

#### Features

-   [`3e5839e`](eslint/eslint@3e5839e) feat: Enable eslint.config.js lookup from CLI ([#&#8203;16235](eslint/eslint#16235)) (Nicholas C. Zakas)
-   [`30b1a2d`](eslint/eslint@30b1a2d) feat: add `allowEmptyCase` option to no-fallthrough rule ([#&#8203;15887](eslint/eslint#15887)) (Amaresh  S M)
-   [`43f03aa`](eslint/eslint@43f03aa) feat: no-warning-comments support comments with decoration ([#&#8203;16120](eslint/eslint#16120)) (Lachlan Hunt)

#### Documentation

-   [`b1918da`](eslint/eslint@b1918da) docs: package.json conventions ([#&#8203;16206](eslint/eslint#16206)) (Patrick McElhaney)
-   [`0e03c33`](eslint/eslint@0e03c33) docs: remove word immediately ([#&#8203;16217](eslint/eslint#16217)) (Strek)
-   [`c6790db`](eslint/eslint@c6790db) docs: add anchor link for "migrating from jscs" ([#&#8203;16207](eslint/eslint#16207)) (Percy Ma)
-   [`7137344`](eslint/eslint@7137344) docs: auto-generation edit link ([#&#8203;16213](eslint/eslint#16213)) (Percy Ma)

#### Chores

-   [`2e004ab`](eslint/eslint@2e004ab) chore: upgrade [@&#8203;eslint/eslintrc](https://github.com/eslint/eslintrc)[@&#8203;1](https://github.com/1).3.1 ([#&#8203;16249](eslint/eslint#16249)) (Milos Djermanovic)
-   [`d35fbbe`](eslint/eslint@d35fbbe) chore: Upgrade to espree@9.4.0 ([#&#8203;16243](eslint/eslint#16243)) (Milos Djermanovic)
-   [`ed26229`](eslint/eslint@ed26229) test: add no-extra-parens tests with rest properties ([#&#8203;16236](eslint/eslint#16236)) (Milos Djermanovic)
-   [`deaf69f`](eslint/eslint@deaf69f) chore: fix off-by-one `min-width: 1023px` media queries ([#&#8203;15974](eslint/eslint#15974)) (Milos Djermanovic)
-   [`63dec9f`](eslint/eslint@63dec9f) refactor: simplify `parseListConfig` ([#&#8203;16241](eslint/eslint#16241)) (Milos Djermanovic)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox.

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzMi4xNzcuMSIsInVwZGF0ZWRJblZlciI6IjMyLjE4MS4wIn0=-->

Co-authored-by: cabr2-bot <cabr2.help@gmail.com>
Reviewed-on: https://codeberg.org/Calciumdibromid/CaBr2/pulls/1527
Reviewed-by: Epsilon_02 <epsilon_02@noreply.codeberg.org>
Co-authored-by: Calciumdibromid Bot <cabr2_bot@noreply.codeberg.org>
Co-committed-by: Calciumdibromid Bot <cabr2_bot@noreply.codeberg.org>
@eslint-github-bot eslint-github-bot bot locked and limited conversation to collaborators Feb 23, 2023
@eslint-github-bot eslint-github-bot bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Feb 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion enhancement This change enhances an existing feature of ESLint feature This change adds a new feature to ESLint rule Relates to ESLint's core rules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Request: add option for no-fallthrough with newlines
3 participants