-
Notifications
You must be signed in to change notification settings - Fork 178
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
first pass on merging eslint rules #2914
first pass on merging eslint rules #2914
Conversation
e880400
to
0f44a1a
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2914 +/- ##
==========================================
- Coverage 79.36% 78.52% -0.85%
==========================================
Files 1139 1139
Lines 24284 24171 -113
Branches 6186 6099 -87
==========================================
- Hits 19273 18980 -293
- Misses 5011 5191 +180 see 142 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
/retest |
backend/src/routes/api/accelerator-profiles/acceleratorProfilesUtils.ts
Outdated
Show resolved
Hide resolved
const customObjectsApi = fastify.kube.customObjectsApi; | ||
const namespace = fastify.kube.namespace; | ||
if (typeof fastify.kube === 'undefined') { | ||
throw new Error('fastify.kube is not defined.'); | ||
} | ||
const { customObjectsApi } = fastify.kube; | ||
const { namespace } = fastify.kube; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like kube
should always be defined since we own the plugin and install it always.
Fix KubeFastifyInstance
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One problem is that lots of functions take in FastifyInstance
as the parameter like: export default fp(async (fastify: FastifyInstance) => {
. However, when it tries to call a function requiring KubeFastifyInstance
, there's a type mismatch now that kube
is required. How should this be dealt with? Should I implement a typeguard essentially checking if kube
is present like 'kube' in fastify
?
Error:
src/plugins/kube.ts:81:30 - error TS2345: Argument of type 'FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault>' is not assignable to parameter of type 'KubeFastifyInstance'.
Property 'kube' is missing in type 'FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault>' but required in type '{ kube: KubeDecorator; }'.
81 initializeWatchedResources(fastify);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, i fixed this by changing the parameter types. Don't know if that's how it should be done though.
87efeef
to
d26e8dc
Compare
backend/src/routes/api/accelerator-profiles/acceleratorProfilesUtils.ts
Outdated
Show resolved
Hide resolved
backend/src/routes/api/accelerator-profiles/acceleratorProfilesUtils.ts
Outdated
Show resolved
Hide resolved
backend/src/routes/api/cluster-settings/clusterSettingsUtils.ts
Outdated
Show resolved
Hide resolved
backend/src/routes/api/cluster-settings/clusterSettingsUtils.ts
Outdated
Show resolved
Hide resolved
backend/src/utils/userUtils.ts
Outdated
if ( | ||
typeof e === 'object' && | ||
e !== null && | ||
'message' in e && | ||
typeof e.message === 'string' && | ||
'statusCode' in e && | ||
typeof e.statusCode === 'number' | ||
) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this can use createError.isHttpError
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created a new method instead for this instance, since Cannot find name 'createError'.ts(2304)
backend/src/utils/userUtils.ts
Outdated
if (isHttpError(e)) { | ||
const error = createCustomError( | ||
e.message, | ||
`Error getting Oauth Info for user, ${errorHandler(e)}`, | ||
e.statusCode, | ||
); | ||
throw error; | ||
} else { | ||
throw new Error(`Error getting Oauth Info for user, ${errorHandler(e)}`); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can probably default to status code 401:
if (isHttpError(e)) { | |
const error = createCustomError( | |
e.message, | |
`Error getting Oauth Info for user, ${errorHandler(e)}`, | |
e.statusCode, | |
); | |
throw error; | |
} else { | |
throw new Error(`Error getting Oauth Info for user, ${errorHandler(e)}`); | |
} | |
const error = createCustomError( | |
e.message, | |
`Error getting Oauth Info for user, ${errorHandler(e)}`, | |
(isHttpError(e) && e.statusCode) || 401, | |
); | |
throw error; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replaced e.message
with errorHandler(e)
, since e
might be undefined
backend/src/routes/api/accelerator-profiles/acceleratorProfilesUtils.ts
Outdated
Show resolved
Hide resolved
backend/src/routes/api/accelerator-profiles/acceleratorProfilesUtils.ts
Outdated
Show resolved
Hide resolved
backend/src/routes/api/cluster-settings/clusterSettingsUtils.ts
Outdated
Show resolved
Hide resolved
backend/src/utils/route-security.ts
Outdated
if (![notebookNamespace, dashboardNamespace, MODEL_REGISTRY_NAMESPACE].includes(namespace)) { | ||
if (![notebookNamespace, dashboardNamespace].includes(namespace)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is MODEL_REGISTRY_NAMESPACE
removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no idea how that happened
/lgtm did a bunch of ad hoc testing of various parts of the UI |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: christianvogt The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Partially Closes: RHOAIENG-2534
Description
Added frontend
eslint
andtsconfig
rules to the backend, as well aspackage.json
packages.You can see the added rules here
How Has This Been Tested?
cd backend && npm run test
npm run build
Test Impact
I have not implemented functionality, just refactored code.
Request review criteria:
Self checklist (all need to be checked):
ran npm run test
)If you have UI changes:
After the PR is posted & before it merges:
main