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

first pass on merging eslint rules #2914

Merged
merged 1 commit into from
Jul 10, 2024

Conversation

rsun19
Copy link
Contributor

@rsun19 rsun19 commented Jun 13, 2024

Partially Closes: RHOAIENG-2534

Description

Added frontend eslint and tsconfig rules to the backend, as well as package.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):

  • The developer has manually tested the changes and verified that the changes work (ran npm run test)
  • Commits have been squashed into descriptive, self-contained units of work (e.g. 'WIP' and 'Implements feedback' style messages have been removed)
  • Testing instructions have been added in the PR body (for PRs involving changes that are not immediately obvious).
  • The developer has added tests or explained why testing cannot be added (unit or cypress tests for related changes)

If you have UI changes:

  • Included any necessary screenshots or gifs if it was a UI change.
  • Included tags to the UX team if it was a UI/UX change (find relevant UX in the SMEs section).

After the PR is posted & before it merges:

  • The developer has tested their solution on a cluster by using the image produced by the PR to main

@openshift-ci openshift-ci bot requested review from alexcreasy and lucferbux June 13, 2024 21:44
@openshift-merge-robot openshift-merge-robot added the needs-rebase PR needs to be rebased label Jun 13, 2024
@rsun19 rsun19 changed the title first pass on merging eslint rules [WIP] first pass on merging eslint rules Jun 13, 2024
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress This PR is in WIP state label Jun 13, 2024
@rsun19 rsun19 force-pushed the merge-eslint-v2 branch 2 times, most recently from e880400 to 0f44a1a Compare June 14, 2024 20:16
@openshift-merge-robot openshift-merge-robot removed the needs-rebase PR needs to be rebased label Jun 14, 2024
@rsun19 rsun19 changed the title [WIP] first pass on merging eslint rules first pass on merging eslint rules Jun 14, 2024
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress This PR is in WIP state label Jun 14, 2024
@rsun19 rsun19 changed the title first pass on merging eslint rules [WIP] first pass on merging eslint rules Jun 14, 2024
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress This PR is in WIP state label Jun 14, 2024
@rsun19 rsun19 force-pushed the merge-eslint-v2 branch from 0f44a1a to dbc66dd Compare June 14, 2024 20:40
@rsun19 rsun19 changed the title [WIP] first pass on merging eslint rules first pass on merging eslint rules Jun 14, 2024
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress This PR is in WIP state label Jun 14, 2024
Copy link

codecov bot commented Jun 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.52%. Comparing base (0c6256d) to head (a2e33eb).

Current head a2e33eb differs from pull request most recent head ecbd421

Please upload reports for the commit ecbd421 to get more accurate results.

Additional details and impacted files

Impacted file tree graph

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

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

@rsun19 rsun19 changed the title first pass on merging eslint rules [WIP] first pass on merging eslint rules Jun 17, 2024
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress This PR is in WIP state label Jun 17, 2024
@rsun19 rsun19 force-pushed the merge-eslint-v2 branch from dbc66dd to 475d092 Compare June 17, 2024 14:02
@rsun19 rsun19 changed the title [WIP] first pass on merging eslint rules first pass on merging eslint rules Jun 17, 2024
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress This PR is in WIP state label Jun 17, 2024
@rsun19
Copy link
Contributor Author

rsun19 commented Jun 17, 2024

/retest

@rsun19 rsun19 force-pushed the merge-eslint-v2 branch from 475d092 to a2e33eb Compare June 18, 2024 13:55
backend/src/plugins/kube.ts Outdated Show resolved Hide resolved
backend/src/plugins/kube.ts Outdated Show resolved Hide resolved
Comment on lines 53 to 55
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;
Copy link
Contributor

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

Copy link
Contributor Author

@rsun19 rsun19 Jun 20, 2024

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);

Copy link
Contributor Author

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.

