Fix up import paths and groups in new TypeScript code.

Review Request #13171 — Created Aug. 1, 2023 and submitted

Information

Review Board
release-6.x

Reviewers

As we've defined how our JS codebase is going to work going forward,
we've not been terribly disciplined about how we do imports. This change
makes everything consistent with three import groups (3rd party, other
modules, and the current module) that kind of matches the way that our
Python code works. Where we can, this has been simplified to import
everything from the top-level indexes, which makes sorting things
alphabetically by module name much easier.

Ran js-tests.

Summary ID
Fix up import paths and groups in new TypeScript code.
As we've defined how our JS codebase is going to work going forward, we've not been terribly disciplined about how we do imports. This change makes everything consistent with three import groups (3rd party, other modules, and the current module) that kind of matches the way that our Python code works. Where we can, this has been simplified to import everything from the top-level indexes, which makes sorting things alphabetically by module name much easier. Testing Done: Ran js-tests.
9310e38b67583e72be549e97daa9d580af4d5cc7
Description From Last Updated

This module is within this bundle, so it should use a relative import in a separate import group.

chipx86chipx86

Should reviewboard/common be before reviewboard/common/...?

chipx86chipx86

common should be before ui.

chipx86chipx86

reviewRequestEditorModel sorts before reviewablePageModel (R < a).

chipx86chipx86

This is in the same bundle, so it should use relative imports.

chipx86chipx86

common before ui.

chipx86chipx86

Isn't this one supposed to be a relative import since its in the same bundle?

maubinmaubin

Should we import this one from reviewboard/common like we do with ReviewReply?

maubinmaubin
chipx86
  1. We should document the import rules in Notion.

    To make sure I have this right (maybe this would be good for the description), do higher-level paths sort before deeper paths? E.g. ../z sorts before ./a?

  2. Show all issues

    This module is within this bundle, so it should use a relative import in a separate import group.

  3. Show all issues

    Should reviewboard/common be before reviewboard/common/...?

  4. reviewboard/static/rb/js/reviews/views/reviewablePageView.ts (Diff revision 1)
     
     
     
     
     
     
     
    Show all issues

    common should be before ui.

  5. Show all issues

    reviewRequestEditorModel sorts before reviewablePageModel (R < a).

  6. Show all issues

    This is in the same bundle, so it should use relative imports.

  7. Show all issues

    common before ui.

  8. 
      
david
maubin
  1. Thanks for standardizing these! Looking forward to having a document in Notion for this too.

  2. Show all issues

    Isn't this one supposed to be a relative import since its in the same bundle?

    1. UserSession is kind of a special case, when combined with test files. The tests are their own bundle, even though we import related things relatively (though I'm wondering if perhaps we should change that). Doing a cross-bundle import into the test file and then having other things get it from the common bundle meant that we actually had two singleton instances.

  3. Show all issues

    Should we import this one from reviewboard/common like we do with ReviewReply?

  4. 
      
david
maubin
  1. Ship It!
  2. 
      
david
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to release-6.x (1119cbf)
Loading...