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

chore: Enable a few eslint rules that overlap with biomes rule list #83693

Merged
merged 2 commits into from
Jan 18, 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
32 changes: 13 additions & 19 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ export default typescript.config([
'consistent-return': 'error',
'default-case': 'error',
'dot-notation': 'error',
eqeqeq: 'error',
'guard-for-in': 'off', // TODO(ryan953): Fix violations and enable this rule
'multiline-comment-style': ['error', 'separate-lines'],
'no-alert': 'error',
Expand Down Expand Up @@ -268,6 +269,7 @@ export default typescript.config([
'no-sequences': 'error',
'no-throw-literal': 'error',
'object-shorthand': ['error', 'properties'],
radix: 'error',
'require-await': 'error', // Enabled in favor of @typescript-eslint/require-await, which requires type info
'spaced-comment': [
'error',
Expand All @@ -277,10 +279,9 @@ export default typescript.config([
block: {exceptions: ['*'], balanced: true},
},
],
strict: 'error',
'vars-on-top': 'off',
'wrap-iife': ['error', 'any'],
radix: 'error',
strict: 'error',
yoda: 'error',

// https://github.com/eslint/eslint/blob/main/packages/js/src/configs/eslint-recommended.js
Expand Down Expand Up @@ -369,6 +370,7 @@ export default typescript.config([
{selector: 'typeLike', format: ['PascalCase'], leadingUnderscore: 'allow'},
{selector: 'enumMember', format: ['UPPER_CASE']},
],

'@typescript-eslint/no-restricted-types': [
'error',
{
Expand All @@ -392,6 +394,7 @@ export default typescript.config([
],
'@typescript-eslint/no-shadow': 'error',
'@typescript-eslint/no-use-before-define': 'off', // Enabling this will cause a lot of thrash to the git history
'@typescript-eslint/no-useless-empty-export': 'error',
},
},
// https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/base.ts
Expand All @@ -406,8 +409,8 @@ export default typescript.config([
// https://typescript-eslint.io/rules/
plugins: {'@typescript-eslint': typescript.plugin},
rules: {
'no-var': 'off', // TODO(ryan953): Fix violations and delete this line
'prefer-spread': 'off', // TODO(ryan953): Fix violations and delete this line
'@typescript-eslint/prefer-enum-initializers': 'error',

// Recommended overrides
'@typescript-eslint/ban-ts-comment': 'off', // TODO(ryan953): Fix violations and delete this line
Expand All @@ -427,7 +430,7 @@ export default typescript.config([
'@typescript-eslint/no-extraneous-class': 'off', // TODO(ryan953): Fix violations and delete this line
'@typescript-eslint/no-invalid-void-type': 'off', // TODO(ryan953): Fix violations and delete this line
'@typescript-eslint/no-non-null-assertion': 'off', // TODO(ryan953): Fix violations and delete this line
'@typescript-eslint/prefer-literal-enum-member': 'off', // TODO(ryan953): Fix violations and delete this line
'@typescript-eslint/prefer-literal-enum-member': 'error', // TODO(ryan953): Fix violations and delete this line
'@typescript-eslint/unified-signatures': 'off', // TODO(ryan953): Fix violations and delete this line

// Stylistic overrides
Expand All @@ -439,7 +442,6 @@ export default typescript.config([
'@typescript-eslint/no-empty-function': 'off', // TODO(ryan953): Fix violations and delete this line
'@typescript-eslint/no-inferrable-types': 'off', // TODO(ryan953): Fix violations and delete this line
'@typescript-eslint/prefer-for-of': 'off', // TODO(ryan953): Fix violations and delete this line
'@typescript-eslint/prefer-function-type': 'off', // TODO(ryan953): Fix violations and delete this line

// Customization
'@typescript-eslint/no-unused-vars': [
Expand Down Expand Up @@ -558,26 +560,18 @@ export default typescript.config([
// https://github.com/jest-community/eslint-plugin-jest/tree/main/docs/rules
plugins: jest.configs['flat/recommended'].plugins,
rules: {
'jest/max-nested-describe': 'error',
'jest/no-duplicate-hooks': 'error',
'jest/no-large-snapshots': ['error', {maxSize: 2000}], // We don't recommend snapshots, but if there are any keep it small

// https://github.com/jest-community/eslint-plugin-jest/blob/main/src/index.ts
...jest.configs['flat/recommended'].rules,
...jest.configs['flat/style'].rules,

// `recommended` set this to warn, we've upgraded to error
'jest/no-disabled-tests': 'error',

// `recommended` set this to warn, we've downgraded to off
// Disabled as we have many tests which render as simple validations
'jest/expect-expect': 'off',

// Disabled as we have some comment out tests that cannot be
// uncommented due to typescript errors.
'jest/expect-expect': 'off', // Disabled as we have many tests which render as simple validations
'jest/no-commented-out-tests': 'off', // TODO(ryan953): Fix violations then delete this line

// Disabled as we do sometimes have conditional expects
'jest/no-conditional-expect': 'off', // TODO(ryan953): Fix violations then delete this line

// We don't recommend snapshots, but if there are any keep it small
'jest/no-large-snapshots': ['error', {maxSize: 2000}],
'jest/no-disabled-tests': 'error', // `recommended` set this to warn, we've upgraded to error
},
},
{
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@
"qrcode.react": "^3.1.0",
"query-string": "7.0.1",
"react": "18.2.0",
"react-textarea-autosize": "8.5.7",
"react-date-range": "^1.4.0",
"react-dom": "18.2.0",
"react-grid-layout": "^1.3.4",
Expand All @@ -156,6 +155,7 @@
"react-router-dom": "^6.26.2",
"react-select": "4.3.1",
"react-sparklines": "1.7.0",
"react-textarea-autosize": "8.5.7",
"react-virtualized": "^9.22.5",
"reflux": "0.4.1",
"screenfull": "^6.0.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ function AutofixMessageBox({
}

if (text.trim() !== '' || allowEmptyMessage) {
if (onSend != null) {
if (onSend !== null) {
onSend(text);
} else {
send({
Expand Down
14 changes: 6 additions & 8 deletions static/app/utils/profiling/renderers/UIFramesRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@ import type {UIFrameNode, UIFrames} from 'sentry/utils/profiling/uiFrames';

import {upperBound} from '../gl/utils';

export interface UIFramesRendererConstructor {
new (
canvas: HTMLCanvasElement,
uiFrames: UIFrames,
theme: FlamegraphTheme,
options?: {draw_border: boolean}
): UIFramesRenderer;
}
export type UIFramesRendererConstructor = new (
canvas: HTMLCanvasElement,
uiFrames: UIFrames,
theme: FlamegraphTheme,
options?: {draw_border: boolean}
) => UIFramesRenderer;
Comment on lines +9 to +14
Copy link
Member Author

Choose a reason for hiding this comment

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

Something formatting it this way.


export abstract class UIFramesRenderer {
ctx: CanvasRenderingContext2D | WebGLRenderingContext | null = null;
Expand Down
14 changes: 6 additions & 8 deletions static/app/utils/profiling/renderers/flamegraphRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@ export const DEFAULT_FLAMEGRAPH_RENDERER_OPTIONS: FlamegraphRendererOptions = {
draw_border: false,
};

export interface FlamegraphRendererConstructor {
new (
canvas: HTMLCanvasElement,
flamegraph: Flamegraph,
theme: FlamegraphTheme,
options?: FlamegraphRendererOptions
): FlamegraphRenderer;
}
export type FlamegraphRendererConstructor = new (
canvas: HTMLCanvasElement,
flamegraph: Flamegraph,
theme: FlamegraphTheme,
options?: FlamegraphRendererOptions
) => FlamegraphRenderer;

export abstract class FlamegraphRenderer {
ctx: CanvasRenderingContext2D | WebGLRenderingContext | null = null;
Expand Down
2 changes: 1 addition & 1 deletion static/app/utils/statics-setup.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint no-native-reassign:0 */

// biome-ignore lint/style/noVar: Not required
declare var __webpack_public_path__: string;
declare var __webpack_public_path__: string; // eslint-disable-line no-var

/**
* Set the webpack public path at runtime. This is necessary so that imports
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function SetupMessagingIntegrationButton({
messagingIntegrationsQuery.isError ||
integrationProvidersQuery.some(({isPending}) => isPending) ||
integrationProvidersQuery.some(({isError}) => isError) ||
integrationProvidersQuery[0]!.data == null
integrationProvidersQuery[0]!.data === undefined
) {
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion static/app/views/insights/mobile/screens/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {formatPercentage} from 'sentry/utils/number/formatPercentage';
import {VitalState} from 'sentry/views/performance/vitalDetail/utils';

const formatMetricValue = (metric: MetricValue, field?: string | undefined): string => {
if (metric.value == null) {
if (metric.value === undefined) {
return '-';
}
if (typeof metric.value === 'number' && metric.type === 'duration' && metric.unit) {
Expand Down
2 changes: 1 addition & 1 deletion static/app/views/issueList/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type {Organization} from 'sentry/types/organization';
export enum Query {
FOR_REVIEW = 'is:unresolved is:for_review assigned_or_suggested:[me, my_teams, none]',
// biome-ignore lint/style/useLiteralEnumMembers: Disable for maintenance cost.
PRIORITIZED = DEFAULT_QUERY,
PRIORITIZED = DEFAULT_QUERY, // eslint-disable-line @typescript-eslint/prefer-literal-enum-member
UNRESOLVED = 'is:unresolved',
IGNORED = 'is:ignored',
NEW = 'is:new',
Expand Down
2 changes: 2 additions & 0 deletions tests/js/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,12 @@ declare global {
/**
* Generates a promise that resolves on the next macro-task
*/
// eslint-disable-next-line no-var
var tick: () => Promise<void>;
/**
* Used to mock API requests
*/
// eslint-disable-next-line no-var
var MockApiClient: typeof Client;
}

Expand Down
Loading