For MongoDB 8.1, both ReplSetTest and ShardingTest were converted to ES6 modules (SERVER-81339, SERVER-81341), and thus they need to be imported in jstests as follows:
import {ShardingTest} from "jstests/libs/shardingtest.js";
For older versions, they should not be imported, and it is an error to do so. However, multiple BACKPORT tickets have been merged with that problem (BACKPORT-23229, BACKPORT-23849, BACKPORT-21361), causing redness in the test suite.
We should make such mistakes fail the commit queue checks so PRs with them can not be merged. This can be done by adding a ESLint rule in .eslintrc as follows:
no-restricted-syntax: [ 'error', { message: "Invalid import. Please do not import replsettest.js in MongoDB v8.0 and below.", selector: "ImportDeclaration[source.value=/^jstests\\u002Flibs\\u002Freplsettest.js$/]" }, { message: "Invalid import. Please do not import shardingtest.js in MongoDB v8.0 and below.", selector: "ImportDeclaration[source.value=/^jstests\\u002Flibs\\u002Fshardingtest.js$/]" }, ]