Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase "react", "api" import specificity #2973

Merged
merged 4 commits into from
Apr 22, 2024
Merged

Conversation

imnasnainaec
Copy link
Collaborator

@imnasnainaec imnasnainaec commented Feb 28, 2024

Also, avoids usage of import React and React. for potential upcoming TS transpiler change.

This change is Reviewable

@imnasnainaec imnasnainaec added documentation Improvements or additions to documentation frontend maintenance Issue that makes it difficult to maintain the software or to upgrade installations post-release. Size: S Small sized issue labels Feb 28, 2024
@imnasnainaec imnasnainaec self-assigned this Feb 28, 2024
Copy link

codecov bot commented Feb 28, 2024

Codecov Report

Attention: Patch coverage is 53.84615% with 6 lines in your changes are missing coverage. Please review.

Project coverage is 74.97%. Comparing base (613bd07) to head (943f4ac).

Files Patch % Lines
src/components/AppBar/UserMenu.tsx 0.00% 1 Missing ⚠️
...Table/EntryCellComponents/GlossWithSuggestions.tsx 0.00% 1 Missing ⚠️
...yTable/EntryCellComponents/VernWithSuggestions.tsx 0.00% 1 Missing ⚠️
src/components/Dialogs/DeleteEditTextDialog.tsx 0.00% 1 Missing ⚠️
src/components/Dialogs/EditTextDialog.tsx 0.00% 1 Missing ⚠️
src/components/Dialogs/SubmitTextDialog.tsx 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2973      +/-   ##
==========================================
- Coverage   74.98%   74.97%   -0.01%     
==========================================
  Files         269      269              
  Lines       10358    10358              
  Branches     1225     1225              
==========================================
- Hits         7767     7766       -1     
  Misses       2234     2234              
- Partials      357      358       +1     
Flag Coverage Δ
backend 84.03% <ø> (-0.03%) ⬇️
frontend 66.62% <53.84%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@imnasnainaec imnasnainaec requested a review from jmgrady April 19, 2024 15:30
Copy link
Collaborator

@jmgrady jmgrady left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 15 of 31 files at r1, all commit messages.
Reviewable status: 15 of 31 files reviewed, all discussions resolved (waiting on @imnasnainaec)

Copy link
Collaborator

@jmgrady jmgrady left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 16 of 31 files at r1.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @imnasnainaec)


src/components/TreeView/TreeNavigator.tsx line 1 at r1 (raw file):

import { Fragment, type ReactElement, useEffect } from "react";

Here the type import is not at the beginning of the list but in other updates, the types are all moved to the front, e.g. in src/components/TreeView/tests/TreeSearch.test.tsx:

import TreeSearch, {
  type TreeSearchProps,
  insertDecimalPoints,
  testId,
  useTreeSearch,
} from "components/TreeView/TreeSearch";
```.
Should `type ReactElement` be moved to the beginning?

Code quote:

import { Fragment, type ReactElement, useEffect } from "react";

src/components/TreeView/tests/TreeSearch.test.tsx line 13 at r1 (raw file):
This seems to contradict the recommendation:

  • Generally import the specific things needed (e.g., not React when { type ReactElement } will do)

That recommendation suggests that default exports should be avoided and only export specific types/objects.

If that is a direction we want to take, I am in favor of it being a separate PR.

Code quote:

import TreeSearch, {
  type TreeSearchProps,
  insertDecimalPoints,
  testId,
  useTreeSearch,
} from "components/TreeView/TreeSearch";

Copy link
Collaborator Author

@imnasnainaec imnasnainaec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @imnasnainaec)


src/components/TreeView/TreeNavigator.tsx line 1 at r1 (raw file):

Previously, jmgrady (Jim Grady) wrote…

Here the type import is not at the beginning of the list but in other updates, the types are all moved to the front, e.g. in src/components/TreeView/tests/TreeSearch.test.tsx:

import TreeSearch, {
  type TreeSearchProps,
  insertDecimalPoints,
  testId,
  useTreeSearch,
} from "components/TreeView/TreeSearch";
```.
Should `type ReactElement` be moved to the beginning?

I hadn't intended to move type imports all to the front, but was maintaining the alphabetic sort (and with ESLint defaults, all capital letters sort before lowercase). Would it be easier to have the type imports clustered if they're to be type-prefixed?


src/components/TreeView/tests/TreeSearch.test.tsx line 13 at r1 (raw file):

Previously, jmgrady (Jim Grady) wrote…

This seems to contradict the recommendation:

  • Generally import the specific things needed (e.g., not React when { type ReactElement } will do)

That recommendation suggests that default exports should be avoided and only export specific types/objects.

If that is a direction we want to take, I am in favor of it being a separate PR.

My intent is not to generally move away from default exports, but from using import * as ____ from if just a few things are needed. The * as is not needed with React because its default export is already a cumulative object. Any thoughts on better wording for the style guide?

@imnasnainaec imnasnainaec merged commit 8bee879 into master Apr 22, 2024
18 checks passed
@imnasnainaec imnasnainaec deleted the import-react branch April 22, 2024 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation frontend maintenance Issue that makes it difficult to maintain the software or to upgrade installations post-release. Size: S Small sized issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants