Fix up import paths and groups in new TypeScript code.

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

david
Review Board
release-6.x
reviewboard

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
Fix up import paths and groups in new TypeScript code.
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. This module is within this bundle, so it should use a relative import in a separate import group.

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

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

    common should be before ui.

  5. reviewRequestEditorModel sorts before reviewablePageModel (R < a).

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

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

  2. 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. 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...