openedx / openedx/frontend-app-authoring
Remove module self-import hacks
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 17
- Forks
- 218
- Avg merge
- 9d 20h
- Merged PRs (30d)
- 20
Description
A lot of the code in src/editors/ uses this sketchy self-import hack to facilitate mocking and avoid circular import errors. It is bad practice and I think it only works because of webpack black magic. All usage of importing from the current file should be removed.
Example of this import * as module from './(self)' pattern:
As part of this, we should likely create a new ADR that supersedes ADR 0005 for testing - see some of the principles listed in https://github.com/openedx/frontend-app-authoring/issues/2075
Personally, I (@bradenmacdonald) try to keep mocking to a minimum and instead of mocking out and overriding hooks, just simulate realistic user interactions with the UI. The only hooks that I recommend mocking out are data loading hooks / mutation hooks, and those are easy enough to mock without these self-import hacks.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the self-import example in src/editors/containers/ProblemEditor/components/EditProblemView/AnswerWidget/hooks.js, then inventory the same import pattern throughout src/editors. Review ADR 0005 and the principles in issue 2075 before deciding whether a replacement ADR is needed. Done means the self-import hacks are removed across the editors code and the testing guidance is updated if required.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- documentation, frontend, testing
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100