+ /**
+ * Adds the `only` property to a test to run it in isolation.
+ * @param {string | ValidTestCase | InvalidTestCase} item A single test to run by itself.
+ * @returns {ValidTestCase | InvalidTestCase} The test with `only` set.
+ */
+ static only(item) {
+ if (typeof item === "string") {
+ return { code: item, only: true };
+ }
+
+ return { ...item, only: true };
+ }
+
+ static get itOnly() {
+ if (typeof this[IT_ONLY] === "function") {
+ return this[IT_ONLY];
+ }
+ if (typeof this[IT] === "function" && typeof this[IT].only === "function") {
+ return Function.bind.call(this[IT].only, this[IT]);
+ }
+ if (typeof it === "function" && typeof it.only === "function") {
+ return Function.bind.call(it.only, it);
+ }
+
+ if (typeof this[DESCRIBE] === "function" || typeof this[IT] === "function") {
+ throw new Error(
+ "Set `RuleTester.itOnly` to use `only` with a custom test framework.\n" +
+ "See https://eslint.org/docs/developer-guide/nodejs-api#customizing-ruletester for more."
+ );
+ }
+ if (typeof it === "function") {
+ throw new Error("The current test framework does not support exclusive tests with `only`.");
+ }
+ throw new Error("To use `only`, use RuleTester with a test framework that provides `it.only()` like Mocha.");
+ }
+
+ static set itOnly(value) {
+ this[IT_ONLY] = value;
+ }
+