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

Thoughts on padded-blocks rule? #86

Closed
mattdesl opened this issue Mar 25, 2015 · 7 comments

Comments

@mattdesl
Copy link

commented Mar 25, 2015

What are your thoughts on the padded-blocks rule?
http://eslint.org/docs/rules/padded-blocks.html

I have some code like this:

function foo () {
  return doAsync()
    .then(function () {
      return ...
    }, function () {
      // user exited early 
      return ...
    })
}

But because of this rule I am getting an error because // user exited early is treated as a blank line.

Personally I find super strict rules like this just slow down my dev cycle.

@maxogden

This comment has been minimized.

Copy link
Contributor

commented Mar 25, 2015

hmm wouldn't a fix be to treat comments as non-blank lines?

@Flet

This comment has been minimized.

Copy link
Member

commented Mar 25, 2015

I was able to verify that this passes with no linting problems:

function doAsync () {}

function foo () {
  return doAsync()
    .then(function () {
      return 'yay'
    }, function () {
      // user exited early
      return 'wee'
    })
}

module.exports = foo

Is it possible to run standard --verbose to see what rule is being violated for your snippet?

@mattdesl

This comment has been minimized.

Copy link
Author

commented Mar 25, 2015

Error: Use JavaScript Standard Style (https://github.com/feross/standard)
  foobar.js:17:24: Block must not be padded by blank lines. (eslint/padded-blocks)

Exact code:

var argv = {}
commit()

//commits current working dir, resolves to html_url
function commit (result) {
  var url = result.html_url
  //user opted not to commit anything
  if (argv.b || argv.bare) {
    return Promise.resolve(url)
  }
  return getMessage().then(function (message) {
    return gitCommit({
      message: message,
      url: url + '.git'
    }).catch(function () {
      return Promise.resolve(url)
    }).then(function () {
      // some stuff
      return url
    })
  })
}

function getMessage () {

}

function gitCommit () {

}
@maxogden

This comment has been minimized.

Copy link
Contributor

commented Mar 25, 2015

For that snippet w/ latest npm standard I get:

$ standard
Error: Use JavaScript Standard Style (https://github.com/feross/standard)
  index.js:4:0: Expected space or tab after // in comment.
  index.js:7:2: Expected space or tab after // in comment.
  index.js:30:1: Newline required at end of file but not found.
@Flet

This comment has been minimized.

Copy link
Member

commented Mar 25, 2015

@maxogden same! After fixing them it is clean.

@mattdesl

This comment has been minimized.

Copy link
Author

commented Mar 25, 2015

I'm using latest as well (3.2.1). I get the newline issue but not the space or tab after //.

I think this is related to the babel-eslint issue. #85

@mattdesl

This comment has been minimized.

Copy link
Author

commented Mar 26, 2015

Resolved after #85 was fixed

@mattdesl mattdesl closed this Mar 26, 2015

@lock lock bot locked as resolved and limited conversation to collaborators May 11, 2018

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