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

Comments

Projects
None yet
5 participants
@cho45
Copy link

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

This comment has been minimized.

Copy link

commented Nov 11, 2015

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 label Nov 11, 2015

@platinumazure

This comment has been minimized.

Copy link
Member

commented Nov 11, 2015

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

@nzakas

This comment has been minimized.

Copy link
Member

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.

@alberto

This comment has been minimized.

Copy link
Member

commented Dec 19, 2015

Working on this.

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

@nzakas

This comment has been minimized.

Copy link
Member

commented Dec 19, 2015

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

@alberto alberto self-assigned this Dec 19, 2015

alberto added a commit that referenced this issue Dec 20, 2015

alberto added a commit that referenced this issue Dec 22, 2015

alberto added a commit that referenced this issue Dec 23, 2015

@alberto alberto closed this in 68dbc64 Dec 23, 2015

nzakas added a commit that referenced this issue Dec 23, 2015

Merge pull request #4750 from eslint/issue4385
Update: Allow to omit semi for one-line blocks (fixes #4385)

@eslint eslint bot locked and limited conversation to collaborators Feb 7, 2018

@eslint eslint bot added the archived due to age label Feb 7, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.