FEAT: add sap-no-deep-collection-facets eslint rule - #5174
vinayhospete wants to merge 4 commits into
Conversation
🦋 Changeset detectedLatest commit: 7ee7ed7 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
I found a few build/type-safety issues that should be addressed before merge, including the missing diagnostic union entries, a registered rule whose implementation is absent, and an incompatible minimatch import for the currently declared dependency version. The new rule is otherwise well covered with focused test scenarios.
| export interface NoDeepCollectionFacets { | ||
| type: typeof NO_DEEP_COLLECTION_FACETS; | ||
| pageNames: string[]; | ||
| annotation: { | ||
| reference: AnnotationReference; | ||
| reportedParent: Element; | ||
| }; | ||
| } |
There was a problem hiding this comment.
Bug: New diagnostic types are not included in the Diagnostic union
createFioriRule constrains rule IDs and validation results to Diagnostic['type'], so the new rules will fail type checking or infer never until their interfaces are added to the union. Consider adding both NoSingleFacetInCollection and NoDeepCollectionFacets to Diagnostic.
Please provide feedback on the review comment by checking the appropriate box:
- 🌟 Awesome comment, a human might have missed that.
- ✅ Helpful comment
- 🤷 Neutral
- ❌ This comment is not helpful
| import textArrangementHidden from './sap-text-arrangement-hidden.js'; | ||
| import noLiveMode from './sap-no-live-mode.js'; | ||
| import cloudDevAdaptationStatus from './sap-cloud-dev-adaptation-status.js'; | ||
| import noSingleFacetInCollection from './sap-no-single-facet-in-collection.js'; |
There was a problem hiding this comment.
Bug: Missing rule implementation is imported
This import points to sap-no-single-facet-in-collection.js, but that rule file is not present in the PR, so the package will fail to build when resolving the module. Consider adding the missing rule implementation and docs/tests, or remove its README/config/index registrations from this PR.
Please provide feedback on the review comment by checking the appropriate box:
- 🌟 Awesome comment, a human might have missed that.
- ✅ Helpful comment
- 🤷 Neutral
- ❌ This comment is not helpful
| @@ -0,0 +1,208 @@ | |||
| # UI.CollectionFacet should not be nested at third level or deeper (sap-no-deep-collection-facets) | |||
There was a problem hiding this comment.
| # UI.CollectionFacet should not be nested at third level or deeper (sap-no-deep-collection-facets) | |
| # UI.CollectionFacet UI.collectionfacet Should Not Be Nested at Third Level or Deeper (`sap-no-deep-collection-facets`) |
| @@ -0,0 +1,208 @@ | |||
| # UI.CollectionFacet should not be nested at third level or deeper (sap-no-deep-collection-facets) | |||
|
|
|||
| SAP Fiori elements does not consider `UI.CollectionFacet` elements that are nested at the third level or deeper within the `UI.Facets` annotation. This rule detects deeply nested collection facets and recommends reorganizing the facet structure to use a maximum of two nesting levels for proper rendering and functionality. | |||
There was a problem hiding this comment.
| SAP Fiori elements does not consider `UI.CollectionFacet` elements that are nested at the third level or deeper within the `UI.Facets` annotation. This rule detects deeply nested collection facets and recommends reorganizing the facet structure to use a maximum of two nesting levels for proper rendering and functionality. | |
| SAP Fiori elements does not consider `UI.CollectionFacet` elements that are nested at the third level or deeper within the `UI.Facets` annotation. This rule detects deeply nested collection facets and recommends reorganizing the facet structure to use a maximum of two nesting levels. |
|
|
||
| - **Level 1** (direct children of `UI.Facets`): ✅ Supported | ||
| - **Level 2** (children of level 1 `UI.CollectionFacet`): ✅ Supported | ||
| - **Level 3 and deeper**: ❌ Not considered by Fiori elements |
There was a problem hiding this comment.
| - **Level 3 and deeper**: ❌ Not considered by Fiori elements | |
| - **Level 3 and deeper**: ❌ Not considered by SAP fiori elements |
|
|
||
| Reorganize your facet structure to flatten deeply nested `UI.CollectionFacet` elements. Consider one of these approaches: | ||
|
|
||
| 1. **Remove unnecessary nesting:** If a `UI.CollectionFacet` contains only one child, replace it with a direct `UI.ReferenceFacet`. |
There was a problem hiding this comment.
| 1. **Remove unnecessary nesting:** If a `UI.CollectionFacet` contains only one child, replace it with a direct `UI.ReferenceFacet`. | |
| - **Remove unnecessary nesting:** If a `UI.CollectionFacet` contains only one child, replace it with a direct `UI.ReferenceFacet`. |
|
|
||
| 1. **Remove unnecessary nesting:** If a `UI.CollectionFacet` contains only one child, replace it with a direct `UI.ReferenceFacet`. | ||
|
|
||
| 2. **Flatten the hierarchy:** Move nested content up to a higher level by combining or reorganizing sections. |
There was a problem hiding this comment.
| 2. **Flatten the hierarchy:** Move nested content up to a higher level by combining or reorganizing sections. | |
| - **Flatten the hierarchy:** Move nested content up to a higher level by combining or reorganizing sections. |
|
|
||
| 2. **Flatten the hierarchy:** Move nested content up to a higher level by combining or reorganizing sections. | ||
|
|
||
| 3. **Use side-by-side facets:** Place facets at the same level rather than nesting them deeply. |
There was a problem hiding this comment.
| 3. **Use side-by-side facets:** Place facets at the same level rather than nesting them deeply. | |
| - **Use side-by-side facets:** Place facets at the same level rather than nesting them deeply. |
|
|
||
| ## Bug Report | ||
|
|
||
| In case you detect an issue with this rule, please open a GitHub issue [here](https://github.com/SAP/open-ux-tools/issues). |
There was a problem hiding this comment.
| In case you detect an issue with this rule, please open a GitHub issue [here](https://github.com/SAP/open-ux-tools/issues). | |
| If you encounter any problems, open a [GitHub issue](https://github.com/SAP/open-ux-tools/issues). |
|
|
||
| 3. **Use side-by-side facets:** Place facets at the same level rather than nesting them deeply. | ||
|
|
||
| **Before (3 levels - violation):** |
There was a problem hiding this comment.
| **Before (3 levels - violation):** | |
| **Before (Three levels: violation):** |
| </Record> | ||
| ``` | ||
|
|
||
| **After (2 levels - correct):** |
There was a problem hiding this comment.
| **After (2 levels - correct):** | |
| **After (Two levels: correct):** |
Add ESLint rule to flag deeply nested CollectionFacets
Description
Adds the new
sap-no-deep-collection-facetsESLint rule for Fiori annotation sources. The rule reportsUI.CollectionFacetrecords nested at the third level or deeper inUI.Facets, since SAP Fiori elements only considers up to two levels.This PR includes:
sap-no-deep-collection-facetsType of change
How have you tested?
Added
RuleTestercoverage for the new rule, including:UI.CollectionFacetstructuresUI.FacetsannotationsChecklist:
The code conforms to the general development principles
Supplied as many details as possible on this change
The code is easy to read and maintainable by others
Corresponding changes to the documentation has been done
Already existing and new unit tests pass locally
I have reviewed and addressed all Hyperspace bot findings (or explicitly explained dismissals)
I have done an Agentic review
🔄 Regenerate and Update Summary
PR Bot Information
Version:
1.31.30pull_request.openedgpt-5.563b2e3f0-adb5-11f1-9bbb-f0333a3e7b8d