Skip to content

Commit

Permalink
[core] Enable trailing comma in TypeScript files (#25931)
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon authored Apr 24, 2021
1 parent c5ec5a5 commit e0e959a
Show file tree
Hide file tree
Showing 38 changed files with 61 additions and 68 deletions.
6 changes: 3 additions & 3 deletions docs/types/react-docgen.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ declare module 'react-docgen' {
export type Handler = (
documentation: Documentation,
componentDefinition: NodePath,
importer: Importer
importer: Importer,
) => void;

export const defaultHandlers: readonly Handler[];
Expand All @@ -27,7 +27,7 @@ declare module 'react-docgen' {
export type Resolver = (
ast: ASTNode,
parser: unknown,
importer: Importer
importer: Importer,
) => NodePath | NodePath[] | undefined;

export namespace resolver {
Expand Down Expand Up @@ -180,7 +180,7 @@ declare module 'react-docgen' {
source: string,
componentResolver: null | Resolver,
handlers: null | readonly Handler[],
options: { filename: string }
options: { filename: string },
): any;

export namespace utils {
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui-lab/src/TreeItem/useTreeItem.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';

export default function useTreeItem(
nodeId: string
nodeId: string,
): {
disabled: boolean;
expanded: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ export interface ThemeProviderProps<Theme = DefaultTheme> {
theme: Partial<Theme> | ((outerTheme: Theme) => Theme);
}
export default function ThemeProvider<T = DefaultTheme>(
props: ThemeProviderProps<T>
props: ThemeProviderProps<T>,
): React.ReactElement<ThemeProviderProps<T>>;
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ import { StyleRules } from '@material-ui/styles/withStyles';
// See https://github.com/mui-org/material-ui/issues/15942
// and https://github.com/microsoft/TypeScript/issues/31735
export default function createStyles<ClassKey extends string, Props extends {}>(
styles: StyleRules<Props, ClassKey>
styles: StyleRules<Props, ClassKey>,
): StyleRules<Props, ClassKey>;
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ export interface StylesCreator<Theme, Props extends object, ClassKey extends str
}

export default function getStylesCreator<S extends Styles<any, any>>(
style: S
style: S,
): StylesCreator<any, any>;
2 changes: 1 addition & 1 deletion packages/material-ui-styles/src/makeStyles/makeStyles.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default function makeStyles<
ClassKey extends string = string
>(
styles: Styles<Theme, Props, ClassKey>,
options?: Omit<WithStylesOptions<Theme>, 'withTheme'>
options?: Omit<WithStylesOptions<Theme>, 'withTheme'>,
): keyof Props extends never
? // `makeStyles` where the passed `styles` do not depend on props
(props?: any) => ClassNameMap<ClassKey>
Expand Down
4 changes: 2 additions & 2 deletions packages/material-ui-styles/src/styled/styled.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export type ComponentCreator<Component extends React.ElementType> = <
styles:
| CreateCSSProperties<Props>
| ((props: { theme: Theme } & Props) => CreateCSSProperties<Props>),
options?: WithStylesOptions<Theme>
options?: WithStylesOptions<Theme>,
) => StyledComponent<
DistributiveOmit<
JSX.LibraryManagedAttributes<Component, React.ComponentProps<Component>>,
Expand All @@ -35,5 +35,5 @@ export interface StyledProps {
}

export default function styled<Component extends React.ElementType>(
Component: Component
Component: Component,
): ComponentCreator<Component>;
4 changes: 2 additions & 2 deletions packages/material-ui-styles/src/withStyles/withStyles.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export type StyleRules<Props extends object = {}, ClassKey extends string = stri
* @internal
*/
export type StyleRulesCallback<Theme, Props extends object, ClassKey extends string = string> = (
theme: Theme
theme: Theme,
) => StyleRules<Props, ClassKey>;

export type Styles<Theme, Props extends object, ClassKey extends string = string> =
Expand Down Expand Up @@ -125,7 +125,7 @@ export default function withStyles<
Options extends WithStylesOptions<ThemeOfStyles<StylesType>> = {}
>(
style: StylesType,
options?: Options
options?: Options,
): PropInjector<
WithStyles<StylesType, Options['withTheme']>,
StyledComponentProps<ClassKeyOfStyles<StylesType>> & PropsOfStyles<StylesType>
Expand Down
4 changes: 2 additions & 2 deletions packages/material-ui-styles/src/withTheme/withTheme.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ export interface ThemedComponentProps extends Partial<WithTheme> {
}

export function withThemeCreator<Theme = DefaultTheme>(
option?: WithThemeCreatorOption<Theme>
option?: WithThemeCreatorOption<Theme>,
): PropInjector<WithTheme<Theme>, ThemedComponentProps>;

export default function withTheme<
Theme,
C extends React.ComponentType<ConsistentWith<React.ComponentProps<C>, WithTheme<Theme>>>
>(
component: C
component: C,
): React.ComponentType<
DistributiveOmit<
JSX.LibraryManagedAttributes<C, React.ComponentProps<C>>,
Expand Down
8 changes: 4 additions & 4 deletions packages/material-ui-system/src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ type DefaultBreakPoints = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
export function handleBreakpoints<Props>(
props: Props,
propValue: any,
styleFromPropValue: (value: any) => any
styleFromPropValue: (value: any) => any,
): any;

/**
* @returns An enhanced stylefunction that considers breakpoints
*/
export function breakpoints<Props, Breakpoints extends string = DefaultBreakPoints>(
styleFunction: StyleFunction<Props>
styleFunction: StyleFunction<Props>,
): StyleFunction<Partial<Record<Breakpoints, Props>> & Props>;

// restructures the breakpoints in the in the correct order and merges all styles args
Expand Down Expand Up @@ -241,7 +241,7 @@ export interface StyleOptions<PropKey> {
transform?: (cssValue: unknown) => number | string | React.CSSProperties | CSSObject;
}
export function style<PropKey extends string, Theme extends object>(
options: StyleOptions<PropKey>
options: StyleOptions<PropKey>,
): StyleFunction<{ [K in PropKey]?: unknown } & { theme: Theme }>;

// typography.js
Expand Down Expand Up @@ -308,7 +308,7 @@ export type SimpleSystemKeys = keyof Omit<
typeof shadows,
typeof sizing,
typeof spacing,
typeof typography
typeof typography,
]
>
>,
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui-types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export type ConsistentWith<DecorationTargetProps, InjectedProps> = {
export type PropInjector<InjectedProps, AdditionalProps = {}> = <
C extends React.JSXElementConstructor<ConsistentWith<React.ComponentProps<C>, InjectedProps>>
>(
component: C
component: C,
) => React.JSXElementConstructor<
DistributiveOmit<JSX.LibraryManagedAttributes<C, React.ComponentProps<C>>, keyof InjectedProps> &
AdditionalProps
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export interface OverridableComponent<M extends OverridableTypeMap> {
* Either a string to use a HTML element or a component.
*/
component: C;
} & OverrideProps<M, C>
} & OverrideProps<M, C>,
): JSX.Element;
(props: DefaultComponentProps<M>): JSX.Element;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui-utils/src/debounce.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ export interface Cancelable {

export default function debounce<T extends (...args: any[]) => any>(
func: T,
wait?: number
wait?: number,
): T & Cancelable;
2 changes: 1 addition & 1 deletion packages/material-ui-utils/src/requirePropFactory.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ import * as React from 'react';

export default function requirePropFactory(
componentNameInError: string,
Component?: React.ComponentType
Component?: React.ComponentType,
): any;
2 changes: 1 addition & 1 deletion packages/material-ui-utils/src/unsupportedProp.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ export default function unsupportedProp(
propName: string,
componentName: string,
location: string,
propFullName: string
propFullName: string,
): Error | null;
2 changes: 1 addition & 1 deletion packages/material-ui-utils/src/useControlled.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ export interface UseControlledProps<T = unknown> {
}

export default function useControlled<T = unknown>(
props: UseControlledProps<T>
props: UseControlledProps<T>,
): [T, (newValue: T | ((prevValue: T) => T)) => void];
2 changes: 1 addition & 1 deletion packages/material-ui-utils/src/useEnhancedEffect.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ import * as React from 'react';

export default function useEnhancedEffect(
effect: React.EffectCallback,
deps?: React.DependencyList
deps?: React.DependencyList,
): void;
2 changes: 1 addition & 1 deletion packages/material-ui/src/Autocomplete/Autocomplete.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ export interface AutocompleteProps<
renderOption?: (
props: React.HTMLAttributes<HTMLLIElement>,
option: T,
state: AutocompleteRenderOptionState
state: AutocompleteRenderOptionState,
) => React.ReactNode;
/**
* Render the selected value.
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/Button/Button.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ export interface ExtendButtonTypeMap<M extends OverridableTypeMap> {
}

export type ExtendButton<M extends OverridableTypeMap> = ((
props: { href: string } & OverrideProps<ExtendButtonBaseTypeMap<M>, 'a'>
props: { href: string } & OverrideProps<ExtendButtonBaseTypeMap<M>, 'a'>,
) => JSX.Element) &
OverridableComponent<ExtendButtonBaseTypeMap<M>>;

Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/ButtonBase/ButtonBase.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export interface ExtendButtonBaseTypeMap<M extends OverridableTypeMap> {
}

export type ExtendButtonBase<M extends OverridableTypeMap> = ((
props: { href: string } & OverrideProps<ExtendButtonBaseTypeMap<M>, 'a'>
props: { href: string } & OverrideProps<ExtendButtonBaseTypeMap<M>, 'a'>,
) => JSX.Element) &
OverridableComponent<ExtendButtonBaseTypeMap<M>>;

Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/CardHeader/CardHeader.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export interface OverridableCardHeader extends OverridableComponent<CardHeaderTy
Props,
TitleTypographyComponent,
SubheaderTypographyComponent
>
>,
): JSX.Element;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/OverridableComponent.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export interface OverridableComponent<M extends OverridableTypeMap> {
* Either a string to use a HTML element or a component.
*/
component: C;
} & OverrideProps<M, C>
} & OverrideProps<M, C>,
): JSX.Element;
(props: DefaultComponentProps<M>): JSX.Element;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/Pagination/Pagination.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export interface PaginationProps
getItemAriaLabel?: (
type: 'page' | 'first' | 'last' | 'next' | 'previous',
page: number,
selected: boolean
selected: boolean,
) => string;
/**
* Render the item.
Expand Down
4 changes: 2 additions & 2 deletions packages/material-ui/src/Select/SelectInput.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export interface SelectInputProps<T = unknown> {
disabled?: boolean;
IconComponent?: React.ElementType;
inputRef?: (
ref: HTMLSelectElement | { node: HTMLInputElement; value: SelectInputProps<T>['value'] }
ref: HTMLSelectElement | { node: HTMLInputElement; value: SelectInputProps<T>['value'] },
) => void;
MenuProps?: Partial<MenuProps>;
multiple: boolean;
Expand All @@ -18,7 +18,7 @@ export interface SelectInputProps<T = unknown> {
onBlur?: React.FocusEventHandler<any>;
onChange?: (
event: React.ChangeEvent<{ name?: string; value: T; event: Event | React.SyntheticEvent }>,
child: React.ReactNode
child: React.ReactNode,
) => void;
onClose?: (event: React.SyntheticEvent) => void;
onFocus?: React.FocusEventHandler<any>;
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/styles/ThemeProvider.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ export interface ThemeProviderProps<Theme = DefaultTheme> {
* - [ThemeProvider API](https://material-ui.com/api/theme-provider/)
*/
export default function ThemeProvider<T = DefaultTheme>(
props: ThemeProviderProps<T>
props: ThemeProviderProps<T>,
): React.ReactElement<ThemeProviderProps<T>>;
2 changes: 1 addition & 1 deletion packages/material-ui/src/styles/createMixins.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ export interface MixinsOptions extends Partial<Mixins> {
export default function createMixins(
breakpoints: Breakpoints,
spacing: Spacing,
mixins: MixinsOptions
mixins: MixinsOptions,
): Mixins;
2 changes: 1 addition & 1 deletion packages/material-ui/src/styles/createTypography.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,5 @@ export interface TypographyOptions

export default function createTypography(
palette: Palette,
typography: TypographyOptions | ((palette: Palette) => TypographyOptions)
typography: TypographyOptions | ((palette: Palette) => TypographyOptions),
): Typography;
16 changes: 8 additions & 8 deletions packages/material-ui/src/styles/experimentalStyled.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ export interface StyledComponent<InnerProps, StyleProps, Theme extends object>
* @desc this method is type-unsafe
*/
withComponent<NewTag extends keyof JSXInEl>(
tag: NewTag
tag: NewTag,
): StyledComponent<JSXInEl[NewTag], StyleProps, Theme>;
withComponent<Tag extends React.ComponentType<any>>(
tag: Tag
tag: Tag,
): StyledComponent<PropsOf<Tag>, StyleProps, Theme>;
}

