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

Merged
merged 14 commits into from
Dec 11, 2024

Conversation

nicholas-codecov
Copy link
Contributor

@nicholas-codecov nicholas-codecov commented Nov 21, 2024

Description

Note

Requires #3508 to be merged before reviewing.

This PR applies the recommended rules from eslint and typescript-eslint

Ticket: codecov/engineering-team#2124

Notable Changes

  • Enable eslint:recommended and plugin:@typescript-eslint/recommended
  • Fix lint warnings, and errors
    • 99% of these fixes are resolving unused vars and ts-expect-error with no message
      • Unused types may either be removed or by prepending a _ to the argument
    • Replacing args typed as {} to object or correct type
    • There are a couple other changes that have been applied automatically by the linter, they include:
      • Removing double !! when they're not needed such as in conditionals
      • Converting let to const for values that aren't being reassigned

@codecov-staging
Copy link

codecov-staging bot commented Nov 21, 2024

Bundle Report

Changes will increase total bundle size by 5.04kB (0.03%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
gazebo-staging-system-esm 5.72MB 2.92kB (0.05%) ⬆️
gazebo-staging-system 5.67MB 2.12kB (0.04%) ⬆️

@codecov-staging
Copy link

codecov-staging bot commented Nov 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

✅ All tests successful. No failed tests found.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #3524   +/-   ##
=======================================
  Coverage   98.90%   98.90%           
=======================================
  Files         806      806           
  Lines       14484    14484           
  Branches     4111     4115    +4     
=======================================
+ Hits        14325    14326    +1     
+ Misses        152      151    -1     
  Partials        7        7           
Files with missing lines Coverage Δ
...rc/pages/AdminSettings/AdminAccess/AdminAccess.tsx 100.00% <ø> (ø)
...inSettings/AdminMembers/MemberList/MemberTable.tsx 100.00% <100.00%> (ø)
src/pages/AnalyticsPage/Chart/useCoverage.ts 100.00% <100.00%> (ø)
...tailPage/CommitCoverage/UploadsCard/UploadItem.tsx 100.00% <ø> (ø)
...age/CommitCoverage/UploadsCard/UploadReference.tsx 100.00% <ø> (ø)
...ailPage/CommitCoverage/UploadsCard/UploadsCard.tsx 97.93% <ø> (ø)
...CommitCoverage/YamlErrorBanner/YamlErrorBanner.tsx 88.88% <ø> (ø)
...mitDetailFileExplorer/CommitDetailFileExplorer.tsx 100.00% <ø> (ø)
...lFileExplorer/hooks/useRepoCommitContentsTable.tsx 100.00% <ø> (ø)
...e/routes/ComponentsSelector/ComponentsSelector.tsx 100.00% <100.00%> (ø)
... and 53 more

... and 9 files with indirect coverage changes

Components Coverage Δ
Assets 100.00% <ø> (ø)
Layouts 99.71% <ø> (ø)
Pages 98.59% <100.00%> (ø)
Services 99.33% <ø> (ø)
Shared 99.33% <ø> (+0.06%) ⬆️
UI 99.14% <ø> (+<0.01%) ⬆️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cdd2bcd...dba750f. Read the comment docs.

@codecov-qa
Copy link

codecov-qa bot commented Nov 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.90%. Comparing base (cdd2bcd) to head (dba750f).
Report is 1 commits behind head on main.

✅ All tests successful. No failed tests found.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #3524   +/-   ##
=======================================
  Coverage   98.90%   98.90%           
=======================================
  Files         806      806           
  Lines       14484    14484           
  Branches     4118     4108   -10     
=======================================
+ Hits        14325    14326    +1     
+ Misses        152      151    -1     
  Partials        7        7           
Files with missing lines Coverage Δ
...rc/pages/AdminSettings/AdminAccess/AdminAccess.tsx 100.00% <ø> (ø)
...inSettings/AdminMembers/MemberList/MemberTable.tsx 100.00% <100.00%> (ø)
src/pages/AnalyticsPage/Chart/useCoverage.ts 100.00% <100.00%> (ø)
...tailPage/CommitCoverage/UploadsCard/UploadItem.tsx 100.00% <ø> (ø)
...age/CommitCoverage/UploadsCard/UploadReference.tsx 100.00% <ø> (ø)
...ailPage/CommitCoverage/UploadsCard/UploadsCard.tsx 97.93% <ø> (ø)
...CommitCoverage/YamlErrorBanner/YamlErrorBanner.tsx 88.88% <ø> (ø)
...mitDetailFileExplorer/CommitDetailFileExplorer.tsx 100.00% <ø> (ø)
...lFileExplorer/hooks/useRepoCommitContentsTable.tsx 100.00% <ø> (ø)
...e/routes/ComponentsSelector/ComponentsSelector.tsx 100.00% <100.00%> (ø)
... and 53 more

... and 9 files with indirect coverage changes

Components Coverage Δ
Assets 100.00% <ø> (ø)
Layouts 99.71% <ø> (ø)
Pages 98.59% <100.00%> (ø)
Services 99.33% <ø> (ø)
Shared 99.33% <ø> (+0.06%) ⬆️
UI 99.14% <ø> (+<0.01%) ⬆️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cdd2bcd...dba750f. Read the comment docs.

Copy link

codecov-public-qa bot commented Nov 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.90%. Comparing base (cdd2bcd) to head (dba750f).
Report is 1 commits behind head on main.

✅ All tests successful. No failed tests found.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #3524   +/-   ##
=======================================
  Coverage   98.90%   98.90%           
=======================================
  Files         806      806           
  Lines       14484    14484           
  Branches     4111     4108    -3     
=======================================
+ Hits        14325    14326    +1     
+ Misses        152      151    -1     
  Partials        7        7           
Files with missing lines Coverage Δ
...rc/pages/AdminSettings/AdminAccess/AdminAccess.tsx 100.00% <ø> (ø)
...inSettings/AdminMembers/MemberList/MemberTable.tsx 100.00% <100.00%> (ø)
src/pages/AnalyticsPage/Chart/useCoverage.ts 100.00% <100.00%> (ø)
...tailPage/CommitCoverage/UploadsCard/UploadItem.tsx 100.00% <ø> (ø)
...age/CommitCoverage/UploadsCard/UploadReference.tsx 100.00% <ø> (ø)
...ailPage/CommitCoverage/UploadsCard/UploadsCard.tsx 97.93% <ø> (ø)
...CommitCoverage/YamlErrorBanner/YamlErrorBanner.tsx 88.88% <ø> (ø)
...mitDetailFileExplorer/CommitDetailFileExplorer.tsx 100.00% <ø> (ø)
...lFileExplorer/hooks/useRepoCommitContentsTable.tsx 100.00% <ø> (ø)
...e/routes/ComponentsSelector/ComponentsSelector.tsx 100.00% <100.00%> (ø)
... and 53 more

... and 9 files with indirect coverage changes

Components Coverage Δ
Assets 100.00% <ø> (ø)
Layouts 99.71% <ø> (ø)
Pages 98.59% <100.00%> (ø)
Services 99.33% <ø> (ø)
Shared 99.33% <ø> (+0.06%) ⬆️
UI 99.14% <ø> (+<0.01%) ⬆️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cdd2bcd...dba750f. Read the comment docs.

Copy link

codecov bot commented Nov 21, 2024

Bundle Report

Changes will increase total bundle size by 5.04kB (0.03%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
gazebo-production-system 5.67MB 2.12kB (0.04%) ⬆️
gazebo-production-system-esm 5.72MB 2.92kB (0.05%) ⬆️

Copy link

codecov bot commented Nov 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.90%. Comparing base (cdd2bcd) to head (dba750f).
Report is 1 commits behind head on main.

✅ All tests successful. No failed tests found.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #3524   +/-   ##
=======================================
  Coverage   98.90%   98.90%           
=======================================
  Files         806      806           
  Lines       14484    14484           
  Branches     4111     4108    -3     
=======================================
+ Hits        14325    14326    +1     
+ Misses        152      151    -1     
  Partials        7        7           
Files with missing lines Coverage Δ
...rc/pages/AdminSettings/AdminAccess/AdminAccess.tsx 100.00% <ø> (ø)
...inSettings/AdminMembers/MemberList/MemberTable.tsx 100.00% <100.00%> (ø)
src/pages/AnalyticsPage/Chart/useCoverage.ts 100.00% <100.00%> (ø)
...tailPage/CommitCoverage/UploadsCard/UploadItem.tsx 100.00% <ø> (ø)
...age/CommitCoverage/UploadsCard/UploadReference.tsx 100.00% <ø> (ø)
...ailPage/CommitCoverage/UploadsCard/UploadsCard.tsx 97.93% <ø> (ø)
...CommitCoverage/YamlErrorBanner/YamlErrorBanner.tsx 88.88% <ø> (ø)
...mitDetailFileExplorer/CommitDetailFileExplorer.tsx 100.00% <ø> (ø)
...lFileExplorer/hooks/useRepoCommitContentsTable.tsx 100.00% <ø> (ø)
...e/routes/ComponentsSelector/ComponentsSelector.tsx 100.00% <100.00%> (ø)
... and 53 more

... and 9 files with indirect coverage changes

Components Coverage Δ
Assets 100.00% <ø> (ø)
Layouts 99.71% <ø> (ø)
Pages 98.59% <100.00%> (ø)
Services 99.33% <ø> (ø)
Shared 99.33% <ø> (+0.06%) ⬆️
UI 99.14% <ø> (+<0.01%) ⬆️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cdd2bcd...dba750f. Read the comment docs.

@codecov-releaser
Copy link
Contributor

codecov-releaser commented Nov 21, 2024

✅ Deploy preview for gazebo ready!

Previews expire after 1 month automatically.

Storybook

Commit Created Cloud Enterprise
19770fe Thu, 21 Nov 2024 19:02:05 GMT Expired Expired
4668dd4 Thu, 21 Nov 2024 19:18:05 GMT Expired Expired
a8d9dc9 Thu, 21 Nov 2024 20:24:33 GMT Expired Expired
0f2baf4 Thu, 05 Dec 2024 11:29:46 GMT Expired Expired
dba750f Wed, 11 Dec 2024 17:16:04 GMT Cloud Enterprise

@@ -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

@@ -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

@@ -79,7 +79,7 @@ describe('useOktaConfig', () => {
})

describe('invalid schema', () => {
let consoleSpy = vi.spyOn(console, 'error').mockImplementation(() => {})
const consoleSpy = vi.spyOn(console, 'error').mockImplementation(() => {})
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 - wasn't being reassigned

return HttpResponse.json({ data: response })
})
)
}

