📄 utils/rules¶
📊 Analysis Summary¶
| Metric | Count |
|---|---|
| 🔧 Functions | 6 |
| 📦 Imports | 4 |
| 📊 Variables & Constants | 1 |
| 📑 Type Aliases | 1 |
📚 Table of Contents¶
🛠️ File Location:¶
📂 packages/website/plugins/utils/rules.ts
📦 Imports¶
| Name | Source |
|---|---|
ESLintPluginRuleModule |
@typescript-eslint/eslint-plugin/use-at-your-own-risk/rules |
RuleModule |
@typescript-eslint/utils/ts-eslint |
VFile |
vfile |
nodeIsHeading |
./nodes |
Variables & Constants¶
| Name | Type | Kind | Value | Exported |
|---|---|---|---|---|
sourceUrlPrefix |
"https://github.com/typescript-eslint... |
const | 'https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/es... |
✓ |
Functions¶
getRulesString(extendsBaseRuleName: string, stem: string, withComment: boolean): string¶
Parameters:
withCommentany: Whether to include a full comment note.
Tags: @remarks withComment can't be used inside a JSON object which is needed for eslintrc in the playground
Raw JSDoc
Code
convertToPlaygroundHash(eslintrc: string): string¶
Parameters:
eslintrcstring
Returns: string
Calls:
lz.compressToEncodedURIComponent
Code
getUrlForRuleTest(ruleName: string): string¶
Parameters:
ruleNamestring
Returns: string
Calls:
fs.existsSync
Code
export function getUrlForRuleTest(ruleName: string): string {
for (const localPath of [
`tests/rules/${ruleName}.test.ts`,
`tests/rules/${ruleName}/`,
]) {
if (fs.existsSync(`${eslintPluginDirectory}/${localPath}`)) {
return `${sourceUrlPrefix}${localPath}`;
}
}
throw new Error(`Could not find test file for ${ruleName}.`);
}
isESLintPluginRuleModule(rule: RuleModule<string, readonly unknown[]> …): rule is ESLintPluginRuleModule¶
Parameters:
ruleRuleModule<string, readonly unknown[]> | undefined
Returns: rule is ESLintPluginRuleModule
Code
isVFileWithStem(file: VFile): file is VFileWithStem¶
Parameters:
fileVFile
Returns: file is VFileWithStem
findHeadingIndex(children: readonly unist.Node[], depth: 2 | 3, contents: string | ((node: mdast.PhrasingContent)…): number¶
Parameters:
childrenreadonly unist.Node[]depth2 | 3contentsstring | ((node: mdast.PhrasingContent) => boolean)
Returns: number
Calls:
children.findIndexnodeIsHeading (from ./nodes)childMatch
Code
export function findHeadingIndex(
children: readonly unist.Node[],
depth: 2 | 3,
contents: string | ((node: mdast.PhrasingContent) => boolean),
): number {
const childMatch =
typeof contents === 'string'
? (node: mdast.PhrasingContent): boolean =>
node.type === 'text' && node.value === contents
: contents;
return children.findIndex(
node =>
nodeIsHeading(node) &&
node.depth === depth &&
node.children.length === 1 &&
childMatch(node.children[0]),
);
}
Type Aliases¶
VFileWithStem¶
Generated by Syntax Scribe