UNPKG

@effective/eslint-cfg

Version:

A library for generating ESLint Flat Configs with React and TypeScript support.

33 lines (32 loc) 779 B
import { createHash } from "crypto"; export const flags = [ // mode options "strict", "style", // additional rules options "node", "react", // output options "disabled", "fast", "biome" ]; export function optionsToNumber(opts) { let num = 0; for (let i = 0; i < flags.length; i++) { if (opts[flags[i]]) { num |= 1 << i; } } return num; } export function numberToShortHash(num) { return createHash("sha1").update(String(num)).digest("hex").slice(0, 8); } export function getConfigObject(config, objectName = "base") { const obj = config.find((c) => c.name === `effective/${objectName}`); if (!obj) { throw new Error(`Config ${objectName} not found!`); } return obj; }