Skip to content

Commit 37a6465

Browse files
ref(eslint): prefer-arrow-callback for anonymous callback functions (#97853)
Co-authored-by: getsantry[bot] <66042841+getsantry[bot]@users.noreply.github.com>
1 parent 7a04836 commit 37a6465

File tree

1,128 files changed

+8889
-8912
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,128 files changed

+8889
-8912
lines changed

eslint.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,7 @@ export default typescript.config([
355355
'no-sequences': 'error',
356356
'no-throw-literal': 'error',
357357
'object-shorthand': ['error', 'properties'],
358+
'prefer-arrow-callback': ['error', {allowNamedFunctions: true}],
358359
radix: 'error',
359360
'require-await': 'error', // Enabled in favor of @typescript-eslint/require-await, which requires type info
360361
'spaced-comment': [

static/app/actionCreators/account.spec.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {testableWindowLocation} from 'sentry/utils/testableWindowLocation';
55
import {logout} from './account';
66

77
describe('logout', () => {
8-
it('has can logout', async function () {
8+
it('has can logout', async () => {
99
const mockApi = new MockApiClient();
1010
const mockApiDelete = MockApiClient.addMockResponse({
1111
url: '/auth/',

static/app/actionCreators/events.spec.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {ProjectFixture} from 'sentry-fixture/project';
33

44
import {doEventsRequest} from 'sentry/actionCreators/events';
55

6-
describe('Events ActionCreator', function () {
6+
describe('Events ActionCreator', () => {
77
const api = new MockApiClient();
88
const organization = OrganizationFixture();
99
const project = ProjectFixture();
@@ -15,7 +15,7 @@ describe('Events ActionCreator', function () {
1515

1616
let mock: jest.Mock;
1717

18-
beforeEach(function () {
18+
beforeEach(() => {
1919
MockApiClient.clearMockResponses();
2020
mock = MockApiClient.addMockResponse({
2121
url: '/organizations/org-slug/events-stats/',
@@ -32,7 +32,7 @@ describe('Events ActionCreator', function () {
3232
});
3333
});
3434

35-
it('requests events stats with relative period', async function () {
35+
it('requests events stats with relative period', async () => {
3636
await doEventsRequest<false>(api, {
3737
...opts,
3838
includeAllArgs: false,
@@ -53,7 +53,7 @@ describe('Events ActionCreator', function () {
5353
);
5454
});
5555

56-
it('requests events stats with relative period including previous period', async function () {
56+
it('requests events stats with relative period including previous period', async () => {
5757
await doEventsRequest<false>(api, {
5858
...opts,
5959
includeAllArgs: false,
@@ -74,7 +74,7 @@ describe('Events ActionCreator', function () {
7474
);
7575
});
7676

77-
it('requests events stats with absolute period', async function () {
77+
it('requests events stats with absolute period', async () => {
7878
const start = new Date('2017-10-12T12:00:00.000Z');
7979
const end = new Date('2017-10-17T00:00:00.000Z');
8080
await doEventsRequest<false>(api, {
@@ -100,7 +100,7 @@ describe('Events ActionCreator', function () {
100100
);
101101
});
102102

103-
it('requests events stats with absolute period including previous period', async function () {
103+
it('requests events stats with absolute period including previous period', async () => {
104104
const start = new Date('2017-10-12T12:00:00.000Z');
105105
const end = new Date('2017-10-17T00:00:00.000Z');
106106
await doEventsRequest<false>(api, {
@@ -125,7 +125,7 @@ describe('Events ActionCreator', function () {
125125
);
126126
});
127127

128-
it('spreads query extras', async function () {
128+
it('spreads query extras', async () => {
129129
await doEventsRequest<false>(api, {
130130
...opts,
131131
includeAllArgs: false,

static/app/actionCreators/group.spec.tsx

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import {bulkUpdate, mergeGroups, paramsToQueryArgs} from 'sentry/actionCreators/
22
import GroupStore from 'sentry/stores/groupStore';
33

44
describe('group', () => {
5-
describe('paramsToQueryArgs()', function () {
6-
it('should convert itemIds properties to id array', function () {
5+
describe('paramsToQueryArgs()', () => {
6+
it('should convert itemIds properties to id array', () => {
77
expect(
88
paramsToQueryArgs({
99
itemIds: ['1', '2', '3'],
@@ -12,7 +12,7 @@ describe('group', () => {
1212
).toEqual({id: ['1', '2', '3']});
1313
});
1414

15-
it('should extract query property if no itemIds', function () {
15+
it('should extract query property if no itemIds', () => {
1616
const invalidArgs: any = {
1717
foo: 'bar',
1818
};
@@ -22,7 +22,7 @@ describe('group', () => {
2222
});
2323
});
2424

25-
it('should convert params w/o itemIds or query to empty object', function () {
25+
it('should convert params w/o itemIds or query to empty object', () => {
2626
const invalidArgs: any = {
2727
foo: 'bar',
2828
bar: 'baz', // paramsToQueryArgs ignores these
@@ -31,7 +31,7 @@ describe('group', () => {
3131
expect(paramsToQueryArgs(invalidArgs)).toEqual({});
3232
});
3333

34-
it('should keep environment when query is provided', function () {
34+
it('should keep environment when query is provided', () => {
3535
expect(
3636
paramsToQueryArgs({
3737
query: 'is:unresolved',
@@ -40,7 +40,7 @@ describe('group', () => {
4040
).toEqual({query: 'is:unresolved', environment: 'production'});
4141
});
4242

43-
it('should exclude environment when it is null/undefined', function () {
43+
it('should exclude environment when it is null/undefined', () => {
4444
expect(
4545
paramsToQueryArgs({
4646
query: 'is:unresolved',
@@ -49,7 +49,7 @@ describe('group', () => {
4949
).toEqual({query: 'is:unresolved'});
5050
});
5151

52-
it('should handle non-empty projects', function () {
52+
it('should handle non-empty projects', () => {
5353
expect(
5454
paramsToQueryArgs({
5555
itemIds: ['1', '2', '3'],
@@ -73,12 +73,12 @@ describe('group', () => {
7373
});
7474
});
7575

76-
describe('bulkUpdate()', function () {
77-
beforeEach(function () {
76+
describe('bulkUpdate()', () => {
77+
beforeEach(() => {
7878
jest.spyOn(GroupStore, 'onUpdate'); // stub GroupStore.onUpdate call from update
7979
});
8080

81-
it('should use itemIds as query if provided', function () {
81+
it('should use itemIds as query if provided', () => {
8282
const request = MockApiClient.addMockResponse({
8383
url: '/projects/1337/1337/issues/',
8484
method: 'PUT',
@@ -103,7 +103,7 @@ describe('group', () => {
103103
);
104104
});
105105

106-
it('should use query as query if itemIds are absent', function () {
106+
it('should use query as query if itemIds are absent', () => {
107107
const request = MockApiClient.addMockResponse({
108108
url: '/projects/1337/1337/issues/',
109109
method: 'PUT',
@@ -128,7 +128,7 @@ describe('group', () => {
128128
);
129129
});
130130

131-
it('should apply project option', function () {
131+
it('should apply project option', () => {
132132
const request = MockApiClient.addMockResponse({
133133
url: '/organizations/1337/issues/',
134134
method: 'PUT',
@@ -153,14 +153,14 @@ describe('group', () => {
153153
});
154154
});
155155

156-
describe('mergeGroups()', function () {
156+
describe('mergeGroups()', () => {
157157
// TODO: this is totally copypasta from the test above. We need to refactor
158158
// these API methods/tests.
159-
beforeEach(function () {
159+
beforeEach(() => {
160160
jest.spyOn(GroupStore, 'onMerge'); // stub GroupStore.onMerge call from mergeGroups
161161
});
162162

163-
it('should use itemIds as query if provided', function () {
163+
it('should use itemIds as query if provided', () => {
164164
const request = MockApiClient.addMockResponse({
165165
url: '/projects/1337/1337/issues/',
166166
method: 'PUT',
@@ -184,7 +184,7 @@ describe('group', () => {
184184
);
185185
});
186186

187-
it('should use query as query if itemIds are absent', function () {
187+
it('should use query as query if itemIds are absent', () => {
188188
const request = MockApiClient.addMockResponse({
189189
url: '/projects/1337/1337/issues/',
190190
method: 'PUT',

static/app/actionCreators/navigation.spec.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ describe('navigation ActionCreator', () => {
9999
expect(openModal).toHaveBeenCalled();
100100
});
101101

102-
it('normalizes URLs for customer domains', function () {
102+
it('normalizes URLs for customer domains', () => {
103103
ConfigStore.set('customerDomain', {
104104
subdomain: 'albertos-apples',
105105
organizationUrl: 'https://albertos-apples.sentry.io',
@@ -115,7 +115,7 @@ describe('navigation ActionCreator', () => {
115115
expect(router.push).toHaveBeenCalledWith('/settings/projects/project-slug/alerts/');
116116
});
117117

118-
it('preserves query parameters in path object', function () {
118+
it('preserves query parameters in path object', () => {
119119
router.location.query.project = '2';
120120
navigateTo(
121121
{

static/app/actionCreators/organization.spec.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,28 @@ import OrganizationStore from 'sentry/stores/organizationStore';
88
import ProjectsStore from 'sentry/stores/projectsStore';
99
import TeamStore from 'sentry/stores/teamStore';
1010

11-
describe('OrganizationActionCreator', function () {
11+
describe('OrganizationActionCreator', () => {
1212
const org = OrganizationFixture();
1313

1414
const teams = [TeamFixture()];
1515
const projects = [ProjectFixture()];
1616

1717
const api = new MockApiClient();
1818

19-
beforeEach(function () {
19+
beforeEach(() => {
2020
jest.spyOn(TeamStore, 'loadInitialData');
2121
jest.spyOn(ProjectsStore, 'loadInitialData');
2222
jest.spyOn(OrganizationStore, 'onUpdate');
2323
jest.spyOn(OrganizationStore, 'onFetchOrgError');
2424
jest.spyOn(OrganizationsActionCreator, 'setActiveOrganization');
2525
});
2626

27-
afterEach(function () {
27+
afterEach(() => {
2828
jest.restoreAllMocks();
2929
MockApiClient.clearMockResponses();
3030
});
3131

32-
it('fetches organization details', async function () {
32+
it('fetches organization details', async () => {
3333
const getOrgMock = MockApiClient.addMockResponse({
3434
url: `/organizations/${org.slug}/`,
3535
body: org,
@@ -65,7 +65,7 @@ describe('OrganizationActionCreator', function () {
6565
expect(ProjectsStore.loadInitialData).toHaveBeenCalledWith(projects);
6666
});
6767

68-
it('errors out correctly', async function () {
68+
it('errors out correctly', async () => {
6969
const getOrgMock = MockApiClient.addMockResponse({
7070
url: `/organizations/${org.slug}/`,
7171
statusCode: 400,

static/app/actionCreators/organizations.spec.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ import {fetchOrganizations} from 'sentry/actionCreators/organizations';
44
import ConfigStore from 'sentry/stores/configStore';
55
import {testableWindowLocation} from 'sentry/utils/testableWindowLocation';
66

7-
describe('fetchOrganizations', function () {
7+
describe('fetchOrganizations', () => {
88
const api = new MockApiClient();
99
const usorg = OrganizationFixture({slug: 'us-org'});
1010
const deorg = OrganizationFixture({slug: 'de-org'});
1111

12-
beforeEach(function () {
12+
beforeEach(() => {
1313
MockApiClient.clearMockResponses();
1414
});
1515

16-
it('fetches from multiple regions', async function () {
16+
it('fetches from multiple regions', async () => {
1717
ConfigStore.set('memberRegions', [
1818
{name: 'us', url: 'https://us.example.org'},
1919
{name: 'de', url: 'https://de.example.org'},
@@ -44,7 +44,7 @@ describe('fetchOrganizations', function () {
4444
expect(deMock).toHaveBeenCalledTimes(1);
4545
});
4646

47-
it('ignores 401 errors from a region', async function () {
47+
it('ignores 401 errors from a region', async () => {
4848
ConfigStore.set('memberRegions', [
4949
{name: 'us', url: 'https://us.example.org'},
5050
{name: 'de', url: 'https://de.example.org'},

0 commit comments

Comments
 (0)