Browse Source

lint(eslint): Special case *.js config and script files in eslint (#83286)

Ryan Albrecht 1 month ago
parent
commit
4d683ef66d

+ 40 - 4
eslint.config.mjs

@@ -285,11 +285,7 @@ export default typescript.config([
       'no-dupe-class-members': 'off', // TODO(ryan953): Fix violations and delete this line
       'no-import-assign': 'off', // TODO(ryan953): Fix violations and delete this line
       'no-prototype-builtins': 'off', // TODO(ryan953): Fix violations and delete this line
-      'no-redeclare': 'off', // TODO(ryan953): Fix violations and delete this line
-      'no-self-assign': 'off', // TODO(ryan953): Fix violations and delete this line
-      'no-undef': 'off', // TODO(ryan953): Fix violations and delete this line
       'no-unsafe-optional-chaining': 'off', // TODO(ryan953): Fix violations and delete this line
-      'no-unused-vars': 'off', // TODO(ryan953): Fix violations and delete this line
       'no-useless-catch': 'off', // TODO(ryan953): Fix violations and delete this line
       'no-useless-escape': 'off', // TODO(ryan953): Fix violations and delete this line
       'valid-typeof': 'off', // TODO(ryan953): Fix violations and delete this line
@@ -607,6 +603,46 @@ export default typescript.config([
     name: 'plugin/prettier',
     ...prettier,
   },
+  {
+    name: 'files/*.config.*',
+    files: ['*.config.*'],
+    languageOptions: {
+      globals: {
+        ...globals.commonjs,
+        ...globals.node,
+      },
+    },
+  },
+  {
+    name: 'files/scripts',
+    files: ['scripts/**/*.{js,ts}', 'tests/js/test-balancer/index.js'],
+    languageOptions: {
+      sourceType: 'commonjs',
+      globals: {
+        ...globals.commonjs,
+        ...globals.node,
+      },
+    },
+    rules: {
+      'no-console': 'off',
+    },
+  },
+  {
+    name: 'files/jest related',
+    files: [
+      'tests/js/jest-pegjs-transform.js',
+      'tests/js/sentry-test/echartsMock.js',
+      'tests/js/sentry-test/importStyleMock.js',
+      'tests/js/sentry-test/svgMock.js',
+    ],
+    languageOptions: {
+      sourceType: 'commonjs',
+      globals: {
+        ...globals.commonjs,
+      },
+    },
+    rules: {},
+  },
   {
     name: 'files/devtoolbar',
     files: ['static/app/components/devtoolbar/**/*.{ts,tsx}'],

+ 2 - 1
scripts/build-js-loader.ts

@@ -1,4 +1,5 @@
-/* eslint-disable no-console */
+'use strict';
+
 import fs from 'node:fs';
 import {minify} from 'terser';
 import * as ts from 'typescript';

+ 2 - 0
scripts/extract-android-device-names.js

@@ -1,3 +1,5 @@
+'use strict';
+
 const csv = require('csv-parser');
 const fs = require('node:fs');
 

+ 2 - 4
scripts/extract-ios-device-names.ts

@@ -1,4 +1,4 @@
-/* eslint-env node */
+'use strict';
 import {existsSync, unlinkSync} from 'node:fs';
 import fs from 'node:fs/promises';
 import path from 'node:path';
@@ -103,6 +103,4 @@ async function run() {
   await fs.rename(tmpOutputPath, outputPath);
 }
 
-run()
-  // eslint-disable-next-line no-console
-  .catch(error => console.error(`Failed to run extract-ios-device-names`, error));
+run().catch(error => console.error(`Failed to run extract-ios-device-names`, error));

+ 2 - 4
scripts/test.js

@@ -1,4 +1,4 @@
-/* global process */
+'use strict';
 
 // Do this as the first thing so that any code reading it knows the right env.
 // process.env.BABEL_ENV = 'test';
@@ -13,8 +13,6 @@ process.on('unhandledRejection', err => {
   throw err;
 });
 
-const jest = require('jest');
-
 let argv = process.argv.slice(2);
 
 // Remove watch if in CI or in coverage mode
@@ -22,4 +20,4 @@ if (process.env.CI || process.env.SENTRY_PRECOMMIT || argv.includes('--coverage'
   argv = argv.filter(arg => arg !== '--watch');
 }
 
-jest.run(argv);
+require('jest').run(argv);

+ 1 - 4
static/app/components/autoplayVideo.spec.tsx

@@ -26,10 +26,7 @@ const makeProxyMock = (video: Partial<HTMLVideoElement>) => {
       get(obj, prop) {
         return obj[prop];
       },
-      set(obj, prop) {
-        if (prop === 'current') {
-          obj.current = obj.current;
-        }
+      set(_obj, _prop) {
         return true;
       },
     }

+ 2 - 4
static/app/views/performance/newTraceDetails/traceRenderers/virtualizedViewManager.tsx

@@ -1778,11 +1778,9 @@ export class VirtualizedList {
       }
     } else {
       // If no anchor is provided, we default to 'auto'
-      if (position < top) {
-        position = position;
-      } else if (position > top + height) {
+      if (position > top + height) {
         position = index * 24 - height + 24;
-      } else {
+      } else if (position >= top) {
         return;
       }
     }

+ 1 - 1
static/app/views/routeError.tsx

@@ -114,7 +114,7 @@ function RouteError({error, disableLogSentry, disableReport, project}: Props) {
             link: (
               <a
                 onClick={() => {
-                  window.location.href = window.location.href;
+                  window.location.href = String(window.location.href);
                 }}
               />
             ),

+ 3 - 3
tests/js/jest-pegjs-transform.js

@@ -1,10 +1,10 @@
-/* eslint-env node */
+'use strict';
 
-const crypto = require('node:crypto');
+const nodeCrypto = require('node:crypto');
 const peggy = require('peggy');
 
 function getCacheKey(fileData, _filePath, config, _options) {
-  return crypto
+  return nodeCrypto
     .createHash('md5')
     .update(fileData)
     .update(config.configString)

+ 1 - 0
tests/js/sentry-test/echartsMock.js

@@ -1,3 +1,4 @@
+'use strict';
 // empty stub file for echarts with jest
 
 module.exports = {default: {id: 'echarts'}, use: () => {}};

Some files were not shown because too many files changed in this diff