Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
danez committed May 20, 2023
1 parent c99978c commit 72f3d72
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 7 deletions.
10 changes: 6 additions & 4 deletions packages/react-docgen/src/handlers/defaultPropsHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ import type {
RestElement,
SpreadElement,
} from '@babel/types';
import type { ComponentNode } from '../resolver/index.js';
import type {
ComponentNode,
StatelessComponentNode,
} from '../resolver/index.js';
import type { Handler } from './index.js';
import type { StatelessComponentNode } from '../resolver/index.js';

function getDefaultValue(path: NodePath): DefaultValueDescriptor | null {
let defaultValue: string | undefined;
Expand Down Expand Up @@ -57,7 +59,7 @@ function getDefaultValue(path: NodePath): DefaultValueDescriptor | null {
}

function getStatelessPropsPath(
componentDefinition: NodePath<StatelessComponentNode | CallExpression>,
componentDefinition: NodePath<CallExpression | StatelessComponentNode>,
): NodePath | undefined {
let value: NodePath = componentDefinition;

Expand Down Expand Up @@ -165,7 +167,7 @@ const defaultPropsHandler: Handler = function (
*/
if (!isReactComponentClass(componentDefinition)) {
statelessProps = getStatelessPropsPath(
componentDefinition as NodePath<StatelessComponentNode | CallExpression>,
componentDefinition as NodePath<CallExpression | StatelessComponentNode>,
);
}

Expand Down
3 changes: 3 additions & 0 deletions packages/react-docgen/src/utils/flowUtilityTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,14 @@ export function isSupportedUtilityType(
*/
export function unwrapUtilityType(path: NodePath): NodePath {
let resultPath: NodePath = path;

while (isSupportedUtilityType(resultPath)) {
const typeParameters = resultPath.get('typeParameters');

if (!typeParameters.hasNode()) break;

const firstParam = typeParameters.get('params')[0];

if (!firstParam) break;

resultPath = firstParam;
Expand Down
1 change: 1 addition & 0 deletions packages/react-docgen/src/utils/getFlowType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ const flowLiteralTypes = {
const namedTypes: Record<
string,
(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
path: NodePath<any>,
typeParams: TypeParameters | null,
) => TypeDescriptor | null
Expand Down
1 change: 1 addition & 0 deletions packages/react-docgen/src/utils/getTSType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const tsTypes: Record<string, string> = {
const namedTypes: Record<
string,
(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
path: NodePath<any>,
typeParams: TypeParameters | null,
) => TypeDescriptor | null
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { NodePath } from '@babel/traverse';
import isReactModuleName from './isReactModuleName.js';
import resolveToModule from './resolveToModule.js';
import { CallExpression } from '@babel/types';
import type { CallExpression } from '@babel/types';

/**
* Returns true if the expression is a function call of the form
Expand Down
2 changes: 1 addition & 1 deletion packages/react-docgen/src/utils/isReactCreateClassCall.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { NodePath } from '@babel/traverse';
import resolveToModule from './resolveToModule.js';
import isReactBuiltinCall from './isReactBuiltinCall.js';
import { CallExpression } from '@babel/types';
import type { CallExpression } from '@babel/types';

/**
* Returns true if the expression is a function call of the form
Expand Down
2 changes: 1 addition & 1 deletion packages/react-docgen/src/utils/isReactForwardRefCall.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { NodePath } from '@babel/traverse';
import isReactBuiltinCall from './isReactBuiltinCall.js';
import { CallExpression } from '@babel/types';
import type { CallExpression } from '@babel/types';

/**
* Returns true if the expression is a function call of the form
Expand Down

0 comments on commit 72f3d72

Please sign in to comment.