Eslint-plugin-import: Add equivalent of object-property-newline for import declaration

Created on 15 May 2016  路  6Comments  路  Source: benmosher/eslint-plugin-import

object-property-newline

While formatting preferences are very personal, a number of style guides require that object properties be placed on separate lines for better readability.
Another argument in favor of this style is that it improves the readability of diffs when a property is changed:

Examples of _incorrect_ code for this rule:

import {createMovieMatcher,matcher} from './../src/movieRecognizer';

Examples of _correct_ code for this rule:

import {
    createMovieMatcher,
    matcher
} from './../src/movieRecognizer';
accepted help wanted rule proposal semver-minor style-guide

Most helpful comment

Sounds good to me. Would prefer having an option like "always" / "never" on this rule, so that one could decide to go the opposite way if preferred.

All 6 comments

Sounds good to me. Would prefer having an option like "always" / "never" on this rule, so that one could decide to go the opposite way if preferred.

Is this still a work in progress? This was posted in 2016

yep.

Given that exists as a model, it seems like someone could make a PR to add it here. cc @gmsorrow

It would also be nice if you could have an as-needed option which takes the configured maximum line length (or you just configure it again with the rule) and puts it on one line if it fits within the line length but breaks it up into multiple lines if it doesn't.

There is a VSCode extension that made this feature pretty configurable so some things might be nice to implement into such an ESLint rule: https://marketplace.visualstudio.com/items?itemName=dozerg.tsimportsorter

Was this page helpful?
0 / 5 - 0 ratings