From 4926a280d86a4db7664b8602d43f2dff524b9357 Mon Sep 17 00:00:00 2001 From: Sam Reid Date: Tue, 8 Oct 2024 17:14:25 -0600 Subject: [PATCH] Update eslint.config.mjs for browser vs node, see https://github.com/phetsims/chipper/issues/1463 --- eslint/buildtools.eslint.config.mjs | 18 ------------- eslint/chipper.eslint.config.mjs | 16 ----------- eslint/node.eslint.config.mjs | 42 +++++++++++++++++++++-------- 3 files changed, 31 insertions(+), 45 deletions(-) delete mode 100644 eslint/buildtools.eslint.config.mjs delete mode 100644 eslint/chipper.eslint.config.mjs diff --git a/eslint/buildtools.eslint.config.mjs b/eslint/buildtools.eslint.config.mjs deleted file mode 100644 index 2a01e371..00000000 --- a/eslint/buildtools.eslint.config.mjs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2024, University of Colorado Boulder - -/** - * The buildtools-specific eslint config applied only to "server-side" files that aren't run in sims. - * @author Sam Reid (PhET Interactive Simulations) - * @author Michael Kauzmann (PhET Interactive Simulations) - */ -export default { - rules: { - - // TODO: we only want to turn these off in node code, still run them in the browser, see https://github.com/phetsims/chipper/issues/1451 - '@typescript-eslint/no-require-imports': 'off', - '@typescript-eslint/no-var-requires': 'off', - '@typescript-eslint/no-explicit-any': 'off', // TODO: Use IntentionalAny, https://github.com/phetsims/chipper/issues/1465 - '@typescript-eslint/no-floating-promises': 'off', - 'phet/bad-sim-text': 'off' - } -}; \ No newline at end of file diff --git a/eslint/chipper.eslint.config.mjs b/eslint/chipper.eslint.config.mjs deleted file mode 100644 index 26f4c41b..00000000 --- a/eslint/chipper.eslint.config.mjs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2018, University of Colorado Boulder -// @author Michael Kauzmann - -import nodeEslintConfig from './node.eslint.config.mjs'; - -/** - * The node-specific eslint config applied only to "server-side" files that aren't run in sims. - */ -export default [ - ...nodeEslintConfig, - { - rules: { - 'phet/bad-chipper-text': 'error' - } - } -]; \ No newline at end of file diff --git a/eslint/node.eslint.config.mjs b/eslint/node.eslint.config.mjs index a9ec6bd9..d55e7700 100644 --- a/eslint/node.eslint.config.mjs +++ b/eslint/node.eslint.config.mjs @@ -4,19 +4,39 @@ import globals from 'globals'; import rootEslintConfig from './root.eslint.config.mjs'; +export const nodeLanguageOptionsAndRules = { + languageOptions: { + globals: { + ...globals.node, + + // Deno + // TODO: define only where needed https://github.com/phetsims/chipper/issues/1451 + Deno: 'readonly' + } + }, + rules: { + '@typescript-eslint/no-require-imports': 'off', + '@typescript-eslint/no-var-requires': 'off' + } +}; + +export const nodeNoFloatingPromises = { + + // For entry points like scripts and "grunt" tasks, we often end with a floating promise which is not a problem + files: [ + '**/js/grunt/tasks/**/*', + '**/js/scripts/**/*' + ], + rules: { + '@typescript-eslint/no-floating-promises': 'off' + } +}; + /** * The node-specific eslint config applied only to "server-side" files that aren't run in sims. */ export default [ ...rootEslintConfig, - { - languageOptions: { - globals: { - ...globals.node, - - // Deno - // TODO: define only where needed https://github.com/phetsims/chipper/issues/1451 - Deno: 'readonly' - } - } - } ]; \ No newline at end of file + nodeLanguageOptionsAndRules, + nodeNoFloatingPromises +]; \ No newline at end of file