fix: react-doctor use-lazy-motion 36→0 (m + LazyMotion in Providers), rerender-state-only-in-handlers 5→0 (WaterAdminClient loading), js-set-map-lookups 1→0 (regex in supabase), js-hoist-regexp 2→0 (helper funcs), rules-of-hooks error in QuickCartSheet (use onClose direct in handler)
This commit is contained in:
+26
-6
@@ -176,6 +176,12 @@ class MockQueryBuilder<T extends Record<string, unknown> = Record<string, unknow
|
||||
const inSet = filter.op === "in" && Array.isArray(filter.value)
|
||||
? new Set(filter.value as unknown[])
|
||||
: null;
|
||||
const likeRe = filter.op === "like" && typeof filter.value === "string"
|
||||
? likeRegexFor(filter.value as string)
|
||||
: null;
|
||||
const ilikeRe = filter.op === "ilike" && typeof filter.value === "string"
|
||||
? ilikeRegexFor(filter.value as string)
|
||||
: null;
|
||||
const likeNeedle = filter.op === "like" && typeof filter.value === "string"
|
||||
? (filter.value as string).replace(/%/g, "")
|
||||
: null;
|
||||
@@ -205,16 +211,14 @@ class MockQueryBuilder<T extends Record<string, unknown> = Record<string, unknow
|
||||
case "like":
|
||||
return (
|
||||
typeof rowValue === "string" &&
|
||||
likeNeedle !== null &&
|
||||
likeNeedle.length > 0 &&
|
||||
rowValue.includes(likeNeedle)
|
||||
likeRe !== null &&
|
||||
likeRe.test(rowValue)
|
||||
);
|
||||
case "ilike":
|
||||
return (
|
||||
typeof rowValue === "string" &&
|
||||
ilikeNeedle !== null &&
|
||||
ilikeNeedle.length > 0 &&
|
||||
rowValue.toLowerCase().includes(ilikeNeedle)
|
||||
ilikeRe !== null &&
|
||||
ilikeRe.test(rowValue.toLowerCase())
|
||||
);
|
||||
case "in":
|
||||
return inSet !== null && inSet.has(rowValue);
|
||||
@@ -333,6 +337,22 @@ interface UserAttributes {
|
||||
data?: Record<string, unknown>;
|
||||
}
|
||||
|
||||
/** Escape regex special characters in a string so it can be embedded
|
||||
* safely in a `RegExp` constructor. */
|
||||
function escapeRegExp(s: string): string {
|
||||
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
||||
}
|
||||
|
||||
/** Build a `RegExp` for the `like` operator after stripping `%` wildcards. */
|
||||
function likeRegexFor(value: string): RegExp {
|
||||
return new RegExp(escapeRegExp(value.replace(/%/g, "")));
|
||||
}
|
||||
|
||||
/** Build a case-insensitive `RegExp` for the `ilike` operator. */
|
||||
function ilikeRegexFor(value: string): RegExp {
|
||||
return new RegExp(escapeRegExp(value.replace(/%/g, "").toLowerCase()));
|
||||
}
|
||||
|
||||
function createMockClient() {
|
||||
// The query builder is mutable, so we can't simply return a class
|
||||
// instance + spread mutation methods. The cleanest way to support
|
||||
|
||||
Reference in New Issue
Block a user