Skip to content

Commit 6c4630f

Browse files
authored
feat: enable JSX types enforcement and explicit return types lint rules to v8 react config, sync flat configs and resolve all v8 lint errors (#35303)
1 parent 10d0f1e commit 6c4630f

File tree

222 files changed

+987
-650
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

222 files changed

+987
-650
lines changed

apps/perf-test/.eslintrc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"root": true,
44
"rules": {
55
"no-console": "off",
6-
"no-restricted-globals": "off"
6+
"no-restricted-globals": "off",
7+
"@typescript-eslint/explicit-module-boundary-types": "off"
78
}
89
}

apps/perf-test/src/scenarios/OverflowSet.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ import { OverflowSet, IOverflowSetItemProps } from '@fluentui/react';
33

44
const noOp = () => undefined;
55

6-
const onRenderItem = (item: IOverflowSetItemProps): React.JSX.Element => {
6+
const onRenderItem = (item: IOverflowSetItemProps): React.ReactElement => {
77
return <div>{item.name}</div>;
88
};
99

1010
// eslint-disable-next-line @typescript-eslint/no-explicit-any
11-
const onRenderOverflowButton = (overflowItems: any[] | undefined): React.JSX.Element => {
11+
const onRenderOverflowButton = (overflowItems: any[] | undefined): React.ReactElement => {
1212
return <button> ... </button>;
1313
};
1414

apps/public-docsite-resources/.eslintrc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"@typescript-eslint/explicit-member-accessibility": "off",
77
"@typescript-eslint/member-ordering": "off",
88
"no-restricted-globals": "off",
9-
"@typescript-eslint/no-deprecated": "off"
9+
"@typescript-eslint/no-deprecated": "off",
10+
"@typescript-eslint/explicit-module-boundary-types": "off"
1011
}
1112
}

