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

Update @angular-eslint/template/i18n to ignore common nimble and sl-lib attributes #140

Merged

Conversation

rbell517
Copy link
Contributor

@rbell517 rbell517 commented May 3, 2024

Justification

Update @angular-eslint/template/i18n to ignore common nimble and sl-lib attributes (and excludes tests of the name *.spec.ts with inline templates).

fixes #83

Implementation

A new file template/options.js is added to list all well-known attributes that should not be localized for using in NI javascript codebases. This includes common nimble attributes, systemlink-lib-angular attributes, and attributes from commonly used third-party libraries.

This list is used to modify the @angular-eslint/template/i18n eslint rule to ignore any attribute in the list by default. If apps need to change this to ignore only nimble attributes, they have the option to do that by overriding the rule's config in their app's eslintrc.

Testing

  • I have made modifications to the angular test project to include attributes on the two sample templates that should either be ignored or not ignored and verified the eslint rule modification is being correctly applied in each.
  • Added a test to verify custom attributes can be added to ignore lists by apps.

Copy link
Collaborator

@jattasNI jattasNI left a comment

Choose a reason for hiding this comment

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

Looks great, thanks for tackling this! I'm checking with other owners to see if they want to review; I'll approve once I hear back.

@rbell517 rbell517 force-pushed the users/rbell/angular-eslint-i18n-ignore-attributes branch from 80f23f0 to 0b9ab0a Compare May 6, 2024 21:46
@jattasNI jattasNI requested a review from rajsite May 10, 2024 19:49
Copy link
Collaborator

@jattasNI jattasNI left a comment

Choose a reason for hiding this comment

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

You can complete this once @rajsite approves, no need to wait on the remaining reviewers.

