Custom ESLint rule to disable sorting for ref
attribute, as it needs to be the last property in JSX to ensure it is up-to-date.
#7659
Labels
4 - verified
Issues that have been released and confirmed resolved.
eslint-plugin-calcite-components
Issues specific to the @esri/eslint-plugin-calcite-components package.
estimate - 5
A few days of work, definitely requires updates to tests.
p - medium
Issue is non core or affecting less that 60% of people using the library
refactor
Issues tied to code that needs to be significantly reworked.
Milestone
Description
This GitHub issue relates to an existing bug in the Stencil library (bug: ref called in specified order and not after initializing element with all its attributes/properties stenciljs/core#4074). The current behavior is that the order of
ref
usage can result in outdated props/attributes when the callback is invoked.The expected behavior is for
ref
to be called immediately after the element is fully initialized with all props/attributes, aligning with similar mechanisms in other libraries like React and Preact. Properties are applied in the order they are specified. If you place theref
at the end of the component's properties, it ensures that the component's render and updates are processed before the ref callback is triggered. This means the ref callback will have access to the fully rendered and updated component or DOM element.The suggested solution involves setting
ref
as the last property in JSX to ensure that node attributes/properties are up-to-date. However, this requires disabling thejsx-sort-props
rule specifically for this case using an ESLint comment (eslint-disable-next-line
) (refactor: move ref prop last to ensure ref node is in sync #6530, chore: add explainers to disabled jsx-sort-props on ref prop #7584).The request is to create a custom ESLint rule that catches this pattern instead of relying on manual comments throughout the repository.
Proposed Advantages
Provides an automated solution to manual comments to disable sorting rules throughout the repository.
Which Component
All.
Relevant Info
No response
Calcite package
The text was updated successfully, but these errors were encountered: