Skip to content

Latest commit

 

History

History
51 lines (40 loc) · 1.24 KB

README.md

File metadata and controls

51 lines (40 loc) · 1.24 KB

nolint

pkg.go.dev

nolint is an analyzer which provides a reporter which ignores diagnostics with nolint comment.

query GetA() {
    a {
	name # nolint: ignore it
    }
}

How to use

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
	},
}

Author

Appify Technologies, Inc.