β¬ οΈ Back to Table of Contents
π RuleAttributes¶
π Analysis Summary¶
| Metric | Count |
|---|---|
| π§ Functions | 5 |
| π¦ Imports | 14 |
| π Variables & Constants | 1 |
| π JSX Elements | 17 |
| π Type Aliases | 2 |
π Table of Contents¶
π οΈ File Location:¶
π packages/website/src/theme/MDXComponents/RuleAttributes.tsx
π¦ Imports¶
| Name | Source |
|---|---|
ESLintPluginDocs |
@typescript-eslint/eslint-plugin/use-at-your-own-risk/rules |
RuleRecommendation |
@typescript-eslint/utils/ts-eslint |
RuleRecommendationAcrossConfigs |
@typescript-eslint/utils/ts-eslint |
Link |
@docusaurus/Link |
useRulesMeta |
@site/src/hooks/useRulesMeta |
React |
react |
FeatureProps |
./Feature |
FIXABLE_EMOJI |
../../components/constants |
RECOMMENDED_CONFIG_EMOJI |
../../components/constants |
STRICT_CONFIG_EMOJI |
../../components/constants |
STYLISTIC_CONFIG_EMOJI |
../../components/constants |
SUGGESTIONS_EMOJI |
../../components/constants |
Feature |
./Feature |
styles |
./RuleAttributes.module.css |
Variables & Constants¶
| Name | Type | Kind | Value | Exported |
|---|---|---|---|---|
recommendations |
Record< RuleRecommendation, [string, ... |
const | { recommended: [RECOMMENDED_CONFIG_EMOJI, 'recommended'], strict: [STRICT_CON... |
β |
JSX Elements¶
| Component | Type | Props | Children |
|---|---|---|---|
Fragment |
fragment | none | text: "Extending", , text: "in an", , text: "enables this rule." |
Link |
component | to={/users/configs#${recommendation}}, target="_blank" |
|
code |
element | className={styles.code} | text: ""plugin:@typescript-eslint/", {recommendation}, text: """ |
Link |
component | href="https://eslint.org/docs/latest/user-guide/configuring/configuration-fil... | text: "ESLint configuration" |
Fragment |
fragment | none | text: "Some problems reported by this rule are automatically fixable by the",... |
Link |
component | href="https://eslint.org/docs/latest/user-guide/command-line-interface#--fix" | , text: "ESLint command line option" |
code |
element | none | text: "--fix" |
Fragment |
fragment | none | text: "Some problems reported by this rule are manually fixable by editor", <... |
Link |
component | href="https://eslint.org/docs/latest/developer-guide/working-with-rules#provi... | text: "suggestions" |
Fragment |
fragment | none | text: "This rule requires", , text: "to run, which comes with performan... |
Link |
component | href="/getting-started/typed-linting", target="_blank" | text: "type information" |
Fragment |
fragment | none | text: "This is an "extension" rule that replaces a core ESLint rule to work w... |
Link |
component | href="/rules#extension-rules" | text: "Rules > Extension Rules" |
Fragment |
fragment | none | text: "This rule is currently", , text: "and is not accepting feature r... |
Link |
component | href="/rules#frozen-rules" | text: "frozen" |
div |
element | className={styles.features} | {features.map(feature => ( |
Feature |
component | key={feature.emoji} | none |
Functions¶
getRecommendationWithEmoji(recommended: RecommendedRuleMetaDataDocs['recommendeβ¦): [string, RuleRecommendation]¶
Parameters:
recommendedRecommendedRuleMetaDataDocs['recommended']
Returns: [string, RuleRecommendation]
Calls:
resolveRecommendation
Code
RuleAttributes({ name }: { name: string }): React.ReactNode¶
Parameters:
{ name }{ name: string }
Returns: React.ReactNode
Calls:
useRulesMeta (from @site/src/hooks/useRulesMeta)rules.findisRecommendedDocsgetRecommendationfeatures.pushfeatures.map
Code
export function RuleAttributes({ name }: { name: string }): React.ReactNode {
const rules = useRulesMeta();
const rule = rules.find(rule => rule.name === name);
if (!rule?.docs) {
return null;
}
const features: FeatureProps[] = [];
if (isRecommendedDocs(rule.docs)) {
const [emoji, recommendation] = getRecommendation(rule.docs);
features.push({
children: (
<>
Extending{' '}
<Link to={`/users/configs#${recommendation}`} target="_blank">
<code className={styles.code}>
"plugin:@typescript-eslint/{recommendation}"
</code>
</Link>{' '}
in an{' '}
<Link href="https://eslint.org/docs/latest/user-guide/configuring/configuration-files#extending-configuration-files">
ESLint configuration
</Link>{' '}
enables this rule.
</>
),
emoji,
});
}
if (rule.fixable) {
features.push({
children: (
<>
Some problems reported by this rule are automatically fixable by the{' '}
<Link href="https://eslint.org/docs/latest/user-guide/command-line-interface#--fix">
<code>--fix</code> ESLint command line option
</Link>
.
</>
),
emoji: FIXABLE_EMOJI,
});
}
if (rule.hasSuggestions) {
features.push({
children: (
<>
Some problems reported by this rule are manually fixable by editor{' '}
<Link href="https://eslint.org/docs/latest/developer-guide/working-with-rules#providing-suggestions">
suggestions
</Link>
.
</>
),
emoji: SUGGESTIONS_EMOJI,
});
}
if (rule.docs.requiresTypeChecking) {
features.push({
children: (
<>
This rule requires{' '}
<Link href="/getting-started/typed-linting" target="_blank">
type information
</Link>{' '}
to run, which comes with performance tradeoffs.
</>
),
emoji: 'π',
});
}
if (rule.docs.extendsBaseRule) {
features.push({
children: (
<>
{' '}
This is an "extension" rule that replaces a core ESLint rule to work
with TypeScript. See{' '}
<Link href="/rules#extension-rules">Rules > Extension Rules</Link>.
</>
),
emoji: 'π§±',
});
}
if (rule.docs.frozen) {
features.push({
children: (
<>
This rule is currently <Link href="/rules#frozen-rules">frozen</Link>{' '}
and is not accepting feature requests.
</>
),
emoji: 'βοΈ',
});
}
return (
<div className={styles.features}>
{features.map(feature => (
<Feature {...feature} key={feature.emoji} />
))}
</div>
);
}
isRecommendedDocs(docs: ESLintPluginDocs): docs is RecommendedRuleMetaDataDocs¶
Parameters:
docsESLintPluginDocs
Returns: docs is RecommendedRuleMetaDataDocs
resolveRecommendation(recommended: RuleRecommendationAcrossConfigs<unknownβ¦): RuleRecommendation¶
Parameters:
recommendedRuleRecommendationAcrossConfigs<unknown[]>
Returns: RuleRecommendation
Code
getRecommendation(docs: RecommendedRuleMetaDataDocs): string[]¶
Parameters:
docsRecommendedRuleMetaDataDocs
Returns: string[]
Calls:
getRecommendationWithEmoji
Code
Type Aliases¶
MakeRequired<Base, Key extends keyof Base>¶
type MakeRequired<Base, Key extends keyof Base> = Omit<Base, Key> &
Required<Record<Key, NonNullable<Base[Key]>>>;
RecommendedRuleMetaDataDocs¶
Generated by Syntax Scribe