Expand Down Expand Up @@ -160,7 +160,7 @@ export interface CreateMUIStyled<Theme extends object = DefaultTheme> {
>(
component: C,
options: FilteringStyledOptions<React.ComponentProps<C>, ForwardedProps>,
muiOptions?: MuiStyledOptions
muiOptions?: MuiStyledOptions,
): CreateStyledComponent<
Pick<PropsOf<C>, ForwardedProps> & {
theme?: Theme;
Expand All @@ -176,7 +176,7 @@ export interface CreateMUIStyled<Theme extends object = DefaultTheme> {
<C extends React.ComponentClass<React.ComponentProps<C>>>(
component: C,
options?: StyledOptions,
muiOptions?: MuiStyledOptions
muiOptions?: MuiStyledOptions,
): CreateStyledComponent<
PropsOf<C> & {
theme?: Theme;
Expand All @@ -195,7 +195,7 @@ export interface CreateMUIStyled<Theme extends object = DefaultTheme> {
>(
component: C,
options: FilteringStyledOptions<React.ComponentProps<C>, ForwardedProps>,
muiOptions?: MuiStyledOptions
muiOptions?: MuiStyledOptions,
): CreateStyledComponent<
Pick<PropsOf<C>, ForwardedProps> & {
theme?: Theme;
Expand All @@ -207,7 +207,7 @@ export interface CreateMUIStyled<Theme extends object = DefaultTheme> {
<C extends React.ComponentType<React.ComponentProps<C>>>(
component: C,
options?: StyledOptions,
muiOptions?: MuiStyledOptions
muiOptions?: MuiStyledOptions,
): CreateStyledComponent<
PropsOf<C> & {
theme?: Theme;
Expand All @@ -222,7 +222,7 @@ export interface CreateMUIStyled<Theme extends object = DefaultTheme> {
>(
tag: Tag,
options: FilteringStyledOptions<JSX.IntrinsicElements[Tag], ForwardedProps>,
muiOptions?: MuiStyledOptions
muiOptions?: MuiStyledOptions,
): CreateStyledComponent<
{ theme?: Theme; as?: React.ElementType; sx?: SxProps<Theme> },
Pick<JSX.IntrinsicElements[Tag], ForwardedProps>
Expand All @@ -231,7 +231,7 @@ export interface CreateMUIStyled<Theme extends object = DefaultTheme> {
<Tag extends keyof JSX.IntrinsicElements>(
tag: Tag,
options?: StyledOptions,
muiOptions?: MuiStyledOptions
muiOptions?: MuiStyledOptions,
): CreateStyledComponent<
{ theme?: Theme; as?: React.ElementType; sx?: SxProps<Theme> },
JSX.IntrinsicElements[Tag]
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/styles/makeStyles.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default function makeStyles<
ClassKey extends string = string
>(
styles: Styles<Theme, Props, ClassKey>,
options?: DistributiveOmit<WithStylesOptions<Theme>, 'withTheme'>
options?: DistributiveOmit<WithStylesOptions<Theme>, 'withTheme'>,
): keyof Props extends never
? // `makeStyles` where the passed `styles` do not depend on props
(props?: any) => ClassNameMap<ClassKey>
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/styles/responsiveFontSizes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ export interface ResponsiveFontSizesOptions {

export default function responsiveFontSizes(
theme: Theme,
options?: ResponsiveFontSizesOptions
options?: ResponsiveFontSizesOptions,
): Theme;
2 changes: 1 addition & 1 deletion packages/material-ui/src/styles/shadows.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export type Shadows = [
string,
string,
string,
string
string,
];
declare const shadows: Shadows;
export default shadows;
Loading

0 comments on commit e0e959a

Please sign in to comment.