Fix most lint warnings

Summary:
I noticed that after the typescript upgrade, I got several weird positives from ESLint (like unused parameters in a type definition, which are obviously always unused, e.g. `type onClick = (e: Event) => void`). After some investigation, it turned out these warnings are generated by eslint, but that those rules should be performaned by typescript/eslint instead. For future reference to which rules this applies:

https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/README.md#extension-rules

Updated the config, and while at it, fixed all warnings in our codebase, except for `react-hooks/exhaustive-deps` warnings, since those require semantic changes.

This reduces the amount of eslint warnings from 86 to 39.

Reviewed By: passy

Differential Revision: D23905630

fbshipit-source-id: 0557708fd9ec6b17840a3c191e7d3baf225bdf23
This commit is contained in:
Michel Weststrate
2020-09-28 01:40:50 -07:00
committed by Facebook GitHub Bot
parent aaabe1cc82
commit ecf4cff7cf
26 changed files with 166 additions and 87 deletions

View File

@@ -63,7 +63,7 @@ import {useLocalStorage} from '../../utils/useLocalStorage';
import {PluginDefinition, ClientPluginMap, DevicePluginMap} from '../../plugin';
type FlipperPlugins = PluginDefinition[];
type PluginsByCategory = [string, FlipperPlugins][];
type PluginsByCategoryType = [string, FlipperPlugins][];
type SectionLevel = 1 | 2 | 3;
@@ -398,10 +398,12 @@ function isStaticViewActive(
return current && selected && current === selected;
}
function groupPluginsByCategory(plugins: FlipperPlugins): PluginsByCategory {
function groupPluginsByCategory(
plugins: FlipperPlugins,
): PluginsByCategoryType {
const sortedPlugins = plugins.slice().sort(sortPluginsByName);
const byCategory: {[cat: string]: FlipperPlugins} = {};
const res: PluginsByCategory = [];
const res: PluginsByCategoryType = [];
sortedPlugins.forEach((plugin) => {
const category = plugin.category || '';
(byCategory[category] || (byCategory[category] = [])).push(plugin);
@@ -477,7 +479,7 @@ const PluginList = memo(function PluginList({
selectedApp?: null | string;
}) {
// client is a mutable structure, so we need the event emitter to detect the addition of plugins....
const [_, setPluginsChanged] = useState(0);
const [, setPluginsChanged] = useState(0);
useEffect(() => {
const listener = () => setPluginsChanged((v) => v + 1);
client.on('plugins-change', listener);
@@ -493,7 +495,7 @@ const PluginList = memo(function PluginList({
plugin,
});
},
[client],
[client, starPlugin],
);
const allPlugins = Array.from(clientPlugins.values()).filter(

View File

@@ -227,7 +227,7 @@ class StripLogPrefix extends Transform {
_transform(
data: any,
encoding: string,
_encoding: string,
callback: (err?: Error, data?: any) => void,
) {
if (this.passedPrefix) {

View File

@@ -17,10 +17,6 @@ import {
TestUtils,
} from 'flipper-plugin';
interface PersistedState {
count: 1;
}
const pluginDetails = TestUtils.createMockPluginDetails();
let initialized = false;

View File

@@ -18,10 +18,6 @@ import {
TestUtils,
} from 'flipper-plugin';
interface PersistedState {
count: 1;
}
const pluginDetails = TestUtils.createMockPluginDetails();
let initialized = false;

View File

@@ -358,7 +358,7 @@ class Server extends EventEmitter {
};
_untrustedRequestHandler = (
socket: ReactiveSocket<string, any>,
_socket: ReactiveSocket<string, any>,
payload: Payload<string, any>,
): Partial<Responder<string, any>> => {
if (!payload.data) {

View File

@@ -35,7 +35,7 @@ function createHighlightManager(initialText: string = ''): HighlightManager {
let currentFilter = initialText;
const Highlight: React.FC<{text: string}> = memo(({text}) => {
const [_update, setUpdate] = useState(0);
const [, setUpdate] = useState(0);
const elem = useRef<HTMLSpanElement | null>(null);
useEffect(() => {
function onChange(prevHighlight: string, newHighlight: string) {

View File

@@ -120,21 +120,12 @@ const TooltipTail = styled.div<{
}));
TooltipTail.displayName = 'TooltipProvider:TooltipTail';
type TooltipProps = {
children: React.ReactNode;
};
type TooltipObject = {
rect: ClientRect;
title: React.ReactNode;
options: TooltipOptions;
};
type TooltipState = {
tooltip: TooltipObject | null | undefined;
timeoutID: ReturnType<typeof setTimeout> | null | undefined;
};
interface TooltipManager {
open(
container: HTMLDivElement,

View File

@@ -539,8 +539,6 @@ function parseColor(
return {a, b, g, r};
}
const pencilStyle = {cursor: 'pointer', marginLeft: 8};
type Picker = {
values: Set<string>;
selected: string;

View File

@@ -314,14 +314,6 @@ function isComponentExpanded(data: any, diffType: string, diffValue: any) {
return false;
}
type DataInspectorState = {
shouldExpand: boolean;
isExpanded: boolean;
isExpandable: boolean;
res: any;
resDiff: any;
};
const recursiveMarker = <RecursiveBaseWrapper>Recursive</RecursiveBaseWrapper>;
/**

View File

@@ -8,13 +8,7 @@
*/
import * as React from 'react';
import {
render,
fireEvent,
waitFor,
act,
waitForElement,
} from '@testing-library/react';
import {render, fireEvent, waitFor, act} from '@testing-library/react';
import ManagedDataInspector from '../ManagedDataInspector';
import {sleep} from '../../../../utils';

View File

@@ -94,10 +94,6 @@ type ProcessNotificationStatesOptions = {
statusUpdate?: (msg: string) => void;
};
type SerializePluginStatesOptions = {
pluginStates: PluginStatesState;
};
type PluginsToProcess = {
pluginKey: string;
pluginId: string;

View File

@@ -15,7 +15,6 @@ import {killOrphanedInstrumentsProcesses} from './processCleanup';
import {reportPlatformFailures} from './metrics';
import {promises, constants} from 'fs';
import memoize from 'lodash.memoize';
import GK from '../fb-stubs/GK';
import {notNull} from './typeUtils';
// Use debug to get helpful logs when idb fails

View File

@@ -27,7 +27,7 @@ export function deserialize(str: string): any {
}
function processArray(
element: any,
_element: any,
array: Array<any>,
stack: Array<any>,
dict: Map<any, any>,
@@ -50,7 +50,7 @@ function processArray(
}
function processKeyValuePair(
element: any,
_element: any,
key: any,
value: any,
stack: Array<any>,

View File

@@ -112,7 +112,7 @@ export function maybeSnapLeft(
}
export function maybeSnapTop(
props: Rect,
_props: Rect,
windows: Array<Rect>,
top: number,
): number {