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

feat: ESLint rule - all ngrx "Fail" actions should have implements ErrorAction #19042

Merged
merged 49 commits into from
Jul 17, 2024

Conversation

Platonn
Copy link
Contributor

@Platonn Platonn commented Jul 11, 2024

Goal: ensure that each NgRx Failure Action in our repo has an error property. It's ensured by enforcing each such action to have implements ErrorAction.

Means:

  • added ESLint rule which marks a class as invalid when it has /Fail/ in its name but is missing implements ErrorAction
    • it's coped ONLY to files with a suffix *.action*.ts ( supposed to be files with NgRx actions )

Moreover, the ESLint rule provides an auto-fixer which:

  • adds missing implements ErrorAction
  • imports ErrorAction from @sparatcus/core in the current file

Note: to run unit tests of the ESLint rule, execute:

cd tools/eslint-rules
npx nx run test --watch

fixes https://jira.tools.sap/browse/CXSPA-7756

Platonn added 30 commits July 4, 2024 13:04
…ror property in actions implementing ErrorAction
… any' - wherever needed. In non-needed places, removed this line.
…ded after renaming the parameter names from 'error' to 'payload'
…ready `implements ErrorAction` but didn't have public `error` property
… an action that already `extends LoaderFailAction`
… of github.com:SAP/spartacus into feature/CXSPA-7198--v2
…d`. Moreover create new `error` property based on `payload`.
@pawelfras pawelfras marked this pull request as ready for review July 16, 2024 12:21
@pawelfras pawelfras requested review from a team as code owners July 16, 2024 12:21
this.meta = entityFailMeta(entityType, id, error);
this.error = 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.

[note]
Here it's OK, to implement this line. Thanks to it, all actions extending this class won't need to implement analogical mapping for this.error property, I guess.

Same for: LoaderFailAction and EntityScopedFailAction

Copy link
Contributor Author

@Platonn Platonn left a comment

Choose a reason for hiding this comment

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

✅ LGTM

Copy link
Contributor

@pawelfras pawelfras left a comment

Choose a reason for hiding this comment

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

LGTM too!

@pawelfras pawelfras merged commit 031ec7d into epic/ssr-error-handling Jul 17, 2024
11 checks passed
@pawelfras pawelfras deleted the feature/CXSPA-7756 branch July 17, 2024 13:48
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.

2 participants