Skip to content

Import Declaration Newline Rules Confusing/Not Documented Correctly #2340

@tradical-allstripes

Description

@tradical-allstripes

In the ESLint config, the object-curly-newline section configures a number of things that are not made clear in the text of the guide:

'object-curly-newline': ['error', {
  ObjectExpression: { minProperties: 4, multiline: true, consistent: true },
  ObjectPattern: { minProperties: 4, multiline: true, consistent: true },
  ImportDeclaration: { minProperties: 4, multiline: true, consistent: true },
  ExportDeclaration: { minProperties: 4, multiline: true, consistent: true },
}],

The only place this rule is mentioned in the guide is under 10.8, which states only that imports on newlines need to be indented. The following to things about this config are not made clear in the guide:

  • The minProperties part of the rule is not mentioned; it is not made clear that, after 4 properties, you must use newlines
  • The rule applied here for imports also applies to other objects

In addition, the code snippet in this section suggests that the rule is saying "put all of your imports from the same module on new lines", but the text says it is about indenting imports when they are put on new lines. I found this quite confusing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions