Skip to content
/ nolint Public

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

License

Notifications You must be signed in to change notification settings

gqlgo/nolint

Repository files navigation

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.

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages