Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linting globals need work #1485

Closed
zepumph opened this issue Oct 11, 2024 · 8 comments
Closed

Linting globals need work #1485

zepumph opened this issue Oct 11, 2024 · 8 comments

Comments

@zepumph
Copy link
Member

zepumph commented Oct 11, 2024

Lots of awkward linting globals revealed themselves as we worked on #1451. Basically phetSimBrowserGlobals includes many browser-specific globals, but the object is used in the root config, which also needs to support node code. There are also many spots to only use certain globals where needed, or maybe delete some. Search for TODOs linking here as the main part of this issue.

zepumph added a commit that referenced this issue Oct 11, 2024
zepumph added a commit to phetsims/perennial that referenced this issue Oct 22, 2024
@samreid samreid self-assigned this Oct 24, 2024
@samreid
Copy link
Member

samreid commented Oct 24, 2024

I moved the phetSimBrowserGlobals out of root, and it is going very well. With this patch, perennial and chipper are linting correctly:

Subject: [PATCH] Use tsxCommand instead of 'node', force precommit hooks in precommit-hook-multi, see https://github.com/phetsims/perennial/issues/379
---
Index: perennial-alias/eslint.config.mjs
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/perennial-alias/eslint.config.mjs b/perennial-alias/eslint.config.mjs
--- a/perennial-alias/eslint.config.mjs	(revision 8ec75342097dd4e6e4b46d1af606b9d569d921d0)
+++ b/perennial-alias/eslint.config.mjs	(date 1729810509416)
@@ -1,13 +1,45 @@
 // Copyright 2024, University of Colorado Boulder
 
-import nodeEslintConfig from './js/eslint/node.eslint.config.mjs';
+import globals from 'globals';
+import { getBrowserConfiguration } from '../perennial-alias/js/eslint/browser.eslint.config.mjs';
+import getNodeConfiguration from '../perennial-alias/js/eslint/getNodeConfiguration.mjs';
+
+import phetSimBrowserGlobalsEslintConfig from '../perennial-alias/js/eslint/phetSimBrowserGlobals.eslint.config.mjs';
+import rootEslintConfig from '../perennial-alias/js/eslint/root.eslint.config.mjs';
+
+const browserFiles = [
+  'js/common/SimVersion.js',
+  'js/grunt/decaf/getPreloads.js',
+  'js/scripts/test/release-branch-checks.js',
+  'js/test/puppeteerQUnit.js'
+];
 
 /**
  * @author Sam Reid (PhET Interactive Simulations)
  * @author Michael Kauzmann (PhET Interactive Simulations)
  */
 export default [
-  ...nodeEslintConfig,
+  ...rootEslintConfig,
+  ...getBrowserConfiguration( { files: browserFiles } ),
+  ...getNodeConfiguration( {
+    files: [ '**/*' ],
+    ignores: browserFiles
+  } ),
+  {
+    files: browserFiles,
+    ...phetSimBrowserGlobalsEslintConfig
+
+  },
+  {
+    files: browserFiles,
+    languageOptions: {
+      globals: {
+
+        // UMD files also get require
+        ...globals.node
+      }
+    }
+  },
   {
     rules: {
 
Index: perennial-alias/js/eslint/sim.eslint.config.mjs
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/perennial-alias/js/eslint/sim.eslint.config.mjs b/perennial-alias/js/eslint/sim.eslint.config.mjs
--- a/perennial-alias/js/eslint/sim.eslint.config.mjs	(revision 8ec75342097dd4e6e4b46d1af606b9d569d921d0)
+++ b/perennial-alias/js/eslint/sim.eslint.config.mjs	(date 1729809798041)
@@ -3,6 +3,7 @@
 import assert from 'assert';
 import { getBrowserConfiguration } from './browser.eslint.config.mjs';
 import rootEslintConfig from './root.eslint.config.mjs';
+import phetSimBrowserGlobalsEslintConfig from './phetSimBrowserGlobals.eslint.config.mjs';
 
 // Ensure the pattern only applies to HTML files.
 const getHTMLPatterns = pattern => {
@@ -24,6 +25,7 @@
 
   return [
     ...getBrowserConfiguration( pattern ),
+    phetSimBrowserGlobalsEslintConfig,
     {
       rules: {
         'phet/bad-sim-text': 'error'
Index: chipper/eslint.config.mjs
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/chipper/eslint.config.mjs b/chipper/eslint.config.mjs
--- a/chipper/eslint.config.mjs	(revision 26e5ed0159285b96b23051422d60c9b640a019c9)
+++ b/chipper/eslint.config.mjs	(date 1729810119532)
@@ -9,11 +9,18 @@
 
 import { getBrowserConfiguration } from '../perennial-alias/js/eslint/browser.eslint.config.mjs';
 import getNodeConfiguration from '../perennial-alias/js/eslint/getNodeConfiguration.mjs';
+
+import phetSimBrowserGlobalsEslintConfig from '../perennial-alias/js/eslint/phetSimBrowserGlobals.eslint.config.mjs';
 import rootEslintConfig from '../perennial-alias/js/eslint/root.eslint.config.mjs';
 
 const browserFiles = [
   'js/*', // not recursive
-  'js/sim-tests/**/*'
+  'js/sim-tests/**/*',
+
+  // These files can optionally run in the browser, so they can use browser-capable linting
+  'js/common/documentationToHTML.js',
+  'js/common/extractDocumentation.js',
+  'js/phet-io/phetioCompareAPIs.js'
 ];
 
 export default [
@@ -24,6 +31,10 @@
     ignores: browserFiles
   } ),
   {
+    files: browserFiles,
+    ...phetSimBrowserGlobalsEslintConfig
+  },
+  {
     rules: {
       'phet/bad-chipper-text': 'error'
     }
Index: chipper/js/grunt/GruntfileTests.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/chipper/js/grunt/GruntfileTests.js b/chipper/js/grunt/GruntfileTests.js
--- a/chipper/js/grunt/GruntfileTests.js	(revision 26e5ed0159285b96b23051422d60c9b640a019c9)
+++ b/chipper/js/grunt/GruntfileTests.js	(date 1729810038631)
@@ -8,7 +8,6 @@
 
 
 const qunit = require( 'qunit' );
-// eslint-disable-next-line phet/require-statement-match
 const { execSync } = require( 'child_process' );
 qunit.module( 'GruntfileTests' );
 
Index: chipper/js/grunt/webpackBuild.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/chipper/js/grunt/webpackBuild.ts b/chipper/js/grunt/webpackBuild.ts
--- a/chipper/js/grunt/webpackBuild.ts	(revision 26e5ed0159285b96b23051422d60c9b640a019c9)
+++ b/chipper/js/grunt/webpackBuild.ts	(date 1729810046094)
@@ -14,7 +14,6 @@
 
 const webpackGlobalLibraries = require( '../common/webpackGlobalLibraries' );
 const webpack = require( 'webpack' );
-// eslint-disable-next-line phet/require-statement-match
 const { ModifySourcePlugin, ConcatOperation } = require( 'modify-source-webpack-plugin' );
 
 const activeRepos = fs.readFileSync( path.resolve( __dirname, '../../../perennial-alias/data/active-repos' ), 'utf-8' ).trim().split( /\r?\n/ ).map( s => s.trim() );
Index: perennial-alias/js/eslint/root.eslint.config.mjs
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/perennial-alias/js/eslint/root.eslint.config.mjs b/perennial-alias/js/eslint/root.eslint.config.mjs
--- a/perennial-alias/js/eslint/root.eslint.config.mjs	(revision 8ec75342097dd4e6e4b46d1af606b9d569d921d0)
+++ b/perennial-alias/js/eslint/root.eslint.config.mjs	(date 1729809798033)
@@ -8,7 +8,6 @@
 import getNodeConfiguration from './getNodeConfiguration.mjs';
 import phetRules from './phetRules.mjs';
 import rootRules from './rootRules.mjs';
-import phetSimBrowserGlobalsEslintConfig from './phetSimBrowserGlobals.eslint.config.mjs';
 import rootRulesTypeScript from './rootRulesTypeScript.mjs';
 
 /**
@@ -110,7 +109,6 @@
       'eol-last': [ 'error', 'never' ]
     }
   },
-  phetSimBrowserGlobalsEslintConfig,
 
   ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
   ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

We still have problems in:

aqua
binder
phet-info
phet-io-website
phet-io-wrapper-classroom-activity
phet-io-wrapper-haptics
phet-io-wrapper-lab-book
phet-io-wrappers
phetmarks
phettest
quake
rosetta
skiffle
studio
weddell
yotta

So I will probably want to check in with @zepumph that the proposed approach is good before expanding it.

@zepumph
Copy link
Member Author

zepumph commented Oct 27, 2024

Yes. That file is a monolith that does not appropriately apply globals where they belong. Most of this issue is in teasing out those interconnections. I think we may want a design conversation or two before we're done too. I can take the next pass if you'd like.

@zepumph
Copy link
Member Author

zepumph commented Oct 28, 2024

  • eliminate "module" as a phetSimGlobal
  • tsconfig files would also want to be updated as we change the eslint config. That said, if a repo doesn't have any typescript yet anyways (phettest), then perhaps we can just have the tsconfig files get updated when we convert to typescript. But that said, chipper/ config should also update the tsconfig files for those umd specific files.
  • Ideally we wouldn't have a config that imported browserConfig AND a specific globals declaration. Instead, it would be best to just make sure that chipper was importing the correct config to begin with. Should we have "browserGlobals" defined in browser config, and the "simGlobals" defined in simConfig so that we get everything in the chipper config from "getBrowserConfiguration`

I believe that more progress can be made right now about this issue without collaboration. Even if it is just going through the TODOs and handling things individually (webgl globals to alpenglow, react globals to somewhere else). That said, we may want to hold off on propagating the getNodeConfiguration() pattern until #1483 is ready. Now that I said that out loud. I don't think we need to hold off that pattern. It should be just as easy to refactor new usages as the ones in chipper/aqua.

@samreid
Copy link
Member

samreid commented Oct 29, 2024

Here is a refreshed patch with no conflicts or spurious whitespace.

Subject: [PATCH] Use tsxCommand instead of 'node', force precommit hooks in precommit-hook-multi, see https://github.com/phetsims/perennial/issues/379
---
Index: perennial-alias/eslint.config.mjs
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/perennial-alias/eslint.config.mjs b/perennial-alias/eslint.config.mjs
--- a/perennial-alias/eslint.config.mjs	(revision b610d13654c5fd8f7d92ee8dc130c30d9275908d)
+++ b/perennial-alias/eslint.config.mjs	(date 1730230774837)
@@ -1,13 +1,45 @@
 // Copyright 2024, University of Colorado Boulder
 
-import nodeEslintConfig from './js/eslint/node.eslint.config.mjs';
+import globals from 'globals';
+import { getBrowserConfiguration } from '../perennial-alias/js/eslint/browser.eslint.config.mjs';
+import getNodeConfiguration from '../perennial-alias/js/eslint/getNodeConfiguration.mjs';
+
+import phetSimBrowserGlobalsEslintConfig from '../perennial-alias/js/eslint/phetSimBrowserGlobals.eslint.config.mjs';
+import rootEslintConfig from '../perennial-alias/js/eslint/root.eslint.config.mjs';
+
+const browserFiles = [
+  'js/common/SimVersion.js',
+  'js/grunt/decaf/getPreloads.js',
+  'js/scripts/test/release-branch-checks.js',
+  'js/test/puppeteerQUnit.js'
+];
 
 /**
  * @author Sam Reid (PhET Interactive Simulations)
  * @author Michael Kauzmann (PhET Interactive Simulations)
  */
 export default [
-  ...nodeEslintConfig,
+  ...rootEslintConfig,
+  ...getBrowserConfiguration( { files: browserFiles } ),
+  ...getNodeConfiguration( {
+    files: [ '**/*' ],
+    ignores: browserFiles
+  } ),
+  {
+    files: browserFiles,
+    ...phetSimBrowserGlobalsEslintConfig
+
+  },
+  {
+    files: browserFiles,
+    languageOptions: {
+      globals: {
+
+        // UMD files also get require
+        ...globals.node
+      }
+    }
+  },
   {
     rules: {
 
Index: perennial-alias/js/eslint/sim.eslint.config.mjs
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/perennial-alias/js/eslint/sim.eslint.config.mjs b/perennial-alias/js/eslint/sim.eslint.config.mjs
--- a/perennial-alias/js/eslint/sim.eslint.config.mjs	(revision b610d13654c5fd8f7d92ee8dc130c30d9275908d)
+++ b/perennial-alias/js/eslint/sim.eslint.config.mjs	(date 1730230774830)
@@ -3,6 +3,7 @@
 import assert from 'assert';
 import { getBrowserConfiguration } from './browser.eslint.config.mjs';
 import rootEslintConfig from './root.eslint.config.mjs';
+import phetSimBrowserGlobalsEslintConfig from './phetSimBrowserGlobals.eslint.config.mjs';
 
 // Ensure the pattern only applies to HTML files.
 const getHTMLPatterns = pattern => {
@@ -24,6 +25,7 @@
 
   return [
     ...getBrowserConfiguration( pattern ),
+    phetSimBrowserGlobalsEslintConfig,
     {
       rules: {
         'phet/bad-sim-text': 'error'
Index: chipper/eslint.config.mjs
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/chipper/eslint.config.mjs b/chipper/eslint.config.mjs
--- a/chipper/eslint.config.mjs	(revision 0f33a8428b1f894b3a403a20e8888b2e1c8e9dd5)
+++ b/chipper/eslint.config.mjs	(date 1730230774816)
@@ -9,11 +9,18 @@
 
 import { getBrowserConfiguration } from '../perennial-alias/js/eslint/browser.eslint.config.mjs';
 import getNodeConfiguration from '../perennial-alias/js/eslint/getNodeConfiguration.mjs';
+
+import phetSimBrowserGlobalsEslintConfig from '../perennial-alias/js/eslint/phetSimBrowserGlobals.eslint.config.mjs';
 import rootEslintConfig from '../perennial-alias/js/eslint/root.eslint.config.mjs';
 
 const browserFiles = [
   'js/*', // not recursive
-  'js/sim-tests/**/*'
+  'js/sim-tests/**/*',
+
+  // These files can optionally run in the browser, so they can use browser-capable linting
+  'js/common/documentationToHTML.js',
+  'js/common/extractDocumentation.js',
+  'js/phet-io/phetioCompareAPIs.js'
 ];
 
 export default [
@@ -24,6 +31,10 @@
     ignores: browserFiles
   } ),
   {
+    files: browserFiles,
+    ...phetSimBrowserGlobalsEslintConfig
+  },
+  {
     rules: {
       'phet/bad-chipper-text': 'error'
     }
Index: perennial-alias/js/eslint/root.eslint.config.mjs
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/perennial-alias/js/eslint/root.eslint.config.mjs b/perennial-alias/js/eslint/root.eslint.config.mjs
--- a/perennial-alias/js/eslint/root.eslint.config.mjs	(revision b610d13654c5fd8f7d92ee8dc130c30d9275908d)
+++ b/perennial-alias/js/eslint/root.eslint.config.mjs	(date 1730230774823)
@@ -8,7 +8,6 @@
 import getNodeConfiguration from './getNodeConfiguration.mjs';
 import phetRules from './phetRules.mjs';
 import rootRules from './rootRules.mjs';
-import phetSimBrowserGlobalsEslintConfig from './phetSimBrowserGlobals.eslint.config.mjs';
 import rootRulesTypeScript from './rootRulesTypeScript.mjs';
 
 /**
@@ -110,7 +109,6 @@
       'eol-last': [ 'error', 'never' ]
     }
   },
-  phetSimBrowserGlobalsEslintConfig,
 
   ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
   ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

@samreid
Copy link
Member

samreid commented Oct 29, 2024

Subject: [PATCH] Use tsxCommand instead of 'node', force precommit hooks in precommit-hook-multi, see https://github.com/phetsims/perennial/issues/379
---
Index: perennial-alias/js/eslint/browser.eslint.config.mjs
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/perennial-alias/js/eslint/browser.eslint.config.mjs b/perennial-alias/js/eslint/browser.eslint.config.mjs
--- a/perennial-alias/js/eslint/browser.eslint.config.mjs	(revision b610d13654c5fd8f7d92ee8dc130c30d9275908d)
+++ b/perennial-alias/js/eslint/browser.eslint.config.mjs	(date 1730233826789)
@@ -7,6 +7,7 @@
  */
 
 import globals from 'globals';
+import { myGlobals } from './phetSimBrowserGlobals.eslint.config.mjs';
 import rootEslintConfig from './root.eslint.config.mjs';
 
 export const getBrowserConfiguration = ( pattern = {} ) => {
@@ -16,7 +17,8 @@
     {
       languageOptions: {
         globals: {
-          ...globals.browser
+          ...globals.browser,
+          ...myGlobals
         }
       },
       ...pattern
Index: chipper/js/common/documentationToHTML.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/chipper/js/common/documentationToHTML.js b/chipper/js/common/documentationToHTML.js
--- a/chipper/js/common/documentationToHTML.js	(revision 0f33a8428b1f894b3a403a20e8888b2e1c8e9dd5)
+++ b/chipper/js/common/documentationToHTML.js	(date 1730233927415)
@@ -7,6 +7,7 @@
  * @author Jonathan Olson <[email protected]>
  */
 
+/* global window */
 ( function() {
 
   let typeURLs = {
Index: chipper/js/phet-io/phetioCompareAPIs.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/chipper/js/phet-io/phetioCompareAPIs.js b/chipper/js/phet-io/phetioCompareAPIs.js
--- a/chipper/js/phet-io/phetioCompareAPIs.js	(revision 0f33a8428b1f894b3a403a20e8888b2e1c8e9dd5)
+++ b/chipper/js/phet-io/phetioCompareAPIs.js	(date 1730233952793)
@@ -26,6 +26,8 @@
  * @property {Object} phetioTypes
  */
 
+/* global window */
+
 /**
  * See phetioEngine.js for where this is generated in main. Keep in mind that we support different versions, including
  * APIs that don't have a version attribute.
Index: aqua/js/node-client/runTest.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/aqua/js/node-client/runTest.js b/aqua/js/node-client/runTest.js
--- a/aqua/js/node-client/runTest.js	(revision d9f3e43586e0f04093877dd51085d270c7a719a4)
+++ b/aqua/js/node-client/runTest.js	(date 1730234052813)
@@ -14,6 +14,8 @@
 const path = require( 'path' );
 require( 'dotenv' ).config();
 
+/* global window */
+
 /**
  * Runs a CT test
  * @public
Index: chipper/js/common/extractDocumentation.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/chipper/js/common/extractDocumentation.js b/chipper/js/common/extractDocumentation.js
--- a/chipper/js/common/extractDocumentation.js	(revision 0f33a8428b1f894b3a403a20e8888b2e1c8e9dd5)
+++ b/chipper/js/common/extractDocumentation.js	(date 1730233937860)
@@ -6,7 +6,7 @@
  *
  * @author Jonathan Olson <[email protected]>
  */
-
+/* global window */
 ( function() {
 
   /**
Index: binder/js/getFromSimInMain.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/binder/js/getFromSimInMain.js b/binder/js/getFromSimInMain.js
--- a/binder/js/getFromSimInMain.js	(revision 1c5d53a29d981dd54ff522e938f706bf53f97a6c)
+++ b/binder/js/getFromSimInMain.js	(date 1730234076892)
@@ -18,6 +18,7 @@
  * @author Michael Kauzmann (PhET Interactive Simulations)
  */
 
+/* global window phet */
 
 // modules
 const _ = require( 'lodash' );
Index: perennial-alias/js/eslint/root.eslint.config.mjs
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/perennial-alias/js/eslint/root.eslint.config.mjs b/perennial-alias/js/eslint/root.eslint.config.mjs
--- a/perennial-alias/js/eslint/root.eslint.config.mjs	(revision b610d13654c5fd8f7d92ee8dc130c30d9275908d)
+++ b/perennial-alias/js/eslint/root.eslint.config.mjs	(date 1730232253058)
@@ -8,7 +8,6 @@
 import getNodeConfiguration from './getNodeConfiguration.mjs';
 import phetRules from './phetRules.mjs';
 import rootRules from './rootRules.mjs';
-import phetSimBrowserGlobalsEslintConfig from './phetSimBrowserGlobals.eslint.config.mjs';
 import rootRulesTypeScript from './rootRulesTypeScript.mjs';
 
 /**
@@ -110,7 +109,6 @@
       'eol-last': [ 'error', 'never' ]
     }
   },
-  phetSimBrowserGlobalsEslintConfig,
 
   ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
   ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Index: perennial-alias/js/eslint/phetSimBrowserGlobals.eslint.config.mjs
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/perennial-alias/js/eslint/phetSimBrowserGlobals.eslint.config.mjs b/perennial-alias/js/eslint/phetSimBrowserGlobals.eslint.config.mjs
--- a/perennial-alias/js/eslint/phetSimBrowserGlobals.eslint.config.mjs	(revision b610d13654c5fd8f7d92ee8dc130c30d9275908d)
+++ b/perennial-alias/js/eslint/phetSimBrowserGlobals.eslint.config.mjs	(date 1730233814199)
@@ -1,157 +1,158 @@
 // Copyright 2024, University of Colorado Boulder
 
-/**
- * @author Michael Kauzmann (PhET Interactive Simulations)
- * @author Sam Reid (PhET Interactive Simulations)
- */
-const phetSimBrowserGlobals = {
-  languageOptions: {
-    globals: {
+export const myGlobals = {
 
-      //=============================================================================================
-      // globals that should never be accessed
-      //=============================================================================================
+  //=============================================================================================
+  // globals that should never be accessed
+  //=============================================================================================
 
-      // TODO: Does this work if they are overridden later? https://github.com/phetsims/chipper/issues/1485
-      // TODO: Is this still needed? https://github.com/phetsims/chipper/issues/1485
-      // Using window.event is most likely a bug, instead the event should be passed through via a parameter,
-      // discovered in https://github.com/phetsims/scenery/issues/1053
-      event: 'off',
+  // TODO: Does this work if they are overridden later? https://github.com/phetsims/chipper/issues/1485
+  // TODO: Is this still needed? https://github.com/phetsims/chipper/issues/1485
+  // Using window.event is most likely a bug, instead the event should be passed through via a parameter,
+  // discovered in https://github.com/phetsims/scenery/issues/1053
+  event: 'off',
 
-      //=============================================================================================
-      // read-only globals
-      //=============================================================================================
+  //=============================================================================================
+  // read-only globals
+  //=============================================================================================
 
-      phet: 'readonly',
+  phet: 'readonly',
 
-      // allow assertions
-      assert: 'readonly',
+  // allow assertions
+  assert: 'readonly',
 
-      // allow slow assertions
-      assertSlow: 'readonly',
+  // allow slow assertions
+  assertSlow: 'readonly',
 
-      phetio: 'readonly',
+  phetio: 'readonly',
 
-      // underscore, lodash
-      _: 'readonly',
+  // underscore, lodash
+  _: 'readonly',
 
-      // jQuery
-      $: 'readonly',
+  // jQuery
+  $: 'readonly',
 
-      // jQuery for type documentation
-      JQuery: 'readonly',
+  // jQuery for type documentation
+  JQuery: 'readonly',
 
-      // JSON diffs
-      jsondiffpatch: 'readonly',
+  // JSON diffs
+  jsondiffpatch: 'readonly',
 
-      document: 'readonly',
+  document: 'readonly',
 
-      // for linting Node.js code
-      global: 'readonly',
+  // for linting Node.js code
+  global: 'readonly',
 
-      // QUnit
-      QUnit: 'readonly',
+  // QUnit
+  QUnit: 'readonly',
 
-      // Misc
-      QueryStringMachine: 'readonly',
-      QueryStringMachineSchema: 'readonly',
-      QSMParsedParameters: 'readonly',
+  // Misc
+  QueryStringMachine: 'readonly',
+  QueryStringMachineSchema: 'readonly',
+  QSMParsedParameters: 'readonly',
 
-      // Prism is a syntax highlighter that renders code in the browser. It is used for PhET-iO wrappers and for a11y.
-      // TODO: define only where needed https://github.com/phetsims/chipper/issues/1485
-      Prism: 'readonly',
+  // Prism is a syntax highlighter that renders code in the browser. It is used for PhET-iO wrappers and for a11y.
+  // TODO: define only where needed https://github.com/phetsims/chipper/issues/1485
+  Prism: 'readonly',
 
-      // sole/tween.js
-      TWEEN: 'readonly',
+  // sole/tween.js
+  TWEEN: 'readonly',
 
-      // TODO: redundant right? https://github.com/phetsims/chipper/issues/1485
-      window: 'readonly',
+  // TODO: redundant right? https://github.com/phetsims/chipper/issues/1485
+  window: 'readonly',
 
-      // TODO: old and unused right? Otherwise define only where needed https://github.com/phetsims/chipper/issues/1485
-      handlePlaybackEvent: 'readonly',
+  // TODO: old and unused right? Otherwise define only where needed https://github.com/phetsims/chipper/issues/1485
+  handlePlaybackEvent: 'readonly',
 
-      // TODO: define only where needed. https://github.com/phetsims/chipper/issues/1485
-      paper: 'readonly',
+  // TODO: define only where needed. https://github.com/phetsims/chipper/issues/1485
+  paper: 'readonly',
 
-      // TODO: define only where needed https://github.com/phetsims/chipper/issues/1485
-      pako: 'readonly',
+  // TODO: define only where needed https://github.com/phetsims/chipper/issues/1485
+  pako: 'readonly',
 
-      // define globals for missing Web Audio types, see https://github.com/phetsims/chipper/issues/1214
-      // TODO: define only where needed https://github.com/phetsims/chipper/issues/1485
-      OscillatorType: 'readonly',
-      AudioContextState: 'readonly',
+  // define globals for missing Web Audio types, see https://github.com/phetsims/chipper/issues/1214
+  // TODO: define only where needed https://github.com/phetsims/chipper/issues/1485
+  OscillatorType: 'readonly',
+  AudioContextState: 'readonly',
 
-      // type for QUnit assert
-      // TODO: define only where needed https://github.com/phetsims/chipper/issues/1485
-      Assert: 'readonly',
+  // type for QUnit assert
+  // TODO: define only where needed https://github.com/phetsims/chipper/issues/1485
+  Assert: 'readonly',
 
-      // TODO: redundant right? https://github.com/phetsims/chipper/issues/1485
-      fetch: 'readonly',
+  // TODO: redundant right? https://github.com/phetsims/chipper/issues/1485
+  fetch: 'readonly',
 
-      // TODO: define only where needed https://github.com/phetsims/chipper/issues/1485
-      // React
-      React: 'readonly',
-      ReactDOM: 'readonly',
+  // TODO: define only where needed https://github.com/phetsims/chipper/issues/1485
+  // React
+  React: 'readonly',
+  ReactDOM: 'readonly',
 
-      BigInt: 'readonly',
+  BigInt: 'readonly',
 
-      FlatQueue: 'readonly',
+  FlatQueue: 'readonly',
 
-      // TODO: define only where needed https://github.com/phetsims/chipper/issues/1485
-      // WebGPU
-      GPUShaderModule: 'readonly',
-      GPUBindGroupLayout: 'readonly',
-      GPUDevice: 'readonly',
-      GPUShaderStage: 'readonly',
-      GPUBindGroupLayoutEntry: 'readonly',
-      GPUComputePipeline: 'readonly',
-      GPUBuffer: 'readonly',
-      GPUTextureView: 'readonly',
-      GPUCommandEncoder: 'readonly',
-      GPUBindGroupEntry: 'readonly',
-      GPUBufferUsage: 'readonly',
-      GPUTextureUsage: 'readonly',
-      GPUTexture: 'readonly',
-      GPUCanvasContext: 'readonly',
-      GPUTextureFormat: 'readonly',
-      GPUImageCopyExternalImageSource: 'readonly',
-      GPUPipelineLayout: 'readonly',
-      GPURenderPipeline: 'readonly',
-      GPUBindGroup: 'readonly',
-      GPUMapMode: 'readonly',
-      GPUFeatureName: 'readonly',
-      GPUQuerySet: 'readonly',
-      GPUComputePassDescriptor: 'readonly',
-      GPUComputePassTimestampWrites: 'readonly',
-      GPUComputePipelineDescriptor: 'readonly',
-      GPUComputePassEncoder: 'readonly',
-      GPUTextureViewDimension: 'readonly',
-      GPUStorageTextureAccess: 'readonly',
-      GPUBufferBindingType: 'readonly',
-      GPUTextureSampleType: 'readonly',
-      GPUBufferBinding: 'readonly',
-      GPURequestAdapterOptions: 'readonly',
-      GPUDeviceDescriptor: 'readonly',
-      GPUBufferDescriptor: 'readonly',
-      GPUQueue: 'readonly',
-      GPUQuerySetDescriptor: 'readonly',
-      GPUAdapter: 'readonly',
-      GPUMapModeFlags: 'readonly',
-      GPUPipelineLayoutDescriptor: 'readonly',
-      GPUCommandEncoderDescriptor: 'readonly',
-      GPUCommandBuffer: 'readonly',
-      GPUBindGroupDescriptor: 'readonly',
-      GPUBindGroupLayoutDescriptor: 'readonly',
-      GPUShaderModuleDescriptor: 'readonly',
-      GPURenderPassDescriptor: 'readonly',
-      GPURenderPassEncoder: 'readonly',
-      GPUCommandBufferDescriptor: 'readonly',
-      GPUImageCopyBuffer: 'readonly',
-      GPUImageCopyTexture: 'readonly',
-      GPUExtent3DStrict: 'readonly',
-      GPUSampler: 'readonly',
-      GPUExternalTexture: 'readonly'
-    }
+  // TODO: define only where needed https://github.com/phetsims/chipper/issues/1485
+  // WebGPU
+  GPUShaderModule: 'readonly',
+  GPUBindGroupLayout: 'readonly',
+  GPUDevice: 'readonly',
+  GPUShaderStage: 'readonly',
+  GPUBindGroupLayoutEntry: 'readonly',
+  GPUComputePipeline: 'readonly',
+  GPUBuffer: 'readonly',
+  GPUTextureView: 'readonly',
+  GPUCommandEncoder: 'readonly',
+  GPUBindGroupEntry: 'readonly',
+  GPUBufferUsage: 'readonly',
+  GPUTextureUsage: 'readonly',
+  GPUTexture: 'readonly',
+  GPUCanvasContext: 'readonly',
+  GPUTextureFormat: 'readonly',
+  GPUImageCopyExternalImageSource: 'readonly',
+  GPUPipelineLayout: 'readonly',
+  GPURenderPipeline: 'readonly',
+  GPUBindGroup: 'readonly',
+  GPUMapMode: 'readonly',
+  GPUFeatureName: 'readonly',
+  GPUQuerySet: 'readonly',
+  GPUComputePassDescriptor: 'readonly',
+  GPUComputePassTimestampWrites: 'readonly',
+  GPUComputePipelineDescriptor: 'readonly',
+  GPUComputePassEncoder: 'readonly',
+  GPUTextureViewDimension: 'readonly',
+  GPUStorageTextureAccess: 'readonly',
+  GPUBufferBindingType: 'readonly',
+  GPUTextureSampleType: 'readonly',
+  GPUBufferBinding: 'readonly',
+  GPURequestAdapterOptions: 'readonly',
+  GPUDeviceDescriptor: 'readonly',
+  GPUBufferDescriptor: 'readonly',
+  GPUQueue: 'readonly',
+  GPUQuerySetDescriptor: 'readonly',
+  GPUAdapter: 'readonly',
+  GPUMapModeFlags: 'readonly',
+  GPUPipelineLayoutDescriptor: 'readonly',
+  GPUCommandEncoderDescriptor: 'readonly',
+  GPUCommandBuffer: 'readonly',
+  GPUBindGroupDescriptor: 'readonly',
+  GPUBindGroupLayoutDescriptor: 'readonly',
+  GPUShaderModuleDescriptor: 'readonly',
+  GPURenderPassDescriptor: 'readonly',
+  GPURenderPassEncoder: 'readonly',
+  GPUCommandBufferDescriptor: 'readonly',
+  GPUImageCopyBuffer: 'readonly',
+  GPUImageCopyTexture: 'readonly',
+  GPUExtent3DStrict: 'readonly',
+  GPUSampler: 'readonly',
+  GPUExternalTexture: 'readonly'
+};
+/**
+ * @author Michael Kauzmann (PhET Interactive Simulations)
+ * @author Sam Reid (PhET Interactive Simulations)
+ */
+const phetSimBrowserGlobals = {
+  languageOptions: {
+    globals: myGlobals
   }
 };
 

@samreid
Copy link
Member

samreid commented Oct 29, 2024

I will continue with the recent patch, and can either solve problems with things like /* global window */ in individual files, or by factoring out blocks to eslint.config.mjs files.

samreid added a commit to phetsims/scenery that referenced this issue Oct 30, 2024
samreid added a commit to phetsims/alpenglow that referenced this issue Oct 30, 2024
samreid added a commit to phetsims/least-squares-regression that referenced this issue Oct 30, 2024
samreid added a commit to phetsims/charges-and-fields that referenced this issue Oct 30, 2024
samreid added a commit to phetsims/kite that referenced this issue Oct 30, 2024
samreid added a commit to phetsims/perennial that referenced this issue Oct 30, 2024
samreid added a commit to phetsims/perennial that referenced this issue Oct 30, 2024
samreid added a commit to phetsims/scenery that referenced this issue Oct 30, 2024
samreid added a commit to phetsims/perennial that referenced this issue Oct 30, 2024
samreid added a commit to phetsims/models-of-the-hydrogen-atom that referenced this issue Oct 30, 2024
samreid added a commit to phetsims/perennial that referenced this issue Oct 30, 2024
samreid added a commit to phetsims/scenery that referenced this issue Oct 30, 2024
samreid added a commit to phetsims/perennial that referenced this issue Oct 30, 2024
samreid added a commit to phetsims/circuit-construction-kit-common that referenced this issue Oct 30, 2024
samreid added a commit to phetsims/perennial that referenced this issue Oct 30, 2024
samreid added a commit to phetsims/perennial that referenced this issue Oct 30, 2024
samreid added a commit to phetsims/alpenglow that referenced this issue Oct 30, 2024
samreid added a commit to phetsims/quake that referenced this issue Oct 30, 2024
samreid added a commit to phetsims/perennial that referenced this issue Oct 30, 2024
samreid added a commit to phetsims/perennial that referenced this issue Oct 30, 2024
@samreid
Copy link
Member

samreid commented Oct 30, 2024

Ready for check-in with @zepumph

@samreid samreid removed their assignment Oct 30, 2024
zepumph added a commit to phetsims/perennial that referenced this issue Oct 30, 2024
@zepumph
Copy link
Member Author

zepumph commented Oct 30, 2024

@samreid and I co-reviewed this. Closing

@zepumph zepumph closed this as completed Oct 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants