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

Rule for braces when used semicolon free style #4114

Closed
kof opened this issue Oct 11, 2015 · 13 comments
Closed

Rule for braces when used semicolon free style #4114

kof opened this issue Oct 11, 2015 · 13 comments
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 documentation Relates to ESLint's documentation help wanted The team would welcome a contribution from the community for this issue rule Relates to ESLint's core rules

Comments

@kof
Copy link

kof commented Oct 11, 2015

I personally prefer semicolon free javascript. But there are some pitfalls when braces are in place. We can add a lint rule which will ensure not to have those runtime errors.

Is eslint project itself interested in adding such a rule?
Is somebody else is interested in a separate project which can implement this rule or maybe it exists already and I missed it?

@eslintbot
Copy link

Thanks for the issue! If you're reporting a bug, please be sure to include:

  1. The version of ESLint you are using (run eslint -v)
  2. What you did (the source code and ESLint configuration)
  3. The actual ESLint output complete with numbers
  4. What you expected to happen instead

Requesting a new rule? Please see Proposing a New Rule for instructions.

@eslintbot eslintbot added the triage An ESLint team member will look at this issue soon label Oct 11, 2015
@kof
Copy link
Author

kof commented Oct 11, 2015

Also linting this possible runtime errors would end the debates about semicolons hopefully as there will be no risk any more.

@kof
Copy link
Author

kof commented Oct 11, 2015

cc @feross

@mr-mig
Copy link

mr-mig commented Oct 11, 2015

I know about 2 pitfalls with omitting semicolons.

Return statements

function add(a, b){
  return 
    a + b
}

() or [] at the beginning of the line

function fnA() {}

(function myModule(){

})()

and

function highOrderFunction() {}

[fn1, fn2, fn3].map(highOrderFunction)

@ilyavolodin
Copy link
Member

@kof Could you provide more details about what you are looking for? We have guidelines for new rule proposal here

@ilyavolodin ilyavolodin added rule Relates to ESLint's core rules evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion and removed triage An ESLint team member will look at this issue soon labels Oct 11, 2015
@kof
Copy link
Author

kof commented Oct 11, 2015

When does this rule warn? Please describe and show example code:

When options semi is defined as: "semi": [2, "never"] and following code was detected (just an example, there are more):

(function a() {})
(function(){
})

Is this rule preventing an error or is it stylistic?

ERROR

Why is this rule a candidate for inclusion instead of creating a custom rule?

because eslint has already a rule for semicolon free style, this options will just ensure not having side effects from using the other rule with provided options.

Are you willing to create the rule yourself?

it depends on how hard it is.

@nzakas
Copy link
Member

nzakas commented Oct 11, 2015

Have you looked at: http://eslint.org/docs/rules/no-unexpected-multiline

@kof
Copy link
Author

kof commented Oct 11, 2015

Oh this is exactly what I was looking for, I think we should link this rule within related rules of "semi" rule ...

Also worth mentioning it is off by default.

@michaelficarra
Copy link
Member

@kof where would you need a semicolon in that program?

@kof
Copy link
Author

kof commented Oct 11, 2015

@michaelficarra changed it a bit to produce the effect I wanted to point out, its all fine we have a rule for this, just documentation issue.

@michaelficarra
Copy link
Member

Now it makes a lot more sense.

@nzakas
Copy link
Member

nzakas commented Oct 12, 2015

@kof all rules are off by default, so there's little value in restating that in documentation.

Feel free to submit a PR for the other doc change.

@nzakas nzakas added documentation Relates to ESLint's documentation accepted There is consensus among the team that this change meets the criteria for inclusion help wanted The team would welcome a contribution from the community for this issue and removed evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion labels Oct 12, 2015
ilyavolodin added a commit that referenced this issue Oct 13, 2015
Docs: Reference no-unexpected-multiline in semi (fixes #4114)
@kof
Copy link
Author

kof commented Oct 13, 2015

thanks @ilyavolodin you was a bit faster)

lizardruss pushed a commit to codeschool/eslint that referenced this issue Oct 29, 2015
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Feb 7, 2018
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Feb 7, 2018
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 documentation Relates to ESLint's documentation help wanted The team would welcome a contribution from the community for this issue rule Relates to ESLint's core rules
Projects
None yet
Development

No branches or pull requests

6 participants