apps/public-docsite-resources/src/components/pages/ColorsPage.tsx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export class ColorsPage extends React.Component<{}, IColorsPageState> {
6363
ThemeGenerator.insureSlots(themeRules, isDark(themeRules[BaseSlots[BaseSlots.backgroundColor]].color!));
6464

6565
this.state = {
66-
themeRules: themeRules,
66+
themeRules,
6767
colorPickerSlotRule: null,
6868
colorPickerElement: null,
6969
colorPickerVisible: false,
@@ -86,7 +86,7 @@ export class ColorsPage extends React.Component<{}, IColorsPageState> {
8686
this._async.dispose();
8787
}
8888

89-
public render(): JSX.Element {
89+
public render(): React.ReactElement {
9090
const { colorPickerVisible, colorPickerSlotRule, colorPickerElement } = this.state;
9191

9292
const fabricThemeSlots = [
@@ -270,7 +270,7 @@ export class ColorsPage extends React.Component<{}, IColorsPageState> {
270270
true,
271271
true,
272272
);
273-
this.setState({ themeRules: themeRules }, this._makeNewTheme);
273+
this.setState({ themeRules }, this._makeNewTheme);
274274
}, 20);
275275
// 20ms is low enough that you can slowly drag to change color and see that theme,
276276
// but high enough that quick changes don't get bogged down by a million changes inbetween
@@ -298,7 +298,7 @@ export class ColorsPage extends React.Component<{}, IColorsPageState> {
298298
}
299299
};
300300

301-
private _slotWidget = (slotRule: IThemeSlotRule): JSX.Element => {
301+
private _slotWidget = (slotRule: IThemeSlotRule): React.ReactElement => {
302302
return (
303303
<div key={slotRule.name} className="ms-themer-slot">
304304
{this._colorSquareSwatchWidget(slotRule)}
@@ -310,11 +310,11 @@ export class ColorsPage extends React.Component<{}, IColorsPageState> {
310310
);
311311
};
312312

313-
private _fabricSlotWidget = (fabricSlot: FabricSlots): JSX.Element => {
313+
private _fabricSlotWidget = (fabricSlot: FabricSlots): React.ReactElement => {
314314
return this._slotWidget(this.state.themeRules[FabricSlots[fabricSlot]]);
315315
};
316316

317-
private _colorSquareSwatchWidget(slotRule: IThemeSlotRule): JSX.Element {
317+
private _colorSquareSwatchWidget(slotRule: IThemeSlotRule): React.ReactElement {
318318
return (
319319
<div
320320
key={slotRule.name}
@@ -325,7 +325,7 @@ export class ColorsPage extends React.Component<{}, IColorsPageState> {
325325
);
326326
}
327327

328-
private _accessibilityRow = (foreground: FabricSlots, background: FabricSlots): JSX.Element => {
328+
private _accessibilityRow = (foreground: FabricSlots, background: FabricSlots): React.ReactElement => {
329329
const themeRules = this.state.themeRules;
330330
const bgc: IColor = themeRules[FabricSlots[background]].color!;
331331
const fgc: IColor = themeRules[FabricSlots[foreground]].color!;
@@ -346,8 +346,8 @@ export class ColorsPage extends React.Component<{}, IColorsPageState> {
346346
);
347347
};
348348

349-
private _accessibilityTableBody = (): JSX.Element => {
350-
const accessibilityRows: JSX.Element[] = [
349+
private _accessibilityTableBody = (): React.ReactElement => {
350+
const accessibilityRows: React.ReactElement[] = [
351351
this._accessibilityRow(FabricSlots.neutralPrimary, FabricSlots.white), // default
352352
// primary color also needs to be accessible, this is also strong variant default
353353
this._accessibilityRow(FabricSlots.white, FabricSlots.themePrimary),
@@ -375,7 +375,7 @@ export class ColorsPage extends React.Component<{}, IColorsPageState> {
375375
return <tbody>{accessibilityRows}</tbody>;
376376
};
377377

378-
private _outputSection = (): JSX.Element => {
378+
private _outputSection = (): React.ReactElement => {
379379
const themeRules = this.state.themeRules;
380380

381381
// strip out the unnecessary shade slots from the final output theme
@@ -453,7 +453,7 @@ export class ColorsPage extends React.Component<{}, IColorsPageState> {
453453
console.log('New theme:', finalTheme);
454454
};
455455

456-
private _baseColorSlotPicker = (baseSlot: BaseSlots, title: string): JSX.Element => {
456+
private _baseColorSlotPicker = (baseSlot: BaseSlots, title: string): React.ReactElement => {
457457
let colorChangeTimeout: number;
458458

459459
const onChange = (ev: React.MouseEvent<HTMLElement>, newColor: IColor): void => {
@@ -468,7 +468,7 @@ export class ColorsPage extends React.Component<{}, IColorsPageState> {
468468
// isInverted got swapped, so need to refresh slots with new shading rules
469469
ThemeGenerator.insureSlots(themeRules, !currentIsDark);
470470
}
471-
this.setState({ themeRules: themeRules }, this._makeNewTheme);
471+
this.setState({ themeRules }, this._makeNewTheme);
472472
}, 20);
473473
// 20ms is low enough that you can slowly drag to change color and see that theme,
474474
// but high enough that quick changes don't get bogged down by a million changes inbetween

apps/public-docsite-resources/src/components/pages/ThemePage.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export class ThemePage extends React.Component<IThemePageProps, IThemePageState>
6363
};
6464
}
6565

66-
public render(): JSX.Element {
66+
public render(): React.ReactElement {
6767
// Don't mutate state to display lists
6868
const palette = [...this.state.palette];
6969
const semanticColors = [...this.state.semanticColors];
@@ -152,7 +152,7 @@ export class ThemePage extends React.Component<IThemePageProps, IThemePageState>
152152
colorPickerProps: {
153153
targetElement: (ev.currentTarget as HTMLElement).children[0] as HTMLElement,
154154
value: item.value,
155-
index: index,
155+
index,
156156
},
157157
activeList: list,
158158
});

apps/public-docsite/.eslintrc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"prefer-const": "off",
88
"react/jsx-no-bind": "off",
99
"no-restricted-globals": "off",
10-
"@typescript-eslint/no-deprecated": "off"
10+
"@typescript-eslint/no-deprecated": "off",
11+
"@typescript-eslint/explicit-module-boundary-types": "off"
1112
}
1213
}

apps/public-docsite/src/components/IconGrid/IconGrid.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export class IconGrid extends React.Component<IIconGridProps, IIconGridState> {
9696
}
9797
}
9898

99-
public render(): JSX.Element {
99+
public render(): React.ReactElement {
100100
const areIconsLoaded = !!this.state.resolvedIcons;
101101
const icons = this._getItems();
102102

@@ -132,8 +132,8 @@ export class IconGrid extends React.Component<IIconGridProps, IIconGridState> {
132132
return resolvedIcons.filter(icon => icon.name.toLowerCase().indexOf(searchQuery.toLowerCase()) !== -1);
133133
};
134134

135-
private _renderIcon = (icon: IIconDefinition, index?: number): JSX.Element => {
136-
let renderedIcon: JSX.Element;
135+
private _renderIcon = (icon: IIconDefinition, index?: number): React.ReactElement => {
136+
let renderedIcon: React.ReactElement;
137137
switch (icon.iconType) {
138138
case 'core-font':
139139
let iconClassName = `ms-Icon ms-Icon--${icon.name}`;

apps/public-docsite/src/components/Nav/Nav.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export class Nav extends React.Component<INavProps, INavState> {
7979
}
8080
}
8181

82-
public render(): JSX.Element | null {
82+
public render(): React.ReactElement | null {
8383
const { pages, searchablePageTitle } = this.props;
8484
const { sortState } = this.state;
8585
if (!pages) {
@@ -100,7 +100,7 @@ export class Nav extends React.Component<INavProps, INavState> {
100100
);
101101
}
102102

103-
private _renderLinkList = (pages: INavPage[], isSubMenu: boolean): JSX.Element => {
103+
private _renderLinkList = (pages: INavPage[], isSubMenu: boolean): React.ReactElement => {
104104
const { searchablePageTitle } = this.props;
105105
const { sortState } = this.state;
106106

@@ -127,7 +127,7 @@ export class Nav extends React.Component<INavProps, INavState> {
127127
);
128128
};
129129

130-
private _renderLink = (page: INavPage, linkIndex: number): JSX.Element => {
130+
private _renderLink = (page: INavPage, linkIndex: number): React.ReactElement => {
131131
const searchQuery = this.state.searchQuery.toLowerCase();
132132
const childLinks = page.pages ? this._renderLinkList(page.pages, true) : null;
133133
const text = page.title;

apps/public-docsite/src/components/Site/Site.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -246,12 +246,12 @@ export class Site<TPlatforms extends string = string> extends React.Component<
246246
};
247247
}
248248

249-
private _renderMessageBar(): JSX.Element | null {
249+
private _renderMessageBar(): React.ReactElement | null {
250250
const { pagePath } = this.state;
251251
const { siteDefinition } = this.props;
252252
const { messageBars } = siteDefinition;
253253

254-
let _messageBar: JSX.Element | null = null;
254+
let _messageBar: React.ReactElement | null = null;
255255

256256
if (messageBars && pagePath) {
257257
for (const messageBar of messageBars) {
@@ -277,7 +277,7 @@ export class Site<TPlatforms extends string = string> extends React.Component<
277277
return _messageBar;
278278
}
279279

280-
private _renderPageNav(): JSX.Element | null {
280+
private _renderPageNav(): React.ReactElement | null {
281281
const { activePages, searchablePageTitle, isContentFullBleed } = this.state;
282282

283283
if (!isContentFullBleed && activePages) {
@@ -315,7 +315,7 @@ export class Site<TPlatforms extends string = string> extends React.Component<
315315
return 'default' as TPlatforms;
316316
};
317317

318-
private _renderTopNav = (): JSX.Element | undefined => {
318+
private _renderTopNav = (): React.ReactElement | undefined => {
319319
const { platform } = this.state;
320320
const { siteDefinition, hasUHF } = this.props;
321321

@@ -333,11 +333,11 @@ export class Site<TPlatforms extends string = string> extends React.Component<
333333
}
334334
};
335335

336-
private _renderTopBanner = (): JSX.Element | undefined => {
336+
private _renderTopBanner = (): React.ReactElement | undefined => {
337337
return <TopBanner cdnUrl={cdnUrl} />;
338338
};
339339

340-
private _renderPlatformPicker = (): JSX.Element | null => {
340+
private _renderPlatformPicker = (): React.ReactElement | null => {
341341
const { siteDefinition } = this.props;
342342
const { hasPlatformPicker, platform, pagePlatforms } = this.state;
343343

@@ -354,7 +354,7 @@ export class Site<TPlatforms extends string = string> extends React.Component<
354354
return null;
355355
};
356356

357-
private _renderPlatformBar = (): JSX.Element | null => {
357+
private _renderPlatformBar = (): React.ReactElement | null => {
358358
const { siteDefinition } = this.props;
359359
const { platform, pagePlatforms, hasPlatformPicker } = this.state;
360360

apps/public-docsite/src/components/Table/Table.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export class Table extends React.Component<ITableProps, ITableState> {
4141
window.removeEventListener('resize', this._handleResize);
4242
}
4343

44-
public render(): JSX.Element {
44+
public render(): React.ReactElement {
4545
let { content } = this.props;
4646
return this.state.currentBreakpoint === 'mobile' && this.props.responsive
4747
? this._renderMobile(content)
@@ -52,7 +52,7 @@ export class Table extends React.Component<ITableProps, ITableState> {
5252
* Render Table cell. Cell content is either cell's value property, or cell's html property
5353
* (if value is an empty string).
5454
*/
55-
private _renderCell(cell: ITableCell, index: number): JSX.Element {
55+
private _renderCell(cell: ITableCell, index: number): React.ReactElement {
5656
return cell.value.length ? (
5757
<td className={cell.className} key={index}>
5858
{cell.value}
@@ -63,7 +63,7 @@ export class Table extends React.Component<ITableProps, ITableState> {
6363
);
6464
}
6565

66-
private _renderDesktop(content: ITableContent): JSX.Element {
66+
private _renderDesktop(content: ITableContent): React.ReactElement {
6767
return (
6868
<table className={styles.table}>
6969
<thead>
@@ -82,7 +82,7 @@ export class Table extends React.Component<ITableProps, ITableState> {
8282
);
8383
}
8484

85-
private _renderMobile(content: ITableContent): JSX.Element {
85+
private _renderMobile(content: ITableContent): React.ReactElement {
8686
const headers = this.props.content.headers;
8787
return (
8888
<div>

0 commit comments

Comments
 (0)