diff --git a/eslint.config.mjs b/eslint.config.mjs index 10103b57b0e4dc..73a2acab619f4e 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -29,11 +29,6 @@ const restrictedImportPatterns = [ group: ['sentry/components/devtoolbar/*'], message: 'Do not depend on toolbar internals', }, - { - group: ['*.spec*'], - message: - 'Do not import from test files. This causes tests to be executed multiple times.', - }, ]; const restrictedImportPaths = [ @@ -752,23 +747,30 @@ export default typescript.config([ files: ['**/*.spec.{ts,js,tsx,jsx}', 'tests/js/**/*.{ts,js,tsx,jsx}'], plugins: jest.configs['flat/recommended'].plugins, rules: { + ...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/no-commented-out-tests': 'off', + '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', - - // Useful for exporting some test utilities - 'jest/no-export': 'off', + '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-alias-methods': 'off', // TODO(ryan953): Fix violations then delete this line + 'jest/prefer-to-be': 'off', // TODO(ryan953): Fix violations then delete this line + 'jest/prefer-to-contain': 'off', // TODO(ryan953): Fix violations then delete this line + 'jest/prefer-to-have-length': 'off', // TODO(ryan953): Fix violations then delete this line }, }, { diff --git a/static/app/components/events/contexts/knownContext/browser.spec.tsx b/static/app/components/events/contexts/knownContext/browser.spec.tsx index d42e6c3b02a949..7018b6581b0ba7 100644 --- a/static/app/components/events/contexts/knownContext/browser.spec.tsx +++ b/static/app/components/events/contexts/knownContext/browser.spec.tsx @@ -8,7 +8,7 @@ import { getBrowserContextData, } from 'sentry/components/events/contexts/knownContext/browser'; -export const MOCK_BROWSER_CONTEXT: BrowserContext = { +const MOCK_BROWSER_CONTEXT: BrowserContext = { version: '83.0.4103', type: 'browser', name: '', @@ -17,7 +17,7 @@ export const MOCK_BROWSER_CONTEXT: BrowserContext = { unknown_key: 123, }; -export const MOCK_REDACTION = { +const MOCK_REDACTION = { name: { '': { chunks: [ diff --git a/static/app/components/events/contexts/platformContext/unity.spec.tsx b/static/app/components/events/contexts/platformContext/unity.spec.tsx index 5ef900a88519ee..8d920d535ba252 100644 --- a/static/app/components/events/contexts/platformContext/unity.spec.tsx +++ b/static/app/components/events/contexts/platformContext/unity.spec.tsx @@ -5,7 +5,7 @@ import {render, screen} from 'sentry-test/reactTestingLibrary'; import ContextCard from 'sentry/components/events/contexts/contextCard'; import {getUnityContextData} from 'sentry/components/events/contexts/platformContext/unity'; -export const MOCK_UNITY_CONTEXT = { +const MOCK_UNITY_CONTEXT = { type: 'unity' as const, copy_texture_support: 'Basic, Copy3D, DifferentTypes, TextureToRT, RTToTexture', editor_version: '2022.1.23f1', @@ -17,7 +17,7 @@ export const MOCK_UNITY_CONTEXT = { unknown_key: 123, }; -export const MOCK_REDACTION = { +const MOCK_REDACTION = { install_mode: { '': { rem: [['organization:0', 'x']], diff --git a/static/app/utils/profiling/profile/profile.spec.tsx b/static/app/utils/profiling/profile/profile.spec.tsx index 4d37e2467d90bc..5c19deb97fca18 100644 --- a/static/app/utils/profiling/profile/profile.spec.tsx +++ b/static/app/utils/profiling/profile/profile.spec.tsx @@ -1,39 +1,8 @@ -import type {CallTreeNode} from 'sentry/utils/profiling/callTreeNode'; import {Frame} from 'sentry/utils/profiling/frame'; import {Profile} from 'sentry/utils/profiling/profile/profile'; import {c, f, makeTestingBoilerplate} from './testUtils'; -// Since it's easy to make mistakes or accidentally assign parents to the wrong nodes, this utility fn -// will format the stack samples as a tree string so it's more human friendly. -export const _logExpectedStack = (samples: Profile['samples']): string => { - const head = ` -Samples follow a top-down chronological order\n\n`; - - const tail = `\n ------------------------> -stack top -> stack bottom`; - - const final: string[] = []; - - const visit = (node: CallTreeNode, str: string[]) => { - str.push(`${node.frame.name}`); - - if (node.parent) { - visit(node.parent, str); - } - }; - - for (const stackTop of samples) { - const str = []; - visit(stackTop, str); - - final.push(str.join(' -> ')); - } - - return `${head}${final.join('\n')}${tail}`; -}; - describe('Profile', () => { it('Empty profile duration is not infinity', () => { const profile = Profile.Empty; diff --git a/static/app/utils/tokenizeSearch.spec.tsx b/static/app/utils/tokenizeSearch.spec.tsx index 40e20571e6461f..9826acf9bde12e 100644 --- a/static/app/utils/tokenizeSearch.spec.tsx +++ b/static/app/utils/tokenizeSearch.spec.tsx @@ -197,7 +197,7 @@ describe('utils/tokenizeSearch', function () { ]; for (const {name, string, object} of cases) { - it(name, () => expect(new MutableSearch(string)).toEqual(object)); + it(`${name}`, () => expect(new MutableSearch(string)).toEqual(object)); } }); @@ -504,7 +504,7 @@ describe('utils/tokenizeSearch', function () { ]; for (const {name, string, object} of cases) { - it(name, () => expect(object.formatString()).toEqual(string)); + it(`${name}`, () => expect(object.formatString()).toEqual(string)); } }); }); diff --git a/static/app/views/discover/table/quickContext/releaseContext.spec.tsx b/static/app/views/discover/table/quickContext/releaseContext.spec.tsx index b443c16a499186..3008c48dee40b0 100644 --- a/static/app/views/discover/table/quickContext/releaseContext.spec.tsx +++ b/static/app/views/discover/table/quickContext/releaseContext.spec.tsx @@ -12,7 +12,7 @@ import {QueryClientProvider} from 'sentry/utils/queryClient'; import ReleaseContext from './releaseContext'; import {defaultRow, mockedCommit, mockedUser1, mockedUser2} from './testUtils'; -export const mockedReleaseWithHealth = ReleaseFixture({ +const mockedReleaseWithHealth = ReleaseFixture({ id: '1', shortVersion: 'sentry-android-shop@1.2.0', version: 'sentry-android-shop@1.2.0', diff --git a/static/app/views/monitors/components/timeline/checkInTooltip.spec.tsx b/static/app/views/monitors/components/timeline/checkInTooltip.spec.tsx index 0599acf5fde9ec..3b24ba10236dab 100644 --- a/static/app/views/monitors/components/timeline/checkInTooltip.spec.tsx +++ b/static/app/views/monitors/components/timeline/checkInTooltip.spec.tsx @@ -14,7 +14,7 @@ type StatusCounts = [ unknown: number, ]; -export function generateEnvMapping(name: string, counts: StatusCounts) { +function generateEnvMapping(name: string, counts: StatusCounts) { const [in_progress, ok, missed, timeout, error, unknown] = counts; return { [name]: {in_progress, ok, missed, timeout, error, unknown}, diff --git a/static/app/views/monitors/components/timeline/utils/getAggregateStatus.spec.tsx b/static/app/views/monitors/components/timeline/utils/getAggregateStatus.spec.tsx index b0ab489cee5d1b..0d6d12597e64b8 100644 --- a/static/app/views/monitors/components/timeline/utils/getAggregateStatus.spec.tsx +++ b/static/app/views/monitors/components/timeline/utils/getAggregateStatus.spec.tsx @@ -14,14 +14,14 @@ type StatusCounts = [ unknown: number, ]; -export function generateEnvMapping(name: string, counts: StatusCounts) { +function generateEnvMapping(name: string, counts: StatusCounts) { const [in_progress, ok, missed, timeout, error, unknown] = counts; return { [name]: {in_progress, ok, missed, timeout, error, unknown}, }; } -export function generateStats(counts: StatusCounts) { +function generateStats(counts: StatusCounts) { const [in_progress, ok, missed, timeout, error, unknown] = counts; return { in_progress, diff --git a/static/app/views/monitors/components/timeline/utils/getAggregateStatusFromMultipleBuckets.spec.tsx b/static/app/views/monitors/components/timeline/utils/getAggregateStatusFromMultipleBuckets.spec.tsx index cec4ec0569395a..209cd6eb3cd93c 100644 --- a/static/app/views/monitors/components/timeline/utils/getAggregateStatusFromMultipleBuckets.spec.tsx +++ b/static/app/views/monitors/components/timeline/utils/getAggregateStatusFromMultipleBuckets.spec.tsx @@ -14,14 +14,14 @@ type StatusCounts = [ unknown: number, ]; -export function generateEnvMapping(name: string, counts: StatusCounts) { +function generateEnvMapping(name: string, counts: StatusCounts) { const [in_progress, ok, missed, timeout, error, unknown] = counts; return { [name]: {in_progress, ok, missed, timeout, error, unknown}, }; } -export function generateStats(counts: StatusCounts) { +function generateStats(counts: StatusCounts) { const [in_progress, ok, missed, timeout, error, unknown] = counts; return { in_progress, diff --git a/static/app/views/monitors/components/timeline/utils/mergeBuckets.spec.tsx b/static/app/views/monitors/components/timeline/utils/mergeBuckets.spec.tsx index 0bc05f1828975f..154ca5d4481102 100644 --- a/static/app/views/monitors/components/timeline/utils/mergeBuckets.spec.tsx +++ b/static/app/views/monitors/components/timeline/utils/mergeBuckets.spec.tsx @@ -13,7 +13,7 @@ type StatusCounts = [ unknown: number, ]; -export function generateEnvMapping(name: string, counts: StatusCounts) { +function generateEnvMapping(name: string, counts: StatusCounts) { const [in_progress, ok, missed, timeout, error, unknown] = counts; return { [name]: {in_progress, ok, missed, timeout, error, unknown}, diff --git a/static/app/views/monitors/components/timeline/utils/mergeEnvMappings.spec.tsx b/static/app/views/monitors/components/timeline/utils/mergeEnvMappings.spec.tsx index 913c5e2a321b8b..2e27116c7b0245 100644 --- a/static/app/views/monitors/components/timeline/utils/mergeEnvMappings.spec.tsx +++ b/static/app/views/monitors/components/timeline/utils/mergeEnvMappings.spec.tsx @@ -14,7 +14,7 @@ type StatusCounts = [ unknown: number, ]; -export function generateStats(counts: StatusCounts) { +function generateStats(counts: StatusCounts) { const [in_progress, ok, missed, timeout, error, unknown] = counts; return { in_progress, diff --git a/tests/js/setup.ts b/tests/js/setup.ts index 22b7d07fa09c32..89f36a61b5c5fc 100644 --- a/tests/js/setup.ts +++ b/tests/js/setup.ts @@ -10,6 +10,7 @@ import {ConfigFixture} from 'sentry-fixture/config'; import {resetMockDate} from 'sentry-test/utils'; +// eslint-disable-next-line jest/no-mocks-import import type {Client} from 'sentry/__mocks__/api'; // eslint-disable-next-line no-restricted-imports import {DEFAULT_LOCALE_DATA, setLocale} from 'sentry/locale';