📄 insertWhenNotToUseIt¶
📊 Analysis Summary¶
| Metric | Count |
|---|---|
| 🔧 Functions | 1 |
| 📦 Imports | 2 |
📚 Table of Contents¶
🛠️ File Location:¶
📂 packages/website/plugins/generated-rule-docs/insertions/insertWhenNotToUseIt.ts
📦 Imports¶
| Name | Source |
|---|---|
RuleDocsPage |
../RuleDocsPage |
nodeIsHeading |
../../utils/nodes |
Functions¶
insertWhenNotToUseIt(page: RuleDocsPage): void¶
Parameters:
pageRuleDocsPage
Returns: void
Calls:
page.children.findIndexnodeIsHeading (from ../../utils/nodes)page.spliceChildren
Code
export function insertWhenNotToUseIt(page: RuleDocsPage): void {
if (!page.rule.meta.docs.requiresTypeChecking) {
return;
}
const hasExistingText =
page.headingIndices.whenNotToUseIt < page.children.length - 1 &&
page.children[page.headingIndices.whenNotToUseIt + 1].type !== 'heading';
const nextHeadingIndex = page.children.findIndex(
(child, index) =>
index > page.headingIndices.whenNotToUseIt &&
nodeIsHeading(child) &&
child.depth === 2,
);
page.spliceChildren(
nextHeadingIndex === -1 ? page.children.length : nextHeadingIndex,
0,
...(hasExistingText ? ['---'] : []),
'Type checked lint rules are more powerful than traditional lint rules, but also require configuring [type checked linting](/getting-started/typed-linting).',
'See [Troubleshooting > Linting with Type Information > Performance](/troubleshooting/typed-linting/performance) if you experience performance degradations after enabling type checked rules.',
);
}
Generated by Syntax Scribe