question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Rule Enhancement Proposal: "object-curly-newline" add configuration for named imports and exports

See original GitHub issue

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 to minImportSpecifiers or similar.

Question

Maybe this should be separate rule instead of configuration of object-curly-newline rule.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:6
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
platinumazurecommented, Apr 24, 2017

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.

0reactions
alexander-akaitcommented, Apr 24, 2017

/cc @kaicataldo what is real status, accept? I have to time to PR 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

object-curly-newline - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
@sailshq/eslint | Yarn - Package Manager
In other words, there will never be any new methods or options added to eslint ... abc765c Fix: object-curly-newline minProperties w/default export (fixes ......
Read more >
Eslint rule to put a new line inside import
I was looking for such a rule for both import and export declaration. As a result I've made a plugin with autofix.
Read more >
Diff - 402e1b6e55e9041dfd1a93580e45e5c5dba1db55^!
-0,0 +1,15 @@ +Name: DevTools Node Modules +Short Name: ... in object-curly-spacing for import/export (fixes #3324) (Henry Zhu) +* Update: ...
Read more >
A brand new website interface for an even better experience!
Proposal : "object-curly-newline" add configuration for named imports and exports (or create new rule for import/export specifiers) · Overview · Backers () ·...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found