Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 64 additions & 9 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ module.exports = {

plugins: [
'babel',
'flowtype',
'ft-flow',
'jest',
'no-for-of-loops',
'no-function-declare-after-return',
'react',
'react-internal',
],

parser: 'babel-eslint',
parser: 'hermes-eslint',
parserOptions: {
ecmaVersion: 9,
sourceType: 'script',
Expand All @@ -36,6 +36,16 @@ module.exports = {
// We're stricter than the default config, mostly. We'll override a few rules
// and then enable some React specific ones.
rules: {
'ft-flow/array-style-complex-type': [OFF, 'verbose'],
'ft-flow/array-style-simple-type': [OFF, 'verbose'], // TODO should be WARNING
'ft-flow/boolean-style': ERROR,
'ft-flow/no-dupe-keys': ERROR,
'ft-flow/no-primitive-constructor-types': ERROR,
'ft-flow/no-types-missing-file-annotation': OFF, // TODO should be ERROR
'ft-flow/no-unused-expressions': ERROR,
// 'ft-flow/no-weak-types': WARNING,
// 'ft-flow/require-valid-file-annotation': ERROR,

'no-cond-assign': OFF,
'no-constant-condition': OFF,
'no-control-regex': OFF,
Expand Down Expand Up @@ -90,7 +100,7 @@ module.exports = {
'no-param-reassign': OFF,
'no-process-env': OFF,
'no-proto': ERROR,
'no-redeclare': WARNING,
'no-redeclare': OFF, // TODO should be WARNING?
'no-return-assign': OFF,
'no-script-url': ERROR,
'no-self-compare': WARNING,
Expand Down Expand Up @@ -209,8 +219,6 @@ module.exports = {
'react/require-render-return': OFF,
'react/sort-comp': OFF,
'react/sort-prop-types': OFF,
'flowtype/define-flow-type': WARNING,
'flowtype/use-flow-type': WARNING,

'accessor-pairs': OFF,
'brace-style': [ERROR, '1tbs'],
Expand All @@ -230,7 +238,6 @@ module.exports = {
'no-restricted-globals': [ERROR].concat(restrictedGlobals),
'no-restricted-syntax': [ERROR, 'WithStatement'],
'no-shadow': ERROR,
'no-unused-expressions': ERROR,
'no-unused-vars': [ERROR, {args: 'none'}],
'no-use-before-define': OFF,
'no-useless-concat': OFF,
Expand All @@ -253,8 +260,6 @@ module.exports = {
// deal. But I turned it off because loading the plugin causes some obscure
// syntax error and it didn't seem worth investigating.
'max-len': OFF,
// Prettier forces semicolons in a few places
'flowtype/object-type-delimiter': OFF,

// React & JSX
// Our transforms set this automatically
Expand Down Expand Up @@ -345,7 +350,7 @@ module.exports = {
// We apply these settings to the source files that get compiled.
// They can use all features including JSX (but shouldn't use `var`).
files: esNextPaths,
parser: 'babel-eslint',
parser: 'hermes-eslint',
parserOptions: {
ecmaVersion: 8,
sourceType: 'module',
Expand Down Expand Up @@ -433,6 +438,56 @@ module.exports = {
},

globals: {
$Call: 'readonly',
$ElementType: 'readonly',
$Flow$ModuleRef: 'readonly',
$FlowFixMe: 'readonly',
$Keys: 'readonly',
$NonMaybeType: 'readonly',
$PropertyType: 'readonly',
$ReadOnly: 'readonly',
$ReadOnlyArray: 'readonly',
$Shape: 'readonly',
AnimationFrameID: 'readonly',
Class: 'readonly',
ClientRect: 'readonly',
CopyInspectedElementPath: 'readonly',
DOMHighResTimeStamp: 'readonly',
EventListener: 'readonly',
Iterable: 'readonly',
Iterator: 'readonly',
JSONValue: 'readonly',
JSResourceReference: 'readonly',
MouseEventHandler: 'readonly',
PropagationPhases: 'readonly',
PropertyDescriptor: 'readonly',
React$AbstractComponent: 'readonly',
React$Component: 'readonly',
React$ComponentType: 'readonly',
React$Config: 'readonly',
React$Context: 'readonly',
React$Element: 'readonly',
React$ElementConfig: 'readonly',
React$ElementProps: 'readonly',
React$ElementRef: 'readonly',
React$ElementType: 'readonly',
React$Key: 'readonly',
React$Node: 'readonly',
React$Portal: 'readonly',
React$Ref: 'readonly',
React$StatelessFunctionalComponent: 'readonly',
ReadableStreamController: 'readonly',
RequestInfo: 'readonly',
RequestOptions: 'readonly',
ResponseState: 'readonly',
StoreAsGlobal: 'readonly',
symbol: 'readonly',
SyntheticEvent: 'readonly',
SyntheticMouseEvent: 'readonly',
Thenable: 'readonly',
TimeoutID: 'readonly',
WheelEventHandler: 'readonly',

spyOnDev: 'readonly',
spyOnDevAndProd: 'readonly',
spyOnProd: 'readonly',
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,12 @@
"create-react-class": "^15.6.3",
"danger": "^9.2.10",
"error-stack-parser": "^2.0.6",
"eslint": "^7.7.0",
"eslint": "^8.29.0",
"eslint-config-prettier": "^6.9.0",
"eslint-plugin-babel": "^5.3.0",
"eslint-plugin-eslint-plugin": "^3.5.3",
"eslint-plugin-flowtype": "^2.25.0",
"eslint-plugin-ft-flow": "^2.0.3",
"eslint-plugin-jest": "^22.15.0",
"eslint-plugin-no-for-of-loops": "^1.0.0",
"eslint-plugin-no-function-declare-after-return": "^1.0.0",
Expand All @@ -66,6 +67,7 @@
"glob-stream": "^6.1.0",
"google-closure-compiler": "^20200517.0.0",
"gzip-size": "^5.1.1",
"hermes-eslint": "^0.9.0",
"jasmine-check": "^1.0.0-rc.0",
"jest": "^26.6.3",
"jest-cli": "^26.6.3",
Expand Down
2 changes: 2 additions & 0 deletions packages/react-art/src/ReactARTHostConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,7 @@ export function preparePortalMount(portalInstance: any): void {
// noop
}

// eslint-disable-next-line no-undef
export function detachDeletedInstance(node: Instance): void {
// noop
}
Expand All @@ -458,6 +459,7 @@ export function requestPostPaintCallback(callback: (time: number) => void) {
// noop
}

// eslint-disable-next-line no-undef
export function prepareRendererToRender(container: Container): void {
// noop
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@
declare var $$$hostConfig: any;

export type Response = any;
export opaque type BundlerConfig = mixed; // eslint-disable-line no-undef
export opaque type ModuleMetaData = mixed; // eslint-disable-line no-undef
export opaque type ModuleReference<T> = mixed; // eslint-disable-line no-undef
export opaque type BundlerConfig = mixed;
export opaque type ModuleMetaData = mixed;
export opaque type ModuleReference<T> = mixed; // eslint-disable-line no-unused-vars
export const resolveModuleReference = $$$hostConfig.resolveModuleReference;
export const preloadModule = $$$hostConfig.preloadModule;
export const requireModule = $$$hostConfig.requireModule;

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

export type UninitializedModel = string;
export const parseModel = $$$hostConfig.parseModel;
Expand Down
13 changes: 11 additions & 2 deletions packages/react-devtools-extensions/flow-typed/jest.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/

'use strict';

/* eslint-disable no-unused-vars */

type JestMockFn<TArguments: $ReadOnlyArray<*>, TReturn> = {
(...args: TArguments): TReturn,
/**
Expand Down Expand Up @@ -693,13 +704,11 @@ interface JestExpectType {
* specific arguments.
*/
toHaveBeenCalledWith(...args: Array<any>): void;
toBeCalledWith(...args: Array<any>): void;
/**
* Use .toHaveBeenLastCalledWith to ensure that a mock function was last called
* with specific arguments.
*/
toHaveBeenLastCalledWith(...args: Array<any>): void;
lastCalledWith(...args: Array<any>): void;
/**
* Check that an object has a .length property and it is set to a certain
* numeric value.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

'use strict';

/* eslint-disable no-unused-vars */

type ReactComponentInstance = React$Component<any>;

type ReactTestRendererJSON = {
Expand Down Expand Up @@ -77,7 +79,7 @@ declare module 'react-test-renderer/shallow' {
static createRenderer(): ShallowRenderer;
getMountedInstance(): ReactTestInstance;
getRenderOutput<E: React$Element<any>>(): E;
getRenderOutput(): React$Element<any>;
getRenderOutput(): React$Element<any>; // eslint-disable-line ft-flow/no-dupe-keys
Copy link
Collaborator

@gaearon gaearon Dec 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this declaration for? can this line be deleted entirely?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought it was method overloading, but looking at it again that doesn't seem to be the case. I'll try if flow passes when I remove this.

render(element: React$Element<any>, context?: any): void;
unmount(): void;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
describe('Profiler change descriptions', () => {
let React;
let legacyRender;
let store: Store;
let store;
let utils;

beforeEach(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('profiling HostRoot', () => {
let ReactDOMClient;
let Scheduler;
let legacyRender;
let store: Store;
let store;
let utils;
let getEffectDurations;
let effectDurations;
Expand Down
9 changes: 9 additions & 0 deletions packages/react-devtools-shell/src/e2e/devtools.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @noflow
*/

import * as React from 'react';
import * as ReactDOM from 'react-dom';
import {createRoot} from 'react-dom/client';
Expand Down
9 changes: 9 additions & 0 deletions packages/react-devtools-shell/src/multi/devtools.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @noflow
*/

import * as React from 'react';
import {createRoot} from 'react-dom/client';
import {
Expand Down
7 changes: 7 additions & 0 deletions packages/react-devtools-shell/src/multi/left.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

import * as React from 'react';
import {useState} from 'react';
import {createRoot} from 'react-dom';
Expand Down
7 changes: 7 additions & 0 deletions packages/react-devtools-shell/src/multi/right.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

import * as React from 'react';
import {useLayoutEffect, useRef, useState} from 'react';
import {render} from 'react-dom';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ import preprocessData from './preprocessData';
import {readInputData} from './readInputData';
import InvalidProfileError from './InvalidProfileError';

declare var self: DedicatedWorkerGlobalScope;

export async function importFile(file: File): Promise<ImportWorkerOutputData> {
try {
const readFile = await readInputData(file);
Expand Down
4 changes: 2 additions & 2 deletions packages/react-dom-bindings/src/client/ReactDOMSelection.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ export function getOffsets(outerNode) {
// catch any error that may otherwise arise. See
// https://bugzilla.mozilla.org/show_bug.cgi?id=208427
try {
/* eslint-disable no-unused-expressions */
/* eslint-disable ft-flow/no-unused-expressions */
anchorNode.nodeType;
focusNode.nodeType;
/* eslint-enable no-unused-expressions */
/* eslint-enable ft-flow/no-unused-expressions */
} catch (e) {
return null;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/react-dom/src/test-utils/ReactTestUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ function executeDispatchesInOrder(event) {
* @param {?object} event Synthetic event to be dispatched.
* @private
*/
const executeDispatchesAndRelease = function(event: ReactSyntheticEvent) {
const executeDispatchesAndRelease = function(event /* ReactSyntheticEvent */) {
if (event) {
executeDispatchesInOrder(event);

Expand Down Expand Up @@ -470,7 +470,7 @@ function shouldPreventMouseEvent(name, type, props) {
* @param {string} registrationName Name of listener (e.g. `onClick`).
* @return {?function} The stored callback.
*/
function getListener(inst: Fiber, registrationName: string) {
function getListener(inst /* Fiber */, registrationName: string) {
// TODO: shouldPreventMouseEvent is DOM-specific and definitely should not
// live here; needs to be moved to a better place soon
const stateNode = inst.stateNode;
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native-renderer/fabric.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import type {ReactFabricType} from './src/ReactNativeTypes';
import * as ReactFabric from './src/ReactFabric';
// Assert that the exports line up with the type we're going to expose.
// eslint-disable-next-line no-unused-expressions
// eslint-disable-next-line ft-flow/no-unused-expressions
(ReactFabric: ReactFabricType);

export * from './src/ReactFabric';
2 changes: 1 addition & 1 deletion packages/react-native-renderer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
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 no-unused-expressions
// eslint-disable-next-line ft-flow/no-unused-expressions
(ReactNative: ReactNativeType);

export * from './src/ReactNativeRenderer';
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,6 @@ class ReactFabricHostComponent {
}
}

// eslint-disable-next-line no-unused-expressions
// $FlowFixMe[class-object-subtyping] found when upgrading Flow
// $FlowFixMe[method-unbinding] found when upgrading Flow
(ReactFabricHostComponent.prototype: $ReadOnly<{...NativeMethods, ...}>);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ class ReactNativeFiberHostComponent {
}
}

// eslint-disable-next-line no-unused-expressions
// $FlowFixMe[class-object-subtyping] found when upgrading Flow
// $FlowFixMe[method-unbinding] found when upgrading Flow
(ReactNativeFiberHostComponent.prototype: $ReadOnly<{...NativeMethods, ...}>);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1402,7 +1402,6 @@ describe('ResponderEventPlugin', () => {
class ParentComponent extends React.Component {
pRef = React.createRef();
p_P1Ref = React.createRef();
p_P1Ref = React.createRef();
p_P1_C1Ref = React.createRef();
p_P1_C2Ref = React.createRef();
p_OneOffRef = React.createRef();
Expand Down
2 changes: 1 addition & 1 deletion packages/react-reconciler/src/ReactFiberCacheComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const AbortControllerLocal: typeof AbortController = enableCache
: (null: any);

export type Cache = {
controller: AbortControllerLocal,
controller: AbortController,
data: Map<() => mixed, mixed>,
refCount: number,
};
Expand Down
Loading