Skip to content

Propose a new rule. Combine imports and exports from the same file #33

Open
@fshabanov

Description

@fshabanov

Problem

JS allows to have multiple imports/exports from the same source within one file. This can reduce readability of code and create some confusion when trying to understand the code.
Example:

import { type UserDto } from "shared";
import { type UserCreateRequestDto } from "shared";
import { type UserCreateResponseDto } from "shared";

Or the same with exports:

export { type UserDto } from "shared";
export { type UserCreateRequestDto } from "shared";
export { type UserCreateResponseDto } from "shared";

Proposal

I propose to add a rule, where combining those imports/exports is mandatory. I believe in one file we should only have one import/export from a particular source file. This will make it easier to understand and see the imports and exports in a file.

import {
  type UserDto,
  type UserCreateRequestDto,
  type UserCreateResponseDto
} from "shared";

And for exports:

export {
  type UserDto,
  type UserCreateRequestDto,
  type UserCreateResponseDto
} from "shared";

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions