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

build: Apply recommended lint rules #3524

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
c26bf00
add new deps for eslint rules
nicholas-codecov Nov 18, 2024
e1120f3
update eslint related packages
nicholas-codecov Nov 18, 2024
72eb6f6
build out eslint config based off of react-scripts lint rules
nicholas-codecov Nov 18, 2024
cc027fc
Merge branch 'main' into gh-eng-2124-audit-and-update-lint-rules-for-…
nicholas-codecov Nov 18, 2024
9130e2c
also remove storybook create-react-app preset
nicholas-codecov Nov 18, 2024
052d2c8
remove duplicated or deprecated rules
nicholas-codecov Nov 18, 2024
5ee1ca4
allow unused vars to be ignored with an underscore
nicholas-codecov Nov 19, 2024
49332de
ignore errors in catch statement with underscores
nicholas-codecov Nov 19, 2024
2f67f48
remove unused vars for their respective type declartions
nicholas-codecov Nov 19, 2024
4c9f62b
use underscore to silence lint warning
nicholas-codecov Nov 19, 2024
614ae25
re-org rules to be split between modified base rules and custom rules
nicholas-codecov Nov 21, 2024
9f7867b
apply recommended rules
nicholas-codecov Nov 21, 2024
a8725b2
enable base eslint recomendations
nicholas-codecov Nov 21, 2024
b8039c4
apply eslint recommendations to files
nicholas-codecov Nov 21, 2024
aced51f
enable typescript-eslint recommended rules
nicholas-codecov Nov 21, 2024
19770fe
fix linting issues
nicholas-codecov Nov 21, 2024
4668dd4
expect ts error for useUpdateRepo as it's not typed yet
nicholas-codecov Nov 21, 2024
a8d9dc9
remove these two quick changes that aren't lint related
nicholas-codecov Nov 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
410 changes: 294 additions & 116 deletions .eslintrc.cjs

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion .storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const config: StorybookConfig = {
'@storybook/addon-a11y',
'@storybook/addon-links',
'@storybook/addon-essentials',
'@storybook/preset-create-react-app',
'@chromatic-com/storybook',
],
docs: {},
Expand Down
22 changes: 15 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
},
"devDependencies": {
"@acemarke/react-prod-sourcemaps": "^0.3.1",
"@babel/eslint-parser": "^7.25.9",
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
"@chromatic-com/storybook": "^1",
"@codecov/vite-plugin": "^1.2.1",
Expand All @@ -100,21 +101,22 @@
"@storybook/builder-vite": "^8.3.4",
"@storybook/manager-api": "^8.3.4",
"@storybook/node-logger": "^8.3.4",
"@storybook/preset-create-react-app": "^8.3.4",
"@storybook/react": "^8.3.4",
"@storybook/react-vite": "^8.3.4",
"@storybook/theming": "^8.3.4",
"@tailwindcss/container-queries": "^0.1.1",
"@tanstack/eslint-plugin-query": "^4.29.4",
"@tanstack/eslint-plugin-query": "^4.38.0",
"@tanstack/react-query-devtools": "^4.29.6",
"@testing-library/dom": "10.3.2",
"@testing-library/jest-dom": "^6.4.2",
"@testing-library/react": "^16.0.0",
"@testing-library/user-event": "^14.5.2",
"@total-typescript/ts-reset": "^0.4.2",
"@types/confusing-browser-globals": "^1",
"@types/d3": "7.4.3",
"@types/d3-array": "3.2.1",
"@types/d3-scale": "4.0.8",
"@types/eslint-plugin-jsx-a11y": "^6.9.0",
"@types/js-cookie": "3.0.6",
"@types/lodash": "4.17.6",
"@types/node": "^20.5.7",
Expand All @@ -126,27 +128,33 @@
"@types/react-modal": "^3.16.2",
"@types/react-router-dom": "^5.3.3",
"@types/semver": "^7",
"@typescript-eslint/eslint-plugin": "^8.14.0",
"@typescript-eslint/parser": "^8.14.0",
"@vitejs/plugin-legacy": "^5.4.3",
"@vitejs/plugin-react": "^4.3.3",
"@vitest/coverage-istanbul": "^2.1.3",
"@vitest/eslint-plugin": "^1.1.7",
"@vitest/ui": "^2.1.3",
"autoprefixer": "^10.4.14",
"eslint": "^8.39.0",
"babel-preset-react-app": "^10.0.1",
"confusing-browser-globals": "^1.0.11",
"eslint": "^8.57.1",
"eslint-config-prettier": "^9.1.0",
"eslint-import-resolver-alias": "^1.1.2",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-jsx-a11y": "^6.10.2",
"eslint-plugin-react": "^7.37.2",
"eslint-plugin-react-hooks": "^5.0.0",
"eslint-plugin-storybook": "^0.8.0",
"eslint-plugin-tailwindcss": "^3.17.4",
"eslint-plugin-testing-library": "^6.3.0",
"eslint-plugin-tailwindcss": "^3.17.5",
"eslint-plugin-testing-library": "^6.4.0",
"http-proxy-middleware": "^2.0.7",
"husky": "^9.1.4",
"jsdom": "^25.0.0",
"lint-staged": "^15.2.8",
"msw": "^2.4.11",
"postcss": "^8.4.31",
"prettier": "^3.3.3",
"react-scripts": "^5.0.1",
"react-test-renderer": "^18.3.1",
"remark-gfm": "^3.0.1",
"resolve-url-loader": "^5.0.0",
Expand Down
30 changes: 15 additions & 15 deletions src/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -180,56 +180,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: {} })
})
)
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 @@ -222,29 +222,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: {} })
}),
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 @@ -258,10 +258,10 @@ describe('BaseLayout', () => {
},
})
}),
graphql.mutation('updateDefaultOrganization', (info) => {
graphql.mutation('updateDefaultOrganization', () => {
return HttpResponse.json({ data: {} })
}),
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 } = {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Auto fix as this wasn't being reassigned

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 @@ -115,7 +115,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
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Linter autofix

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 @@ -181,17 +181,17 @@ interface SetupArgs {
describe('Header Navigator', () => {
function setup({ isMyOrg = true }: SetupArgs) {
server.use(
graphql.query('MyContexts', (info) => {
graphql.query('MyContexts', () => {
return HttpResponse.json({ data: mockMyContexts })
}),
graphql.query('DetailOwner', (info) => {
graphql.query('DetailOwner', () => {
if (!isMyOrg) {
return HttpResponse.json({ data: mockDetailOwnerNotMyOrg })
}

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 @@ -113,10 +113,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
Loading