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

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,18 @@ import (
"github.com/web-infra-dev/rslint/internal/plugins/typescript/rules/no_empty_interface"
"github.com/web-infra-dev/rslint/internal/plugins/typescript/rules/no_explicit_any"
"github.com/web-infra-dev/rslint/internal/plugins/typescript/rules/no_extraneous_class"
"github.com/web-infra-dev/rslint/internal/plugins/typescript/rules/no_invalid_void_type"
"github.com/web-infra-dev/rslint/internal/plugins/typescript/rules/no_floating_promises"
"github.com/web-infra-dev/rslint/internal/plugins/typescript/rules/no_for_in_array"
"github.com/web-infra-dev/rslint/internal/plugins/typescript/rules/no_implied_eval"
"github.com/web-infra-dev/rslint/internal/plugins/typescript/rules/no_invalid_void_type"
"github.com/web-infra-dev/rslint/internal/plugins/typescript/rules/no_meaningless_void_operator"
"github.com/web-infra-dev/rslint/internal/plugins/typescript/rules/no_misused_promises"
"github.com/web-infra-dev/rslint/internal/plugins/typescript/rules/no_misused_spread"
"github.com/web-infra-dev/rslint/internal/plugins/typescript/rules/no_mixed_enums"
"github.com/web-infra-dev/rslint/internal/plugins/typescript/rules/no_namespace"
"github.com/web-infra-dev/rslint/internal/plugins/typescript/rules/no_redundant_type_constituents"
"github.com/web-infra-dev/rslint/internal/plugins/typescript/rules/no_this_alias"
"github.com/web-infra-dev/rslint/internal/plugins/typescript/rules/no_require_imports"
"github.com/web-infra-dev/rslint/internal/plugins/typescript/rules/no_this_alias"
"github.com/web-infra-dev/rslint/internal/plugins/typescript/rules/no_unnecessary_boolean_literal_compare"
"github.com/web-infra-dev/rslint/internal/plugins/typescript/rules/no_unnecessary_template_expression"
"github.com/web-infra-dev/rslint/internal/plugins/typescript/rules/no_unnecessary_type_arguments"
Expand Down Expand Up @@ -94,6 +94,7 @@ import (
"github.com/web-infra-dev/rslint/internal/rules/no_constant_binary_expression"
"github.com/web-infra-dev/rslint/internal/rules/no_constant_condition"
"github.com/web-infra-dev/rslint/internal/rules/no_constructor_return"
"github.com/web-infra-dev/rslint/internal/rules/no_debugger"
)

// RslintConfig represents the top-level configuration array
Expand Down Expand Up @@ -457,6 +458,7 @@ func registerAllCoreEslintRules() {
GlobalRuleRegistry.Register("no-constant-binary-expression", no_constant_binary_expression.NoConstantBinaryExpressionRule)
GlobalRuleRegistry.Register("no-constant-condition", no_constant_condition.NoConstantConditionRule)
GlobalRuleRegistry.Register("no-constructor-return", no_constructor_return.NoConstructorReturnRule)
GlobalRuleRegistry.Register("no-debugger", no_debugger.NoDebuggerRule)
}

// getAllTypeScriptEslintPluginRules returns all registered rules (for backward compatibility when no config is provided)
Expand Down
21 changes: 21 additions & 0 deletions internal/rules/no_debugger/no_debugger.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package no_debugger

import (
"github.com/microsoft/typescript-go/shim/ast"
"github.com/web-infra-dev/rslint/internal/rule"
)

// https://eslint.org/docs/latest/rules/no-debugger
var NoDebuggerRule = rule.Rule{
Name: "no-debugger",
Run: func(ctx rule.RuleContext, options any) rule.RuleListeners {
return rule.RuleListeners{
ast.KindDebuggerStatement: func(node *ast.Node) {
ctx.ReportNode(node, rule.RuleMessage{
Id: "no-debugger",
Description: "Unexpected 'debugger' statement.",
})
},
}
},
}
30 changes: 30 additions & 0 deletions internal/rules/no_debugger/no_debugger_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package no_debugger

import (
"testing"

"github.com/web-infra-dev/rslint/internal/plugins/typescript/rules/fixtures"
"github.com/web-infra-dev/rslint/internal/rule_tester"
)

func TestNoDebuggerRule(t *testing.T) {
rule_tester.RunRuleTester(
fixtures.GetRootDir(),
"tsconfig.json",
t,
&NoDebuggerRule,
// Valid cases - ported from ESLint
[]rule_tester.ValidTestCase{
{Code: `var test = { debugger: 1 }; test.debugger;`},
},
// Invalid cases - ported from ESLint
[]rule_tester.InvalidTestCase{
{
Code: `if (foo) debugger`,
Errors: []rule_tester.InvalidTestCaseError{
{MessageId: "no-debugger", Line: 1, Column: 10},
},
},
},
)
}
Loading