From b565373afd0cc1988497e1107106e851e8cfb261 Mon Sep 17 00:00:00 2001 From: Jan Kassens Date: Fri, 21 Jun 2024 12:24:32 -0400 Subject: [PATCH] lint: enable reportUnusedDisableDirectives and remove unused suppressions (#28721) This enables linting against unused suppressions and removes the ones that were unused. --- .eslintrc.js | 2 ++ .../react-client/src/ReactFlightClient.js | 2 -- .../src/ReactFlightReplyClient.js | 11 ------ .../forks/ReactFlightClientConfig.custom.js | 2 +- .../flow-typed/jest.js | 5 --- .../npm/react-test-renderer_v16.x.x.js | 1 - .../__tests__/__e2e__/utils.js | 1 - .../src/__tests__/inspectedElement-test.js | 3 +- .../__tests__/legacy/inspectElement-test.js | 3 +- .../src/backend/DevToolsConsolePatching.js | 2 -- .../src/backend/renderer.js | 1 - .../UnserializableProps.js | 2 +- packages/react-devtools/app.js | 2 +- .../src/client/DOMPropertyOperations.js | 4 +-- .../src/client/ReactFiberConfigDOM.js | 2 +- .../src/client/validateDOMNesting.js | 1 - .../src/server/ReactFizzConfigDOM.js | 4 +-- .../src/shared/ReactDOMUnknownPropertyHook.js | 2 +- .../src/shared/isAttributeNameSafe.js | 2 -- .../src/shared/sanitizeURL.js | 1 - .../src/__tests__/ReactComponent-test.js | 2 -- .../__tests__/ReactComponentLifeCycle-test.js | 2 -- .../ReactDOMServerIntegrationElements-test.js | 2 +- ...ctDOMServerIntegrationReconnecting-test.js | 6 ++-- .../src/__tests__/ReactLegacyUpdates-test.js | 2 -- .../src/__tests__/ReactUpdates-test.js | 2 -- .../react-dom/src/client/ReactDOMClientFB.js | 2 -- packages/react-native-renderer/index.js | 1 - .../src/createReactNoop.js | 1 - packages/react-reconciler/src/ReactFiber.js | 4 +-- .../src/ReactFiberClassComponent.js | 2 +- .../src/ReactFiberWorkLoop.js | 3 -- .../src/__tests__/ReactEffectOrdering-test.js | 2 -- .../src/__tests__/ReactHooks-test.internal.js | 10 ------ .../src/__tests__/useEffectEvent-test.js | 2 -- .../src/__tests__/useRef-test.internal.js | 2 -- .../src/forks/ReactFiberConfig.custom.js | 34 +++++++++---------- .../src/__tests__/ReactFresh-test.js | 2 -- .../__tests__/ReactFreshIntegration-test.js | 2 -- .../src/ReactFlightDOMServerNode.js | 1 - .../src/ReactFlightDOMServerNode.js | 1 - .../src/ReactFlightTurbopackNodeRegister.js | 1 - .../src/ReactFlightDOMServerNode.js | 1 - .../src/ReactFlightWebpackNodeRegister.js | 1 - .../ReactFlightServerTemporaryReferences.js | 1 - .../src/forks/ReactFizzConfig.custom.js | 2 +- .../forks/ReactServerStreamConfig.custom.js | 8 ++--- .../src/ReactTestRenderer.js | 3 -- .../ReactTestRenderer-test.internal.js | 1 - .../src/__tests__/ReactStrictMode-test.js | 6 ---- .../npm/umd/scheduler.development.js | 2 -- .../npm/umd/scheduler.production.min.js | 2 -- .../npm/umd/scheduler.profiling.min.js | 2 -- .../scheduler/src/__tests__/Scheduler-test.js | 2 -- .../__tests__/SchedulerSetImmediate-test.js | 2 -- packages/shared/ConsolePatchingDev.js | 3 -- packages/shared/isArray.js | 1 - packages/shared/reportGlobalError.js | 1 - .../useSyncExternalStoreNative-test.js | 2 -- .../useSyncExternalStoreShimServer-test.js | 2 -- .../babel/transform-react-version-pragma.js | 2 -- .../__tests__/transform-error-messages.js | 2 +- scripts/flow/react-native-host-hooks.js | 4 +-- scripts/jest/devtools/setupEnv.js | 1 - scripts/tasks/eslint.js | 1 - scripts/tasks/linc.js | 1 - 66 files changed, 44 insertions(+), 148 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index c92fc4739eded..1d45d68055078 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -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', diff --git a/packages/react-client/src/ReactFlightClient.js b/packages/react-client/src/ReactFlightClient.js index e1d43db1ecffa..866805b5578c1 100644 --- a/packages/react-client/src/ReactFlightClient.js +++ b/packages/react-client/src/ReactFlightClient.js @@ -1839,7 +1839,6 @@ function resolveHint( dispatchHint(code, hintModel); } -// eslint-disable-next-line react-internal/no-production-logging const supportsCreateTask = __DEV__ && enableOwnerStacks && !!(console: any).createTask; @@ -1977,7 +1976,6 @@ function initializeFakeTask( ? null : initializeFakeTask(response, componentInfo.owner); - // eslint-disable-next-line react-internal/no-production-logging const createTaskFn = (console: any).createTask.bind( console, getServerComponentTaskName(componentInfo), diff --git a/packages/react-client/src/ReactFlightReplyClient.js b/packages/react-client/src/ReactFlightReplyClient.js index e5f7a559e7a45..ff80f4b310a77 100644 --- a/packages/react-client/src/ReactFlightReplyClient.js +++ b/packages/react-client/src/ReactFlightReplyClient.js @@ -227,14 +227,11 @@ export function processReply( function progress(entry: {done: boolean, value: ReactServerValue, ...}) { if (entry.done) { const blobId = nextPartId++; - // eslint-disable-next-line react-internal/safe-string-coercion data.append(formFieldPrefix + blobId, new Blob(buffer)); - // eslint-disable-next-line react-internal/safe-string-coercion data.append( formFieldPrefix + streamId, '"$o' + blobId.toString(16) + '"', ); - // eslint-disable-next-line react-internal/safe-string-coercion data.append(formFieldPrefix + streamId, 'C'); // Close signal pendingParts--; if (pendingParts === 0) { @@ -262,7 +259,6 @@ export function processReply( function progress(entry: {done: boolean, value: ReactServerValue, ...}) { if (entry.done) { - // eslint-disable-next-line react-internal/safe-string-coercion data.append(formFieldPrefix + streamId, 'C'); // Close signal pendingParts--; if (pendingParts === 0) { @@ -272,7 +268,6 @@ export function processReply( try { // $FlowFixMe[incompatible-type]: While plain JSON can return undefined we never do here. const partJSON: string = JSON.stringify(entry.value, resolveToJSON); - // eslint-disable-next-line react-internal/safe-string-coercion data.append(formFieldPrefix + streamId, partJSON); reader.read().then(progress, reject); } catch (x) { @@ -326,7 +321,6 @@ export function processReply( ) { if (entry.done) { if (entry.value === undefined) { - // eslint-disable-next-line react-internal/safe-string-coercion data.append(formFieldPrefix + streamId, 'C'); // Close signal } else { // Unlike streams, the last value may not be undefined. If it's not @@ -348,7 +342,6 @@ export function processReply( try { // $FlowFixMe[incompatible-type]: While plain JSON can return undefined we never do here. const partJSON: string = JSON.stringify(entry.value, resolveToJSON); - // eslint-disable-next-line react-internal/safe-string-coercion data.append(formFieldPrefix + streamId, partJSON); iterator.next().then(progress, reject); } catch (x) { @@ -441,7 +434,6 @@ export function processReply( const partJSON = serializeModel(resolvedModel, lazyId); // $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) { @@ -461,7 +453,6 @@ export function processReply( const partJSON = serializeModel(value, lazyId); // $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) { @@ -502,7 +493,6 @@ export function processReply( const partJSON = serializeModel(partValue, promiseId); // $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) { @@ -784,7 +774,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); } diff --git a/packages/react-client/src/forks/ReactFlightClientConfig.custom.js b/packages/react-client/src/forks/ReactFlightClientConfig.custom.js index 3add5988aab8a..88694f59324d4 100644 --- a/packages/react-client/src/forks/ReactFlightClientConfig.custom.js +++ b/packages/react-client/src/forks/ReactFlightClientConfig.custom.js @@ -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; diff --git a/packages/react-devtools-extensions/flow-typed/jest.js b/packages/react-devtools-extensions/flow-typed/jest.js index cdbe32bee7ba6..66c8f0d41fe55 100644 --- a/packages/react-devtools-extensions/flow-typed/jest.js +++ b/packages/react-devtools-extensions/flow-typed/jest.js @@ -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, }; @@ -1098,10 +1096,8 @@ type JestPrettyFormatColors = { }; type JestPrettyFormatIndent = string => string; -// eslint-disable-next-line no-unused-vars type JestPrettyFormatRefs = Array; type JestPrettyFormatPrint = any => string; -// eslint-disable-next-line no-unused-vars type JestPrettyFormatStringOrNull = string | null; type JestPrettyFormatOptions = { @@ -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, diff --git a/packages/react-devtools-extensions/flow-typed/npm/react-test-renderer_v16.x.x.js b/packages/react-devtools-extensions/flow-typed/npm/react-test-renderer_v16.x.x.js index f706d830ebc00..c9a96b1d4b9f8 100644 --- a/packages/react-devtools-extensions/flow-typed/npm/react-test-renderer_v16.x.x.js +++ b/packages/react-devtools-extensions/flow-typed/npm/react-test-renderer_v16.x.x.js @@ -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, diff --git a/packages/react-devtools-inline/__tests__/__e2e__/utils.js b/packages/react-devtools-inline/__tests__/__e2e__/utils.js index 1e0efabb15466..5f0505b71e070 100644 --- a/packages/react-devtools-inline/__tests__/__e2e__/utils.js +++ b/packages/react-devtools-inline/__tests__/__e2e__/utils.js @@ -7,7 +7,6 @@ const config = require('../../playwright.config'); const {test} = require('@playwright/test'); function runOnlyForReactRange(range) { - // eslint-disable-next-line jest/no-disabled-tests test.skip( !semver.satisfies(config.use.react_version, range), `This test requires a React version of ${range} to run. ` + diff --git a/packages/react-devtools-shared/src/__tests__/inspectedElement-test.js b/packages/react-devtools-shared/src/__tests__/inspectedElement-test.js index a49f2d464bc65..ba6bd0ad092af 100644 --- a/packages/react-devtools-shared/src/__tests__/inspectedElement-test.js +++ b/packages/react-devtools-shared/src/__tests__/inspectedElement-test.js @@ -665,7 +665,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} @@ -1876,7 +1875,7 @@ describe('InspectedElement', () => { xyz: 1, }, }); - const bigInt = BigInt(123); // eslint-disable-line no-undef + const bigInt = BigInt(123); await utils.actAsync(() => render( diff --git a/packages/react-devtools-shared/src/__tests__/legacy/inspectElement-test.js b/packages/react-devtools-shared/src/__tests__/legacy/inspectElement-test.js index f05c832c56c15..243759e5b02e7 100644 --- a/packages/react-devtools-shared/src/__tests__/legacy/inspectElement-test.js +++ b/packages/react-devtools-shared/src/__tests__/legacy/inspectElement-test.js @@ -185,7 +185,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, @@ -888,7 +887,7 @@ describe('InspectedElementContext', () => { xyz: 1, }, }); - const bigInt = BigInt(123); // eslint-disable-line no-undef + const bigInt = BigInt(123); act(() => ReactDOM.render( diff --git a/packages/react-devtools-shared/src/backend/DevToolsConsolePatching.js b/packages/react-devtools-shared/src/backend/DevToolsConsolePatching.js index bc133590f89b8..71ede689250ea 100644 --- a/packages/react-devtools-shared/src/backend/DevToolsConsolePatching.js +++ b/packages/react-devtools-shared/src/backend/DevToolsConsolePatching.js @@ -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; @@ -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, diff --git a/packages/react-devtools-shared/src/backend/renderer.js b/packages/react-devtools-shared/src/backend/renderer.js index fa2b098a81dc2..4ec7de9529548 100644 --- a/packages/react-devtools-shared/src/backend/renderer.js +++ b/packages/react-devtools-shared/src/backend/renderer.js @@ -1604,7 +1604,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: diff --git a/packages/react-devtools-shell/src/app/InspectableElements/UnserializableProps.js b/packages/react-devtools-shell/src/app/InspectableElements/UnserializableProps.js index 906683c0975fb..2c279a1bdbf87 100644 --- a/packages/react-devtools-shell/src/app/InspectableElements/UnserializableProps.js +++ b/packages/react-devtools-shell/src/app/InspectableElements/UnserializableProps.js @@ -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; diff --git a/packages/react-devtools/app.js b/packages/react-devtools/app.js index 3912a80ef09d5..c427852b408ba 100644 --- a/packages/react-devtools/app.js +++ b/packages/react-devtools/app.js @@ -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 diff --git a/packages/react-dom-bindings/src/client/DOMPropertyOperations.js b/packages/react-dom-bindings/src/client/DOMPropertyOperations.js index 867eeba4a0869..1d5211e451ff2 100644 --- a/packages/react-dom-bindings/src/client/DOMPropertyOperations.js +++ b/packages/react-dom-bindings/src/client/DOMPropertyOperations.js @@ -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); @@ -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': { diff --git a/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js b/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js index 03fcee884186b..3d5c730e428dd 100644 --- a/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js +++ b/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js @@ -443,7 +443,7 @@ export function createInstance( didWarnScriptTags = true; } } - div.innerHTML = '