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

Enforce braces for if-else and switch-case #3474

Merged
merged 9 commits into from
Dec 7, 2023
Merged

Conversation

bhavik001
Copy link
Contributor

@bhavik001 bhavik001 commented Dec 6, 2023

Fixes

Fixes #3386 by @dhruvkb

This PR incorporates changes to the ESLint configuration to enforce the use of braces in one-line if-else statements and case blocks inside switch statements. This update aims to enhance code readability and prevent potential issues in the future. The specific ESLint rules added are:

  • Enabled ESLint's built-in curly rule.
  • Enabled the unicorn plugin's switch-case-braces rule.

Testing Instructions

  1. Run ESLint on the project to check for adherence to the new rules: pnpm run eslint
  2. If necessary, automatically fix fixable issues using: pnpm run eslint --fix

Checklist

  • My pull request targets the default branch of the repository (main) or a parent feature branch.
  • My commit messages follow best practices.
  • My code follows the established code style of the repository.
  • I ran the project locally and verified that there are no visible errors.

@bhavik001 bhavik001 requested review from a team as code owners December 6, 2023 07:36
@fcoveram fcoveram removed their request for review December 6, 2023 08:29
@obulat obulat added 🟩 priority: low Low priority and doesn't need to be rushed ✨ goal: improvement Improvement to an existing user-facing feature 💻 aspect: code Concerns the software code in the repository 🧱 stack: frontend Related to the Nuxt frontend labels Dec 6, 2023
api/Pipfile.lock Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

Awesome start, @bhavik001. So many changes!
Could you revert the unrelated changes to the Pipfile.lock files?

Copy link
Contributor

@obulat obulat left a comment

Choose a reason for hiding this comment

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

I removed all of the unrelated changes (Pipfile.lock and pnpm lock file).
Thank you for your contribution, @bhavik001!

Copy link
Collaborator

@sarayourfriend sarayourfriend 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 for the quick follow up 🙏

frontend/src/components/VAudioTrack/VAudioControl.vue Outdated Show resolved Hide resolved
frontend/src/components/VAudioTrack/VWaveform.vue Outdated Show resolved Hide resolved
Copy link
Member

@dhruvkb dhruvkb left a comment

Choose a reason for hiding this comment

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

Changes LGTM, thanks for the contribution @bhavik001 and thanks @obulat for pushing this over the finish line!

@@ -33,6 +33,8 @@ export const project: TSESLint.Linter.Config = {
semi: ["error", "never"],
"no-console": "off",
"unicorn/filename-case": ["error", { case: "kebabCase" }],
"unicorn/switch-case-braces": ["error"],
Copy link
Member

Choose a reason for hiding this comment

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

TIL about unicorn 🤦. This turned out to be quite straightforward.

@dhruvkb dhruvkb changed the title Adding IF-ELSE and Switch Case Curly Braces rules Enforce braces for if-else and switch-case Dec 7, 2023
@dhruvkb dhruvkb merged commit 005af7e into WordPress:main Dec 7, 2023
43 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💻 aspect: code Concerns the software code in the repository ✨ goal: improvement Improvement to an existing user-facing feature 🟩 priority: low Low priority and doesn't need to be rushed 🧱 stack: frontend Related to the Nuxt frontend
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Add ESLint rules to mandate braces around if-else and switch-case
4 participants