Rule Enhancement Proposal: "object-curly-newline" add configuration for named imports and exports
See original GitHub issueESLint 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 to minImportSpecifiers
or similar.
Question
Maybe this should be separate rule instead of configuration of object-curly-newline
rule.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:6
- Comments:6 (4 by maintainers)
I don’t remember seeing this issue, so I’ve just given it a 👍. We just need a champion (and maybe one more 👍 if that champion already 👍’d the issue).
@eslint/eslint-team Is anyone willing to champion this issue, or should we leave it closed? Seems @evilebottnawi is willing to make a PR if we accept this.
/cc @kaicataldo what is real status, accept? I have to time to PR 😄