lint
The lint command runs configurable lint rules on your GraphQL documents.
graphql lint [OPTIONS]Options
Section titled “Options”| Option | Description |
|---|---|
-f, --format <FORMAT> | Output format: human (default), json, github, sarif |
-w, --watch | Watch for file changes and re-lint |
--fix | Automatically fix issues that have safe fixes |
--fix-dry-run | Show what would be fixed without modifying files |
--max-warnings <N> | Maximum number of warnings allowed before returning a non-zero exit code (exit code 6) |
Examples
Section titled “Examples”# Basic lintinggraphql lint
# JSON output for CIgraphql lint --format json
# Watch mode for developmentgraphql lint --watch
# Auto-fix lint issuesgraphql lint --fix
# Preview fixes without applying themgraphql lint --fix-dry-run
# Specific projectgraphql --project frontend lintExit codes
Section titled “Exit codes”0— No lint errors (warnings don’t cause non-zero exit)1— Lint errors found6— Warning threshold exceeded (--max-warnings)
Configuring rules
Section titled “Configuring rules”Lint rules are configured in .graphqlrc.yml:
extensions: graphql-analyzer: lint: extends: recommended rules: noDeprecated: warn uniqueNames: errorSee Linting Configuration and the Rules Catalog for all available rules.