blob: 659b6dd9b8eab5a08e10629b473b9776b92a44c0 [file] [log] [blame]
// Copyright 2021 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package rules
import (
"go.fuchsia.dev/fuchsia/tools/mdlint/core"
)
func init() {
core.RegisterLintRuleOverTokens(noExtraSpaceOnRightName, func(reporter core.Reporter) core.LintRuleOverTokens {
return &noExtraSpaceOnRight{reporter: reporter}
})
}
const noExtraSpaceOnRightName = "no-extra-space-on-right"
type noExtraSpaceOnRight struct {
core.DefaultLintRuleOverTokens
reporter core.Reporter
lastTok core.Token
}
var _ core.LintRuleOverTokens = (*noExtraSpaceOnRight)(nil)
func (rule *noExtraSpaceOnRight) OnNext(tok core.Token) {
if rule.lastTok.Kind == core.Space && tok.Kind == core.Newline {
rule.reporter.Warnf(rule.lastTok, "extra whitespace")
}
rule.lastTok = tok
}