```ts
export function matchSetting(rules: Record<string, string>, name: string): string | null {
  if (typeof name !== "string" || name === "" || name.includes("*")) {
    throw new Error("name must be a star-free non-empty string");
  }

  for (const [selector, value] of Object.entries(rules)) {
    if (selector === name) return value;
    if (selector.startsWith(name + ".")) return value;
    if (selector === "*") return value;
  }

  return null;
}
```