-
-
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.
- Loading branch information
1 parent
7688e8e
commit db9b0f4
Showing
7 changed files
with
214 additions
and
27 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
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
39 changes: 39 additions & 0 deletions
39
selene-lib/tests/lints/roblox_roact_non_exhaustive_deps/too_complex_deps.lua
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,39 @@ | ||
local React | ||
|
||
local function Component() | ||
local a = {} | ||
React.useEffect(function() | ||
print(a[b]) | ||
end, { a[b] }) | ||
end | ||
|
||
local function Component() | ||
local a = {} | ||
React.useEffect(function() | ||
print(a.b["c"]()) | ||
end, { a.b["c"]() }) | ||
end | ||
|
||
local function Component() | ||
local a = {} | ||
React.useEffect(function() | ||
print(a()) | ||
-- FIXME: false negatives for function calls without indexing | ||
end, { a() }) | ||
end | ||
|
||
local function Component() | ||
local a = {} | ||
React.useEffect(function() | ||
-- A function call in place of array brackets should NOT warn about complex expr | ||
-- due to lua-specific pattern of helper functions to patch holes in arrays | ||
end, a.b()) | ||
|
||
React.useEffect(function() | ||
-- Now this should warn | ||
end, a.b(a.b())) | ||
|
||
React.useEffect(function() | ||
-- Now this should warn | ||
end, { a.b() }) | ||
end |
2 changes: 2 additions & 0 deletions
2
selene-lib/tests/lints/roblox_roact_non_exhaustive_deps/too_complex_deps.std.yml
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,2 @@ | ||
--- | ||
name: roblox |
32 changes: 32 additions & 0 deletions
32
selene-lib/tests/lints/roblox_roact_non_exhaustive_deps/too_complex_deps.stderr
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,32 @@ | ||
error[roblox_roact_non_exhaustive_deps]: react hook useEffect has a complex expression in the dependency array | ||
┌─ too_complex_deps.lua:7:10 | ||
│ | ||
7 │ end, { a[b] }) | ||
│ ^^^^^^^^ | ||
│ | ||
= help: extract it to a separate variable so it can be statically checked | ||
|
||
error[roblox_roact_non_exhaustive_deps]: react hook useEffect has a complex expression in the dependency array | ||
┌─ too_complex_deps.lua:14:10 | ||
│ | ||
14 │ end, { a.b["c"]() }) | ||
│ ^^^^^^^^^^^^^^ | ||
│ | ||
= help: extract it to a separate variable so it can be statically checked | ||
|
||
error[roblox_roact_non_exhaustive_deps]: react hook useEffect has a complex expression in the dependency array | ||
┌─ too_complex_deps.lua:34:10 | ||
│ | ||
34 │ end, a.b(a.b())) | ||
│ ^^^^^^^^^^ | ||
│ | ||
= help: extract it to a separate variable so it can be statically checked | ||
|
||
error[roblox_roact_non_exhaustive_deps]: react hook useEffect has a complex expression in the dependency array | ||
┌─ too_complex_deps.lua:38:10 | ||
│ | ||
38 │ end, { a.b() }) | ||
│ ^^^^^^^^^ | ||
│ | ||
= help: extract it to a separate variable so it can be statically checked | ||
|