Skip to content

Commit

Permalink
lint: enable reportUnusedDisableDirectives and remove unused suppress…
Browse files Browse the repository at this point in the history
…ions

This enables linting against unused suppressions and removes the ones that were unused.
  • Loading branch information
kassens committed Apr 2, 2024
1 parent 8cb6a1c commit 0086bf2
Show file tree
Hide file tree
Showing 56 changed files with 44 additions and 125 deletions.
2 changes: 2 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ module.exports = {
// Stop ESLint from looking for a configuration file in parent folders
root: true,

reportUnusedDisableDirectives: true,

plugins: [
'babel',
'ft-flow',
Expand Down
4 changes: 0 additions & 4 deletions packages/react-client/src/ReactFlightReplyClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ export function processReply(
const partJSON = JSON.stringify(resolvedModel, resolveToJSON);
// $FlowFixMe[incompatible-type] We know it's not null because we assigned it above.
const data: FormData = formData;
// eslint-disable-next-line react-internal/safe-string-coercion
data.append(formFieldPrefix + lazyId, partJSON);
return serializeByValueID(lazyId);
} catch (x) {
Expand All @@ -263,7 +262,6 @@ export function processReply(
const partJSON = JSON.stringify(value, resolveToJSON);
// $FlowFixMe[incompatible-type] We know it's not null because we assigned it above.
const data: FormData = formData;
// eslint-disable-next-line react-internal/safe-string-coercion
data.append(formFieldPrefix + lazyId, partJSON);
pendingParts--;
if (pendingParts === 0) {
Expand Down Expand Up @@ -304,7 +302,6 @@ export function processReply(
const partJSON = JSON.stringify(partValue, resolveToJSON);
// $FlowFixMe[incompatible-type] We know it's not null because we assigned it above.
const data: FormData = formData;
// eslint-disable-next-line react-internal/safe-string-coercion
data.append(formFieldPrefix + promiseId, partJSON);
pendingParts--;
if (pendingParts === 0) {
Expand Down Expand Up @@ -459,7 +456,6 @@ export function processReply(
}
// The reference to this function came from the same client so we can pass it back.
const refId = nextPartId++;
// eslint-disable-next-line react-internal/safe-string-coercion
formData.set(formFieldPrefix + refId, metaDataJSON);
return serializeServerReferenceID(refId);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const usedWithSSR = true;

export opaque type Source = mixed;

export opaque type StringDecoder = mixed; // eslint-disable-line no-undef
export opaque type StringDecoder = mixed;

export const createStringDecoder = $$$config.createStringDecoder;
export const readPartialStringChunk = $$$config.readPartialStringChunk;
Expand Down
5 changes: 0 additions & 5 deletions packages/react-devtools-extensions/flow-typed/jest.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,11 @@ type JestPromiseType = {
* Use rejects to unwrap the reason of a rejected promise so any other
* matcher can be chained. If the promise is fulfilled the assertion fails.
*/
// eslint-disable-next-line no-use-before-define
rejects: JestExpectType,
/**
* Use resolves to unwrap the value of a fulfilled promise so any other
* matcher can be chained. If the promise is rejected the assertion fails.
*/
// eslint-disable-next-line no-use-before-define
resolves: JestExpectType,
};

Expand Down Expand Up @@ -1098,10 +1096,8 @@ type JestPrettyFormatColors = {
};

type JestPrettyFormatIndent = string => string;
// eslint-disable-next-line no-unused-vars
type JestPrettyFormatRefs = Array<any>;
type JestPrettyFormatPrint = any => string;
// eslint-disable-next-line no-unused-vars
type JestPrettyFormatStringOrNull = string | null;

type JestPrettyFormatOptions = {
Expand All @@ -1112,7 +1108,6 @@ type JestPrettyFormatOptions = {
indent: number,
maxDepth: number,
min: boolean,
// eslint-disable-next-line no-use-before-define
plugins: JestPrettyFormatPlugins,
printFunctionName: boolean,
spacing: string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ type TestRendererOptions = {
};

declare module 'react-test-renderer' {
// eslint-disable-next-line no-inner-declarations
declare export type ReactTestRenderer = {
toJSON(): null | ReactTestRendererJSON,
toTree(): null | ReactTestRendererTree,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,6 @@ describe('InspectedElement', () => {
anonymous_fn={instance.anonymousFunction}
array_buffer={arrayBuffer}
array_of_arrays={arrayOfArrays}
// eslint-disable-next-line no-undef
big_int={BigInt(123)}
bound_fn={exampleFunction.bind(this)}
data_view={dataView}
Expand Down Expand Up @@ -1874,7 +1873,7 @@ describe('InspectedElement', () => {
xyz: 1,
},
});
const bigInt = BigInt(123); // eslint-disable-line no-undef
const bigInt = BigInt(123);

await utils.actAsync(() =>
render(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ describe('InspectedElementContext', () => {
anonymous_fn={instance.anonymousFunction}
array_buffer={arrayBuffer}
array_of_arrays={arrayOfArrays}
// eslint-disable-next-line no-undef
big_int={BigInt(123)}
bound_fn={exampleFunction.bind(this)}
data_view={dataView}
Expand Down Expand Up @@ -868,7 +867,7 @@ describe('InspectedElementContext', () => {
xyz: 1,
},
});
const bigInt = BigInt(123); // eslint-disable-line no-undef
const bigInt = BigInt(123);

act(() =>
ReactDOM.render(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ disabledLog.__reactDisabledLog = true;

export function disableLogs(): void {
if (disabledDepth === 0) {
/* eslint-disable react-internal/no-production-logging */
prevLog = console.log;
prevInfo = console.info;
prevWarn = console.warn;
Expand Down Expand Up @@ -63,7 +62,6 @@ export function disableLogs(): void {
export function reenableLogs(): void {
disabledDepth--;
if (disabledDepth === 0) {
/* eslint-disable react-internal/no-production-logging */
const props = {
configurable: true,
enumerable: true,
Expand Down
1 change: 0 additions & 1 deletion packages/react-devtools-shared/src/backend/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1545,7 +1545,6 @@ export function attach(
return changedKeys;
}

// eslint-disable-next-line no-unused-vars
function didFiberRender(prevFiber: Fiber, nextFiber: Fiber): boolean {
switch (nextFiber.tag) {
case ClassComponent:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const immutable = Immutable.fromJS({
xyz: 1,
},
});
const bigInt = BigInt(123); // eslint-disable-line no-undef
const bigInt = BigInt(123);

class Foo {
flag = false;
Expand Down
2 changes: 1 addition & 1 deletion packages/react-devtools/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ app.on('ready', function () {
});

// and load the index.html of the app.
mainWindow.loadURL('file://' + __dirname + '/app.html'); // eslint-disable-line no-path-concat
mainWindow.loadURL('file://' + __dirname + '/app.html');
// $FlowFixMe[incompatible-use] found when upgrading Flow
mainWindow.webContents.executeJavaScript(
// We use this so that RN can keep relative JSX __source filenames
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export function getValueForAttribute(
// shouldRemoveAttribute
switch (typeof expected) {
case 'function':
case 'symbol': // eslint-disable-line
case 'symbol':
return expected;
case 'boolean': {
const prefix = name.toLowerCase().slice(0, 5);
Expand Down Expand Up @@ -109,7 +109,7 @@ export function setValueForAttribute(
switch (typeof value) {
case 'undefined':
case 'function':
case 'symbol': // eslint-disable-line
case 'symbol':
node.removeAttribute(name);
return;
case 'boolean': {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ export function createInstance(
didWarnScriptTags = true;
}
}
div.innerHTML = '<script><' + '/script>'; // eslint-disable-line
div.innerHTML = '<script><' + '/script>';
// This is guaranteed to yield a script element.
const firstChild = ((div.firstChild: any): HTMLScriptElement);
domElement = div.removeChild(firstChild);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,6 @@ function validateTextNesting(childText: string, parentTag: string): boolean {
return true;
}

// eslint-disable-next-line react-internal/safe-string-coercion
const warnKey = '#text|' + parentTag;
if (didWarn[warnKey]) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1452,7 +1452,7 @@ function pushAttribute(
// shouldRemoveAttribute
switch (typeof value) {
case 'function':
case 'symbol': // eslint-disable-line
case 'symbol':
return;
case 'boolean': {
const prefix = attributeName.toLowerCase().slice(0, 5);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ function validateProperty(tagName, name, value, eventRegistry) {
}
}
case 'function':
case 'symbol': // eslint-disable-line
case 'symbol':
// Warn when a known attribute is a bad type
warnedProperties[name] = true;
return false;
Expand Down
2 changes: 0 additions & 2 deletions packages/react-dom-bindings/src/shared/isAttributeNameSafe.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@

import hasOwnProperty from 'shared/hasOwnProperty';

/* eslint-disable max-len */
const ATTRIBUTE_NAME_START_CHAR =
':A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD';
/* eslint-enable max-len */
export const ATTRIBUTE_NAME_CHAR: string =
ATTRIBUTE_NAME_START_CHAR + '\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040';

Expand Down
1 change: 0 additions & 1 deletion packages/react-dom-bindings/src/shared/sanitizeURL.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
// INFORMATION SEPARATOR ONE, inclusive:
// https://infra.spec.whatwg.org/#c0-control-or-space

/* eslint-disable max-len */
const isJavaScriptProtocol =
/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*\:/i;

Expand Down
2 changes: 0 additions & 2 deletions packages/react-dom/src/__tests__/ReactComponent-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,6 @@ describe('ReactComponent', () => {
root.unmount();
});

/* eslint-disable indent */
expect(log).toEqual([
'start mount',
'inner 1 render',
Expand Down Expand Up @@ -453,7 +452,6 @@ describe('ReactComponent', () => {
'ref 2 got null',
'inner 2 componentWillUnmount',
]);
/* eslint-enable indent */
});

// @gate !disableLegacyMode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1505,7 +1505,6 @@ describe('ReactComponentLifeCycle', () => {
});
}).toWarnDev(
[
/* eslint-disable max-len */
`Warning: componentWillMount has been renamed, and is not recommended for use. See https://react.dev/link/unsafe-component-lifecycles for details.
* Move code with side effects to componentDidMount, and set initial state in the constructor.
Expand All @@ -1525,7 +1524,6 @@ Please update the following components: MyComponent`,
* Rename componentWillUpdate to UNSAFE_componentWillUpdate to suppress this warning in non-strict mode. In React 18.x, only the UNSAFE_ name will work. To rename all deprecated lifecycles to their new names, you can run \`npx react-codemod rename-unsafe-lifecycles\` in your project source folder.
Please update the following components: MyComponent`,
/* eslint-enable max-len */
],
{withoutStack: true},
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ describe('ReactDOMServerIntegration', () => {
'a div with a single child surrounded by whitespace',
async render => {
// prettier-ignore
const e = await render(<div id="parent"> <div id="child" /> </div>); // eslint-disable-line no-multi-spaces
const e = await render(<div id="parent"> <div id="child" /> </div>);
expect(e.childNodes.length).toBe(3);
const textNode1 = e.childNodes[0];
const child = e.childNodes[1];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,13 +310,13 @@ describe('ReactDOMServerIntegration', () => {
<div id="child2" />
</div>,
// prettier-ignore
<div id="parent"><div id="child1" /> <div id="child2" /></div>, // eslint-disable-line no-multi-spaces
<div id="parent"><div id="child1" /> <div id="child2" /></div>,
));

it('should error reconnecting a div with children separated by different whitespace on the server', () =>
expectMarkupMismatch(
// prettier-ignore
<div id="parent"><div id="child1" /> <div id="child2" /></div>, // eslint-disable-line no-multi-spaces
<div id="parent"><div id="child1" /> <div id="child2" /></div>,
<div id="parent">
<div id="child1" />
<div id="child2" />
Expand All @@ -329,7 +329,7 @@ describe('ReactDOMServerIntegration', () => {
<div id="child1" /> <div id="child2" />
</div>,
// prettier-ignore
<div id="parent"><div id="child1" /> <div id="child2" /></div>, // eslint-disable-line no-multi-spaces
<div id="parent"><div id="child1" /> <div id="child2" /></div>,
));

it('can distinguish an empty component from a dom node', () =>
Expand Down
2 changes: 0 additions & 2 deletions packages/react-dom/src/__tests__/ReactLegacyUpdates-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,6 @@ describe('ReactLegacyUpdates', () => {
});
});

/* eslint-disable indent */
expect(updates).toEqual([
'Outer-render-0',
'Inner-render-0-0',
Expand Down Expand Up @@ -680,7 +679,6 @@ describe('ReactLegacyUpdates', () => {
'Inner-didUpdate-2-2',
'Inner-callback-2',
]);
/* eslint-enable indent */
});

// @gate !disableLegacyMode
Expand Down
2 changes: 0 additions & 2 deletions packages/react-dom/src/__tests__/ReactUpdates-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,6 @@ describe('ReactUpdates', () => {
});
});

/* eslint-disable indent */
expect(updates).toEqual([
'Outer-render-0',
'Inner-render-0-0',
Expand Down Expand Up @@ -788,7 +787,6 @@ describe('ReactUpdates', () => {
'Inner-didUpdate-2-2',
'Inner-callback-2',
]);
/* eslint-enable indent */
});

it('should flush updates in the correct order across roots', async () => {
Expand Down
2 changes: 0 additions & 2 deletions packages/react-dom/src/client/ReactDOM.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,7 @@ function hydrateRoot(
// Overload the definition to the two valid signatures.
// Warning, this opts-out of checking the function body.
declare function flushSync<R>(fn: () => R): R;
// eslint-disable-next-line no-redeclare
declare function flushSync(): void;
// eslint-disable-next-line no-redeclare
function flushSync<R>(fn: (() => R) | void): R | void {
if (__DEV__) {
if (isAlreadyRendering()) {
Expand Down
1 change: 0 additions & 1 deletion packages/react-native-renderer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import type {ReactNativeType} from './src/ReactNativeTypes';
import * as ReactNative from './src/ReactNativeRenderer';
// Assert that the exports line up with the type we're going to expose.
// eslint-disable-next-line ft-flow/no-unused-expressions
(ReactNative: ReactNativeType);

export * from './src/ReactNativeRenderer';
1 change: 0 additions & 1 deletion packages/react-noop-renderer/src/createReactNoop.js
Original file line number Diff line number Diff line change
Expand Up @@ -919,7 +919,6 @@ function createReactNoop(reconciler: Function, useMutation: boolean) {

function onRecoverableError(error) {
// TODO: Turn this on once tests are fixed
// eslint-disable-next-line react-internal/no-production-logging, react-internal/warning-args
// console.error(error);
}

Expand Down
4 changes: 2 additions & 2 deletions packages/react-reconciler/src/ReactFiber.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,10 @@ if (__DEV__) {
hasBadMapPolyfill = false;
try {
const nonExtensibleObject = Object.preventExtensions({});
/* eslint-disable no-new */
// eslint-disable-next-line no-new
new Map([[nonExtensibleObject, null]]);
// eslint-disable-next-line no-new
new Set([nonExtensibleObject]);
/* eslint-enable no-new */
} catch (e) {
// TODO: Consider warning about bad polyfills
hasBadMapPolyfill = true;
Expand Down
2 changes: 1 addition & 1 deletion packages/react-reconciler/src/ReactFiberClassComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ function constructClassInstance(
) {
setIsStrictModeForDevtools(true);
try {
instance = new ctor(props, context); // eslint-disable-line no-new
instance = new ctor(props, context);
} finally {
setIsStrictModeForDevtools(false);
}
Expand Down
1 change: 0 additions & 1 deletion packages/react-reconciler/src/ReactFiberCompleteWork.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,6 @@ function appendAllChildrenToContainer(
// children to find all the terminal nodes.
let node = workInProgress.child;
while (node !== null) {
// eslint-disable-next-line no-labels
if (node.tag === HostComponent) {
let instance = node.stateNode;
if (needsVisibilityToggle && isHidden) {
Expand Down
Loading

0 comments on commit 0086bf2

Please sign in to comment.