MCPcopy Create free account
hub / github.com/Effect-TS/tsgo / createDisableFileAction

Function createDisableFileAction

internal/fixables/disable.go:77–90  ·  view source on GitHub ↗

createDisableFileAction creates a code action to disable the diagnostic for the entire file. It inserts: /** @effect-diagnostics {ruleName}:off */ at the top of the file.

(ctx *fixable.Context, ruleName string)

Source from the content-addressed store, hash-verified

75// createDisableFileAction creates a code action to disable the diagnostic for the entire file.
76// It inserts: /** @effect-diagnostics {ruleName}:off */ at the top of the file.
77func createDisableFileAction(ctx *fixable.Context, ruleName string) *ls.CodeAction {
78 // Create the comment text (uses :off for consistency with next-line directives)
79 comment := "/** @effect-diagnostics " + ruleName + ":off */\n"
80
81 // Insert at the very beginning of the file (position 0)
82 insertPos := ctx.BytePosToLSPPosition(0)
83
84 return ctx.NewFixAction(fixable.FixAction{
85 Description: "Disable " + ruleName + " for entire file",
86 Run: func(tracker *rewriter.Tracker) {
87 tracker.InsertText(ctx.SourceFile, insertPos, comment)
88 },
89 })
90}
91
92// getLineStartPositionForPosition finds the start of the line containing the given position.
93func getLineStartPositionForPosition(pos int, sourceFile *ast.SourceFile) int {

Callers 1

runEffectDisableFunction · 0.85

Calls 2

NewFixActionMethod · 0.80
BytePosToLSPPositionMethod · 0.45

Tested by

no test coverage detected