Proposal: "object-curly-newline" add configuration for named imports and exports (or create new rule for import/export specifiers)
See original GitHub issueI’m creating a new issue for this because I’d like to see it considered for inclusion.
From the original post (see #7319):
ESLint version
v3.5.0
Rule object-curly-newline currently supports:
"ObjectExpression"
configuration for object literals;"ObjectPattern"
configuration for object patterns of destructuring assignments.Proposal
I propose to add similar configuration for named imports and exports:
{ "object-curly-newline": ["error", { "ImportDeclaration": { "multiline": true }, "ExportDeclaration": { "multiline": true } }] }
Possible values:
always
Examples of incorrect code for this rule with the
"always"
option: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}; export {foo, bar};
Examples of correct code for this rule with the
"always"
option:import { foo, bar } from 'foo-bar'; import { foo as f, bar } from 'foo-bar'; export { foo, bar }; export { foo as f, bar };
never
Examples of incorrect code for this rule with the
"never"
option:import { foo, bar } from 'foo-bar'; export { foo, bar };
Examples of correct code for this rule with the
"never"
option:import {foo, bar} from 'foo-bar'; export {foo, bar};
multiline
Examples of incorrect code for this rule with the default
{ "multiline": true }
option:import { foo, bar} from 'foo-bar'; import {foo, bar } from 'foo-bar'; import { foo, bar } from 'foo-bar'; export { foo, bar}; export { foo, bar };
Examples of correct code for this rule with the default
{ "multiline": true }
option:import {foo, bar} from 'foo-bar'; import {foo as f, bar} from 'foo-bar'; import { foo, bar } from 'foo-bar'; import { foo as f, bar } from 'foo-bar'; export { foo, bar };
minProperties
Similar to current
minProperties
behavior. Maybe this option should be renamed tominImportSpecifiers
or similar.Question
Maybe this should be separate rule instead of configuration of
object-curly-newline
rule.
Regarding the above question, I like the idea of augmenting object-curly-newline if other object-related rules tend to apply to import/export specifiers, but it’s also true that some elements of objects (e.g., keys/values) simply don’t apply to import specifiers. So I’m okay with a new rule as well. Hopefully that will be a quick bikeshed.
The last issue had been 👍’d by the following people:
But we never had a champion. I’d like to see if we can get one this time. (I’m considering it. Just need to figure out my schedule.)
Issue Analytics
- State:
- Created 6 years ago
- Reactions:7
- Comments:15 (6 by maintainers)
Top GitHub Comments
@kaicataldo maybe it be good do in
v4
? Anyway i do PR, rename is not long procedure 😄I’d like to work on this!