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

Object destructuring spacing #182

Closed
dcousens opened this issue Jul 2, 2015 · 46 comments

Comments

@dcousens
Copy link
Member

commented Jul 2, 2015

var { x} = ...
var {x} = ...
var {x } = ...

These cases probably shouldn't be allowed.
I'm in favour of what we've done elsewhere, enforce the spaces either side.

In any case, consistency, thoughts?

@feross

This comment has been minimized.

Copy link
Member

commented Jul 2, 2015

Yeah, I'm in favor of this if there's some way to get this rule just for object destructuring, i.e. not for object literals too:

var x = { a: 1, b: 2 }

I would like to enforce this spacing for object literals too, but at this point it's a huge breaking change and lots of people are doing:

var x = {a: 1}

I think eslint might have only one rule for object literals and object destructuring, but I can't remember. Want to look into it?

@dcousens

This comment has been minimized.

Copy link
Member Author

commented Jul 3, 2015

@feross are we able to use warnings as syntax deprecation messages?

@feross

This comment has been minimized.

Copy link
Member

commented Jul 6, 2015

I suppose we could, but that's a departure from what we currently do.

@dcousens

This comment has been minimized.

Copy link
Member Author

commented Jul 7, 2015

In an event where the above change would be introduced, I think the warning might be the best way to get an immediate, non-breaking discussion around its usage, if that is desired.

@feross

This comment has been minimized.

Copy link
Member

commented Jul 8, 2015

What about just treating:

var { x} = ...
var {x } = ...

as errors.

var { x } = ...
var {x} = ...

would be allowed.

Same for arrays. If I got var arr = [1, 2, 3] or var arr = [ 1, 2, 3 ] in a PR, I'd have no complaints. It's just var arr = [1, 2, 3 ] or var arr [ 1, 2, 3] that is gross.

Thoughts?

@dcousens

This comment has been minimized.

Copy link
Member Author

commented Jul 8, 2015

100% agree, that is a great start and enforces some form of sane consistency.

@jprichardson

This comment has been minimized.

Copy link
Member

commented Jul 8, 2015

Yep, I like this too 👍

@feross

This comment has been minimized.

Copy link
Member

commented Jul 8, 2015

Does someone want to make an eslint issue for this? I don't think this is a rule option they currently support.

@dcousens

This comment has been minimized.

Copy link
Member Author

commented Jul 8, 2015

@dcousens dcousens added blocked and removed question labels Jul 8, 2015

@dcousens

This comment has been minimized.

Copy link
Member Author

commented Jul 9, 2015

@feross the feedback is that we should just use http://eslint.org/docs/rules/object-curly-spacing.
That might cause issues though as you said.

@dcousens

This comment has been minimized.

Copy link
Member Author

commented Jul 14, 2015

@feross looks like it isn't going to change upstream, do we want to enforce a particular style then?
There is quite a few breaking changes lately (not necessarily our fault either), might be worth while to bump.

@feross

This comment has been minimized.

Copy link
Member

commented Jul 14, 2015

There is quite a few breaking changes lately (not necessarily our fault either)

This should happen a lot less going forward. I locked the eslint version so it's exact now. So if even a patch version of eslint starts causing new tests to fail, we can decide if we want to bump the major version of standard.

looks like it isn't going to change upstream, do we want to enforce a particular style then?

For any breaking style changes, even in a major, I want to make sure that standard-format is bumped in parallel, so users can use standard -F to ease the transition.

Before we do that though, @xjamundx offered to write an eslint plugin that enforces the "either" rule we wanted from eslint.

@xjamundx

This comment has been minimized.

Copy link

commented Jul 14, 2015

I can help you build this. It will take like 15 minutes. Does standard already have its own custom rules or a eslint-plugin-standard plugin we could add this to?

@feross

This comment has been minimized.

Copy link
Member

commented Jul 14, 2015

We don't have any custom rules right now. Can you put custom rules into a lib/ folder in this repo? (for now)

@xjamundx

This comment has been minimized.

Copy link

commented Jul 14, 2015

Yes that's an option, but I'd recommend at the very least you created a dedicated rules directory. To use custom rules with eslint you either need to specify the rulesdir option (which is deprecated, but going to stick around for a long while) or use plugins (which are separate NPM modules and can have multiple rules).

@xjamundx

This comment has been minimized.

Copy link

commented Jul 14, 2015

Also you only care about destructuring spacing or all of the existing things found in object-curly-spacing? I could throw together a separate destructuring-spacing rule.

@feross

This comment has been minimized.

