influxdata / influxdata/ui

Prefer named exports over default exports

Open
#6,007 0 comments 0 reactions 0 assignees View on GitHub
kind/tech-debt team/automation team/dumplings team/ui
Dominant language
TypeScript
Stars
117
Forks
51
Avg merge
2d 15h
Merged PRs (30d)
4

Description

### Background

We're doing away with default exports in favor of named exports. For some background on the issue, see the following blog posts:

- https://www.codingzeal.com/posts/developer-dark-arts-default-exports
- https://betterprogramming.pub/understanding-the-difference-between-named-and-default-exports-in-react-2d253ca9fc22

### Process
**This should happen piecemeal, rather than all-at-once.** It will be too much work, too big a change, and too risky to change all our default exports at the same time. Instead, we should clean up exports as we see them.

The analogy I used is: you can go to the beach to clean it up and pick up trash, or you can go to the beach to hang out, play in the ocean, have a good time, and then on the way back to the car, grab a couple of pieces of trash because every little bit helps. What we should do is akin to picking up a couple pieces of trash on the way back to the car.

If you're modifying a file and you notice it has a default export, if it's not too big a task, change it to a named export and change the files that import that module as part of your larger change. If you're creating a new file, go with named exports from the start.

Obviously, we expect you to use your judgement here. If you're changing one word in a file that has a default export, but there are 30 files that import from it, consider making a follow-up PR to change that default export, or writing a ticket to address it if you can't follow up on it. If you're refactoring a component that has a default export and is imported in two places, it's probably a good idea to just make the change as part of that larger PR (maybe as a separate commit).

### Acceptance Criteria
- Your PR has `Helps with #6007` or `Connects #6007` when it removes a default export so that it can be linked to this issue
- When the only default exports we have are the exceptions to the rule (or we have none at all), we can close this ticket.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.