Skip to content

Commit

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

This enables linting against unused suppressions and removes the ones
that were unused.
  • Loading branch information
kassens authored Jun 21, 2024
1 parent 3563387 commit b565373
Show file tree
Hide file tree
Showing 66 changed files with 44 additions and 148 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
2 changes: 0 additions & 2 deletions packages/react-client/src/ReactFlightClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -1839,7 +1839,6 @@ function resolveHint<Code: HintCode>(
dispatchHint(code, hintModel);
}

// eslint-disable-next-line react-internal/no-production-logging
const supportsCreateTask =
__DEV__ && enableOwnerStacks && !!(console: any).createTask;

Expand Down Expand Up @@ -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),
Expand Down
11 changes: 0 additions & 11 deletions packages/react-client/src/ReactFlightReplyClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down Expand Up @@ -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
Expand All @@ -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) {
Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}
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
1 change: 0 additions & 1 deletion packages/react-devtools-inline/__tests__/__e2e__/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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. ` +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -888,7 +887,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 @@ -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:
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 @@ -443,7 +443,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 @@ -516,7 +516,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
4 changes: 1 addition & 3 deletions packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js
Original file line number Diff line number Diff line change
Expand Up @@ -1464,7 +1464,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 Expand Up @@ -2808,7 +2808,6 @@ function pushStyleImpl(
child !== null &&
child !== undefined
) {
// eslint-disable-next-line react-internal/safe-string-coercion
target.push(stringToChunk(escapeStyleTextContent(child)));
}
pushInnerHTML(target, innerHTML, children);
Expand Down Expand Up @@ -2850,7 +2849,6 @@ function pushStyleContents(
child !== null &&
child !== undefined
) {
// eslint-disable-next-line react-internal/safe-string-coercion
target.push(stringToChunk(escapeStyleTextContent(child)));
}
pushInnerHTML(target, innerHTML, children);
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 @@ -468,7 +468,6 @@ describe('ReactComponent', () => {
root.unmount();
});

/* eslint-disable indent */
expect(log).toEqual([
'start mount',
'inner 1 render',
Expand Down Expand Up @@ -497,7 +496,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 @@ -1503,7 +1503,6 @@ describe('ReactComponentLifeCycle', () => {
});
}).toWarnDev(
[
/* eslint-disable max-len */
`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 @@ -1523,7 +1522,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
Loading

0 comments on commit b565373

Please sign in to comment.