describe('when calling the mutation', () => {
let consoleSpy = vi.spyOn(console, 'error').mockImplementation(() => {})
const consoleSpy = vi.spyOn(console, 'error').mockImplementation(() => {})
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 - wasn't being reassigned

@@ -71,7 +71,7 @@ interface CreateTableArgs {
const createTable = ({ tableData, seatData, mutate }: CreateTableArgs) => {
return tableData?.map(
({ ownerid, activated, email, isAdmin, name, username }) => {
let maxSeats = seatData?.seatsUsed === seatData?.seatsLimit
const maxSeats = seatData?.seatsUsed === seatData?.seatsLimit
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 - wasn't being reassigned

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Remove unused setup functions

@@ -206,7 +206,7 @@ const Select = forwardRef(
{
'border overflow-y-auto': isOpen,
},
!!onSearch ? 'top-16' : 'top-8 rounded'
onSearch ? 'top-16' : 'top-8 rounded'
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 - removing double !!

Comment on lines 193 to +198
const toggleItem = (selectedItem) => {
isItemSelected(selectedItem, selectedItems)
? removeSelectedItem(selectedItem)
: addSelectedItem(selectedItem)
if (isItemSelected(selectedItem, selectedItems)) {
removeSelectedItem(selectedItem)
} else {
addSelectedItem(selectedItem)
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

TS lint rules don't like ternaries being used unless a value is being set/returned so this is the way around that

Comment on lines +236 to +240
if (isAllButton(selectedItem)) {
reset()
} else {
toggleItem(selectedItem)
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

See above 👀

}

const listItems = [
SELECT_ALL_BUTTON,
...selectedItems,
...items?.filter((item) => !isItemSelected(item, selectedItems)),
...(items?.filter((item) => !isItemSelected(item, selectedItems)) ?? []),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Handling the case where items is undefined

@nicholas-codecov nicholas-codecov changed the base branch from main to gh-eng-2124-audit-and-update-lint-rules-for-gazebo November 22, 2024 11:09
@nicholas-codecov nicholas-codecov force-pushed the gh-eng-2124-audit-and-update-lint-rules-for-gazebo branch from 614ae25 to 125652e Compare November 27, 2024 12:22
Base automatically changed from gh-eng-2124-audit-and-update-lint-rules-for-gazebo to main November 27, 2024 13:35
Copy link
Contributor

@calvin-codecov calvin-codecov left a comment

Choose a reason for hiding this comment

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

Left one nit comment but can be applied overall: what was your rule of thumb for deleting unused function arguments vs switching them to underscore variables?

LGTM

@nicholas-codecov nicholas-codecov force-pushed the gh-eng-2124-apply-recommended-rules branch from a8d9dc9 to 223bc79 Compare December 5, 2024 11:16
@nicholas-codecov
Copy link
Contributor Author

what was your rule of thumb for deleting unused function arguments vs switching them to underscore variables?

Hrrm, thinking about this a bit more, we should only use ignored unused variables when they're required in the function (i.e. positional arguments rather than an object where we can select where we want)

For example if we wanted to iterate over an array and we only want access to the index:

const data = [ /* ... */]

data.forEach((_item, index) => {
  // do something with the index
})

@nicholas-codecov
Copy link
Contributor Author

Hrrm for some reason (not really certain), I was required to bring the hash length down from 22 to 21, we got this error here: Hashes cannot be longer than 21 characters, received 22. Check the "output.entryFileNames" option

@nicholas-codecov nicholas-codecov force-pushed the gh-eng-2124-apply-recommended-rules branch from 0f2baf4 to afb5473 Compare December 11, 2024 17:06
@nicholas-codecov nicholas-codecov added this pull request to the merge queue Dec 11, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Dec 11, 2024
@nicholas-codecov nicholas-codecov added this pull request to the merge queue Dec 11, 2024
Merged via the queue into main with commit 0899f21 Dec 11, 2024
62 checks passed
@nicholas-codecov nicholas-codecov deleted the gh-eng-2124-apply-recommended-rules branch December 11, 2024 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants