nolint
is an analyzer which provides a reporter which ignores diagnostics with nolint comment.
query GetA() {
a {
name # nolint: ignore it
}
}
nolint.Analyzer can be set to Requires
field of an analyzer. (*nolint.Reporters).New
creates a reporter which ignore diagnostics with nolint comment. The reporter can be set to (*gqlanalysis.Pass).Report
field.
var Analyzer = &gqlanalysis.Analyzer{
Name: "mylint",
Doc: "mylint",
Requires: []*gqlanalysis.Analyzer{
nolint.Analyzer,
},
Run: func(pass *gqlanalysis.Pass) (interface{}, error) {
pass.Report = pass.ResultOf[nolint.Analyzer].(*nolint.Reporters).New(pass)
for _, q := range pass.Queries {
for _, f := range q.Fragments {
for _, s := range f.SelectionSet {
field, _ := s.(*ast.Field)
if field != nil {
pass.Reportf(field.Position, "NG")
}
}
}
}
return nil, nil
},
}