Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions internal/rules/no_base_to_string/no_base_to_string.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ func buildBaseToStringMessage(name string, certainty usefulness) rule.RuleMessag
}
}

type NoBaseToStringOptions struct {
IgnoredTypeNames []string
}

type usefulness uint32

const (
Expand All @@ -51,12 +47,7 @@ const (
var NoBaseToStringRule = rule.Rule{
Name: "no-base-to-string",
Run: func(ctx rule.RuleContext, options any) rule.RuleListeners {
opts, ok := options.(NoBaseToStringOptions)
if !ok {
opts = NoBaseToStringOptions{
IgnoredTypeNames: []string{"Error", "RegExp", "URL", "URLSearchParams"},
}
}
opts := utils.UnmarshalOptions[NoBaseToStringOptions](options, "no-base-to-string")

var collectToStringCertainty func(
t *checker.Type,
Expand Down
33 changes: 33 additions & 0 deletions internal/rules/no_base_to_string/options.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions internal/rules/no_base_to_string/schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"$schema": "https://json-schema.org/draft-07/schema#",
"definitions": {
"no_base_to_string_options": {
"type": "object",
"properties": {
"ignoredTypeNames": {
"type": "array",
"items": {
"type": "string"
},
"default": ["Error", "RegExp", "URL", "URLSearchParams"]
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,10 @@ func buildVoidExprWrapVoidMessage() rule.RuleMessage {
}
}

type NoConfusingVoidExpressionOptions struct {
IgnoreArrowShorthand bool
IgnoreVoidOperator bool
IgnoreVoidReturningFunctions bool
}

var NoConfusingVoidExpressionRule = rule.Rule{
Name: "no-confusing-void-expression",
Run: func(ctx rule.RuleContext, options any) rule.RuleListeners {
opts, ok := options.(NoConfusingVoidExpressionOptions)
if !ok {
opts = NoConfusingVoidExpressionOptions{}
}
opts := utils.UnmarshalOptions[NoConfusingVoidExpressionOptions](options, "no-confusing-void-expression")

canFix := func(node *ast.Node) bool {
t := utils.GetConstrainedTypeAtLocation(ctx.TypeChecker, node)
Expand Down
Loading