From ac2e861fbe05901b874e3ab49807abab820ef648 Mon Sep 17 00:00:00 2001 From: Brian Vaughn Date: Tue, 13 Aug 2019 21:59:07 -0700 Subject: [PATCH] Fixed a bunch of Lint issues --- .eslintignore | 7 ++++ .gitignore | 11 +++++ .prettierignore | 6 +++ packages/react-devtools-core/src/backend.js | 2 +- .../react-devtools-extensions/.eslintignore | 13 ------ packages/react-devtools-extensions/.eslintrc | 19 --------- .../react-devtools-extensions/.flowconfig | 35 ---------------- packages/react-devtools-extensions/.gitignore | 21 ---------- .../react-devtools-extensions/.prettierignore | 9 ----- .../react-devtools-extensions/.prettierrc | 4 -- .../{shared => }/build.js | 10 +++-- .../react-devtools-extensions/chrome/build.js | 2 + .../chrome/deploy.js | 2 + .../react-devtools-extensions/chrome/test.js | 4 +- .../{shared => }/deploy.chrome.html | 0 .../{shared => }/deploy.firefox.html | 0 .../{shared => }/deploy.html | 0 .../{shared => }/deploy.js | 2 + .../firefox/build.js | 2 + .../firefox/deploy.js | 2 + .../react-devtools-extensions/firefox/test.js | 2 + .../flow-typed/chrome.js | 2 + .../flow-typed/jest.js | 2 + .../npm/react-test-renderer_v16.x.x.js | 2 + packages/react-devtools-extensions/flow.js | 1 - .../{shared => }/icons/128-deadcode.png | Bin .../{shared => }/icons/128-development.png | Bin .../{shared => }/icons/128-disabled.png | Bin .../{shared => }/icons/128-outdated.png | Bin .../{shared => }/icons/128-production.png | Bin .../{shared => }/icons/128-unminified.png | Bin .../{shared => }/icons/16-deadcode.png | Bin .../{shared => }/icons/16-development.png | Bin .../{shared => }/icons/16-disabled.png | Bin .../{shared => }/icons/16-outdated.png | Bin .../{shared => }/icons/16-production.png | Bin .../{shared => }/icons/16-unminified.png | Bin .../{shared => }/icons/32-deadcode.png | Bin .../{shared => }/icons/32-development.png | Bin .../{shared => }/icons/32-disabled.png | Bin .../{shared => }/icons/32-outdated.png | Bin .../{shared => }/icons/32-production.png | Bin .../{shared => }/icons/32-unminified.png | Bin .../{shared => }/icons/48-deadcode.png | Bin .../{shared => }/icons/48-development.png | Bin .../{shared => }/icons/48-disabled.png | Bin .../{shared => }/icons/48-outdated.png | Bin .../{shared => }/icons/48-production.png | Bin .../{shared => }/icons/48-unminified.png | Bin .../{shared => }/icons/deadcode.svg | 0 .../{shared => }/icons/development.svg | 0 .../{shared => }/icons/disabled.svg | 0 .../{shared => }/icons/outdated.svg | 0 .../{shared => }/icons/production.svg | 0 .../{shared => }/main.html | 0 .../{shared => }/panel.html | 0 .../{shared => }/popups/deadcode.html | 0 .../{shared => }/popups/development.html | 0 .../{shared => }/popups/disabled.html | 0 .../{shared => }/popups/outdated.html | 0 .../{shared => }/popups/production.html | 0 .../{shared => }/popups/shared.js | 2 + .../{shared => }/popups/unminified.html | 0 .../{shared => }/src/backend.js | 8 ++-- .../{shared => }/src/background.js | 4 +- .../{shared => }/src/contentScript.js | 10 +++-- .../{shared => }/src/inject.js | 0 .../{shared => }/src/injectGlobalHook.js | 2 +- .../{shared => }/src/main.js | 38 +++++++++--------- .../{shared => }/src/panel.js | 1 + .../{shared => }/src/renderer.js | 2 +- .../{shared => }/src/utils.js | 0 .../{shared => }/webpack.backend.js | 2 + .../{shared => }/webpack.config.js | 2 + packages/react-devtools-inline/src/backend.js | 2 +- .../react-devtools-inline/src/frontend.js | 6 +-- .../src/__tests__/profilingCache-test.js | 3 +- .../src/__tests__/storeStressSync-test.js | 12 +++--- .../storeStressTestConcurrent-test.js | 16 ++++---- .../src/__tests__/treeContext-test.js | 2 +- .../src/__tests__/utils.js | 9 ++--- .../NativeStyleEditor/resolveBoxStyle.js | 1 + .../src/backend/console.js | 1 + .../src/backend/legacy/renderer.js | 2 +- .../src/backend/renderer.js | 11 +++-- .../react-devtools-shared/src/constants.js | 2 +- .../src/devtools/ProfilerStore.js | 5 ++- .../src/devtools/cache.js | 2 - .../src/devtools/store.js | 20 ++++----- .../devtools/views/Components/HooksTree.js | 7 +++- .../Components/InspectedElementContext.js | 2 - .../src/devtools/views/Components/KeyValue.js | 26 ++++++------ .../NativeStyleEditor/StyleEditor.js | 14 +++---- .../Components/NativeStyleEditor/context.js | 1 - .../Components/NativeStyleEditor/index.js | 1 - .../devtools/views/Components/OwnersStack.js | 11 ++--- .../views/Components/SelectedElement.js | 2 +- .../views/Components/SelectedTreeHighlight.js | 1 - .../src/devtools/views/Components/Tree.js | 1 + .../devtools/views/Components/TreeContext.js | 10 ++--- .../src/devtools/views/ModalDialog.js | 5 ++- .../views/Profiler/CommitFlamegraph.js | 13 +++--- .../views/Profiler/CommitTreeBuilder.js | 17 ++++---- .../views/Profiler/FlamegraphChartBuilder.js | 12 +++--- .../views/Profiler/ProfilerContext.js | 1 - .../views/Profiler/RankedChartBuilder.js | 8 ++-- .../views/Profiler/ReloadAndProfileButton.js | 1 - .../devtools/views/Profiler/RootSelector.js | 4 +- .../views/Profiler/SnapshotCommitList.js | 6 +-- .../views/Settings/ComponentsSettings.js | 35 ++++++++-------- .../views/Settings/ProfilerSettings.js | 1 - .../devtools/views/Settings/SettingsModal.js | 1 - .../Settings/SettingsModalContextToggle.js | 1 - packages/react-devtools-shared/src/hook.js | 4 +- .../app/DeeplyNestedComponents/index.js | 0 .../{ => src}/app/EditableProps/index.js | 6 +-- .../{ => src}/app/ElementTypes/index.js | 2 +- .../{ => src}/app/Hydration/index.js | 0 .../{ => src}/app/Iframe/index.js | 0 .../app/InspectableElements/Contexts.js | 0 .../app/InspectableElements/CustomHooks.js | 4 +- .../app/InspectableElements/CustomObject.js | 0 .../InspectableElements.js | 0 .../app/InspectableElements/NestedProps.js | 0 .../app/InspectableElements/SimpleValues.js | 0 .../app/InspectableElements/index.js | 0 .../{ => src}/app/InteractionTracing/index.js | 16 ++++---- .../{ => src}/app/PriorityLevels/index.js | 0 .../{ => src}/app/ReactNativeWeb/index.js | 0 .../{ => src}/app/SuspenseTree/index.js | 0 .../{ => src}/app/ToDoList/List.css | 0 .../{ => src}/app/ToDoList/List.js | 12 +++--- .../{ => src}/app/ToDoList/ListItem.css | 0 .../{ => src}/app/ToDoList/ListItem.js | 4 +- .../{ => src}/app/ToDoList/index.js | 0 .../{ => src}/app/Toggle/index.js | 0 .../{ => src}/app/console.js | 2 +- .../{ => src}/app/index.js | 0 .../{ => src}/app/styles.css | 0 .../react-devtools-shell/webpack.config.js | 2 +- 140 files changed, 253 insertions(+), 305 deletions(-) create mode 100644 .prettierignore delete mode 100644 packages/react-devtools-extensions/.eslintignore delete mode 100644 packages/react-devtools-extensions/.eslintrc delete mode 100644 packages/react-devtools-extensions/.flowconfig delete mode 100644 packages/react-devtools-extensions/.gitignore delete mode 100644 packages/react-devtools-extensions/.prettierignore delete mode 100644 packages/react-devtools-extensions/.prettierrc rename packages/react-devtools-extensions/{shared => }/build.js (98%) rename packages/react-devtools-extensions/{shared => }/deploy.chrome.html (100%) rename packages/react-devtools-extensions/{shared => }/deploy.firefox.html (100%) rename packages/react-devtools-extensions/{shared => }/deploy.html (100%) rename packages/react-devtools-extensions/{shared => }/deploy.js (99%) rename packages/react-devtools-extensions/{shared => }/icons/128-deadcode.png (100%) rename packages/react-devtools-extensions/{shared => }/icons/128-development.png (100%) rename packages/react-devtools-extensions/{shared => }/icons/128-disabled.png (100%) rename packages/react-devtools-extensions/{shared => }/icons/128-outdated.png (100%) rename packages/react-devtools-extensions/{shared => }/icons/128-production.png (100%) rename packages/react-devtools-extensions/{shared => }/icons/128-unminified.png (100%) rename packages/react-devtools-extensions/{shared => }/icons/16-deadcode.png (100%) rename packages/react-devtools-extensions/{shared => }/icons/16-development.png (100%) rename packages/react-devtools-extensions/{shared => }/icons/16-disabled.png (100%) rename packages/react-devtools-extensions/{shared => }/icons/16-outdated.png (100%) rename packages/react-devtools-extensions/{shared => }/icons/16-production.png (100%) rename packages/react-devtools-extensions/{shared => }/icons/16-unminified.png (100%) rename packages/react-devtools-extensions/{shared => }/icons/32-deadcode.png (100%) rename packages/react-devtools-extensions/{shared => }/icons/32-development.png (100%) rename packages/react-devtools-extensions/{shared => }/icons/32-disabled.png (100%) rename packages/react-devtools-extensions/{shared => }/icons/32-outdated.png (100%) rename packages/react-devtools-extensions/{shared => }/icons/32-production.png (100%) rename packages/react-devtools-extensions/{shared => }/icons/32-unminified.png (100%) rename packages/react-devtools-extensions/{shared => }/icons/48-deadcode.png (100%) rename packages/react-devtools-extensions/{shared => }/icons/48-development.png (100%) rename packages/react-devtools-extensions/{shared => }/icons/48-disabled.png (100%) rename packages/react-devtools-extensions/{shared => }/icons/48-outdated.png (100%) rename packages/react-devtools-extensions/{shared => }/icons/48-production.png (100%) rename packages/react-devtools-extensions/{shared => }/icons/48-unminified.png (100%) rename packages/react-devtools-extensions/{shared => }/icons/deadcode.svg (100%) rename packages/react-devtools-extensions/{shared => }/icons/development.svg (100%) rename packages/react-devtools-extensions/{shared => }/icons/disabled.svg (100%) rename packages/react-devtools-extensions/{shared => }/icons/outdated.svg (100%) rename packages/react-devtools-extensions/{shared => }/icons/production.svg (100%) rename packages/react-devtools-extensions/{shared => }/main.html (100%) rename packages/react-devtools-extensions/{shared => }/panel.html (100%) rename packages/react-devtools-extensions/{shared => }/popups/deadcode.html (100%) rename packages/react-devtools-extensions/{shared => }/popups/development.html (100%) rename packages/react-devtools-extensions/{shared => }/popups/disabled.html (100%) rename packages/react-devtools-extensions/{shared => }/popups/outdated.html (100%) rename packages/react-devtools-extensions/{shared => }/popups/production.html (100%) rename packages/react-devtools-extensions/{shared => }/popups/shared.js (97%) rename packages/react-devtools-extensions/{shared => }/popups/unminified.html (100%) rename packages/react-devtools-extensions/{shared => }/src/backend.js (95%) rename packages/react-devtools-extensions/{shared => }/src/background.js (98%) rename packages/react-devtools-extensions/{shared => }/src/contentScript.js (95%) rename packages/react-devtools-extensions/{shared => }/src/inject.js (100%) rename packages/react-devtools-extensions/{shared => }/src/injectGlobalHook.js (99%) rename packages/react-devtools-extensions/{shared => }/src/main.js (94%) rename packages/react-devtools-extensions/{shared => }/src/panel.js (89%) rename packages/react-devtools-extensions/{shared => }/src/renderer.js (98%) rename packages/react-devtools-extensions/{shared => }/src/utils.js (100%) rename packages/react-devtools-extensions/{shared => }/webpack.backend.js (98%) rename packages/react-devtools-extensions/{shared => }/webpack.config.js (99%) rename packages/react-devtools-shell/{ => src}/app/DeeplyNestedComponents/index.js (100%) rename packages/react-devtools-shell/{ => src}/app/EditableProps/index.js (98%) rename packages/react-devtools-shell/{ => src}/app/ElementTypes/index.js (99%) rename packages/react-devtools-shell/{ => src}/app/Hydration/index.js (100%) rename packages/react-devtools-shell/{ => src}/app/Iframe/index.js (100%) rename packages/react-devtools-shell/{ => src}/app/InspectableElements/Contexts.js (100%) rename packages/react-devtools-shell/{ => src}/app/InspectableElements/CustomHooks.js (96%) rename packages/react-devtools-shell/{ => src}/app/InspectableElements/CustomObject.js (100%) rename packages/react-devtools-shell/{ => src}/app/InspectableElements/InspectableElements.js (100%) rename packages/react-devtools-shell/{ => src}/app/InspectableElements/NestedProps.js (100%) rename packages/react-devtools-shell/{ => src}/app/InspectableElements/SimpleValues.js (100%) rename packages/react-devtools-shell/{ => src}/app/InspectableElements/index.js (100%) rename packages/react-devtools-shell/{ => src}/app/InteractionTracing/index.js (91%) rename packages/react-devtools-shell/{ => src}/app/PriorityLevels/index.js (100%) rename packages/react-devtools-shell/{ => src}/app/ReactNativeWeb/index.js (100%) rename packages/react-devtools-shell/{ => src}/app/SuspenseTree/index.js (100%) rename packages/react-devtools-shell/{ => src}/app/ToDoList/List.css (100%) rename packages/react-devtools-shell/{ => src}/app/ToDoList/List.js (94%) rename packages/react-devtools-shell/{ => src}/app/ToDoList/ListItem.css (100%) rename packages/react-devtools-shell/{ => src}/app/ToDoList/ListItem.js (94%) rename packages/react-devtools-shell/{ => src}/app/ToDoList/index.js (100%) rename packages/react-devtools-shell/{ => src}/app/Toggle/index.js (100%) rename packages/react-devtools-shell/{ => src}/app/console.js (95%) rename packages/react-devtools-shell/{ => src}/app/index.js (100%) rename packages/react-devtools-shell/{ => src}/app/styles.css (100%) diff --git a/.eslintignore b/.eslintignore index d95f2bf247e3c..62ca593965173 100644 --- a/.eslintignore +++ b/.eslintignore @@ -12,3 +12,10 @@ scripts/bench/benchmarks/**/*.js # React repository clone scripts/bench/remote-repo/ + +packages/react-devtools-core/dist +packages/react-devtools-extensions/chrome/build +packages/react-devtools-extensions/firefox/build +packages/react-devtools-extensions/shared/build +packages/react-devtools-inline/dist +packages/react-devtools-shell/dist \ No newline at end of file diff --git a/.gitignore b/.gitignore index 53de0c289077e..902e6c9c8838b 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,14 @@ chrome-user-data .vscode *.swp *.swo + +packages/react-devtools-core/dist +packages/react-devtools-extensions/chrome/build +packages/react-devtools-extensions/chrome/*.crx +packages/react-devtools-extensions/chrome/*.pem +packages/react-devtools-extensions/firefox/build +packages/react-devtools-extensions/firefox/*.xpi +packages/react-devtools-extensions/firefox/*.pem +packages/react-devtools-extensions/shared/build +packages/react-devtools-inline/dist +packages/react-devtools-shell/dist \ No newline at end of file diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000000000..bea24210eca5e --- /dev/null +++ b/.prettierignore @@ -0,0 +1,6 @@ +packages/react-devtools-core/dist +packages/react-devtools-extensions/chrome/build +packages/react-devtools-extensions/firefox/build +packages/react-devtools-extensions/shared/build +packages/react-devtools-inline/dist +packages/react-devtools-shell/dist \ No newline at end of file diff --git a/packages/react-devtools-core/src/backend.js b/packages/react-devtools-core/src/backend.js index 1c99eb954a6ce..67238c3d8375a 100644 --- a/packages/react-devtools-core/src/backend.js +++ b/packages/react-devtools-core/src/backend.js @@ -253,7 +253,7 @@ export function connectToDevTools(options: ?ConnectOptions) { } } catch (e) { console.error( - '[React DevTools] Failed to parse JSON: ' + String(event.data), + '[React DevTools] Failed to parse JSON: ' + (event.data: any), ); return; } diff --git a/packages/react-devtools-extensions/.eslintignore b/packages/react-devtools-extensions/.eslintignore deleted file mode 100644 index 7f1c5b3bd4a87..0000000000000 --- a/packages/react-devtools-extensions/.eslintignore +++ /dev/null @@ -1,13 +0,0 @@ -node_modules - -shells/browser/chrome/build -shells/browser/firefox/build -shells/browser/shared/build -shells/dev/dist -packages/react-devtools-core/dist -packages/react-devtools-inline/dist -vendor -*.js.snap - -package-lock.json -yarn.lock diff --git a/packages/react-devtools-extensions/.eslintrc b/packages/react-devtools-extensions/.eslintrc deleted file mode 100644 index 5622bebb6f159..0000000000000 --- a/packages/react-devtools-extensions/.eslintrc +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": ["react-app","plugin:prettier/recommended"], - "plugins": ["react-hooks"], - "rules": { - "jsx-a11y/anchor-has-content": "off", - "no-loop-func": "off", - "react-hooks/exhaustive-deps": "error", - "react-hooks/rules-of-hooks": "error" - }, - "settings": { - "version": "detect" - }, - "globals": { - "__DEV__": "readonly", - "__TEST__": "readonly", - "jasmine": "readonly", - "spyOn": "readonly" - } -} diff --git a/packages/react-devtools-extensions/.flowconfig b/packages/react-devtools-extensions/.flowconfig deleted file mode 100644 index d613bab513a35..0000000000000 --- a/packages/react-devtools-extensions/.flowconfig +++ /dev/null @@ -1,35 +0,0 @@ -[ignore] -.*/react/node_modules/.* -.*/electron/node_modules/.* -.*node_modules/archiver-utils -.*node_modules/babel.* -.*node_modules/browserify-zlib/.* -.*node_modules/gh-pages/.* -.*node_modules/invariant/.* -.*node_modules/json-loader.* -.*node_modules/json5.* -.*node_modules/node-libs-browser.* -.*node_modules/webpack.* -.*node_modules/fbjs/flow.* -.*node_modules/web-ext.* -shells/browser/chrome/build/* -shells/browser/firefox/build/* -shells/dev/build/* - -[include] - -[libs] -/flow-typed/ -./flow.js - -[lints] - -[options] -server.max_workers=4 -esproposal.class_instance_fields=enable -suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe -suppress_comment=\\(.\\|\n\\)*\\$FlowIssue -suppress_comment=\\(.\\|\n\\)*\\$FlowIgnore -module.name_mapper='^src' ->'/src' - -[strict] diff --git a/packages/react-devtools-extensions/.gitignore b/packages/react-devtools-extensions/.gitignore deleted file mode 100644 index 8ec77912d297f..0000000000000 --- a/packages/react-devtools-extensions/.gitignore +++ /dev/null @@ -1,21 +0,0 @@ -/shells/browser/chrome/*.crx -/shells/browser/chrome/*.pem -/shells/browser/firefox/*.xpi -/shells/browser/firefox/*.pem -/shells/browser/shared/build -/packages/react-devtools-core/dist -/packages/react-devtools-inline/dist -/shells/dev/dist -build -/node_modules -/packages/react-devtools-core/node_modules -/packages/react-devtools-inline/node_modules -/packages/react-devtools/node_modules -npm-debug.log -yarn-error.log -.DS_Store -yarn-error.log -.vscode -.idea -.watchmanconfig -*.pem \ No newline at end of file diff --git a/packages/react-devtools-extensions/.prettierignore b/packages/react-devtools-extensions/.prettierignore deleted file mode 100644 index 640e359715bd2..0000000000000 --- a/packages/react-devtools-extensions/.prettierignore +++ /dev/null @@ -1,9 +0,0 @@ -node_modules - -shells/browser/chrome/build -shells/browser/firefox/build -shells/dev/build -vendor - -package-lock.json -yarn.lock \ No newline at end of file diff --git a/packages/react-devtools-extensions/.prettierrc b/packages/react-devtools-extensions/.prettierrc deleted file mode 100644 index c1a6f66713166..0000000000000 --- a/packages/react-devtools-extensions/.prettierrc +++ /dev/null @@ -1,4 +0,0 @@ -{ - "singleQuote": true, - "trailingComma": "es5" -} diff --git a/packages/react-devtools-extensions/shared/build.js b/packages/react-devtools-extensions/build.js similarity index 98% rename from packages/react-devtools-extensions/shared/build.js rename to packages/react-devtools-extensions/build.js index 45773650efa45..f1c3657bff005 100644 --- a/packages/react-devtools-extensions/shared/build.js +++ b/packages/react-devtools-extensions/build.js @@ -1,5 +1,7 @@ #!/usr/bin/env node +'use strict'; + const archiver = require('archiver'); const {execSync} = require('child_process'); const {readFileSync, writeFileSync, createWriteStream} = require('fs'); @@ -28,7 +30,7 @@ const build = async (tempPath, manifestPath) => { '..', 'node_modules', '.bin', - 'webpack' + 'webpack', ); execSync( `${webpackPath} --config webpack.config.js --output-path ${binPath}`, @@ -36,7 +38,7 @@ const build = async (tempPath, manifestPath) => { cwd: __dirname, env: process.env, stdio: 'inherit', - } + }, ); execSync( `${webpackPath} --config webpack.backend.js --output-path ${binPath}`, @@ -44,7 +46,7 @@ const build = async (tempPath, manifestPath) => { cwd: __dirname, env: process.env, stdio: 'inherit', - } + }, ); // Make temp dir @@ -56,7 +58,7 @@ const build = async (tempPath, manifestPath) => { await copy(binPath, join(zipPath, 'build')); await copy(manifestPath, copiedManifestPath); await Promise.all( - STATIC_FILES.map(file => copy(join(__dirname, file), join(zipPath, file))) + STATIC_FILES.map(file => copy(join(__dirname, file), join(zipPath, file))), ); const commit = getGitCommit(); diff --git a/packages/react-devtools-extensions/chrome/build.js b/packages/react-devtools-extensions/chrome/build.js index 76e97a9d06e83..b1a0c92411653 100644 --- a/packages/react-devtools-extensions/chrome/build.js +++ b/packages/react-devtools-extensions/chrome/build.js @@ -1,5 +1,7 @@ #!/usr/bin/env node +'use strict'; + const chalk = require('chalk'); const {execSync} = require('child_process'); const {existsSync} = require('fs'); diff --git a/packages/react-devtools-extensions/chrome/deploy.js b/packages/react-devtools-extensions/chrome/deploy.js index 1cfdf39085e34..b3ca4141364a6 100644 --- a/packages/react-devtools-extensions/chrome/deploy.js +++ b/packages/react-devtools-extensions/chrome/deploy.js @@ -1,5 +1,7 @@ #!/usr/bin/env node +'use strict'; + const deploy = require('../shared/deploy'); const main = async () => await deploy('chrome'); diff --git a/packages/react-devtools-extensions/chrome/test.js b/packages/react-devtools-extensions/chrome/test.js index ac7ac3239671b..98451f39ab0ea 100644 --- a/packages/react-devtools-extensions/chrome/test.js +++ b/packages/react-devtools-extensions/chrome/test.js @@ -1,6 +1,8 @@ #!/usr/bin/env node -const chromeLaunch = require('chrome-launch'); // eslint-disable-line import/no-extraneous-dependencies +'use strict'; + +const chromeLaunch = require('chrome-launch'); const {resolve} = require('path'); const EXTENSION_PATH = resolve('shells/browser/chrome/build/unpacked'); diff --git a/packages/react-devtools-extensions/shared/deploy.chrome.html b/packages/react-devtools-extensions/deploy.chrome.html similarity index 100% rename from packages/react-devtools-extensions/shared/deploy.chrome.html rename to packages/react-devtools-extensions/deploy.chrome.html diff --git a/packages/react-devtools-extensions/shared/deploy.firefox.html b/packages/react-devtools-extensions/deploy.firefox.html similarity index 100% rename from packages/react-devtools-extensions/shared/deploy.firefox.html rename to packages/react-devtools-extensions/deploy.firefox.html diff --git a/packages/react-devtools-extensions/shared/deploy.html b/packages/react-devtools-extensions/deploy.html similarity index 100% rename from packages/react-devtools-extensions/shared/deploy.html rename to packages/react-devtools-extensions/deploy.html diff --git a/packages/react-devtools-extensions/shared/deploy.js b/packages/react-devtools-extensions/deploy.js similarity index 99% rename from packages/react-devtools-extensions/shared/deploy.js rename to packages/react-devtools-extensions/deploy.js index 9564e77c9f902..b0df1cfb85928 100644 --- a/packages/react-devtools-extensions/shared/deploy.js +++ b/packages/react-devtools-extensions/deploy.js @@ -1,5 +1,7 @@ #!/usr/bin/env node +'use strict'; + const {exec, execSync} = require('child_process'); const {readFileSync, writeFileSync} = require('fs'); const {join} = require('path'); diff --git a/packages/react-devtools-extensions/firefox/build.js b/packages/react-devtools-extensions/firefox/build.js index a35e2b1684a0a..d768d8aa618ed 100644 --- a/packages/react-devtools-extensions/firefox/build.js +++ b/packages/react-devtools-extensions/firefox/build.js @@ -1,5 +1,7 @@ #!/usr/bin/env node +'use strict'; + const chalk = require('chalk'); const build = require('../shared/build'); diff --git a/packages/react-devtools-extensions/firefox/deploy.js b/packages/react-devtools-extensions/firefox/deploy.js index b7977d62f0abc..c68ac3040162a 100644 --- a/packages/react-devtools-extensions/firefox/deploy.js +++ b/packages/react-devtools-extensions/firefox/deploy.js @@ -1,5 +1,7 @@ #!/usr/bin/env node +'use strict'; + const deploy = require('../shared/deploy'); const main = async () => await deploy('firefox'); diff --git a/packages/react-devtools-extensions/firefox/test.js b/packages/react-devtools-extensions/firefox/test.js index 65c16fd55a25b..f50d15458d710 100644 --- a/packages/react-devtools-extensions/firefox/test.js +++ b/packages/react-devtools-extensions/firefox/test.js @@ -1,5 +1,7 @@ #!/usr/bin/env node +'use strict'; + const {exec} = require('child-process-promise'); const {Finder} = require('firefox-profile'); const {resolve} = require('path'); diff --git a/packages/react-devtools-extensions/flow-typed/chrome.js b/packages/react-devtools-extensions/flow-typed/chrome.js index 4426e1343a776..c95e6d90653f6 100644 --- a/packages/react-devtools-extensions/flow-typed/chrome.js +++ b/packages/react-devtools-extensions/flow-typed/chrome.js @@ -1,5 +1,7 @@ // @flow +'use strict'; + declare var chrome: { devtools: { network: { diff --git a/packages/react-devtools-extensions/flow-typed/jest.js b/packages/react-devtools-extensions/flow-typed/jest.js index 07c7edbe82a9d..f8cd1b90be611 100644 --- a/packages/react-devtools-extensions/flow-typed/jest.js +++ b/packages/react-devtools-extensions/flow-typed/jest.js @@ -1,3 +1,5 @@ +'use strict'; + type JestMockFn, TReturn> = { (...args: TArguments): TReturn, /** 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 39fbaf9fdb3c1..e34825e46c444 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 @@ -4,6 +4,8 @@ // Type definitions for react-test-renderer 16.x.x // Ported from: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react-test-renderer +'use strict'; + type ReactComponentInstance = React$Component; type ReactTestRendererJSON = { diff --git a/packages/react-devtools-extensions/flow.js b/packages/react-devtools-extensions/flow.js index 8cd9e1b5f333e..4e9111d8c585e 100644 --- a/packages/react-devtools-extensions/flow.js +++ b/packages/react-devtools-extensions/flow.js @@ -18,7 +18,6 @@ declare module 'node-events' { } declare var __DEV__: boolean; -declare var __TEST__: boolean; declare var jasmine: {| getEnv: () => {| diff --git a/packages/react-devtools-extensions/shared/icons/128-deadcode.png b/packages/react-devtools-extensions/icons/128-deadcode.png similarity index 100% rename from packages/react-devtools-extensions/shared/icons/128-deadcode.png rename to packages/react-devtools-extensions/icons/128-deadcode.png diff --git a/packages/react-devtools-extensions/shared/icons/128-development.png b/packages/react-devtools-extensions/icons/128-development.png similarity index 100% rename from packages/react-devtools-extensions/shared/icons/128-development.png rename to packages/react-devtools-extensions/icons/128-development.png diff --git a/packages/react-devtools-extensions/shared/icons/128-disabled.png b/packages/react-devtools-extensions/icons/128-disabled.png similarity index 100% rename from packages/react-devtools-extensions/shared/icons/128-disabled.png rename to packages/react-devtools-extensions/icons/128-disabled.png diff --git a/packages/react-devtools-extensions/shared/icons/128-outdated.png b/packages/react-devtools-extensions/icons/128-outdated.png similarity index 100% rename from packages/react-devtools-extensions/shared/icons/128-outdated.png rename to packages/react-devtools-extensions/icons/128-outdated.png diff --git a/packages/react-devtools-extensions/shared/icons/128-production.png b/packages/react-devtools-extensions/icons/128-production.png similarity index 100% rename from packages/react-devtools-extensions/shared/icons/128-production.png rename to packages/react-devtools-extensions/icons/128-production.png diff --git a/packages/react-devtools-extensions/shared/icons/128-unminified.png b/packages/react-devtools-extensions/icons/128-unminified.png similarity index 100% rename from packages/react-devtools-extensions/shared/icons/128-unminified.png rename to packages/react-devtools-extensions/icons/128-unminified.png diff --git a/packages/react-devtools-extensions/shared/icons/16-deadcode.png b/packages/react-devtools-extensions/icons/16-deadcode.png similarity index 100% rename from packages/react-devtools-extensions/shared/icons/16-deadcode.png rename to packages/react-devtools-extensions/icons/16-deadcode.png diff --git a/packages/react-devtools-extensions/shared/icons/16-development.png b/packages/react-devtools-extensions/icons/16-development.png similarity index 100% rename from packages/react-devtools-extensions/shared/icons/16-development.png rename to packages/react-devtools-extensions/icons/16-development.png diff --git a/packages/react-devtools-extensions/shared/icons/16-disabled.png b/packages/react-devtools-extensions/icons/16-disabled.png similarity index 100% rename from packages/react-devtools-extensions/shared/icons/16-disabled.png rename to packages/react-devtools-extensions/icons/16-disabled.png diff --git a/packages/react-devtools-extensions/shared/icons/16-outdated.png b/packages/react-devtools-extensions/icons/16-outdated.png similarity index 100% rename from packages/react-devtools-extensions/shared/icons/16-outdated.png rename to packages/react-devtools-extensions/icons/16-outdated.png diff --git a/packages/react-devtools-extensions/shared/icons/16-production.png b/packages/react-devtools-extensions/icons/16-production.png similarity index 100% rename from packages/react-devtools-extensions/shared/icons/16-production.png rename to packages/react-devtools-extensions/icons/16-production.png diff --git a/packages/react-devtools-extensions/shared/icons/16-unminified.png b/packages/react-devtools-extensions/icons/16-unminified.png similarity index 100% rename from packages/react-devtools-extensions/shared/icons/16-unminified.png rename to packages/react-devtools-extensions/icons/16-unminified.png diff --git a/packages/react-devtools-extensions/shared/icons/32-deadcode.png b/packages/react-devtools-extensions/icons/32-deadcode.png similarity index 100% rename from packages/react-devtools-extensions/shared/icons/32-deadcode.png rename to packages/react-devtools-extensions/icons/32-deadcode.png diff --git a/packages/react-devtools-extensions/shared/icons/32-development.png b/packages/react-devtools-extensions/icons/32-development.png similarity index 100% rename from packages/react-devtools-extensions/shared/icons/32-development.png rename to packages/react-devtools-extensions/icons/32-development.png diff --git a/packages/react-devtools-extensions/shared/icons/32-disabled.png b/packages/react-devtools-extensions/icons/32-disabled.png similarity index 100% rename from packages/react-devtools-extensions/shared/icons/32-disabled.png rename to packages/react-devtools-extensions/icons/32-disabled.png diff --git a/packages/react-devtools-extensions/shared/icons/32-outdated.png b/packages/react-devtools-extensions/icons/32-outdated.png similarity index 100% rename from packages/react-devtools-extensions/shared/icons/32-outdated.png rename to packages/react-devtools-extensions/icons/32-outdated.png diff --git a/packages/react-devtools-extensions/shared/icons/32-production.png b/packages/react-devtools-extensions/icons/32-production.png similarity index 100% rename from packages/react-devtools-extensions/shared/icons/32-production.png rename to packages/react-devtools-extensions/icons/32-production.png diff --git a/packages/react-devtools-extensions/shared/icons/32-unminified.png b/packages/react-devtools-extensions/icons/32-unminified.png similarity index 100% rename from packages/react-devtools-extensions/shared/icons/32-unminified.png rename to packages/react-devtools-extensions/icons/32-unminified.png diff --git a/packages/react-devtools-extensions/shared/icons/48-deadcode.png b/packages/react-devtools-extensions/icons/48-deadcode.png similarity index 100% rename from packages/react-devtools-extensions/shared/icons/48-deadcode.png rename to packages/react-devtools-extensions/icons/48-deadcode.png diff --git a/packages/react-devtools-extensions/shared/icons/48-development.png b/packages/react-devtools-extensions/icons/48-development.png similarity index 100% rename from packages/react-devtools-extensions/shared/icons/48-development.png rename to packages/react-devtools-extensions/icons/48-development.png diff --git a/packages/react-devtools-extensions/shared/icons/48-disabled.png b/packages/react-devtools-extensions/icons/48-disabled.png similarity index 100% rename from packages/react-devtools-extensions/shared/icons/48-disabled.png rename to packages/react-devtools-extensions/icons/48-disabled.png diff --git a/packages/react-devtools-extensions/shared/icons/48-outdated.png b/packages/react-devtools-extensions/icons/48-outdated.png similarity index 100% rename from packages/react-devtools-extensions/shared/icons/48-outdated.png rename to packages/react-devtools-extensions/icons/48-outdated.png diff --git a/packages/react-devtools-extensions/shared/icons/48-production.png b/packages/react-devtools-extensions/icons/48-production.png similarity index 100% rename from packages/react-devtools-extensions/shared/icons/48-production.png rename to packages/react-devtools-extensions/icons/48-production.png diff --git a/packages/react-devtools-extensions/shared/icons/48-unminified.png b/packages/react-devtools-extensions/icons/48-unminified.png similarity index 100% rename from packages/react-devtools-extensions/shared/icons/48-unminified.png rename to packages/react-devtools-extensions/icons/48-unminified.png diff --git a/packages/react-devtools-extensions/shared/icons/deadcode.svg b/packages/react-devtools-extensions/icons/deadcode.svg similarity index 100% rename from packages/react-devtools-extensions/shared/icons/deadcode.svg rename to packages/react-devtools-extensions/icons/deadcode.svg diff --git a/packages/react-devtools-extensions/shared/icons/development.svg b/packages/react-devtools-extensions/icons/development.svg similarity index 100% rename from packages/react-devtools-extensions/shared/icons/development.svg rename to packages/react-devtools-extensions/icons/development.svg diff --git a/packages/react-devtools-extensions/shared/icons/disabled.svg b/packages/react-devtools-extensions/icons/disabled.svg similarity index 100% rename from packages/react-devtools-extensions/shared/icons/disabled.svg rename to packages/react-devtools-extensions/icons/disabled.svg diff --git a/packages/react-devtools-extensions/shared/icons/outdated.svg b/packages/react-devtools-extensions/icons/outdated.svg similarity index 100% rename from packages/react-devtools-extensions/shared/icons/outdated.svg rename to packages/react-devtools-extensions/icons/outdated.svg diff --git a/packages/react-devtools-extensions/shared/icons/production.svg b/packages/react-devtools-extensions/icons/production.svg similarity index 100% rename from packages/react-devtools-extensions/shared/icons/production.svg rename to packages/react-devtools-extensions/icons/production.svg diff --git a/packages/react-devtools-extensions/shared/main.html b/packages/react-devtools-extensions/main.html similarity index 100% rename from packages/react-devtools-extensions/shared/main.html rename to packages/react-devtools-extensions/main.html diff --git a/packages/react-devtools-extensions/shared/panel.html b/packages/react-devtools-extensions/panel.html similarity index 100% rename from packages/react-devtools-extensions/shared/panel.html rename to packages/react-devtools-extensions/panel.html diff --git a/packages/react-devtools-extensions/shared/popups/deadcode.html b/packages/react-devtools-extensions/popups/deadcode.html similarity index 100% rename from packages/react-devtools-extensions/shared/popups/deadcode.html rename to packages/react-devtools-extensions/popups/deadcode.html diff --git a/packages/react-devtools-extensions/shared/popups/development.html b/packages/react-devtools-extensions/popups/development.html similarity index 100% rename from packages/react-devtools-extensions/shared/popups/development.html rename to packages/react-devtools-extensions/popups/development.html diff --git a/packages/react-devtools-extensions/shared/popups/disabled.html b/packages/react-devtools-extensions/popups/disabled.html similarity index 100% rename from packages/react-devtools-extensions/shared/popups/disabled.html rename to packages/react-devtools-extensions/popups/disabled.html diff --git a/packages/react-devtools-extensions/shared/popups/outdated.html b/packages/react-devtools-extensions/popups/outdated.html similarity index 100% rename from packages/react-devtools-extensions/shared/popups/outdated.html rename to packages/react-devtools-extensions/popups/outdated.html diff --git a/packages/react-devtools-extensions/shared/popups/production.html b/packages/react-devtools-extensions/popups/production.html similarity index 100% rename from packages/react-devtools-extensions/shared/popups/production.html rename to packages/react-devtools-extensions/popups/production.html diff --git a/packages/react-devtools-extensions/shared/popups/shared.js b/packages/react-devtools-extensions/popups/shared.js similarity index 97% rename from packages/react-devtools-extensions/shared/popups/shared.js rename to packages/react-devtools-extensions/popups/shared.js index 0647e1c301a1e..ddb0456e5bbf3 100644 --- a/packages/react-devtools-extensions/shared/popups/shared.js +++ b/packages/react-devtools-extensions/popups/shared.js @@ -1,5 +1,7 @@ /* globals chrome */ +'use strict'; + document.addEventListener('DOMContentLoaded', function() { // Make links work const links = document.getElementsByTagName('a'); diff --git a/packages/react-devtools-extensions/shared/popups/unminified.html b/packages/react-devtools-extensions/popups/unminified.html similarity index 100% rename from packages/react-devtools-extensions/shared/popups/unminified.html rename to packages/react-devtools-extensions/popups/unminified.html diff --git a/packages/react-devtools-extensions/shared/src/backend.js b/packages/react-devtools-extensions/src/backend.js similarity index 95% rename from packages/react-devtools-extensions/shared/src/backend.js rename to packages/react-devtools-extensions/src/backend.js index 85277ec8f0e06..072e8de09f0ef 100644 --- a/packages/react-devtools-extensions/shared/src/backend.js +++ b/packages/react-devtools-extensions/src/backend.js @@ -4,6 +4,8 @@ /** @flow */ +'use strict'; + function welcome(event) { if ( event.source !== window || @@ -51,7 +53,7 @@ function setup(hook) { payload: {event, payload}, }, '*', - transferable + transferable, ); }, }); @@ -66,12 +68,12 @@ function setup(hook) { initBackend(hook, agent, window); // Setup React Native style editor if a renderer like react-native-web has injected it. - if (!!hook.resolveRNStyle) { + if (hook.resolveRNStyle) { setupNativeStyleEditor( bridge, agent, hook.resolveRNStyle, - hook.nativeStyleEditorValidAttributes + hook.nativeStyleEditorValidAttributes, ); } } diff --git a/packages/react-devtools-extensions/shared/src/background.js b/packages/react-devtools-extensions/src/background.js similarity index 98% rename from packages/react-devtools-extensions/shared/src/background.js rename to packages/react-devtools-extensions/src/background.js index 500e18fa57628..389ca1310a910 100644 --- a/packages/react-devtools-extensions/shared/src/background.js +++ b/packages/react-devtools-extensions/src/background.js @@ -1,5 +1,7 @@ /* global chrome */ +'use strict'; + const ports = {}; const IS_FIREFOX = navigator.userAgent.indexOf('Firefox') >= 0; @@ -37,7 +39,7 @@ function installContentScript(tabId: number) { chrome.tabs.executeScript( tabId, {file: '/build/contentScript.js'}, - function() {} + function() {}, ); } diff --git a/packages/react-devtools-extensions/shared/src/contentScript.js b/packages/react-devtools-extensions/src/contentScript.js similarity index 95% rename from packages/react-devtools-extensions/shared/src/contentScript.js rename to packages/react-devtools-extensions/src/contentScript.js index 68a44e21afcf5..c914c6e7b3dfc 100644 --- a/packages/react-devtools-extensions/shared/src/contentScript.js +++ b/packages/react-devtools-extensions/src/contentScript.js @@ -1,5 +1,7 @@ /* global chrome */ +'use strict'; + let backendDisconnected: boolean = false; let backendInitialized: boolean = false; @@ -9,7 +11,7 @@ function sayHelloToBackend() { source: 'react-devtools-content-script', hello: true, }, - '*' + '*', ); } @@ -19,7 +21,7 @@ function handleMessageFromDevtools(message) { source: 'react-devtools-content-script', payload: message, }, - '*' + '*', ); } @@ -48,12 +50,12 @@ function handleDisconnect() { event: 'shutdown', }, }, - '*' + '*', ); } // proxy from main page to devtools (via the background page) -var port = chrome.runtime.connect({ +const port = chrome.runtime.connect({ name: 'content-script', }); port.onMessage.addListener(handleMessageFromDevtools); diff --git a/packages/react-devtools-extensions/shared/src/inject.js b/packages/react-devtools-extensions/src/inject.js similarity index 100% rename from packages/react-devtools-extensions/shared/src/inject.js rename to packages/react-devtools-extensions/src/inject.js diff --git a/packages/react-devtools-extensions/shared/src/injectGlobalHook.js b/packages/react-devtools-extensions/src/injectGlobalHook.js similarity index 99% rename from packages/react-devtools-extensions/shared/src/injectGlobalHook.js rename to packages/react-devtools-extensions/src/injectGlobalHook.js index 9efb34ef2c88c..b56f9a299b378 100644 --- a/packages/react-devtools-extensions/shared/src/injectGlobalHook.js +++ b/packages/react-devtools-extensions/src/injectGlobalHook.js @@ -85,5 +85,5 @@ if (sessionStorageGetItem(SESSION_STORAGE_RELOAD_AND_PROFILE_KEY) === 'true') { // Inject a `__REACT_DEVTOOLS_GLOBAL_HOOK__` global so that React can detect that the // devtools are installed (and skip its suggestion to install the devtools). injectCode( - ';(' + installHook.toString() + '(window))' + saveNativeValues + detectReact + ';(' + installHook.toString() + '(window))' + saveNativeValues + detectReact, ); diff --git a/packages/react-devtools-extensions/shared/src/main.js b/packages/react-devtools-extensions/src/main.js similarity index 94% rename from packages/react-devtools-extensions/shared/src/main.js rename to packages/react-devtools-extensions/src/main.js index ae1182c6a69d7..88ced54db1535 100644 --- a/packages/react-devtools-extensions/shared/src/main.js +++ b/packages/react-devtools-extensions/src/main.js @@ -33,15 +33,15 @@ function syncSavedPreferences() { const componentFilters = getSavedComponentFilters(); chrome.devtools.inspectedWindow.eval( `window.__REACT_DEVTOOLS_COMPONENT_FILTERS__ = ${JSON.stringify( - componentFilters - )};` + componentFilters, + )};`, ); const appendComponentStack = getAppendComponentStack(); chrome.devtools.inspectedWindow.eval( `window.__REACT_DEVTOOLS_APPEND_COMPONENT_STACK__ = ${JSON.stringify( - appendComponentStack - )};` + appendComponentStack, + )};`, ); } @@ -133,7 +133,7 @@ function createPanelIfReactLoaded() { const viewElementSourceFunction = createViewElementSource( bridge, - store + store, ); root = createRoot(document.createElement('div')); @@ -152,7 +152,7 @@ function createPanelIfReactLoaded() { showWelcomeToTheNewDevToolsDialog: true, store, viewElementSourceFunction, - }) + }), ); }; @@ -161,9 +161,11 @@ function createPanelIfReactLoaded() { cloneStyleTags = () => { const linkTags = []; + // eslint-disable-next-line no-for-of-loops/no-for-of-loops for (let linkTag of document.getElementsByTagName('link')) { if (linkTag.rel === 'stylesheet') { const newLinkTag = document.createElement('link'); + // eslint-disable-next-line no-for-of-loops/no-for-of-loops for (let attribute of linkTag.attributes) { newLinkTag.setAttribute(attribute.nodeName, attribute.nodeValue); } @@ -191,11 +193,11 @@ function createPanelIfReactLoaded() { '(window.__REACT_DEVTOOLS_GLOBAL_HOOK__.$0 !== $0) ?' + '(inspect(window.__REACT_DEVTOOLS_GLOBAL_HOOK__.$0), true) :' + 'false', - (didSelectionChange, error) => { - if (error) { - console.error(error); + (didSelectionChange, evalError) => { + if (evalError) { + console.error(evalError); } - } + }, ); } @@ -206,14 +208,14 @@ function createPanelIfReactLoaded() { '(window.__REACT_DEVTOOLS_GLOBAL_HOOK__.$0 !== $0) ?' + '(window.__REACT_DEVTOOLS_GLOBAL_HOOK__.$0 = $0, true) :' + 'false', - (didSelectionChange, error) => { - if (error) { - console.error(error); + (didSelectionChange, evalError) => { + if (evalError) { + console.error(evalError); } else if (didSelectionChange) { // Remember to sync the selection next time we show Components tab. needsToSyncElementSelection = true; } - } + }, ); } @@ -226,7 +228,7 @@ function createPanelIfReactLoaded() { let needsToSyncElementSelection = false; chrome.devtools.panels.create('⚛ Components', '', 'panel.html', panel => { - panel.onShown.addListener(panel => { + panel.onShown.addListener(() => { if (needsToSyncElementSelection) { needsToSyncElementSelection = false; bridge.send('syncSelectionFromNativeElementsPanel'); @@ -251,7 +253,7 @@ function createPanelIfReactLoaded() { }); chrome.devtools.panels.create('⚛ Profiler', '', 'panel.html', panel => { - panel.onShown.addListener(panel => { + panel.onShown.addListener(() => { if (currentPanel === panel) { return; } @@ -281,7 +283,7 @@ function createPanelIfReactLoaded() { bridge.shutdown(); profilingData = store.profilerStore.profilingData; - } + }, ); // Re-initialize DevTools panel when a new page is loaded. @@ -298,7 +300,7 @@ function createPanelIfReactLoaded() { }); }); }); - } + }, ); } diff --git a/packages/react-devtools-extensions/shared/src/panel.js b/packages/react-devtools-extensions/src/panel.js similarity index 89% rename from packages/react-devtools-extensions/shared/src/panel.js rename to packages/react-devtools-extensions/src/panel.js index f84ac11beb1e7..de7d8a68fc5ff 100644 --- a/packages/react-devtools-extensions/shared/src/panel.js +++ b/packages/react-devtools-extensions/src/panel.js @@ -11,6 +11,7 @@ window.injectStyles = getLinkTags => { const linkTags = getLinkTags(); + // eslint-disable-next-line no-for-of-loops/no-for-of-loops for (let linkTag of linkTags) { document.head.appendChild(linkTag); } diff --git a/packages/react-devtools-extensions/shared/src/renderer.js b/packages/react-devtools-extensions/src/renderer.js similarity index 98% rename from packages/react-devtools-extensions/shared/src/renderer.js rename to packages/react-devtools-extensions/src/renderer.js index 8b099b437f3a6..933fd5d6b8a6a 100644 --- a/packages/react-devtools-extensions/shared/src/renderer.js +++ b/packages/react-devtools-extensions/src/renderer.js @@ -22,5 +22,5 @@ Object.defineProperty( get() { return attach; }, - }: Object) + }: Object), ); diff --git a/packages/react-devtools-extensions/shared/src/utils.js b/packages/react-devtools-extensions/src/utils.js similarity index 100% rename from packages/react-devtools-extensions/shared/src/utils.js rename to packages/react-devtools-extensions/src/utils.js diff --git a/packages/react-devtools-extensions/shared/webpack.backend.js b/packages/react-devtools-extensions/webpack.backend.js similarity index 98% rename from packages/react-devtools-extensions/shared/webpack.backend.js rename to packages/react-devtools-extensions/webpack.backend.js index ccca69b347ea4..f206f9d9c7b66 100644 --- a/packages/react-devtools-extensions/shared/webpack.backend.js +++ b/packages/react-devtools-extensions/webpack.backend.js @@ -1,3 +1,5 @@ +'use strict'; + const {resolve} = require('path'); const {DefinePlugin} = require('webpack'); const {getGitHubURL, getVersionString} = require('../utils'); diff --git a/packages/react-devtools-extensions/shared/webpack.config.js b/packages/react-devtools-extensions/webpack.config.js similarity index 99% rename from packages/react-devtools-extensions/shared/webpack.config.js rename to packages/react-devtools-extensions/webpack.config.js index c2b56e66af828..ff5d89c5a33d4 100644 --- a/packages/react-devtools-extensions/shared/webpack.config.js +++ b/packages/react-devtools-extensions/webpack.config.js @@ -1,3 +1,5 @@ +'use strict'; + const {resolve} = require('path'); const {DefinePlugin} = require('webpack'); const {getGitHubURL, getVersionString} = require('../utils'); diff --git a/packages/react-devtools-inline/src/backend.js b/packages/react-devtools-inline/src/backend.js index 55a6aea49af4b..0528e2018d1c1 100644 --- a/packages/react-devtools-inline/src/backend.js +++ b/packages/react-devtools-inline/src/backend.js @@ -77,7 +77,7 @@ function finishActivation(contentWindow: window) { initBackend(hook, agent, contentWindow); // Setup React Native style editor if a renderer like react-native-web has injected it. - if (!!hook.resolveRNStyle) { + if (hook.resolveRNStyle) { setupNativeStyleEditor( bridge, agent, diff --git a/packages/react-devtools-inline/src/frontend.js b/packages/react-devtools-inline/src/frontend.js index 083848c63c38a..286d1c28a65f0 100644 --- a/packages/react-devtools-inline/src/frontend.js +++ b/packages/react-devtools-inline/src/frontend.js @@ -19,7 +19,7 @@ import type {Props} from 'react-devtools-shared/src/devtools/views/DevTools'; export function initialize( contentWindow: window, ): React.AbstractComponent { - const onMessage = ({data, source}) => { + const onGetSavedPreferencesMessage = ({data, source}) => { if (source === 'react-devtools-content-script') { // Ignore messages from the DevTools browser extension. } @@ -28,7 +28,7 @@ export function initialize( case MESSAGE_TYPE_GET_SAVED_PREFERENCES: // This is the only message we're listening for, // so it's safe to cleanup after we've received it. - window.removeEventListener('message', onMessage); + window.removeEventListener('message', onGetSavedPreferencesMessage); // The renderer interface can't read saved preferences directly, // because they are stored in localStorage within the context of the extension. @@ -47,7 +47,7 @@ export function initialize( } }; - window.addEventListener('message', onMessage); + window.addEventListener('message', onGetSavedPreferencesMessage); const bridge: FrontendBridge = new Bridge({ listen(fn) { diff --git a/packages/react-devtools-shared/src/__tests__/profilingCache-test.js b/packages/react-devtools-shared/src/__tests__/profilingCache-test.js index a98345fa54d86..9e5a9b48bfb4d 100644 --- a/packages/react-devtools-shared/src/__tests__/profilingCache-test.js +++ b/packages/react-devtools-shared/src/__tests__/profilingCache-test.js @@ -374,8 +374,7 @@ describe('ProfilingCache', () => { }; const Async = () => { Scheduler.unstable_advanceTime(3); - const data = getData(); - return data; + return getData(); }; utils.act(() => store.profilerStore.startProfiling()); diff --git a/packages/react-devtools-shared/src/__tests__/storeStressSync-test.js b/packages/react-devtools-shared/src/__tests__/storeStressSync-test.js index 37ea32475ad2b..9ee05f6eba90a 100644 --- a/packages/react-devtools-shared/src/__tests__/storeStressSync-test.js +++ b/packages/react-devtools-shared/src/__tests__/storeStressSync-test.js @@ -103,7 +103,7 @@ describe('StoreStress (Sync Mode)', () => { [a, b, [c,
{d}{e}
], ''], [a, [[]], b, c, [d, [[]], e]], [[[a, b, c, d], e]], - [a, b, c, d, e] + [a, b, c, d, e], ]; // 5. Test fresh mount for each case. @@ -214,7 +214,7 @@ describe('StoreStress (Sync Mode)', () => { // 2. Verify that we can update from every step to every other step and back. for (let i = 0; i < steps.length; i++) { for (let j = 0; j < steps.length; j++) { - let container = document.createElement('div'); + container = document.createElement('div'); act(() => ReactDOM.render({steps[i]}, container)); expect(print(store)).toMatch(snapshots[i]); act(() => ReactDOM.render({steps[j]}, container)); @@ -229,7 +229,7 @@ describe('StoreStress (Sync Mode)', () => { // 3. Same test as above, but this time we wrap children in a host component. for (let i = 0; i < steps.length; i++) { for (let j = 0; j < steps.length; j++) { - let container = document.createElement('div'); + container = document.createElement('div'); act(() => ReactDOM.render( @@ -288,7 +288,7 @@ describe('StoreStress (Sync Mode)', () => { [[a]], null, b, - a + a, ]; const Never = () => { @@ -578,7 +578,6 @@ describe('StoreStress (Sync Mode)', () => { // Force fallback. expect(print(store)).toEqual(snapshots[i]); act(() => { - const suspenseID = store.getElementIDAtIndex(2); bridge.send('overrideSuspense', { id: suspenseID, rendererID: store.getRendererIDForElement(suspenseID), @@ -682,7 +681,7 @@ describe('StoreStress (Sync Mode)', () => { [[a]], null, b, - a + a, ]; const Never = () => { @@ -1014,7 +1013,6 @@ describe('StoreStress (Sync Mode)', () => { // Force fallback. expect(print(store)).toEqual(snapshots[i]); act(() => { - const suspenseID = store.getElementIDAtIndex(2); bridge.send('overrideSuspense', { id: suspenseID, rendererID: store.getRendererIDForElement(suspenseID), diff --git a/packages/react-devtools-shared/src/__tests__/storeStressTestConcurrent-test.js b/packages/react-devtools-shared/src/__tests__/storeStressTestConcurrent-test.js index f219c7f813c3c..8e72f41f1a9c7 100644 --- a/packages/react-devtools-shared/src/__tests__/storeStressTestConcurrent-test.js +++ b/packages/react-devtools-shared/src/__tests__/storeStressTestConcurrent-test.js @@ -105,7 +105,7 @@ describe('StoreStressConcurrent', () => { [a, b, [c,
{d}{e}
], ''], [a, [[]], b, c, [d, [[]], e]], [[[a, b, c, d], e]], - [a, b, c, d, e] + [a, b, c, d, e], ]; // 5. Test fresh mount for each case. @@ -222,9 +222,9 @@ describe('StoreStressConcurrent', () => { // 2. Verify that we can update from every step to every other step and back. for (let i = 0; i < steps.length; i++) { for (let j = 0; j < steps.length; j++) { - let container = document.createElement('div'); + container = document.createElement('div'); // $FlowFixMe - let root = ReactDOM.unstable_createRoot(container); + root = ReactDOM.unstable_createRoot(container); act(() => root.render({steps[i]})); expect(print(store)).toMatch(snapshots[i]); act(() => root.render({steps[j]})); @@ -239,9 +239,9 @@ describe('StoreStressConcurrent', () => { // 3. Same test as above, but this time we wrap children in a host component. for (let i = 0; i < steps.length; i++) { for (let j = 0; j < steps.length; j++) { - let container = document.createElement('div'); + container = document.createElement('div'); // $FlowFixMe - let root = ReactDOM.unstable_createRoot(container); + root = ReactDOM.unstable_createRoot(container); act(() => root.render( @@ -297,7 +297,7 @@ describe('StoreStressConcurrent', () => { [[a]], null, b, - a + a, ]; const Never = () => { @@ -584,7 +584,6 @@ describe('StoreStressConcurrent', () => { // Force fallback. expect(print(store)).toEqual(snapshots[i]); act(() => { - const suspenseID = store.getElementIDAtIndex(2); bridge.send('overrideSuspense', { id: suspenseID, rendererID: store.getRendererIDForElement(suspenseID), @@ -686,7 +685,7 @@ describe('StoreStressConcurrent', () => { [[a]], null, b, - a + a, ]; const Never = () => { @@ -1015,7 +1014,6 @@ describe('StoreStressConcurrent', () => { // Force fallback. expect(print(store)).toEqual(snapshots[i]); act(() => { - const suspenseID = store.getElementIDAtIndex(2); bridge.send('overrideSuspense', { id: suspenseID, rendererID: store.getRendererIDForElement(suspenseID), diff --git a/packages/react-devtools-shared/src/__tests__/treeContext-test.js b/packages/react-devtools-shared/src/__tests__/treeContext-test.js index 3983b156eec27..1834e615c48e8 100644 --- a/packages/react-devtools-shared/src/__tests__/treeContext-test.js +++ b/packages/react-devtools-shared/src/__tests__/treeContext-test.js @@ -98,7 +98,7 @@ describe('TreeListContext', () => { const index = ((state.selectedElementIndex: any): number); utils.act(() => dispatch({type: 'SELECT_NEXT_ELEMENT_IN_TREE'})); utils.act(() => renderer.update()); - expect(state).toMatchSnapshot(`3: select element after (${index})`); + expect(state).toMatchSnapshot(`3: select element after (${index})`); } while ( diff --git a/packages/react-devtools-shared/src/__tests__/utils.js b/packages/react-devtools-shared/src/__tests__/utils.js index 1679ab5dcae2a..8501f30b19877 100644 --- a/packages/react-devtools-shared/src/__tests__/utils.js +++ b/packages/react-devtools-shared/src/__tests__/utils.js @@ -78,7 +78,7 @@ export function createDisplayNameFilter( const Types = require('react-devtools-shared/src/types'); let isValid = true; try { - new RegExp(source); + new RegExp(source); // eslint-disable-line no-new } catch (error) { isValid = false; } @@ -118,7 +118,7 @@ export function createLocationFilter( const Types = require('react-devtools-shared/src/types'); let isValid = true; try { - new RegExp(source); + new RegExp(source); // eslint-disable-line no-new } catch (error) { isValid = false; } @@ -136,8 +136,8 @@ export function getRendererID(): number { } const ids = Object.keys(global.agent._rendererInterfaces); - const id = ids.find(id => { - const rendererInterface = global.agent._rendererInterfaces[id]; + const id = ids.find(innerID => { + const rendererInterface = global.agent._rendererInterfaces[innerID]; return rendererInterface.renderer.rendererPackageName === 'react-dom'; }); @@ -162,7 +162,6 @@ export function requireTestRenderer(): ReactTestRenderer { } export function exportImportHelper(bridge: FrontendBridge, store: Store): void { - const {act} = require('./utils'); const { prepareProfilingDataExport, prepareProfilingDataFrontendFromExport, diff --git a/packages/react-devtools-shared/src/backend/NativeStyleEditor/resolveBoxStyle.js b/packages/react-devtools-shared/src/backend/NativeStyleEditor/resolveBoxStyle.js index 3a25494131520..5b8005fab9783 100644 --- a/packages/react-devtools-shared/src/backend/NativeStyleEditor/resolveBoxStyle.js +++ b/packages/react-devtools-shared/src/backend/NativeStyleEditor/resolveBoxStyle.js @@ -24,6 +24,7 @@ export default function resolveBoxStyle( const styleForAll = style[prefix]; if (styleForAll != null) { + // eslint-disable-next-line no-for-of-loops/no-for-of-loops for (const key of Object.keys(result)) { result[key] = styleForAll; } diff --git a/packages/react-devtools-shared/src/backend/console.js b/packages/react-devtools-shared/src/backend/console.js index 8bcc242a5848b..765f0381000b8 100644 --- a/packages/react-devtools-shared/src/backend/console.js +++ b/packages/react-devtools-shared/src/backend/console.js @@ -92,6 +92,7 @@ export function patch(): void { if (!alreadyHasComponentStack) { // If there's a component stack for at least one of the injected renderers, append it. // We don't handle the edge case of stacks for more than one (e.g. interleaved renderers?) + // eslint-disable-next-line no-for-of-loops/no-for-of-loops for (let { getCurrentFiber, getDisplayNameForFiber, diff --git a/packages/react-devtools-shared/src/backend/legacy/renderer.js b/packages/react-devtools-shared/src/backend/legacy/renderer.js index a892bdedcd5de..dfed4c433f988 100644 --- a/packages/react-devtools-shared/src/backend/legacy/renderer.js +++ b/packages/react-devtools-shared/src/backend/legacy/renderer.js @@ -44,7 +44,7 @@ function getData(internalInstance: InternalInstance) { // != used deliberately here to catch undefined and null if (internalInstance._currentElement != null) { if (internalInstance._currentElement.key) { - key = String(internalInstance._currentElement.key); + key = '' + internalInstance._currentElement.key; } const elementType = internalInstance._currentElement.type; diff --git a/packages/react-devtools-shared/src/backend/renderer.js b/packages/react-devtools-shared/src/backend/renderer.js index cfedcf883c286..b4f466c16157e 100644 --- a/packages/react-devtools-shared/src/backend/renderer.js +++ b/packages/react-devtools-shared/src/backend/renderer.js @@ -657,6 +657,7 @@ export function attach( if (hideElementsWithDisplayNames.size > 0) { const displayName = getDisplayNameForFiber(fiber); if (displayName != null) { + // eslint-disable-next-line no-for-of-loops/no-for-of-loops for (let displayNameRegExp of hideElementsWithDisplayNames) { if (displayNameRegExp.test(displayName)) { return true; @@ -667,6 +668,7 @@ export function attach( if (_debugSource != null && hideElementsWithPaths.size > 0) { const {fileName} = _debugSource; + // eslint-disable-next-line no-for-of-loops/no-for-of-loops for (let pathRegExp of hideElementsWithPaths) { if (pathRegExp.test(fileName)) { return true; @@ -940,6 +942,7 @@ export function attach( const keys = new Set([...Object.keys(prev), ...Object.keys(next)]); const changedKeys = []; + // eslint-disable-next-line no-for-of-loops/no-for-of-loops for (let key of keys) { if (prev[key] !== next[key]) { changedKeys.push(key); @@ -1316,7 +1319,7 @@ export function attach( const id = getFiberID(getPrimaryFiber(fiber)); const {actualDuration, treeBaseDuration} = fiber; - idToTreeBaseDurationMap.set(id, fiber.treeBaseDuration || 0); + idToTreeBaseDurationMap.set(id, treeBaseDuration || 0); if (isProfiling) { const {alternate} = fiber; @@ -1327,12 +1330,12 @@ export function attach( ) { // Tree base duration updates are included in the operations typed array. // So we have to convert them from milliseconds to microseconds so we can send them as ints. - const treeBaseDuration = Math.floor( - (fiber.treeBaseDuration || 0) * 1000, + const convertedTreeBaseDuration = Math.floor( + (treeBaseDuration || 0) * 1000, ); pushOperation(TREE_OPERATION_UPDATE_TREE_BASE_DURATION); pushOperation(id); - pushOperation(treeBaseDuration); + pushOperation(convertedTreeBaseDuration); } if (alternate == null || didFiberRender(alternate, fiber)) { diff --git a/packages/react-devtools-shared/src/constants.js b/packages/react-devtools-shared/src/constants.js index c538ddbfb60fe..641602e3d82ed 100644 --- a/packages/react-devtools-shared/src/constants.js +++ b/packages/react-devtools-shared/src/constants.js @@ -39,7 +39,7 @@ let COMPACT_LINE_HEIGHT; try { // $FlowFixMe - const rawStyleString = require('!!raw-loader!src/devtools/views/root.css') // eslint-disable-line import/no-webpack-loader-syntax + const rawStyleString = require('!!raw-loader!react-devtools-shared/src/devtools/views/root.css') .default; const extractVar = varName => { diff --git a/packages/react-devtools-shared/src/devtools/ProfilerStore.js b/packages/react-devtools-shared/src/devtools/ProfilerStore.js index 4967ef1b38a9e..53689d24f2f99 100644 --- a/packages/react-devtools-shared/src/devtools/ProfilerStore.js +++ b/packages/react-devtools-shared/src/devtools/ProfilerStore.js @@ -43,7 +43,7 @@ export default class ProfilerStore extends EventEmitter<{| // Snapshot of the state of the main Store (including all roots) when profiling started. // Once profiling is finished, this snapshot can be used along with "operations" messages emitted during profiling, - // to reconstruct the state of each root for each commit. + // to reconstruct the state of each root for each commit. // It's okay to use a single root to store this information because node IDs are unique across all roots. // // This map is initialized when profiling starts and updated when a new root is added while profiling; @@ -52,7 +52,7 @@ export default class ProfilerStore extends EventEmitter<{| // Map of root (id) to a list of tree mutation that occur during profiling. // Once profiling is finished, these mutations can be used, along with the initial tree snapshots, - // to reconstruct the state of each root for each commit. + // to reconstruct the state of each root for each commit. // // This map is only updated while profiling is in progress; // Upon completion, it is converted into the exportable ProfilingDataFrontend format. @@ -283,6 +283,7 @@ export default class ProfilerStore extends EventEmitter<{| this._rendererQueue.clear(); // Record all renderer IDs initially too (in case of unmount) + // eslint-disable-next-line no-for-of-loops/no-for-of-loops for (let rendererID of this._store.rootIDToRendererID.values()) { if (!this._initialRendererIDs.has(rendererID)) { this._initialRendererIDs.add(rendererID); diff --git a/packages/react-devtools-shared/src/devtools/cache.js b/packages/react-devtools-shared/src/devtools/cache.js index 6c2abe0d8934b..720ea17e9dc18 100644 --- a/packages/react-devtools-shared/src/devtools/cache.js +++ b/packages/react-devtools-shared/src/devtools/cache.js @@ -143,7 +143,6 @@ export function createResource( read(input: Input): Value { // Prevent access outside of render. - // eslint-disable-next-line react-hooks/rules-of-hooks readContext(CacheContext); const key = hashInput(input); @@ -169,7 +168,6 @@ export function createResource( preload(input: Input): void { // Prevent access outside of render. - // eslint-disable-next-line react-hooks/rules-of-hooks readContext(CacheContext); const key = hashInput(input); diff --git a/packages/react-devtools-shared/src/devtools/store.js b/packages/react-devtools-shared/src/devtools/store.js index 5a8e844107b1c..cc657bdec4a45 100644 --- a/packages/react-devtools-shared/src/devtools/store.js +++ b/packages/react-devtools-shared/src/devtools/store.js @@ -484,9 +484,9 @@ export default class Store extends EventEmitter<{| // (1) another node that's already in the tree, or (2) the root (owner) // at which point, our depth is just the depth of that node plus one. sortedIDs.forEach(id => { - const element = this._idToElement.get(id); - if (element != null) { - let parentID = element.parentID; + const innerElement = this._idToElement.get(id); + if (innerElement != null) { + let parentID = innerElement.parentID; let depth = 0; while (parentID > 0) { @@ -506,7 +506,7 @@ export default class Store extends EventEmitter<{| throw Error('Invalid owners list'); } - list.push({...element, depth}); + list.push({...innerElement, depth}); } }); } @@ -717,7 +717,7 @@ export default class Store extends EventEmitter<{| const id = ((operations[i + 1]: any): number); const type = ((operations[i + 2]: any): ElementType); - i = i + 3; + i += 3; if (this._idToElement.has(id)) { throw Error( @@ -829,7 +829,7 @@ export default class Store extends EventEmitter<{| } case TREE_OPERATION_REMOVE: { const removeLength = ((operations[i + 1]: any): number); - i = i + 2; + i += 2; for (let removeIndex = 0; removeIndex < removeLength; removeIndex++) { const id = ((operations[i]: any): number); @@ -840,7 +840,7 @@ export default class Store extends EventEmitter<{| ); } - i = i + 1; + i += 1; const element = ((this._idToElement.get(id): any): Element); const {children, ownerID, parentID, weight} = element; @@ -891,7 +891,7 @@ export default class Store extends EventEmitter<{| case TREE_OPERATION_REORDER_CHILDREN: { const id = ((operations[i + 1]: any): number); const numChildren = ((operations[i + 2]: any): number); - i = i + 3; + i += 3; if (!this._idToElement.has(id)) { throw Error( @@ -920,7 +920,7 @@ export default class Store extends EventEmitter<{| } } } - i = i + numChildren; + i += numChildren; if (__DEBUG__) { debug('Re-order', `Node ${id} children ${children.join(',')}`); @@ -931,7 +931,7 @@ export default class Store extends EventEmitter<{| // Base duration updates are only sent while profiling is in progress. // We can ignore them at this point. // The profiler UI uses them lazily in order to generate the tree. - i = i + 3; + i += 3; break; default: throw Error(`Unsupported Bridge operation ${operation}`); diff --git a/packages/react-devtools-shared/src/devtools/views/Components/HooksTree.js b/packages/react-devtools-shared/src/devtools/views/Components/HooksTree.js index 2bc07bd4d9915..5b239ee5231c4 100644 --- a/packages/react-devtools-shared/src/devtools/views/Components/HooksTree.js +++ b/packages/react-devtools-shared/src/devtools/views/Components/HooksTree.js @@ -211,7 +211,10 @@ function HookView({canEditHooks, hook, id, inspectPath, path}: HookViewProps) { let overrideValueFn = null; // TODO Maybe read editable value from debug hook? if (canEditHooks && isStateEditable) { - overrideValueFn = (absolutePath: Array, value: any) => { + overrideValueFn = ( + absolutePath: Array, + newValue: any, + ) => { const rendererID = store.getRendererIDForElement(id); if (rendererID !== null) { bridge.send('overrideHookState', { @@ -223,7 +226,7 @@ function HookView({canEditHooks, hook, id, inspectPath, path}: HookViewProps) { // so it's important that we remove that part of the path before sending the update. path: absolutePath.slice(path.length + 1), rendererID, - value, + value: newValue, }); } }; diff --git a/packages/react-devtools-shared/src/devtools/views/Components/InspectedElementContext.js b/packages/react-devtools-shared/src/devtools/views/Components/InspectedElementContext.js index a31229ace1c2d..1f0f994ab0a58 100644 --- a/packages/react-devtools-shared/src/devtools/views/Components/InspectedElementContext.js +++ b/packages/react-devtools-shared/src/devtools/views/Components/InspectedElementContext.js @@ -20,7 +20,6 @@ import type { InspectedElementPayload, } from 'react-devtools-shared/src/backend/types'; import type { - DehydratedData, Element, InspectedElement as InspectedElementFrontend, } from 'react-devtools-shared/src/devtools/views/Components/types'; @@ -280,7 +279,6 @@ function InspectedElementContextController({children}: Props) { const value = useMemo( () => ({getInspectedElement, getInspectedElementPath}), // InspectedElement is used to invalidate the cache and schedule an update with React. - // eslint-disable-next-line react-hooks/exhaustive-deps [currentlyInspectedElement, getInspectedElement, getInspectedElementPath], ); diff --git a/packages/react-devtools-shared/src/devtools/views/Components/KeyValue.js b/packages/react-devtools-shared/src/devtools/views/Components/KeyValue.js index d312789c40e50..19f3998972f5c 100644 --- a/packages/react-devtools-shared/src/devtools/views/Components/KeyValue.js +++ b/packages/react-devtools-shared/src/devtools/views/Components/KeyValue.js @@ -154,18 +154,20 @@ export default function KeyValue({ } else { const hasChildren = Object.entries(value).length > 0; - children = Object.entries(value).map>(([name, value]) => ( -