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 rule to avoid using semicolons #260

Merged
merged 2 commits into from
Feb 8, 2024
Merged

Add rule to avoid using semicolons #260

merged 2 commits into from
Feb 8, 2024

Conversation

calda
Copy link
Member

@calda calda commented Feb 2, 2024

Summary

This PR proposes a new rule to avoid using semicolons.

Reasoning

Semicolons are not required at the end of a line, so should be omitted. While you can use semicolons to place two statements on the same line, it is more common and preferred to separate them using a newline instead.

Examples

/// WRONG. Semicolons are not required and can be omitted.
let mercury = planets[0];
let venus = planets[1];
let earth = planets[2];

// WRONG. While you can use semicolons to place multiple statements on a single line,
// it is more common and preferred to separate them using newlines instead.
let mercury = planets[0]; let venus = planets[1]; let earth = planets[2];

// RIGHT
let mercury = planets[0]
let venus = planets[1]
let earth = planets[2]

// WRONG
guard let moon = planet.moon else { completion(nil); return }

// WRONG
guard let moon = planet.moon else { 
  completion(nil); return
}

// RIGHT
guard let moon = planet.moon else { 
  completion(nil)
  return
}

Please react with 👍/👎 if you agree or disagree with this proposal.

@calda calda merged commit 9e403e0 into master Feb 8, 2024
5 checks passed
@calda calda deleted the cal--no-semicolons branch February 8, 2024 23:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants