-
-
Notifications
You must be signed in to change notification settings - Fork 500
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(lint): useNamingConvention should't ignore jsx component name bin…
…ding (#2264)
- Loading branch information
1 parent
d0b18aa
commit 2950aeb
Showing
7 changed files
with
58 additions
and
3 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
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
5 changes: 5 additions & 0 deletions
5
crates/biome_js_analyze/tests/specs/style/useNamingConvention/validComponentName.js
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,5 @@ | ||
function loadWidgetComponent(widgetId) { | ||
const Component = getWidgetComponent(widgetId); | ||
if (!Component) return null; | ||
return <Component />; | ||
} |
40 changes: 40 additions & 0 deletions
40
crates/biome_js_analyze/tests/specs/style/useNamingConvention/validComponentName.js.snap
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,40 @@ | ||
--- | ||
source: crates/biome_js_analyze/tests/spec_tests.rs | ||
expression: validComponentName.js | ||
--- | ||
# Input | ||
```jsx | ||
function loadWidgetComponent(widgetId) { | ||
const Component = getWidgetComponent(widgetId); | ||
if (!Component) return null; | ||
return <Component />; | ||
} | ||
``` | ||
|
||
# Diagnostics | ||
``` | ||
validComponentName.js:2:9 lint/style/useNamingConvention FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ | ||
! This local const name should be in camelCase. | ||
1 │ function loadWidgetComponent(widgetId) { | ||
> 2 │ const Component = getWidgetComponent(widgetId); | ||
│ ^^^^^^^^^ | ||
3 │ if (!Component) return null; | ||
4 │ return <Component />; | ||
i The name could be renamed to `component`. | ||
i Safe fix: Rename this symbol in camelCase. | ||
1 1 │ function loadWidgetComponent(widgetId) { | ||
2 │ - ··const·Component·=·getWidgetComponent(widgetId); | ||
3 │ - ··if·(!Component)·return·null; | ||
4 │ - ··return·<Component·/>; | ||
2 │ + ··const·component·=·getWidgetComponent(widgetId); | ||
3 │ + ··if·(!component)·return·null; | ||
4 │ + ··return·<component·/>; | ||
5 5 │ } | ||
``` |
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