Skip to content

Commit 0387cb8

Browse files
authored
lint(eslint): Special case *.js config and script files in eslint (#83286)
1 parent 54bdd99 commit 0387cb8

File tree

13 files changed

+60
-26
lines changed

13 files changed

+60
-26
lines changed

eslint.config.mjs

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -285,11 +285,7 @@ export default typescript.config([
285285
'no-dupe-class-members': 'off', // TODO(ryan953): Fix violations and delete this line
286286
'no-import-assign': 'off', // TODO(ryan953): Fix violations and delete this line
287287
'no-prototype-builtins': 'off', // TODO(ryan953): Fix violations and delete this line
288-
'no-redeclare': 'off', // TODO(ryan953): Fix violations and delete this line
289-
'no-self-assign': 'off', // TODO(ryan953): Fix violations and delete this line
290-
'no-undef': 'off', // TODO(ryan953): Fix violations and delete this line
291288
'no-unsafe-optional-chaining': 'off', // TODO(ryan953): Fix violations and delete this line
292-
'no-unused-vars': 'off', // TODO(ryan953): Fix violations and delete this line
293289
'no-useless-catch': 'off', // TODO(ryan953): Fix violations and delete this line
294290
'no-useless-escape': 'off', // TODO(ryan953): Fix violations and delete this line
295291
'valid-typeof': 'off', // TODO(ryan953): Fix violations and delete this line
@@ -607,6 +603,46 @@ export default typescript.config([
607603
name: 'plugin/prettier',
608604
...prettier,
609605
},
606+
{
607+
name: 'files/*.config.*',
608+
files: ['*.config.*'],
609+
languageOptions: {
610+
globals: {
611+
...globals.commonjs,
612+
...globals.node,
613+
},
614+
},
615+
},
616+
{
617+
name: 'files/scripts',
618+
files: ['scripts/**/*.{js,ts}', 'tests/js/test-balancer/index.js'],
619+
languageOptions: {
620+
sourceType: 'commonjs',
621+
globals: {
622+
...globals.commonjs,
623+
...globals.node,
624+
},
625+
},
626+
rules: {
627+
'no-console': 'off',
628+
},
629+
},
630+
{
631+
name: 'files/jest related',
632+
files: [
633+
'tests/js/jest-pegjs-transform.js',
634+
'tests/js/sentry-test/echartsMock.js',
635+
'tests/js/sentry-test/importStyleMock.js',
636+
'tests/js/sentry-test/svgMock.js',
637+
],
638+
languageOptions: {
639+
sourceType: 'commonjs',
640+
globals: {
641+
...globals.commonjs,
642+
},
643+
},
644+
rules: {},
645+
},
610646
{
611647
name: 'files/devtoolbar',
612648
files: ['static/app/components/devtoolbar/**/*.{ts,tsx}'],

scripts/build-js-loader.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
/* eslint-disable no-console */
1+
'use strict';
2+
23
import fs from 'node:fs';
34
import {minify} from 'terser';
45
import * as ts from 'typescript';

scripts/extract-android-device-names.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
const csv = require('csv-parser');
24
const fs = require('node:fs');
35

scripts/extract-ios-device-names.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* eslint-env node */
1+
'use strict';
22
import {existsSync, unlinkSync} from 'node:fs';
33
import fs from 'node:fs/promises';
44
import path from 'node:path';
@@ -103,6 +103,4 @@ async function run() {
103103
await fs.rename(tmpOutputPath, outputPath);
104104
}
105105

106-
run()
107-
// eslint-disable-next-line no-console
108-
.catch(error => console.error(`Failed to run extract-ios-device-names`, error));
106+
run().catch(error => console.error(`Failed to run extract-ios-device-names`, error));

scripts/test.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* global process */
1+
'use strict';
22

33
// Do this as the first thing so that any code reading it knows the right env.
44
// process.env.BABEL_ENV = 'test';
@@ -13,13 +13,11 @@ process.on('unhandledRejection', err => {
1313
throw err;
1414
});
1515

16-
const jest = require('jest');
17-
1816
let argv = process.argv.slice(2);
1917

2018
// Remove watch if in CI or in coverage mode
2119
if (process.env.CI || process.env.SENTRY_PRECOMMIT || argv.includes('--coverage')) {
2220
argv = argv.filter(arg => arg !== '--watch');
2321
}
2422

25-
jest.run(argv);
23+
require('jest').run(argv);

static/app/components/autoplayVideo.spec.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,7 @@ const makeProxyMock = (video: Partial<HTMLVideoElement>) => {
2626
get(obj, prop) {
2727
return obj[prop];
2828
},
29-
set(obj, prop) {
30-
if (prop === 'current') {
31-
obj.current = obj.current;
32-
}
29+
set(_obj, _prop) {
3330
return true;
3431
},
3532
}

static/app/views/performance/newTraceDetails/traceRenderers/virtualizedViewManager.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1778,11 +1778,9 @@ export class VirtualizedList {
17781778
}
17791779
} else {
17801780
// If no anchor is provided, we default to 'auto'
1781-
if (position < top) {
1782-
position = position;
1783-
} else if (position > top + height) {
1781+
if (position > top + height) {
17841782
position = index * 24 - height + 24;
1785-
} else {
1783+
} else if (position >= top) {
17861784
return;
17871785
}
17881786
}

static/app/views/routeError.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ function RouteError({error, disableLogSentry, disableReport, project}: Props) {
114114
link: (
115115
<a
116116
onClick={() => {
117-
window.location.href = window.location.href;
117+
window.location.href = String(window.location.href);
118118
}}
119119
/>
120120
),

tests/js/jest-pegjs-transform.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
/* eslint-env node */
1+
'use strict';
22

3-
const crypto = require('node:crypto');
3+
const nodeCrypto = require('node:crypto');
44
const peggy = require('peggy');
55

66
function getCacheKey(fileData, _filePath, config, _options) {
7-
return crypto
7+
return nodeCrypto
88
.createHash('md5')
99
.update(fileData)
1010
.update(config.configString)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
'use strict';
12
// empty stub file for echarts with jest
23

34
module.exports = {default: {id: 'echarts'}, use: () => {}};

0 commit comments

Comments
 (0)