Skip to content

Commit

Permalink
build: Apply recommended lint rules (#3524)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholas-codecov authored Dec 11, 2024
1 parent cdd2bcd commit 0899f21
Show file tree
Hide file tree
Showing 544 changed files with 1,692 additions and 1,461 deletions.
72 changes: 23 additions & 49 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
// This is dangerous as it hides accidentally undefined variables.
// We blacklist the globals that we deem potentially confusing.
// To use them, explicitly reference them, e.g. `window.name` or `window.status`.
// eslint-disable-next-line @typescript-eslint/no-require-imports
const restrictedGlobals = require('confusing-browser-globals')

module.exports = {
extends: [
// 'eslint:recommended',
// 'plugin:@typescript-eslint/recommended',
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:tailwindcss/recommended',
'plugin:@tanstack/eslint-plugin-query/recommended',
'plugin:react/recommended',
Expand Down Expand Up @@ -117,17 +118,6 @@ module.exports = {
},
],
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': [
'warn',
{
args: 'none',
ignoreRestSiblings: true,
argsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
destructuredArrayIgnorePattern: '^_',
varsIgnorePattern: '^_',
},
],
'no-useless-constructor': 'off',
'@typescript-eslint/no-useless-constructor': 'warn',
'@typescript-eslint/no-explicit-any': 'off',
Expand Down Expand Up @@ -379,42 +369,26 @@ module.exports = {
],
// Everything below, copied from https://github.com/facebook/create-react-app/blob/main/packages/eslint-config-react-app/index.js#L97
// http://eslint.org/docs/rules/
// modified recommended rules
'no-cond-assign': ['warn', 'except-parens'],
'no-const-assign': 'warn',
'no-control-regex': 'warn',
'no-delete-var': 'warn',
'no-dupe-args': 'warn',
'no-dupe-class-members': 'warn',
'no-dupe-keys': 'warn',
'no-duplicate-case': 'warn',
'no-empty-character-class': 'warn',
'no-empty-pattern': 'warn',
'no-ex-assign': 'warn',
'no-fallthrough': 'warn',
'no-func-assign': 'warn',
'no-invalid-regexp': 'warn',
'no-global-assign': 'warn',
'no-unsafe-negation': 'warn',
'no-new-symbol': 'warn',
'no-obj-calls': 'warn',
'no-octal': 'warn',
'no-redeclare': 'warn',
'no-regex-spaces': 'warn',
'no-self-assign': 'warn',
'no-shadow-restricted-names': 'warn',
'no-sparse-arrays': 'warn',
'no-this-before-super': 'warn',
'no-undef': 'error',
'no-unreachable': 'warn',
'no-unused-labels': 'warn',
'no-unused-vars': ['warn', { args: 'none', ignoreRestSiblings: true }],
'no-useless-escape': 'warn',
'no-with': 'warn',
'require-yield': 'warn',
'use-isnan': 'warn',
'valid-typeof': 'warn',
'getter-return': 'warn',
'no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
destructuredArrayIgnorePattern: '^_',
varsIgnorePattern: '^_',
ignoreRestSiblings: true,
},
],
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
destructuredArrayIgnorePattern: '^_',
varsIgnorePattern: '^_',
ignoreRestSiblings: true,
},
],

// custom applied base rules
'array-callback-return': 'warn',
Expand Down
30 changes: 15 additions & 15 deletions src/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -195,56 +195,56 @@ describe('App', () => {
hasSession?: boolean
}) {
server.use(
http.get('/internal/user', (info) => {
http.get('/internal/user', () => {
if (hasSession) {
return HttpResponse.json(internalUser)
} else {
return HttpResponse.json({})
}
}),
http.get('/internal/users/current', (info) => {
http.get('/internal/users/current', () => {
return HttpResponse.json({})
}),
graphql.query('DetailOwner', (info) =>
graphql.query('DetailOwner', () =>
HttpResponse.json({ data: { owner: 'codecov' } })
),
graphql.query('CurrentUser', (info) => {
graphql.query('CurrentUser', () => {
if (hasLoggedInUser) {
return HttpResponse.json({ data: user })
}
HttpResponse.json({ data: {} })
}),
graphql.query('GetPlanData', (info) => {
graphql.query('GetPlanData', () => {
return HttpResponse.json({ data: {} })
}),
graphql.query('OwnerTier', (info) => {
graphql.query('OwnerTier', () => {
return HttpResponse.json({ data: {} })
}),
graphql.query('Seats', (info) => {
graphql.query('Seats', () => {
return HttpResponse.json({ data: {} })
}),
graphql.query('HasAdmins', (info) => {
graphql.query('HasAdmins', () => {
return HttpResponse.json({ data: {} })
}),
graphql.query('owner', (info) => {
graphql.query('owner', () => {
return HttpResponse.json({ data: { owner: { isAdmin: true } } })
}),
graphql.query('MyContexts', (info) => {
graphql.query('MyContexts', () => {
return HttpResponse.json({ data: {} })
}),
graphql.query('GetOktaConfig', (info) => {
graphql.query('GetOktaConfig', () => {
return HttpResponse.json({ data: {} })
}),
graphql.query('OwnerPageData', (info) => {
graphql.query('OwnerPageData', () => {
return HttpResponse.json({ data: {} })
}),
graphql.mutation('updateDefaultOrganization', (info) => {
graphql.mutation('updateDefaultOrganization', () => {
return HttpResponse.json({ data: {} })
}),
graphql.query('GetRepoOverview', (info) => {
graphql.query('GetRepoOverview', () => {
return HttpResponse.json({ data: mockRepoOverview })
}),
graphql.query('GetUploadTokenRequired', (info) => {
graphql.query('GetUploadTokenRequired', () => {
return HttpResponse.json({ data: { owner: null } })
}),
graphql.query('NavigatorData', () => {
Expand Down
1 change: 1 addition & 0 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ if (
process.env.NODE_ENV === 'development' &&
process.env.REACT_APP_MSW_BROWSER
) {
// eslint-disable-next-line @typescript-eslint/no-require-imports
const { worker } = require('./mocks/browser')
worker.start()
}
Expand Down
20 changes: 10 additions & 10 deletions src/layouts/BaseLayout/BaseLayout.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -241,29 +241,29 @@ describe('BaseLayout', () => {
mockedUseImpersonate.mockReturnValue({ isImpersonating })

server.use(
http.get('/internal/user', (info) => {
http.get('/internal/user', () => {
return HttpResponse.json(internalUser)
}),
graphql.query('CurrentUser', (info) => {
graphql.query('CurrentUser', () => {
return HttpResponse.json({ data: currentUser })
}),
graphql.query('DetailOwner', (info) => {
graphql.query('DetailOwner', () => {
return HttpResponse.json({ data: mockOwner })
}),
http.get('/internal/:provider/:owner/account-details', (info) => {
http.get('/internal/:provider/:owner/account-details', () => {
return HttpResponse.json({})
}),
// Self hosted only
graphql.query('HasAdmins', (info) => {
graphql.query('HasAdmins', () => {
return HttpResponse.json({ data: { config: null } })
}),
graphql.query('Seats', (info) => {
graphql.query('Seats', () => {
return HttpResponse.json({ data: {} })
}),
graphql.query('TermsOfService', (info) => {
graphql.query('TermsOfService', () => {
return HttpResponse.json({ data: {} })
}),
graphql.query('UseMyOrganizations', (info) => {
graphql.query('UseMyOrganizations', () => {
return HttpResponse.json({
data: {
myOrganizationsData: {
Expand All @@ -277,13 +277,13 @@ describe('BaseLayout', () => {
},
})
}),
graphql.mutation('updateDefaultOrganization', (info) => {
graphql.mutation('updateDefaultOrganization', () => {
return HttpResponse.json({ data: {} })
}),
graphql.query('NavigatorData', () => {
return HttpResponse.json({ data: mockNavigatorData })
}),
http.get('/internal/users/current', (info) => {
http.get('/internal/users/current', () => {
return HttpResponse.json({})
})
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe('InstallationHelpBanner', () => {
const mockGetItem = vi.spyOn(window.localStorage.__proto__, 'getItem')

server.use(
graphql.query('IsSyncing', (info) => {
graphql.query('IsSyncing', () => {
return HttpResponse.json({
data: {
me: {
Expand Down
6 changes: 3 additions & 3 deletions src/layouts/BaseLayout/hooks/useUserAccessGate.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const queryClient = new QueryClient({
})
const server = setupServer()

let testLocation: { pathname: string; search: string } = {
const testLocation: { pathname: string; search: string } = {
pathname: '',
search: '',
}
Expand Down Expand Up @@ -255,11 +255,11 @@ describe('useUserAccessGate', () => {
const mockMutationVariables = vi.fn()

server.use(
http.get('/internal/user', (info) => {
http.get('/internal/user', () => {
return HttpResponse.json(internalUser)
}),

graphql.query('CurrentUser', (info) => {
graphql.query('CurrentUser', () => {
return HttpResponse.json({ data: user })
}),
graphql.mutation('updateDefaultOrganization', async (info) => {
Expand Down
2 changes: 1 addition & 1 deletion src/layouts/Header/Header.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ describe('Header', () => {
function setup({ user = mockUser }: SetupArgs) {
mockedUseImpersonate.mockReturnValue({ isImpersonating: false })
server.use(
graphql.query('CurrentUser', (info) => {
graphql.query('CurrentUser', () => {
return HttpResponse.json({ data: user })
})
)
Expand Down
2 changes: 1 addition & 1 deletion src/layouts/Header/components/AdminLink/AdminLink.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ afterAll(() => {
describe('AdminLink', () => {
function setup(data = {}) {
server.use(
http.get('/internal/users/current', (info) => {
http.get('/internal/users/current', () => {
return HttpResponse.json(data)
})
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ describe('MyContextSwitcher', () => {
return HttpResponse.json({ data: { me: null } })
}

const orgList = !!info.variables?.after ? org2 : org1
const orgList = info.variables?.after ? org2 : org1
const hasNextPage = info.variables?.after ? false : true
const endCursor = info.variables?.after ? 'second' : 'first'

Expand All @@ -105,7 +105,7 @@ describe('MyContextSwitcher', () => {

return HttpResponse.json({ data: queryData })
}),
graphql.query('DetailOwner', (info) => {
graphql.query('DetailOwner', () => {
if (noData) {
return HttpResponse.json({ data: { me: null } })
}
Expand Down
6 changes: 3 additions & 3 deletions src/layouts/Header/components/Navigator/Navigator.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,10 @@ interface SetupArgs {
describe('Header Navigator', () => {
function setup({ isMyOrg = true, orgDoesNotExist = false }: SetupArgs) {
server.use(
graphql.query('MyContexts', (info) => {
graphql.query('MyContexts', () => {
return HttpResponse.json({ data: mockMyContexts })
}),
graphql.query('DetailOwner', (info) => {
graphql.query('DetailOwner', () => {
if (orgDoesNotExist) {
return HttpResponse.json({ data: { owner: null } })
}
Expand All @@ -188,7 +188,7 @@ describe('Header Navigator', () => {

return HttpResponse.json({ data: mockDetailOwner })
}),
graphql.query('OwnerPageData', (info) => {
graphql.query('OwnerPageData', () => {
if (isMyOrg) {
return HttpResponse.json({ data: mockOwnerPageData })
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ afterAll(() => {
describe('SeatDetails', () => {
function setup({ data = mockData }: { data?: any }) {
server.use(
graphql.query('Seats', (info) => {
graphql.query('Seats', () => {
return HttpResponse.json({ data })
})
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ describe('ThemeToggle', () => {

it('assumes light mode when there is no theme in local storage', () => {
setup({ isMediaPrefersDark: false })
mockGetItem.mockImplementation((key) => null)
mockGetItem.mockImplementation(() => null)
render(
<ThemeContextProvider>
<ThemeToggle />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@ describe('UserDropdown', () => {
config.API_URL = ''

server.use(
http.post('/logout', (info) => {
http.post('/logout', () => {
return HttpResponse.json({}, { status: 205 })
}),
graphql.query('CurrentUser', (info) => {
graphql.query('CurrentUser', () => {
return HttpResponse.json({ data: mockUser })
})
)
Expand Down
2 changes: 1 addition & 1 deletion src/layouts/LoginLayout/LoginLayout.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ afterAll(() => {
describe('LoginLayout', () => {
function setup() {
server.use(
graphql.query('CurrentUser', (info) => {
graphql.query('CurrentUser', () => {
return HttpResponse.json({ data: { me: null } })
})
)
Expand Down
2 changes: 1 addition & 1 deletion src/layouts/shared/ErrorBoundary/ErrorBoundary.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ describe('Error Boundary', () => {
beforeEach(() => {
const spySentry = vi.spyOn(Sentry, 'withScope')
spySentry.mockImplementation((callback) => {
// @ts-ignore - this test is skipped
// @ts-expect-error - this test is skipped
callback({ setTag: sentryMockScope })
})
})
Expand Down
Loading

0 comments on commit 0899f21

Please sign in to comment.