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 an option to 'semi' for omitting semicolon before brace on one-line ( JSHint's 'lastsemic' ) #4385

Closed
cho45 opened this issue Nov 11, 2015 · 5 comments
Assignees
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 rule Relates to ESLint's core rules

Comments

@cho45
Copy link

cho45 commented Nov 11, 2015

When does this rule warn? Please describe and show example code:
Current 'semi' has two options 'always' or 'never'. But I want more smart semi constraint.

// Allow this
var reduced = list.reduce(function (r, i) { return r + i });

// But disallow this
var reduced = list.reduce(function (r, i) {
    return r + i 
});

Actually, this is smart exception of 'always'.

Is this rule preventing an error or is it stylistic?
This is stylistic issue.

Why is this rule a candidate for inclusion instead of creating a custom rule?
JSHint has an option like this. ref. http://jshint.com/docs/options/#lastsemic
I'm considering to use eslint instead of jshint. People who use this option may want same behavior of this.

Are you willing to create the rule yourself?
PR: #4386

@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 Nov 11, 2015
@platinumazure
Copy link
Member

"On one line" meaning, in a block which is contained on one line and containing only one statement?

@nzakas
Copy link
Member

nzakas commented Nov 11, 2015

As best I can tell, the number of statements doesn't matter. It's that the block is on one line, so you don't need the last semicolon. These would be valid:

if (foo) { bar() }
if (foo) { bar(); baz() }

While these would be invalid:

if (foo) {
    bar()
}

if (foo) {
    bar();
    baz()
}

We'd need to come up with a good name for the option, though, as I'm not sure always-except-online is accurate.

@nzakas nzakas 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 Nov 11, 2015
@alberto
Copy link
Member

alberto commented Dec 19, 2015

Working on this.

Should it be and additional option or a second argument for always?

@nzakas
Copy link
Member

nzakas commented Dec 19, 2015

Probably an additional option since it would only apply to "always"

@alberto alberto self-assigned this Dec 19, 2015
nzakas added a commit that referenced this issue Dec 23, 2015
Update: Allow to omit semi for one-line blocks (fixes #4385)
@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 enhancement This change enhances an existing feature of ESLint rule Relates to ESLint's core rules
Projects
None yet
Development

No branches or pull requests

5 participants