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

Add Eslint curly lint rule #420

Merged
merged 1 commit into from
Apr 16, 2021
Merged

Add Eslint curly lint rule #420

merged 1 commit into from
Apr 16, 2021

Conversation

richardwestenra
Copy link
Contributor

Description

JavaScript allows the omission of curly braces when a block contains only one statement. However, it is considered by many to be best practice to never omit curly braces around blocks, even when they are optional, because it can lead to bugs and reduces code clarity. So the following:

if (foo) foo++;

must be rewritten as:

if (foo) {
    foo++;
}

See https://eslint.org/docs/rules/curly

Development notes

The npm run lint:js task on the command line can automatically fix some of the problems reported by this rule.

QA notes

n/a

Checklist

  • Read the contributing guidelines
  • Opened this PR as a 'Draft Pull Request' if it is work-in-progress
  • Updated the documentation to reflect the code changes
  • Added new entries to the RELEASE.md file
  • Added tests to cover my changes

Legal notice

  • I acknowledge and agree that, by checking this box and clicking "Submit Pull Request":

  • I submit this contribution under the Apache 2.0 license and represent that I am entitled to do so on behalf of myself, my employer, or relevant third parties, as applicable.

  • I certify that (a) this contribution is my original creation and / or (b) to the extent it is not my original creation, I am authorised to submit this contribution on behalf of the original creator(s) or their licensees.

  • I certify that the use of this contribution as authorised by the Apache 2.0 license does not violate the intellectual property rights of anyone else.

Copy link
Contributor

@rashidakanchwala rashidakanchwala left a comment

Choose a reason for hiding this comment

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

Looks good. I went through all the if's in the code as well and can confirm all of them now have curly braces

@richardwestenra richardwestenra merged commit 6b754d4 into main Apr 16, 2021
@richardwestenra richardwestenra deleted the feature/eslint-curly branch April 16, 2021 11:01
@studioswong studioswong mentioned this pull request Apr 16, 2021
1 task
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.

3 participants