📄 rules.ts
¶
📊 Analysis Summary¶
Metric | Count |
---|---|
🔧 Functions | 6 |
📦 Imports | 4 |
📊 Variables & Constants | 2 |
📑 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/typescript-eslint/blob/main/packages/eslint-plugin/" |
const | 'https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/' |
✓ |
childMatch |
(node: mdast.PhrasingContent) => boolean |
const | `typeof contents === 'string' | |
? (node: mdast.PhrasingContent): boolean => | ||||
node.type === 'text' && node.value === contents | ||||
: contents` | ✗ |
Functions¶
getRulesString(extendsBaseRuleName: string, stem: string, withComment: boolean): string
¶
Code
-
JSDoc:
-
Parameters:
extendsBaseRuleName: string
stem: string
withComment: boolean
- Return Type:
string
convertToPlaygroundHash(eslintrc: string): string
¶
Code
- Parameters:
eslintrc: string
- Return Type:
string
- Calls:
lz.compressToEncodedURIComponent
getUrlForRuleTest(ruleName: string): string
¶
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}.`);
}
- Parameters:
ruleName: string
- Return Type:
string
- Calls:
fs.existsSync
isESLintPluginRuleModule(rule: RuleModule<string, readonly unknown[]> | undefined): rule is ESLintPluginRuleModule
¶
Code
- Parameters:
rule: RuleModule<string, readonly unknown[]> | undefined
- Return Type:
rule is ESLintPluginRuleModule
isVFileWithStem(file: VFile): file is VFileWithStem
¶
- Parameters:
file: VFile
- Return Type:
file is VFileWithStem
findHeadingIndex(children: readonly unist.Node[], depth: 2 | 3, contents: string | ((node: mdast.PhrasingContent) => boolean)): number
¶
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]),
);
}
- Parameters:
children: readonly unist.Node[]
depth: 2 | 3
contents: string | ((node: mdast.PhrasingContent) => boolean)
- Return Type:
number
- Calls:
children.findIndex
nodeIsHeading (from ./nodes)
childMatch