(cwd: string, modes: readonly RulesMode[] = DEFAULT_MODES)
| 148 | } |
| 149 | |
| 150 | function getRuleDirectories(cwd: string, modes: readonly RulesMode[] = DEFAULT_MODES): RuleDirectoryInfo[] { |
| 151 | const globalRooDirectory = getGlobalRooDirectory() |
| 152 | const projectRooDirectory = getProjectRooDirectoryForCwd(cwd) |
| 153 | const bases: Array<{ scope: RuleScope; basePath: string }> = [{ scope: "global", basePath: globalRooDirectory }] |
| 154 | if (cwd) { |
| 155 | bases.push({ scope: "project", basePath: projectRooDirectory }) |
| 156 | } |
| 157 | |
| 158 | return bases.flatMap(({ scope, basePath }) => [ |
| 159 | { |
| 160 | scope, |
| 161 | kind: "generic" as const, |
| 162 | directoryPath: path.join(basePath, "rules"), |
| 163 | }, |
| 164 | ...modes.map((mode) => ({ |
| 165 | scope, |
| 166 | kind: "mode" as const, |
| 167 | modeSlug: mode.slug, |
| 168 | modeName: mode.name, |
| 169 | directoryPath: path.join(basePath, `rules-${mode.slug}`), |
| 170 | })), |
| 171 | ]) |
| 172 | } |
| 173 | |
| 174 | async function scanRuleDirectory(directory: RuleDirectoryInfo): Promise<RuleMetadata[]> { |
| 175 | try { |
no test coverage detected