Skip to content

Conversation

@bradenmacdonald
Copy link
Contributor

@bradenmacdonald bradenmacdonald commented Oct 30, 2025

Description

We've had a "Best Practices Checklist" in our PR template for a while, but I'd like to start using linters to enforce the best practices more. However, that is tough with such a huge codebase where there's a lot of code to refactor.

This PR introduces a new way of running additional, stricter lint rules that only apply to modified files. The idea is that contributors will be expected to make these refactors as they go, improving any code that they happen to touch in their PRs.

For this initial version, the diff check only rejects injectIntl, defaultProps, and connect() as they are all quite easy to refactor. Later, I'd also like to ban propTypes from modified code, although that can require a more significant refactor (to TypeScript) so I'm holding off on it for now.

If this experiment is successful, we may wish to extend it to all repos.

Testing instructions

Check out this branch, modify some files (including .jsx files with defaultProps), then run npm run lint:diff

Other information

Private ref MNG-4670.

Best Practices Checklist

We're trying to move away from some deprecated patterns in this codebase. Please
check if your PR meets these recommendations before asking for a review:

  • Any new files are using TypeScript (.ts, .tsx).
  • Deprecated propTypes, defaultProps, and injectIntl patterns are not used in any new or modified code.
  • Tests should use the helpers in src/testUtils.tsx (specifically initializeMocks)
  • Do not add new fields to the Redux state/store. Use React Context to share state among multiple components.
  • Use React Query to load data from REST APIs. See any apiHooks.ts in this repo for examples.
  • All new i18n messages in messages.ts files have a description for translators to use.
  • Imports avoid using ../. To import from parent folders, use @src, e.g. import { initializeMocks } from '@src/testUtils'; instead of from '../../../../testUtils'

@openedx-webhooks
Copy link

Thanks for the pull request, @bradenmacdonald!

This repository is currently maintained by @bradenmacdonald.

Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review.

🔘 Get product approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.


Where can I find more information?

If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:

When can I expect my changes to be merged?

Our goal is to get community contributions seen and reviewed as efficiently as possible.

However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@openedx-webhooks openedx-webhooks added open-source-contribution PR author is not from Axim or 2U core contributor PR author is a Core Contributor (who may or may not have write access to this repo). labels Oct 30, 2025
@github-project-automation github-project-automation bot moved this to Needs Triage in Contributions Oct 30, 2025
@bradenmacdonald
Copy link
Contributor Author

@brian-smith-tcril @arbrandes Thoughts on this?

@codecov
Copy link

codecov bot commented Oct 30, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.79%. Comparing base (871d988) to head (9abb214).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2586      +/-   ##
==========================================
+ Coverage   94.78%   94.79%   +0.01%     
==========================================
  Files        1225     1226       +1     
  Lines       27399    27490      +91     
  Branches     5992     6029      +37     
==========================================
+ Hits        25969    26060      +91     
  Misses       1372     1372              
  Partials       58       58              

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@brian-smith-tcril
Copy link
Contributor

I'm split on this one. The benefits are obvious, but I have a few concerns:

Pros:

  • Existing files will be updated to follow best practices as changes land

Cons:

  • It breaks the separation of concerns I like to see in PRs
    • Reviewing will now require seeing if the best practice updates are done properly, as well as the change that prompted the PR
    • Change requests on PRs are often addressed with chore: address PR comments commits. If we start landing PRs that are both cleanup and features I'd want to do so without squashing to aid bisecting, meaning we'd likely need to request PR authors rebase their PRs to have clean commit histories
      • chore: update file X to best practices
      • fix/feat: do the new thing I want to do
  • We'd likely need to land high-priority/quick fixes with this lint check failing

I think ideally I'd want to see changes come in as 2 PRs

  • PR N - chore: update fileA, fileB, ... to best practices
  • PR N+1 fix/feat: do the thing (depends on PR N)

That way reviews would stay focused. In the case I had concerns with the best practice cleanup but not the new fix/feature, I'd be able to:

  • Review PR N, leave comments with changes that need to be addressed
  • Review PR N+1, leave a comment saying "This looks great! Once PR N lands and this is rebased on that this should be good to merge!"

This follows a pattern I've used in another project I've worked on where some code is absurdly undocumented (functions named func_12345, variables named unk_12345), and some PRs would come in saying "document undocumented functions/variables in X, and add giant new feature Y." By asking those PR be split and landing the renames first, it has made reviewing and bisecting a lot easier.


I'm not opposed to implementing this rule as it stands in this PR, but I'd like to think about ways to mitigate this change encouraging PRs to move from "do X" to "do X and Y."

@mphilbrick211 mphilbrick211 moved this from Needs Triage to Ready to Merge in Contributions Nov 4, 2025
@mphilbrick211 mphilbrick211 moved this from Ready to Merge to In Eng Review in Contributions Nov 4, 2025
@bradenmacdonald
Copy link
Contributor Author

@brian-smith-tcril I guess I haven't been as concerned with the commit history, especially since we usually squash PRs and there has been a decent amount of "drive-by" cleanups going on in this repo. I do agree it would be nicer to separate the cleanups into their own PRs, but that might be too much to ask from contributors who just came to fix a bug (etc.) and weren't expecting to be roped into doing a separate cleanup PR.

Another option could be to turn on additional lint checks for TypeScript files only. I suspect that many of the extra lints are already passing in TypeScript files since they're newer and using newer patterns. Ideally I would also include a check that PRs never add new JS(X) files. This wouldn't help improve the current codebase, but would ensure that newer code at least is following all the best practices.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core contributor PR author is a Core Contributor (who may or may not have write access to this repo). open-source-contribution PR author is not from Axim or 2U

Projects

Status: In Eng Review

Development

Successfully merging this pull request may close these issues.

3 participants