backend/src/routes/api/builds/list.ts Outdated Show resolved Hide resolved
backend/src/routes/api/prometheus/index.ts Outdated Show resolved Hide resolved
backend/src/utils/route-security.ts Outdated Show resolved Hide resolved
backend/src/utils/route-security.ts Outdated Show resolved Hide resolved
backend/src/utils/route-security.ts Outdated Show resolved Hide resolved
backend/src/utils/route-security.ts Outdated Show resolved Hide resolved
@rsun19 rsun19 force-pushed the merge-eslint-v2 branch from a2e33eb to 332856c Compare June 20, 2024 19:51
@rsun19 rsun19 changed the title first pass on merging eslint rules [WIP] first pass on merging eslint rules Jun 20, 2024
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress This PR is in WIP state label Jun 20, 2024
@rsun19 rsun19 force-pushed the merge-eslint-v2 branch 2 times, most recently from 87efeef to d26e8dc Compare June 21, 2024 17:14
@rsun19 rsun19 force-pushed the merge-eslint-v2 branch from d26e8dc to 387c86e Compare June 21, 2024 18:54
@rsun19 rsun19 changed the title [WIP] first pass on merging eslint rules first pass on merging eslint rules Jun 25, 2024
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress This PR is in WIP state label Jun 25, 2024
backend/src/routes/api/components/list.ts Outdated Show resolved Hide resolved
backend/src/utils/resourceWatcher.ts Outdated Show resolved Hide resolved
backend/src/utils/resourceWatcher.ts Outdated Show resolved Hide resolved
backend/src/utils/userUtils.ts Outdated Show resolved Hide resolved
backend/src/utils/userUtils.ts Outdated Show resolved Hide resolved
Comment on lines 123 to 130
if (
typeof e === 'object' &&
e !== null &&
'message' in e &&
typeof e.message === 'string' &&
'statusCode' in e &&
typeof e.statusCode === 'number'
) {
Copy link
Contributor

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

Copy link
Contributor Author

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)

@rsun19 rsun19 force-pushed the merge-eslint-v2 branch from 387c86e to fb25d3f Compare June 28, 2024 20:59
@openshift-merge-robot openshift-merge-robot added the needs-rebase PR needs to be rebased label Jun 28, 2024
@rsun19 rsun19 force-pushed the merge-eslint-v2 branch from fb25d3f to 2ba750e Compare June 28, 2024 21:04
@openshift-merge-robot openshift-merge-robot removed the needs-rebase PR needs to be rebased label Jun 28, 2024
@rsun19 rsun19 force-pushed the merge-eslint-v2 branch from 2ba750e to ecbd421 Compare June 28, 2024 21:20
backend/src/utils.ts Outdated Show resolved Hide resolved
backend/src/utils/userUtils.ts Outdated Show resolved Hide resolved
Comment on lines 80 to 89
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)}`);
}
Copy link
Contributor

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:

Suggested change
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;

Copy link
Contributor Author

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

@rsun19 rsun19 force-pushed the merge-eslint-v2 branch from ecbd421 to 9403354 Compare July 5, 2024 15:44
backend/src/routes/api/components/list.ts Outdated Show resolved Hide resolved
backend/src/types.ts Outdated Show resolved Hide resolved
if (![notebookNamespace, dashboardNamespace, MODEL_REGISTRY_NAMESPACE].includes(namespace)) {
if (![notebookNamespace, dashboardNamespace].includes(namespace)) {
Copy link
Contributor

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?

Copy link
Contributor Author

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

@rsun19 rsun19 force-pushed the merge-eslint-v2 branch from 9403354 to e50852a Compare July 5, 2024 19:33
@rsun19 rsun19 force-pushed the merge-eslint-v2 branch from e50852a to bb4e9df Compare July 5, 2024 19:35
@christianvogt
Copy link
Contributor

/lgtm
/approve

did a bunch of ad hoc testing of various parts of the UI

Copy link
Contributor

openshift-ci bot commented Jul 10, 2024

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-bot openshift-merge-bot bot merged commit 98a3bbf into opendatahub-io:main Jul 10, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants