Skip to content

Commit

Permalink
Eslint-plugin: Add method-signature-style TypeScript lint rule (WordP…
Browse files Browse the repository at this point in the history
…ress#62718)

This subtle different can influence the type system's behavior in dramatic and surprising ways.

See https://typescript-eslint.io/rules/method-signature-style for details.

---

Co-authored-by: sirreal <[email protected]>
Co-authored-by: youknowriad <[email protected]>
  • Loading branch information
3 people authored and carstingaxion committed Jul 18, 2024
1 parent e4a9ad1 commit b31ed50
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 10 deletions.
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
- `CustomSelectControlV2`: fix trigger button font size. ([#63131](https://github.com/WordPress/gutenberg/pull/63131))
- Extract `TimeInput` component from `TimePicker` ([#60613](https://github.com/WordPress/gutenberg/pull/60613)).
- `TimeInput`: Add `label` prop ([#63106](https://github.com/WordPress/gutenberg/pull/63106)).
- Method style type signatures have been changed to function style ([#62718](https://github.com/WordPress/gutenberg/pull/62718)).

## 28.2.0 (2024-06-26)

Expand Down
3 changes: 2 additions & 1 deletion packages/components/src/menu-items-choice/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ export type MenuItemsChoiceProps = {
* Callback function to be called with the selected choice when user
* selects a new choice.
*/
onSelect( value: string ): void;
onSelect: ( value: string ) => void;

/**
* Callback function to be called with a choice when user
* hovers over a new choice (will be empty on mouse leave).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ interface UseResizeLabelProps {
interface UseResizeLabelArgs {
axis?: Axis;
fadeTimeout: number;
onResize( data: { width: number | null; height: number | null } ): void;
onResize: ( data: { width: number | null; height: number | null } ) => void;
position: Position;
showPx: boolean;
}
Expand Down
4 changes: 4 additions & 0 deletions packages/compose/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Internal

- Method style type signatures have been changed to function style ([#62718](https://github.com/WordPress/gutenberg/pull/62718)).

## 7.2.0 (2024-06-26)

## 7.1.0 (2024-06-15)
Expand Down
4 changes: 2 additions & 2 deletions packages/compose/src/utils/debounce/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export interface DebouncedFunc< T extends ( ...args: any[] ) => any > {
/**
* Throw away any pending invocation of the debounced function.
*/
cancel(): void;
cancel: () => void;

/**
* If there is a pending invocation of the debounced function, invoke it immediately and return
Expand All @@ -68,7 +68,7 @@ export interface DebouncedFunc< T extends ( ...args: any[] ) => any > {
* Otherwise, return the value from the last invocation, or undefined if the debounced function
* was never invoked.
*/
flush(): ReturnType< T > | undefined;
flush: () => ReturnType< T > | undefined;
}

/**
Expand Down
8 changes: 4 additions & 4 deletions packages/compose/src/utils/observable-map/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export type ObservableMap< K, V > = {
get( name: K ): V | undefined;
set( name: K, value: V ): void;
delete( name: K ): void;
subscribe( name: K, listener: () => void ): () => void;
get: ( name: K ) => V | undefined;
set: ( name: K, value: V ) => void;
delete: ( name: K ) => void;
subscribe: ( name: K, listener: () => void ) => () => void;
};

/**
Expand Down
6 changes: 5 additions & 1 deletion packages/dataviews/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@

### New features

- Added a new `DataForm` component to render controls from a given configuration (fields, form), and data.
- Added a new `DataForm` component to render controls from a given configuration (fields, form), and data.

### Internal

- Method style type signatures have been changed to function style ([#62718](https://github.com/WordPress/gutenberg/pull/62718)).

## 2.2.0 (2024-06-26)

Expand Down
2 changes: 1 addition & 1 deletion packages/dataviews/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ export interface ViewBaseProps< Item > {
fields: NormalizedField< Item >[];
getItemId: ( item: Item ) => string;
isLoading?: boolean;
onChangeView( view: View ): void;
onChangeView: ( view: View ) => void;
onSelectionChange: SetSelection;
selection: string[];
setOpenedFilter: ( fieldId: string ) => void;
Expand Down
4 changes: 4 additions & 0 deletions packages/eslint-plugin/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Breaking Changes

- Add [`@typescript-eslint/method-signature-style` rule](https://typescript-eslint.io/rules/method-signature-style) to the recommended TypeScript ruleset ([#62718](https://github.com/WordPress/gutenberg/pull/62718)).

## 19.2.0 (2024-06-26)

## 19.1.0 (2024-06-15)
Expand Down
1 change: 1 addition & 0 deletions packages/eslint-plugin/configs/recommended.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ if ( isPackageInstalled( 'typescript' ) ) {
// no-shadow doesn't work correctly in TS, so let's use a TS-dedicated version instead.
'no-shadow': 'off',
'@typescript-eslint/no-shadow': 'error',
'@typescript-eslint/method-signature-style': 'error',
},
},
];
Expand Down

0 comments on commit b31ed50

Please sign in to comment.