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
Update: add named imports and exports for object-curly-newline #9876
Changes from 10 commits
6463a8c
728ad32
e4017f7
dcef6de
245b20e
d6e275d
9708cdb
0020669
0082680
75bea25
005032d
fd1a780
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,19 +19,23 @@ Or an object option: | |
* `"minProperties"` requires line breaks if the number of properties is at least the given integer. By default, an error will also be reported if an object contains linebreaks and has fewer properties than the given integer. However, the second behavior is disabled if the `consistent` option is set to `true` | ||
* `"consistent": true` requires that either both curly braces, or neither, directly enclose newlines. Note that enabling this option will also change the behavior of the `minProperties` option. (See `minProperties` above for more information) | ||
|
||
You can specify different options for object literals and destructuring assignments: | ||
You can specify different options for object literals and destructuring assignments, named imports and exports: | ||
|
||
```json | ||
{ | ||
"object-curly-newline": ["error", { | ||
"ObjectExpression": "always", | ||
"ObjectPattern": { "multiline": true } | ||
"ObjectPattern": { "multiline": true }, | ||
"ImportDeclaration": "never", | ||
"ExportDeclaration": { "multiline": true, "minProperties": 3 } | ||
}] | ||
} | ||
``` | ||
|
||
* `"ObjectExpression"` configuration for object literals | ||
* `"ObjectPattern"` configuration for object patterns of destructuring assignments | ||
* `"ImportDeclaration"` configuration for named imports | ||
* `"ExportDeclaration"` configuration for named exports | ||
|
||
### always | ||
|
||
|
@@ -463,6 +467,48 @@ let {k = function() { | |
}} = obj; | ||
``` | ||
|
||
### ImportDeclaration and ExportDeclaration | ||
|
||
Examples of **incorrect** code for this rule with the `{ "ImportDeclaration": "always", "ExportDeclaration": "never" }` options: | ||
|
||
```js | ||
/*eslint object-curly-newline: ["error", { "ImportDeclaration": "always", "ExportDeclaration": "never" }]*/ | ||
/*eslint-env es6*/ | ||
|
||
import {foo, bar} from 'foo-bar'; | ||
import {foo as f, bar} from 'foo-bar'; | ||
import {foo, | ||
bar} from 'foo-bar'; | ||
|
||
export { | ||
foo, | ||
bar | ||
}; | ||
export { | ||
foo as f, | ||
bar | ||
} from 'foo-bar'; | ||
``` | ||
|
||
Examples of **correct** code for this rule with the `{ "ImportDeclaration": "always", "ExportDeclaration": "never" }` options: | ||
|
||
```js | ||
/*eslint object-curly-newline: ["error", { "ImportDeclaration": "always", "ExportDeclaration": "never" }]*/ | ||
/*eslint-env es6*/ | ||
|
||
import { | ||
foo, | ||
bar | ||
} from 'foo-bar'; | ||
import { | ||
foo as f, | ||
bar | ||
} from 'foo-bar'; | ||
|
||
export { foo, bar } from 'foo-bar'; | ||
export { foo as f, bar } from 'foo-bar'; | ||
``` | ||
|
||
## Compatibility | ||
|
||
* **JSCS**: [requirePaddingNewLinesInObjects](http://jscs.info/rule/requirePaddingNewLinesInObjects) and [disallowPaddingNewLinesInObjects](http://jscs.info/rule/disallowPaddingNewLinesInObjects) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a JSCS rule we are now compatible with for padding new lines for import/export specifiers? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There doesn't seem to be any JSCS rule regarding new lines and import/export specifiers. Only ones for spaces in the import braces. requireSpacesInsideImportedObjectBraces There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for checking! |
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I wasn't clear in my last comment. The removal of the original "and" was correct, but I wanted a new "and" before the named import/export.
This is what I was going for:
Thanks for your patience!