Copy link
Member

commented Jul 14, 2015

Okay, how about we start with a rules directory and then we can pull it out into a module eventually.

We care about "even spacing" for everything in the object-curly-spacing and array-bracket-spacing rules. If it's not too hard, could you do array-bracket-spacing too?

@xjamundx

This comment has been minimized.

Copy link

commented Jul 14, 2015

Sure. I can do both. Give me a day or so!

@feross

This comment has been minimized.

Copy link
Member

commented Jul 14, 2015

@xjamundx You're awesome!

@xjamundx

This comment has been minimized.

Copy link

commented Jul 16, 2015

so funny to me:

~/dev/standard (custom-rules) $ npm test

> standard@4.5.4 test /Users/jamuferguson/dev/standard
> node ./bin/cmd.js && tape test/*.js

standard: Use JavaScript Standard Style (https://github.com/feross/standard)
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:9:0: Strings must use singlequote.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:9:13: Extra semicolon.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:11:0: Expected space or tab after // in comment.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:13:0: Expected space or tab after // in comment.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:15:25: Missing space before function parentheses.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:16:2: Expected indentation of 2 characters.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:16:40: Strings must use singlequote.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:16:49: Extra semicolon.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:25:2: Expected indentation of 2 characters.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:25:24: Missing space before function parentheses.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:26:4: Expected indentation of 4 characters.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:26:91: Extra semicolon.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:27:2: Expected indentation of 2 characters.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:29:2: Expected indentation of 2 characters.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:31:44: Strings must use singlequote.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:32:46: Strings must use singlequote.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:33:45: Strings must use singlequote.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:34:6: Extra semicolon.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:36:4: Expected space or tab after // in comment.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:38:4: Expected space or tab after // in comment.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:46:2: Expected indentation of 2 characters.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:46:21: Missing space before function parentheses.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:47:4: Expected indentation of 4 characters.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:47:46: Extra semicolon.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:48:2: Expected indentation of 2 characters.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:56:2: Expected indentation of 2 characters.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:56:23: Missing space before function parentheses.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:57:4: Expected indentation of 4 characters.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:57:60: Extra semicolon.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:58:2: Expected indentation of 2 characters.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:66:2: Expected indentation of 2 characters.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:66:35: Missing space before function parentheses.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:67:4: Expected indentation of 4 characters.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:68:68: Extra semicolon.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:69:2: Expected indentation of 2 characters.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:77:2: Expected indentation of 2 characters.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:77:32: Missing space before function parentheses.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:78:4: Expected indentation of 4 characters.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:79:69: Extra semicolon.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:80:2: Expected indentation of 2 characters.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:88:2: Expected indentation of 2 characters.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:88:41: Missing space before function parentheses.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:89:4: Expected indentation of 4 characters.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:90:63: Extra semicolon.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:91:2: Expected indentation of 2 characters.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:99:2: Expected indentation of 2 characters.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:99:38: Missing space before function parentheses.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:100:4: Expected indentation of 4 characters.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:101:72: Extra semicolon.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:102:2: Expected indentation of 2 characters.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:109:2: Expected indentation of 2 characters.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:109:33: Missing space before function parentheses.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:110:4: Expected indentation of 4 characters.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:111:6: Expected indentation of 6 characters.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:111:19: Extra semicolon.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:112:4: Expected indentation of 4 characters.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:114:4: Expected indentation of 4 characters.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:114:8: Split initialized 'var' declarations into multiple statements.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:117:46: Extra semicolon.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:119:4: Expected indentation of 4 characters.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:120:65: Strings must use singlequote.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:121:64: Strings must use singlequote.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:123:51: Extra semicolon.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:125:4: Expected indentation of 4 characters.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:126:70: Strings must use singlequote.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:127:69: Strings must use singlequote.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:129:51: Extra semicolon.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:131:4: Expected indentation of 4 characters.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:132:6: Expected indentation of 6 characters.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:133:8: Expected indentation of 8 characters.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:133:58: Extra semicolon.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:134:6: Expected indentation of 6 characters.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:135:6: Expected indentation of 6 characters.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:136:8: Expected indentation of 8 characters.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:136:52: Extra semicolon.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:137:6: Expected indentation of 6 characters.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:138:4: Expected indentation of 4 characters.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:140:4: Expected indentation of 4 characters.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:141:6: Expected indentation of 6 characters.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:142:8: Expected indentation of 8 characters.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:142:54: Extra semicolon.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:143:6: Expected indentation of 6 characters.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:144:6: Expected indentation of 6 characters.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:145:8: Expected indentation of 8 characters.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:145:48: Extra semicolon.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:146:6: Expected indentation of 6 characters.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:147:4: Expected indentation of 4 characters.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:148:2: Expected indentation of 2 characters.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:150:4: Expected space or tab after // in comment.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:152:4: Expected space or tab after // in comment.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:154:2: Expected indentation of 2 characters.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:157:6: Extra semicolon.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:159:2: Extra semicolon.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:163:8: Strings must use singlequote.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:163:17: Strings must use singlequote.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:163:27: Strings must use singlequote.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:166:8: Strings must use singlequote.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:166:16: Strings must use singlequote.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:167:8: Strings must use singlequote.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:168:12: Strings must use singlequote.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:169:16: Strings must use singlequote.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:169:24: Strings must use singlequote.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:171:12: Strings must use singlequote.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:172:16: Strings must use singlequote.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:172:24: Strings must use singlequote.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:174:12: Strings must use singlequote.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:175:16: Strings must use singlequote.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:175:24: Strings must use singlequote.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:178:8: Strings must use singlequote.
  /Users/jamuferguson/dev/standard/rules/array-bracket-spacing.js:180:2: Extra semicolon.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:9:0: Strings must use singlequote.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:9:13: Extra semicolon.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:11:0: Expected space or tab after // in comment.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:13:0: Expected space or tab after // in comment.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:15:25: Missing space before function parentheses.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:16:2: Expected indentation of 2 characters.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:16:40: Strings must use singlequote.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:16:49: Extra semicolon.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:25:2: Expected indentation of 2 characters.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:25:24: Missing space before function parentheses.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:26:4: Expected indentation of 4 characters.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:26:91: Extra semicolon.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:27:2: Expected indentation of 2 characters.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:29:2: Expected indentation of 2 characters.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:31:46: Strings must use singlequote.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:32:47: Strings must use singlequote.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:33:6: Extra semicolon.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:35:4: Expected space or tab after // in comment.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:37:4: Expected space or tab after // in comment.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:45:2: Expected indentation of 2 characters.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:45:21: Missing space before function parentheses.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:46:4: Expected indentation of 4 characters.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:46:46: Extra semicolon.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:47:2: Expected indentation of 2 characters.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:55:2: Expected indentation of 2 characters.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:55:23: Missing space before function parentheses.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:56:4: Expected indentation of 4 characters.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:56:60: Extra semicolon.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:57:2: Expected indentation of 2 characters.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:65:2: Expected indentation of 2 characters.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:65:35: Missing space before function parentheses.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:66:4: Expected indentation of 4 characters.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:67:68: Extra semicolon.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:68:2: Expected indentation of 2 characters.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:76:2: Expected indentation of 2 characters.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:76:32: Missing space before function parentheses.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:77:4: Expected indentation of 4 characters.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:78:69: Extra semicolon.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:79:2: Expected indentation of 2 characters.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:87:2: Expected indentation of 2 characters.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:87:41: Missing space before function parentheses.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:88:4: Expected indentation of 4 characters.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:89:63: Extra semicolon.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:90:2: Expected indentation of 2 characters.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:98:2: Expected indentation of 2 characters.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:98:38: Missing space before function parentheses.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:99:4: Expected indentation of 4 characters.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:100:72: Extra semicolon.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:101:2: Expected indentation of 2 characters.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:112:2: Expected indentation of 2 characters.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:112:33: Missing space before function parentheses.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:113:4: Expected indentation of 4 characters.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:114:70: Strings must use singlequote.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:115:71: Strings must use singlequote.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:116:51: Extra semicolon.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:118:4: Expected indentation of 4 characters.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:119:6: Expected indentation of 6 characters.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:120:8: Expected indentation of 8 characters.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:120:58: Extra semicolon.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:121:6: Expected indentation of 6 characters.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:122:6: Expected indentation of 6 characters.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:123:8: Expected indentation of 8 characters.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:123:52: Extra semicolon.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:124:6: Expected indentation of 6 characters.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:125:4: Expected indentation of 4 characters.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:127:4: Expected indentation of 4 characters.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:128:6: Expected indentation of 6 characters.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:129:8: Expected indentation of 8 characters.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:129:54: Extra semicolon.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:130:6: Expected indentation of 6 characters.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:131:6: Expected indentation of 6 characters.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:132:8: Expected indentation of 8 characters.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:132:48: Extra semicolon.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:133:6: Expected indentation of 6 characters.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:134:4: Expected indentation of 4 characters.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:135:2: Expected indentation of 2 characters.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:137:4: Expected space or tab after // in comment.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:139:4: Expected space or tab after // in comment.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:141:2: Expected indentation of 2 characters.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:144:31: Missing space before function parentheses.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:145:10: Expected indentation of 10 characters.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:145:12: Split initialized 'var' declarations into multiple statements.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:146:76: Extra semicolon.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:148:10: Expected indentation of 10 characters.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:148:12: Split initialized 'var' declarations into multiple statements.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:151:60: Extra semicolon.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:154:10: Expected indentation of 10 characters.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:154:31: Strings must use singlequote.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:155:12: Expected indentation of 12 characters.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:155:35: Extra semicolon.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:156:12: Expected indentation of 12 characters.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:156:51: Extra semicolon.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:157:10: Expected indentation of 10 characters.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:159:10: Expected indentation of 10 characters.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:159:73: Extra semicolon.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:163:35: Missing space before function parentheses.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:165:10: Expected indentation of 10 characters.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:165:12: Split initialized 'var' declarations into multiple statements.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:166:76: Extra semicolon.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:169:10: Expected indentation of 10 characters.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:169:75: Strings must use singlequote.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:169:119: Strings must use singlequote.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:170:12: Expected indentation of 12 characters.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:170:16: Split initialized 'var' declarations into multiple statements.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:173:64: Extra semicolon.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:175:12: Expected indentation of 12 characters.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:175:77: Extra semicolon.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:176:10: Expected indentation of 10 characters.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:181:40: Missing space before function parentheses.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:182:10: Expected indentation of 10 characters.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:183:12: Expected indentation of 12 characters.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:183:23: Extra semicolon.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:184:10: Expected indentation of 10 characters.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:186:10: Expected indentation of 10 characters.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:186:12: Split initialized 'var' declarations into multiple statements.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:191:60: Extra semicolon.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:193:10: Expected indentation of 10 characters.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:193:73: Extra semicolon.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:198:34: Missing space before function parentheses.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:199:10: Expected indentation of 10 characters.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:200:12: Expected indentation of 12 characters.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:200:23: Extra semicolon.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:201:10: Expected indentation of 10 characters.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:203:10: Expected indentation of 10 characters.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:203:12: Split initialized 'var' declarations into multiple statements.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:206:50: Extra semicolon.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:208:10: Expected indentation of 10 characters.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:208:73: Extra semicolon.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:211:6: Extra semicolon.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:213:2: Extra semicolon.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:217:8: Strings must use singlequote.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:217:17: Strings must use singlequote.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:217:27: Strings must use singlequote.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:220:8: Strings must use singlequote.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:220:16: Strings must use singlequote.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:221:8: Strings must use singlequote.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:222:12: Strings must use singlequote.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:223:16: Strings must use singlequote.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:223:24: Strings must use singlequote.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:225:12: Strings must use singlequote.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:226:16: Strings must use singlequote.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:226:24: Strings must use singlequote.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:229:8: Strings must use singlequote.
  /Users/jamuferguson/dev/standard/rules/object-curly-spacing.js:231:2: Extra semicolon.
npm ERR! Test failed.  See above for more details.

@xjamundx

This comment has been minimized.

Copy link

commented Jul 16, 2015

Working on this. 15 minutes was a bit of an understatement, but I'm on an ✈️ with great wifi and i'm hoping to have it done before we land :)

@xjamundx

This comment has been minimized.

Copy link

commented Jul 16, 2015

Gist of the rule is right here:

    function isEvenlySpaced(node, start, end) {
        var expectedSpace = start[0].range[1] - start[1].range[0];
        var endSpace = end[0].range[1] - end[1].range[0];
        return endSpace === expectedSpace;
    }

When that fails it will say something like "Expected consistent spacing".

I need to add more edge cases, but it's coming along!

@xjamundx

This comment has been minimized.

Copy link

commented Jul 16, 2015

Any thoughts on handling this:

var x = {
    a: 'b'
}

What eslint does it essentially ignore anything with { that's followed by newline (or } that comes after one), which would mean we'd also have to accept things like this:

var x = {
a: 'b'
            }

var x = {
a: 'b' }

You think that's still good enough for now?

I'll try to poke around a bit and see if I can work out something like if one is followed by a newline the other should proceed immediately after one.

@feross

This comment has been minimized.

Copy link
Member

commented Jul 16, 2015

Excellent!

Your idea to special case the newline condition is the right idea. But of course, even without that, the rule would be better that what we have now 👍

@feross

This comment has been minimized.

Copy link
Member

commented Jul 16, 2015

You can try standard --format rules/object-curly-spacing.js to fix most of the style errors :)

@xjamundx

This comment has been minimized.

Copy link

commented Jul 17, 2015

I'm going to see if I can integrate this one rule into the standard package first then work on the array rule later

@xjamundx

This comment has been minimized.

Copy link

commented Jul 17, 2015

Okay, so eslint-tester uses mocha and you folks use tape, so we can't add standard eslint style rule tests, which is bit crazy, but with the latest update the PR now enables the curly space rule and supports custom rules in the rules/ folder. Take a look at that. Play with it. If it seems liek a good approach I'll get going on the array rule.

xjamundx pushed a commit to xjamundx/standard that referenced this issue Jul 17, 2015

xjamundx pushed a commit to xjamundx/standard that referenced this issue Jul 17, 2015

xjamundx pushed a commit to xjamundx/standard that referenced this issue Jul 17, 2015

xjamundx pushed a commit to xjamundx/standard that referenced this issue Jul 17, 2015

xjamundx pushed a commit to xjamundx/standard that referenced this issue Jul 18, 2015

@dcousens

This comment has been minimized.

Copy link
Member Author

commented Jul 19, 2015

@xjamundx awesome work!

{ code: "import { x } from 'y'", ecmaFeatures: { modules: true } },

Should that be acceptable? Can we enforce 0 | 1 spaces?

@xjamundx

This comment has been minimized.

Copy link

commented Jul 20, 2015

@dcousens the way that this rule is setup you're only enforcing consistent spacing for a given objectexpression or objectpattern, not consistent spacing for all objects everywhere.

@dcousens

This comment has been minimized.

Copy link
Member Author

commented Jul 21, 2015

@xjamundx OK, and its not easy to change that consistency to 0 | 1 spaces? (I haven't looked at the solution yet, sorry)

@xjamundx

This comment has been minimized.

Copy link

commented Jul 21, 2015

@dcousens. We certainly could do that if it's desired.

@dcousens

This comment has been minimized.

Copy link
Member Author

commented Jul 21, 2015

@xjamundx would that interfere with multiline?
AFAIK, we want to support these cases (and only these):

var { x } = ...
var {x} = ...
var {
  x,
  y
} = ...
@xjamundx

This comment has been minimized.

Copy link

commented Jul 22, 2015

I see your point. It's up to 1 space.

@xjamundx

This comment has been minimized.

Copy link

commented Jul 22, 2015

Yeah that's easy.

By the way I'm messing around with this idea (not publishing to npm):
https://github.com/xjamundx/eslint-plugin-standard

It's much easier to write out the test cases when they're in a plugin like this:
https://github.com/xjamundx/eslint-plugin-standard/blob/master/tests/object-curly-even-spacing.js#L27

xjamundx pushed a commit to xjamundx/standard that referenced this issue Jul 22, 2015

xjamundx pushed a commit to xjamundx/standard that referenced this issue Jul 23, 2015

@knownasilya

This comment has been minimized.

Copy link

commented Jul 28, 2015

Would love warnings when there is inconsistency, e.g.

var test = {hello: 'blah'}
var test2 = { hello: 'blah' }

console.log(test, test2)

In the same project/file.

Or just sticking with one, and bumping the major version.

@xjamundx

This comment has been minimized.

Copy link

commented Jul 28, 2015

file-level consistency is doable, but not currently supported.

@feross

This comment has been minimized.

Copy link
Member

commented Jul 28, 2015

@xjamundx I'm merging your work on eslint-plugin-standard right now. Wouldn't @knownasilya's example be caught?

@xjamundx

This comment has been minimized.

Copy link

commented Jul 28, 2015

The inconsistency is per instance not per file. Per file would be a minor change, we'd just need to keep track of the first style and compare against future styles.

@feross

This comment has been minimized.

Copy link
Member

commented Jul 28, 2015

@xjamundx Ah.

@feross

This comment has been minimized.

Copy link
Member

commented Jul 28, 2015

Okay, @xjamundx's changes are released as standard 5.0.0-7 and we depend on eslint-plugin-standard now! Thanks for the great work!

@feross feross closed this Jul 28, 2015

@xjamundx

This comment has been minimized.

Copy link

commented Jul 28, 2015

awesome!

@mightyiam

This comment has been minimized.

Copy link
Contributor

commented Jun 5, 2016

Continue conversation @ Object curlies: File/project–wide or standard?

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

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