-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(enforce-ref-last-prop): add fixer (#8671)
**Related Issue:** #8080 ## Summary Adds a fixer to place the `ref` prop last along with a corresponding comment to disable `react/jsx-sort-props`. --------- Co-authored-by: JC Franco <[email protected]>
- Loading branch information
Showing
6 changed files
with
182 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,5 @@ No config is needed | |
```json | ||
{ "@esri/calcite-components/enforce-ref-last-prop": "error" } | ||
``` | ||
|
||
> Fix included |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
...calcite-components/tests/lib/rules/enforce-ref-last-prop/enforce-ref-last-prop.output.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// @ts-nocheck | ||
@Component({ tag: "sample-tag" }) | ||
export class SampleTag { | ||
render() { | ||
return ( | ||
<Host> | ||
<div | ||
class="some-class" | ||
id="use-case-1" | ||
onClick={() => { | ||
/* click! */ | ||
}} | ||
tabIndex={0} | ||
// eslint-disable-next-line react/jsx-sort-props -- auto-generated by @esri/calcite-components/enforce-ref-last-prop | ||
ref={(el: HTMLDivElement): void => { | ||
/* refEl */ | ||
}} | ||
> | ||
case where ref is not last prop | ||
</div> | ||
<div | ||
class="some-class" | ||
id="use-case-2" | ||
onClick={() => { | ||
/* click! */ | ||
}} | ||
tabIndex={0} | ||
// eslint-disable-next-line react/jsx-sort-props -- auto-generated by @esri/calcite-components/enforce-ref-last-prop | ||
ref={(el: HTMLDivElement): void => { | ||
/* refEl */ | ||
}} | ||
> | ||
case where ref last prop, but not commented | ||
</div> | ||
<div | ||
class="some-class" | ||
id="use-case-3" | ||
onClick={() => { | ||
/* click! */ | ||
}} | ||
tabIndex={0} | ||
// eslint-disable-next-line react/jsx-sort-props -- auto-generated by @esri/calcite-components/enforce-ref-last-prop | ||
ref={(el: HTMLDivElement): void => { | ||
/* refEl */ | ||
}} | ||
> | ||
case where ref last prop, and already commented Note: this is marked as wrong because | ||
RuleTester can't configure multiple rules, so we ignore the ESLint error from not finding | ||
the disabled rule | ||
</div> | ||
<div | ||
class="some-class" | ||
id="use-case-4" | ||
onClick={() => { | ||
/* click! */ | ||
}} | ||
tabIndex={0} | ||
// eslint-disable-next-line react/jsx-sort-props -- auto-generated by @esri/calcite-components/enforce-ref-last-prop | ||
ref={(el: HTMLDivElement): void => { | ||
/* refEl */ | ||
}} | ||
> | ||
case where ref is not last prop and already commented Note: this is marked as wrong | ||
because RuleTester can't configure multiple rules, so we ignore the ESLint error from not | ||
finding the disabled rule | ||
</div> | ||
</Host> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters