Skip to content

Commit 6c7702a

Browse files
committed
t
1 parent 38d8c7b commit 6c7702a

File tree

4 files changed

+1107
-1065
lines changed

4 files changed

+1107
-1065
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package react_hooks_plugin
2+
3+
const PLUGIN_NAME = "eslint-plugin-react-hooks"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package rules_of_hooks
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package rules_of_hooks_test
2+
3+
import (
4+
"testing"
5+
6+
"github.com/web-infra-dev/rslint/internal/plugins/import/fixtures"
7+
"github.com/web-infra-dev/rslint/internal/plugins/react-hooks/rules/rules_of_hooks"
8+
"github.com/web-infra-dev/rslint/internal/rule_tester"
9+
)
10+
11+
func TestRulesOfHooks(t *testing.T) {
12+
errors := make([]rule_tester.InvalidTestCaseError, 6)
13+
for i, err := range errors {
14+
err.MessageId = "import/no-self-import"
15+
err.Line = i + 2
16+
err.Column = 1
17+
errors[i] = err
18+
}
19+
20+
rule_tester.RunRuleTester(
21+
fixtures.GetRootDir(),
22+
"tsconfig.json",
23+
t,
24+
&rules_of_hooks.RulesOfHooks,
25+
[]rule_tester.ValidTestCase{
26+
{
27+
Code: `
28+
// Valid because components can use hooks.
29+
function ComponentWithHook() {
30+
useHook();
31+
}
32+
`,
33+
FileName: "foo.ts",
34+
},
35+
},
36+
[]rule_tester.InvalidTestCase{},
37+
)
38+
}

0 commit comments

Comments
 (0)