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

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

Merged
merged 2 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 40 additions & 4 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -289,11 +289,7 @@ export default typescript.config([
'no-import-assign': 'off', // TODO(ryan953): Fix violations and delete this line
'no-loss-of-precision': '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
Expand Down Expand Up @@ -611,6 +607,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}'],
Expand Down
3 changes: 2 additions & 1 deletion scripts/build-js-loader.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-disable no-console */
'use strict';

import fs from 'node:fs';
import {minify} from 'terser';
import * as ts from 'typescript';
Expand Down
2 changes: 2 additions & 0 deletions scripts/extract-android-device-names.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

const csv = require('csv-parser');
const fs = require('node:fs');

Expand Down
6 changes: 2 additions & 4 deletions scripts/extract-ios-device-names.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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));
6 changes: 2 additions & 4 deletions scripts/test.js
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -13,13 +13,11 @@ 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
if (process.env.CI || process.env.SENTRY_PRECOMMIT || argv.includes('--coverage')) {
argv = argv.filter(arg => arg !== '--watch');
}

jest.run(argv);
require('jest').run(argv);
5 changes: 1 addition & 4 deletions static/app/components/autoplayVideo.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Comment on lines -1781 to -1785
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this expected?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it's a weird diff.

It was complaining about the statement 'position = position' in the first IF block. So I removed that but then it was an empty block. So I refactored the conditions from if/elseif/else to be if/elseif. The first IF condition got inverted into the new elseif at the bottom.

} else if (position >= top) {
return;
}
}
Expand Down
2 changes: 1 addition & 1 deletion static/app/views/routeError.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}}
/>
),
Expand Down
9 changes: 3 additions & 6 deletions tests/js/jest-pegjs-transform.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
/* eslint-env node */

const crypto = require('node:crypto');
const peggy = require('peggy');
'use strict';

function getCacheKey(fileData, _filePath, config, _options) {
return crypto
return require('node:crypto')
.createHash('md5')
ryan953 marked this conversation as resolved.
Show resolved Hide resolved
.update(fileData)
.update(config.configString)
Expand All @@ -13,7 +10,7 @@ function getCacheKey(fileData, _filePath, config, _options) {

function process(sourceText) {
return {
code: `module.exports = ${peggy.generate(sourceText, {output: 'source'})}`,
code: `module.exports = ${require('peggy').generate(sourceText, {output: 'source'})}`,
};
}

Expand Down
1 change: 1 addition & 0 deletions tests/js/sentry-test/echartsMock.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use strict';
// empty stub file for echarts with jest

module.exports = {default: {id: 'echarts'}, use: () => {}};
1 change: 1 addition & 0 deletions tests/js/sentry-test/importStyleMock.js
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
'use strict';
module.exports = {};
1 change: 1 addition & 0 deletions tests/js/sentry-test/svgMock.js
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
'use strict';
module.exports = {default: {id: 'test', viewBox: {}}};
3 changes: 2 additions & 1 deletion tests/js/test-balancer/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-env node */
'use strict';

const fs = require('node:fs');
const path = require('node:path');

Expand Down
Loading