Skip to content

Fix-js-linting-errors #90

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

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

Samk13
Copy link
Member

@Samk13 Samk13 commented Jul 8, 2025

❤️ Thank you for your contribution!

Description

  • Enable js tests
  • Fix linting errors and warnings
  • Fix potential memory leak in RunsLogs
  • Other small fixes

Please test thoroughly, as I wasn’t able to run the full job in my dev environment.

Errors that is being fixed:

➜ ./run-js-linter.sh   
Run eslint
Warning: React version was set to "detect" in eslint-plugin-react settings, but the "react" package is not installed. Assuming latest React version for linting.

/Users/test/invenio-jobs/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/JobRunsHeader.js
   11:10  error  Insert `,`                                                   prettier/prettier
   25:7   error  Unused state field: 'title'                                  react/no-unused-state
   26:7   error  Unused state field: 'description'                            react/no-unused-state
   27:7   error  Unused state field: 'config'                                 react/no-unused-state
   28:7   error  Unused state field: 'loading'                                react/no-unused-state
   45:13  error  'data' is missing in props validation                        react/prop-types
   47:30  error  'data.links' is missing in props validation                  react/prop-types
   47:36  error  'data.links.self_admin_html' is missing in props validation  react/prop-types
   49:5   error  Delete `⏎`                                                   prettier/prettier
   54:7   error  'actions' is missing in props validation                     react/prop-types
   55:7   error  'apiEndpoint' is missing in props validation                 react/prop-types
   56:7   error  'idKeyPath' is missing in props validation                   react/prop-types
   57:7   error  'listUIEndpoint' is missing in props validation              react/prop-types
   58:7   error  'resourceName' is missing in props validation                react/prop-types
   59:7   error  'displayDelete' is missing in props validation               react/prop-types
   60:7   error  'displayEdit' is missing in props validation                 react/prop-types
   61:7   error  'data' is missing in props validation                        react/prop-types
   62:7   error  'error' is missing in props validation                       react/prop-types
   63:7   error  'loading' is missing in props validation                     react/prop-types
   69:29  error  'error.response' is missing in props validation              react/prop-types
   69:38  error  'error.response.status' is missing in props validation       react/prop-types
   70:32  error  'error.response' is missing in props validation              react/prop-types
   70:41  error  'error.response.data' is missing in props validation         react/prop-types
   75:40  error  'data.title' is missing in props validation                  react/prop-types
   76:42  error  'data.description' is missing in props validation            react/prop-types
   85:34  error  'data.title' is missing in props validation                  react/prop-types
  113:3   error  'jobId' PropType is defined but prop is never used           react/no-unused-prop-types

/Users/test/invenio-jobs/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/RunActionForm.js
   50:7   error  'loading' is missing in props validation          react/prop-types
   51:7   error  'formData' is missing in props validation         react/prop-types
   52:7   error  'error' is missing in props validation            react/prop-types
   61:17  error  Identifier 'actions_errors' is not in camel case  camelcase
   61:47  error  Insert `;`                                        prettier/prettier
  156:25  error  Identifier 'actions_errors' is not in camel case  camelcase
  158:35  error  'error.content' is missing in props validation    react/prop-types
  172:57  error  Insert `⏎···················`                     prettier/prettier

/Users/test/invenio-jobs/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/RunsLogs.js
    3:9   error    Replace `·Label,·Container,·Divider,·Grid,·Header,·Icon,·List,·Message,·Segment·` with `⏎··Label,⏎··Container,⏎··Divider,⏎··Grid,⏎··Header,⏎··Icon,⏎··List,⏎··Message,⏎··Segment,⏎`                                               prettier/prettier
    5:22  warning  'ErrorMessage' is defined but never used                                                                                                                                                                                          no-unused-vars
   13:13  warning  Must use destructuring props assignment                                                                                                                                                                                           react/destructuring-assignment
   15:71  error    Replace `"yyyy-MM-dd·HH:mm"` with `⏎··········"yyyy-MM-dd·HH:mm"⏎········`                                                                                                                                                        prettier/prettier
   17:12  warning  Must use destructuring props assignment                                                                                                                                                                                           react/destructuring-assignment
   18:13  warning  Must use destructuring props assignment                                                                                                                                                                                           react/destructuring-assignment
   24:3   warning  fetchLogs should be placed after componentWillUnmount                                                                                                                                                                             react/sort-comp
   26:45  error    Replace `.map((value)·=>·`search_after=${value}`)` with `⏎········.map((value)·=>·`search_after=${value}`)⏎········`                                                                                                              prettier/prettier
   37:71  error    Replace `"yyyy-MM-dd·HH:mm"` with `⏎··········"yyyy-MM-dd·HH:mm"⏎········`                                                                                                                                                        prettier/prettier
   56:27  error    Replace `⏎······?·DateTime.fromISO(finishedAt)⏎·····` with `·?·DateTime.fromISO(finishedAt)`                                                                                                                                      prettier/prettier
   82:13  error    Identifier 'formatted_started_at' is not in camel case                                                                                                                                                                            camelcase
   83:53  error    Replace `run.started_at,·run.finished_at` with `⏎········run.started_at,⏎········run.finished_at⏎······`                                                                                                                          prettier/prettier
   84:22  error    Replace `·run:·run,·runDuration:·runDuration,·formatted_started_at:·formatted_started_at` with `⏎········run:·run,⏎········runDuration:·runDuration,⏎········formatted_started_at:·formatted_started_at,⏎·····`                   prettier/prettier
   85:11  error    Replace `run.status·===·"SUCCESS"·||·run.status·===·"FAILED"·||·run.status·===·"PARTIAL_SUCCESS"` with `⏎········run.status·===·"SUCCESS"·||⏎········run.status·===·"FAILED"·||⏎········run.status·===·"PARTIAL_SUCCESS"⏎······`  prettier/prettier
   96:11  error    Identifier 'formatted_started_at' is not in camel case                                                                                                                                                                            camelcase
   97:51  error    Replace `run.started_at,·run.finished_at` with `⏎······run.started_at,⏎······run.finished_at⏎····`                                                                                                                                prettier/prettier
   98:5   error    Do not use setState in componentDidMount                                                                                                                                                                                          react/no-did-mount-set-state
   98:20  error    Replace `·runDuration:·runDuration,·formatted_started_at:·formatted_started_at` with `⏎······runDuration:·runDuration,⏎······formatted_started_at:·formatted_started_at,⏎···`                                                     prettier/prettier
  141:29  error    Replace `The·job·has·not·produced·any·logs·yet.` with `⏎················The·job·has·not·produced·any·logs·yet.⏎··············`                                                                                                    prettier/prettier
  142:29  error    Replace `Logs·were·deleted·due·to·the·retention·policy.` with `⏎················Logs·were·deleted·due·to·the·retention·policy.⏎··············`                                                                                    prettier/prettier
  168:26  error    Identifier 'formatted_started_at' is not in camel case                                                                                                                                                                            camelcase
  171:40  error    Identifier 'formatted_started_at' is not in camel case                                                                                                                                                                            camelcase
  190:27  error    Replace `·key={index}·className={`log-line·${log.level.toLowerCase()}`}` with `⏎························key={index}⏎························className={`log-line·${log.level.toLowerCase()}`}⏎······················`             prettier/prettier
  190:33  warning  Do not use Array index in keys                                                                                                                                                                                                    react/no-array-index-key
  191:57  error    Replace `[{log.formatted_timestamp}]` with `⏎··························[{log.formatted_timestamp}]⏎························`                                                                                                      prettier/prettier
  192:74  error    Replace `{log.level}` with `⏎··························{log.level}⏎························`                                                                                                                                      prettier/prettier

/Users/test/invenio-jobs/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/RunsLogsView.js
   7:8   warning  '_get' is defined but never used                                                                              no-unused-vars
  20:14  error    Replace `⏎······logs={logs}⏎······run={run}⏎······sort={sort}⏎···` with `·logs={logs}·run={run}·sort={sort}`  prettier/prettier

/Users/test/invenio-jobs/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/RunsSearchResultItemLayout.js
  102:34  warning  Do not use Array index in keys  react/no-array-index-key

✖ 64 problems (56 errors, 8 warnings)
  20 errors and 0 warnings potentially fixable with the `--fix` option.

Checklist

Ticks in all boxes and 🟢 on all GitHub actions status checks are required to merge:

Frontend

Reminder

By using GitHub, you have already agreed to the GitHub’s Terms of Service including that:

  1. You license your contribution under the same terms as the current repository’s license.
  2. You agree that you have the right to license your contribution under the current repository’s license.

@Samk13 Samk13 moved this to To test in v13.0.0 Jul 8, 2025
@Samk13 Samk13 added this to v13.0.0 Jul 8, 2025
@@ -18,17 +19,6 @@ import { Divider, Button, Grid, Header } from "semantic-ui-react";
import { AdminUIRoutes } from "@js/invenio_administration";

export class JobRunsHeader extends Component {
constructor(props) {
Copy link
Contributor

Choose a reason for hiding this comment

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

question: why has this been removed?

Copy link
Member Author

Choose a reason for hiding this comment

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

The constructor was removed because title, description, config and loading are now passed as props instead of managed in local state. The component no longer mutates them internally, so keeping a state copy was redundant.

Copy link
Contributor

Choose a reason for hiding this comment

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

but where are they passed as props, i couldn't find that in the diff

Copy link
Member Author

@Samk13 Samk13 Jul 9, 2025

Choose a reason for hiding this comment

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

The props are passed via the data object see: here (containing title and description) and the direct loading prop.
So the parent component now manages these values instead of local state.

<JobRunsHeader 
  data={{
    title: "My Job Title",          // Fills data.title
    description: "Job description", // Fills data.description
    links: { /*...*/ }
  }}
  loading={false}                  // Direct loading prop
  /* other props... */
/>

<Message.Item>The job has not produced any logs yet.</Message.Item>
<Message.Item>Logs were deleted due to the retention policy.</Message.Item>
<Message.Item>
The job has not produced any logs yet.
Copy link
Contributor

Choose a reason for hiding this comment

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

question: should this be marked as translatable?

Copy link
Member Author

Choose a reason for hiding this comment

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

I fixed these in another PR: #93

Samk13 added 7 commits July 9, 2025 09:30
- Added JS job to the CI workflow for testing JavaScript files.
- add node_modules to gitignore
- Removed unused constructor and state initialization.
- Updated propTypes and defaultProps for clarity.
- Added missing import for Actions.
the following is being fixed:
* error  'loading' is missing in props validation
* error  'formData' is missing in props validation
* error  'error' is missing in props validation
* error  Identifier 'actions_errors' is not in camel case  camelcase
* error  Identifier 'actions_errors' is not in camel case  camelcase
* error  'error.content' is missing in props validation
* Fix memory leak by properly canceling requests on unmount
* Initialize derived state in constructor
* Add log deduplication using timestamp-level-message keys
* Use separate cancel tokens for different requests
* Replace array index keys with stable composite keys
* fix linter errors and warnings
@Samk13 Samk13 force-pushed the fix-js-linting-errors branch from 7c97d40 to ccedd3b Compare July 9, 2025 07:31
* Using invenio_base.utils.entry_points for entry_points
@Samk13 Samk13 force-pushed the fix-js-linting-errors branch from 72d0404 to 448a62c Compare July 10, 2025 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: To test
Development

Successfully merging this pull request may close these issues.

3 participants