// CSS selector style element[attribute] ignore entries
// which can be used to scope attribute ignores to specific
// elements.
const ignoreAttributes = {
Copy link
Member

@rajsite rajsite May 10, 2024

Choose a reason for hiding this comment

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

@jattasNI we have this rule disable in nimble: https://github.com/ni/nimble/blob/4e595cc0e67a9903510ba60da17afdb1bf2643d6/packages/angular-workspace/.eslintrc.js#L109

Maybe we should locally enable it with a local build of the changes to see if the example app reveals anymore attributes that need to be marked? How confident are we in the completeness of the current list / should we do any work preemptively to shore-it up for nimble?

After this change goes in maybe we should enable i18n on the example app as a way to catch attributes to add to this list sooner?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I am not very confident in the completeness of the list. In my innovation day prototype PR I generated it by trial and error on the SystemLinkShared libraries so it could easily be missing APIs that are used by apps (or by nobody yet) if they're not used by a shared library. I think this PR largely uses that list, so it's probably incomplete.

I am fine with making the list comprehensive either before or after completing this PR. I suspect that adopting the package in SLE apps will reveal more APIs than adopting it in the Nimble example app since the latter doesn't exercise APIs very comprehensively. But creating a local package and locally adopting it in every app is a lot of busy work so if @rbell517 would rather wait for Renovate to do that work on a production build and then add any missing attributes as a follow up PR, that's ok by me.

Similar thought on enabling i18n on the example app. I don't object to giving it a shot but I think it'll miss a lot of new APIs.

Copy link
Member

@rajsite rajsite May 14, 2024

Choose a reason for hiding this comment

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

But creating a local package and locally adopting it in every app is a lot of busy work so if @rbell517 would rather wait for Renovate to do that work on a production build and then add any missing attributes as a follow up PR, that's ok by me.

If @rbell517 is okay keeping an eye out on rennovate PRs and helping message / coral folks running into issues post merge that works for me 👍

I suspect that adopting the package in SLE apps will reveal more APIs than adopting it in the Nimble example app since the latter doesn't exercise APIs very comprehensively.

Yea that's true. The test suite is intended to test the angular bindings exhaustively though. Maybe we should turn on i18n in nimble-angular's test suite in the future 🤔

Copy link
Member

@rajsite rajsite May 14, 2024

Choose a reason for hiding this comment

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

@rbell517 if you are okay with this direction then we are ready to ship (resolve the comment and should automerge)

Copy link
Member

Choose a reason for hiding this comment

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

Offline sounds like @rbell517 has additional feedback to give so cancelling autocomplete to prevent accidental release.

Copy link
Contributor Author

@rbell517 rbell517 May 15, 2024

Choose a reason for hiding this comment

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

Just so there are not any misunderstandings on the impact of this change, uptaking this new version in libraries and apps will not by itself "reveal more APIs." This change means errors will no longer be generated for the listed attributes when it doesn't have an i18n attribute, but it will not generate errors when the listed attributes do have an i18n attribute. That is just a limitation of the eslint rule. It also does nothing to the standard [attribute]="'value'" trick to avoid the eslint rule without suppressing. The net is this is strictly a loosening of the rule, no new errors should be generated by uptaking the new version, so there shouldn't be any need to monitor Renovate builds.

What I've done instead is use some regex look for cases we worked around the i18n rule (\[[a-zA-Z-]+\]="'.*'") or have added a bad i18n- attribute (i18n-[a-zA-Z-]+) and scrubbed the results for SystemLinkShared, TestInsights, LabManagement, and SystemsManagement. This revealed 5 instances of bad i18n attributes (all Lab Management), which is actually much better than I feared. It revealed 15 more attributes to add to the ignore list, which I've pushed to this PR. Most of these are sl-table and sl-grid related, but there are also 6 new nimble attributes. Between those 4 workspaces I think we will have close to complete coverage. Please give these a look over @jattasNI @rajsite and resolve this if you're satisfied.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correction, only 3 instances of bad i18n- attributes. I mis-identified one and the other was already fixed.
https://dev.azure.com/ni/DevCentral/_git/Skyline/pullrequest/715355

Copy link
Member

Choose a reason for hiding this comment

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

It's strictly a loosening makes sense, that hadn't computed for me. Also justifies the patch revision 👍

Sounds like part of the discussion for the UI Working Group should be to search for and remove those workarounds and update the list. Might even be tech debt tasks to farm out but that could be a working group discussion. LGTM!

tests/angular/custom-ignore-attributes/.eslintrc.js Outdated Show resolved Hide resolved
// CSS selector style element[attribute] ignore entries
// which can be used to scope attribute ignores to specific
// elements.
const ignoreAttributes = {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I am not very confident in the completeness of the list. In my innovation day prototype PR I generated it by trial and error on the SystemLinkShared libraries so it could easily be missing APIs that are used by apps (or by nobody yet) if they're not used by a shared library. I think this PR largely uses that list, so it's probably incomplete.

I am fine with making the list comprehensive either before or after completing this PR. I suspect that adopting the package in SLE apps will reveal more APIs than adopting it in the Nimble example app since the latter doesn't exercise APIs very comprehensively. But creating a local package and locally adopting it in every app is a lot of busy work so if @rbell517 would rather wait for Renovate to do that work on a production build and then add any missing attributes as a follow up PR, that's ok by me.

Similar thought on enabling i18n on the example app. I don't object to giving it a shot but I think it'll miss a lot of new APIs.

@rajsite rajsite enabled auto-merge (squash) May 14, 2024 22:29
@rajsite rajsite disabled auto-merge May 15, 2024 20:59
@rajsite rajsite merged commit 060e310 into ni:main May 15, 2024
1 check passed
@jattasNI
Copy link
Collaborator

This made it into SystemLinkShared with no pipeline failures 🎉

jattasNI added a commit that referenced this pull request May 17, 2024
…te/i18n (#143)

As a follow up to #140, our original list of attributes was incomplete.
I'm adding the attributes that are needed to build Skyline
`Web/Workspaces/SystemLinkShared`.

[Here's the SLE PR that is blocked on
this](https://dev.azure.com/ni/DevCentral/_git/Skyline/pullrequest/716904)
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.

@angular-eslint/template/i18n flags attributes that don't need to be localized
4 participants