-
-
Notifications
You must be signed in to change notification settings - Fork 32
Minor docs improvements #1339
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Minor docs improvements #1339
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -70,7 +70,8 @@ | |
|
|
||
| /** | ||
| * Check whether the given node is a this.setState() call | ||
| * @param node - The node to check | ||
| * @param node The node to check | ||
| * @param node | ||
|
Check warning on line 74 in packages/core/src/component/component-collector-legacy.ts
|
||
| * @internal | ||
| */ | ||
| export function isThisSetState(node: TSESTree.CallExpression) { | ||
|
|
@@ -85,7 +86,8 @@ | |
|
|
||
| /** | ||
| * Check whether the given node is an assignment to this.state | ||
| * @param node - The node to check | ||
| * @param node The node to check | ||
| * @param node | ||
|
Check warning on line 90 in packages/core/src/component/component-collector-legacy.ts
|
||
|
Comment on lines
+89
to
+90
|
||
| * @internal | ||
| */ | ||
| export function isAssignmentToThisState(node: TSESTree.AssignmentExpression) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -35,7 +35,8 @@ | |||||
| /** | ||||||
| * Checks if the given node is a function within a render method of a class component. | ||||||
| * | ||||||
| * @param node - The AST node to check | ||||||
| * @param node The AST node to check | ||||||
| * @param node | ||||||
|
Check warning on line 39 in packages/core/src/component/component-definition.ts
|
||||||
|
Comment on lines
+38
to
+39
|
||||||
| * @returns `true` if the node is a render function inside a class component | ||||||
| * | ||||||
| * @example | ||||||
|
|
@@ -60,8 +61,10 @@ | |||||
| /** | ||||||
| * Checks if a function node should be excluded based on provided detection hints | ||||||
| * | ||||||
| * @param node - The function node to check | ||||||
| * @param hint - Component detection hints as bit flags | ||||||
| * @param node The function node to check | ||||||
| * @param hint Component detection hints as bit flags | ||||||
| * @param node | ||||||
|
Check warning on line 66 in packages/core/src/component/component-definition.ts
|
||||||
| * @param hint | ||||||
|
Check warning on line 67 in packages/core/src/component/component-definition.ts
|
||||||
|
Comment on lines
+66
to
+67
|
||||||
| * @param node | |
| * @param hint |
Check warning on line 95 in packages/core/src/component/component-definition.ts
GitHub Actions / check
Duplicate @param "context"
Check warning on line 95 in packages/core/src/component/component-definition.ts
GitHub Actions / Publish
Duplicate @param "context"
Check warning on line 95 in packages/core/src/component/component-definition.ts
GitHub Actions / check
Duplicate @param "context"
Copilot
AI
Dec 6, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra asterisk in JSDoc parameter format and duplicate @param entries. Should be * @param context The rule context and * @param node The AST node to check (single asterisk, single entry each) instead of having duplicate entries.
Copilot
AI
Dec 6, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra asterisk in JSDoc parameter format and duplicate @param entries. Should be * @param context The rule context, * @param node The function node to analyze, and * @param hint Component detection hints... (single asterisk, single entry each) instead of having duplicate entries.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,23 +7,23 @@ import { getFunctionComponentId } from "./component-id"; | |
|
|
||
| /** | ||
| * Check if a string matches the strict component name pattern | ||
| * @param name - The name to check | ||
| * @param name The name to check | ||
|
||
| */ | ||
| export function isComponentName(name: string) { | ||
| return RE_COMPONENT_NAME.test(name); | ||
| } | ||
|
|
||
| /** | ||
| * Check if a string matches the loose component name pattern | ||
| * @param name - The name to check | ||
| * @param name The name to check | ||
|
||
| */ | ||
| export function isComponentNameLoose(name: string) { | ||
| return RE_COMPONENT_NAME_LOOSE.test(name); | ||
| } | ||
|
|
||
| /** | ||
| * Get component name from an identifier or identifier sequence (e.g., MemberExpression) | ||
| * @param id - The identifier or identifier sequence | ||
| * @param id The identifier or identifier sequence | ||
|
||
| */ | ||
| export function getComponentNameFromId(id: TSESTree.Identifier | TSESTree.Identifier[] | unit) { | ||
| if (id == null) return unit; | ||
|
|
@@ -34,8 +34,8 @@ export function getComponentNameFromId(id: TSESTree.Identifier | TSESTree.Identi | |
|
|
||
| /** | ||
| * Check if the function has no name or a loose component name | ||
| * @param context - The rule context | ||
| * @param fn - The function node | ||
| * @param context The rule context | ||
| * @param fn The function node | ||
Rel1cx marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| */ | ||
| export function hasNoneOrLooseComponentName(context: RuleContext, fn: AST.TSESTreeFunction) { | ||
| const id = getFunctionComponentId(context, fn); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,8 +7,8 @@ import { getJsxElementType } from "./jsx-element-type"; | |
| * Determines if a JSX element is a host element | ||
| * Host elements in React start with lowercase letters (e.g., div, span) | ||
| * | ||
| * @param context - ESLint rule context | ||
| * @param node - AST node to check | ||
| * @param context ESLint rule context | ||
| * @param node AST node to check | ||
|
Comment on lines
+10
to
+11
|
||
| * @returns boolean indicating if the element is a host element | ||
| */ | ||
| export function isJsxHostElement(context: RuleContext, node: TSESTree.Node) { | ||
|
|
@@ -21,8 +21,8 @@ export function isJsxHostElement(context: RuleContext, node: TSESTree.Node) { | |
| * Determines if a JSX element is a React Fragment | ||
| * Fragments can be imported from React and used like <Fragment> or <React.Fragment> | ||
| * | ||
| * @param context - ESLint rule context | ||
| * @param node - AST node to check | ||
| * @param context ESLint rule context | ||
| * @param node AST node to check | ||
|
Comment on lines
+24
to
+25
|
||
| * @returns boolean indicating if the element is a Fragment with type narrowing | ||
| */ | ||
| export function isJsxFragmentElement(context: RuleContext, node: TSESTree.Node): node is TSESTree.JSXElement { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,8 +8,8 @@ import { stringifyJsx } from "./jsx-stringify"; | |
| * For JSX elements, returns the stringified name (e.g., "div", "Button", "React.Fragment") | ||
| * For JSX fragments, returns an empty string | ||
| * | ||
| * @param context - ESLint rule context | ||
| * @param node - JSX element or fragment node | ||
| * @param context ESLint rule context | ||
| * @param node JSX element or fragment node | ||
|
Comment on lines
+11
to
+12
|
||
| * @returns String representation of the element type | ||
| */ | ||
| export function getJsxElementType(context: RuleContext, node: TSESTree.JSXElement | TSESTree.JSXFragment) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,8 +7,8 @@ import { AST_NODE_TYPES as T } from "@typescript-eslint/types"; | |
| /** | ||
| * Traverses up the AST to find a parent JSX attribute node that matches a given test | ||
| * | ||
| * @param node - The starting AST node | ||
| * @param test - Optional predicate function to test if the attribute meets criteria | ||
| * @param node The starting AST node | ||
| * @param test Optional predicate function to test if the attribute meets criteria | ||
|
Comment on lines
+10
to
+11
|
||
| * Defaults to always returning true (matches any attribute) | ||
| * @returns The first matching JSX attribute node found when traversing upwards, or undefined | ||
| */ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,7 +4,7 @@ import type { TSESTree } from "@typescript-eslint/utils"; | |
| /** | ||
| * Incomplete but sufficient stringification of JSX nodes for common use cases | ||
| * | ||
| * @param node - JSX node from TypeScript ESTree | ||
| * @param node JSX node from TypeScript ESTree | ||
|
||
| * @returns String representation of the JSX node | ||
| */ | ||
| export function stringifyJsx( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,6 +13,11 @@ export declare namespace isReactAPI { | |
| }; | ||
| } | ||
|
|
||
| /** | ||
| * Checks if the node is a React API identifier or member expression | ||
| * @param api The React API name to check against (e.g., "useState", "React.memo") | ||
| * @returns A predicate function to check if a node matches the API | ||
| */ | ||
|
Comment on lines
+16
to
+20
|
||
| export function isReactAPI(api: string): isReactAPI.ReturnType { | ||
| const func = (context: RuleContext, node: unit | null | TSESTree.Node): node is | ||
| | TSESTree.Identifier | ||
|
|
@@ -35,6 +40,11 @@ export declare namespace isReactAPICall { | |
| }; | ||
| } | ||
|
|
||
| /** | ||
| * Checks if the node is a call expression to a specific React API | ||
| * @param api The React API name to check against | ||
| * @returns A predicate function to check if a node is a call to the API | ||
| */ | ||
|
Comment on lines
+43
to
+47
|
||
| export function isReactAPICall(api: string): isReactAPICall.ReturnType { | ||
| const func = (context: RuleContext, node: unit | null | TSESTree.Node): node is TSESTree.CallExpression => { | ||
| if (node == null) return false; | ||
|
|
@@ -44,6 +54,7 @@ export function isReactAPICall(api: string): isReactAPICall.ReturnType { | |
| return dual(2, func); | ||
| } | ||
|
|
||
| // React API checks | ||
| export const isCaptureOwnerStack = isReactAPI("captureOwnerStack"); | ||
| export const isChildrenCount = isReactAPI("Children.count"); | ||
| export const isChildrenForEach = isReactAPI("Children.forEach"); | ||
|
|
@@ -58,6 +69,7 @@ export const isForwardRef = isReactAPI("forwardRef"); | |
| export const isMemo = isReactAPI("memo"); | ||
| export const isLazy = isReactAPI("lazy"); | ||
|
|
||
| // React API Call checks | ||
| export const isCaptureOwnerStackCall = isReactAPICall("captureOwnerStack"); | ||
| export const isChildrenCountCall = isReactAPICall("Children.count"); | ||
| export const isChildrenForEachCall = isReactAPICall("Children.forEach"); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -969,7 +969,7 @@ const POPOVER_API_PROPS: string[] = [ | |
|
|
||
| /** | ||
| * Gets all valid DOM property names based on React version | ||
| * @param context - ESLint rule context | ||
| * @param context ESLint rule context | ||
|
||
| * @returns Array of valid DOM property names | ||
| */ | ||
| function getDOMPropertyNames(context: RuleContext<MessageID, unknown[]>): string[] { | ||
|
|
@@ -998,7 +998,7 @@ function getDOMPropertyNames(context: RuleContext<MessageID, unknown[]>): string | |
| /** | ||
| * Checks if a node's parent is a JSX tag that is written with lowercase letters, | ||
| * and is not a custom web component. | ||
| * @param childNode - JSX element being tested | ||
| * @param childNode JSX element being tested | ||
Rel1cx marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| * @returns Whether the node is a valid HTML tag in JSX | ||
| */ | ||
| function isValidHTMLTagInJSX(childNode: JSXAttribute): boolean { | ||
|
|
@@ -1015,7 +1015,7 @@ function isValidHTMLTagInJSX(childNode: JSXAttribute): boolean { | |
|
|
||
| /** | ||
| * Normalizes attribute names that should be case-insensitive | ||
| * @param name - Attribute name to normalize | ||
| * @param name Attribute name to normalize | ||
|
||
| * @returns Normalized attribute name | ||
| */ | ||
| function normalizeAttributeCase(name: string): string { | ||
|
|
@@ -1024,7 +1024,7 @@ function normalizeAttributeCase(name: string): string { | |
|
|
||
| /** | ||
| * Checks if an attribute name is a valid data-* attribute | ||
| * @param name - Attribute name to test | ||
| * @param name Attribute name to test | ||
Rel1cx marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| * @returns Whether the attribute is a valid data attribute | ||
| */ | ||
| function isValidDataAttribute(name: string): boolean { | ||
|
|
@@ -1033,7 +1033,7 @@ function isValidDataAttribute(name: string): boolean { | |
|
|
||
| /** | ||
| * Checks if an attribute name has uppercase characters | ||
| * @param name - Attribute name to test | ||
| * @param name Attribute name to test | ||
|
||
| * @returns Whether the name has uppercase characters | ||
| */ | ||
| function hasUpperCaseCharacter(name: string): boolean { | ||
|
|
@@ -1042,7 +1042,7 @@ function hasUpperCaseCharacter(name: string): boolean { | |
|
|
||
| /** | ||
| * Checks if an attribute is a valid ARIA attribute | ||
| * @param name - Attribute name to test | ||
| * @param name Attribute name to test | ||
|
||
| * @returns Whether the attribute is a valid ARIA attribute | ||
| */ | ||
| function isValidAriaAttribute(name: string): boolean { | ||
|
|
@@ -1051,7 +1051,7 @@ function isValidAriaAttribute(name: string): boolean { | |
|
|
||
| /** | ||
| * Gets the tag name for a JSXAttribute | ||
| * @param node - JSXAttribute to get tag name from | ||
| * @param node JSXAttribute to get tag name from | ||
|
||
| * @returns Tag name or null | ||
| */ | ||
| function getTagName(node: JSXAttribute): string | null { | ||
|
|
@@ -1063,7 +1063,7 @@ function getTagName(node: JSXAttribute): string | null { | |
|
|
||
| /** | ||
| * Checks if the tag name has a dot (member expression) | ||
| * @param node - JSXAttribute to check | ||
| * @param node JSXAttribute to check | ||
Rel1cx marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| * @returns Whether the tag name has a dot | ||
| */ | ||
| function tagNameHasDot(node: JSXAttribute): boolean { | ||
|
|
@@ -1075,8 +1075,8 @@ function tagNameHasDot(node: JSXAttribute): boolean { | |
|
|
||
| /** | ||
| * Gets the standard name of an attribute | ||
| * @param name - Attribute name | ||
| * @param context - ESLint context | ||
| * @param name Attribute name | ||
| * @param context ESLint context | ||
|
Comment on lines
+1078
to
+1079
|
||
| * @returns Standard name or undefined | ||
| */ | ||
| function getStandardName(name: string, context: RuleContext<MessageID, unknown[]>): string | undefined { | ||
|
|
@@ -1092,8 +1092,8 @@ function getStandardName(name: string, context: RuleContext<MessageID, unknown[] | |
|
|
||
| /** | ||
| * Checks if an object has a property | ||
| * @param obj - Object to check | ||
| * @param key - Key to check for | ||
| * @param obj Object to check | ||
| * @param key Key to check for | ||
|
Comment on lines
+1095
to
+1096
|
||
| * @returns Whether the object has the property | ||
| */ | ||
| function has(obj: Record<string, any>, key: string): boolean { | ||
|
|
@@ -1102,8 +1102,8 @@ function has(obj: Record<string, any>, key: string): boolean { | |
|
|
||
| /** | ||
| * Gets text of a node | ||
| * @param context - ESLint context | ||
| * @param node - Node to get text from | ||
| * @param context ESLint context | ||
| * @param node Node to get text from | ||
|
Comment on lines
+1105
to
+1106
|
||
| * @returns Node's text | ||
| */ | ||
| function getText(context: RuleContext<MessageID, unknown[]>, node: any): string { | ||
|
|
@@ -1112,9 +1112,9 @@ function getText(context: RuleContext<MessageID, unknown[]>, node: any): string | |
|
|
||
| /** | ||
| * Tests React version against a comparator | ||
| * @param context - ESLint context | ||
| * @param comparator - Comparison operator | ||
| * @param version - Version to compare against | ||
| * @param context ESLint context | ||
| * @param comparator Comparison operator | ||
| * @param version Version to compare against | ||
|
Comment on lines
+1115
to
+1117
|
||
| * @returns Comparison result | ||
| */ | ||
| function testReactVersion(context: RuleContext<MessageID, unknown[]>, comparator: string, version: string): boolean { | ||
|
|
@@ -1167,7 +1167,7 @@ export default createRule({ | |
|
|
||
| /** | ||
| * Create function for the ESLint rule | ||
| * @param context - ESLint rule context | ||
| * @param context ESLint rule context | ||
|
||
| * @returns Rule listener | ||
| */ | ||
| export function create(context: RuleContext<MessageID, unknown[]>): RuleListener { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,7 +19,7 @@ export type RuleSuggestMessageID = "addRelNoreferrerNoopener"; | |
| /** | ||
| * Checks if a value appears to be an external link. | ||
| * External links typically start with http(s):// or have protocol-relative format. | ||
| * @param value - The value to check | ||
| * @param value The value to check | ||
Rel1cx marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| * @returns Whether the value represents an external link | ||
| */ | ||
| function isExternalLinkLike(value: unknown): boolean { | ||
|
|
@@ -31,7 +31,7 @@ function isExternalLinkLike(value: unknown): boolean { | |
| /** | ||
| * Checks if a rel prop value contains the necessary security attributes. | ||
| * At minimum, it should contain "noreferrer". | ||
| * @param value - The rel prop value to check | ||
| * @param value The rel prop value to check | ||
|
||
| * @returns Whether the rel value is considered secure | ||
| */ | ||
| function isSafeRel(value: unknown): boolean { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra asterisk in JSDoc parameter format and duplicate
@paramentry. Should be* @param node The node to check(single asterisk, single entry) instead of having both* @param node The node to checkand* @param nodeon separate lines.