Skip to content

feat(graphql): honor eslint inline rule configuration comments - #1259

Open
malept wants to merge 2 commits into
malept/dt-5642/feat/graphql-lint-eslint-disable-commentsfrom
malept/dt-5643/feat/graphql-lint-eslint-config-comments
Open

malept wants to merge 2 commits into
malept/dt-5642/feat/graphql-lint-eslint-disable-commentsfrom
malept/dt-5643/feat/graphql-lint-eslint-config-comments

Conversation

@malept

@malept malept commented Oct 24, 2026 •

Copy link
Copy Markdown
Member

What this PR does / why we need it

A schema file can reconfigure a rule for itself with # eslint @graphql-eslint/<rule>: <config>. Devbase ignored these comments and kept applying the repository config to files that override it.

Honor them for Tier 2 and Tier 3 rules the way ESLint does: the comment applies to its whole file, replaces the rule's options instead of merging with them, and the last comment for a rule wins. The value is a severity or a [severity, options] list in YAML flow syntax, which also accepts the unquoted keys ESLint allows. The behavior was checked against @graphql-eslint/eslint-plugin 3.20.1 under ESLint 8.

Jira ID

DT-5643

Notes for your reviewers

Each distinct override reruns only its rule with that configuration and keeps the results for the files that declared it, so no rule needs a per-file configuration. The cost is one extra pass per distinct override.

A file's warn or error still reports at the severity scripts/devbase.yaml gives the rule. Only the on/off state and options can differ per file.

Rejected review findings and intentional non-goals

These were raised in earlier reviews and deliberately left as they are. Do not raise them again unless the reasoning below no longer holds.

Rejected findings

  • Keep a stable output order for a file that adds an override. Overridden results are appended after the other violations, so the order changes. The order is not specified anywhere, so this is cosmetic.
  • Share a helper for the leading-whitespace check that parseEslintConfigComment and parseEslintDirective both make. The duplication is one line.

Intentional behavior

  • An invalid config comment, or one naming an unknown or Tier 1 rule, is ignored without a message. ESLint reports an error for invalid configuration. Devbase does not.
  • Only one options object is read from a [severity, options] list. Extra elements are not supported, since the rules take a single options object.
  • A comment-enabled rule that scripts/devbase.yaml does not configure reports at error, whatever severity the comment gives.
  • Unused config comments are not reported.
  • --diff mode applies each side's own comments, so a changed comment can change the baseline. That follows from linting both sides the same way.

A schema file can reconfigure an @graphql-eslint rule for itself with a
comment such as
"# eslint @graphql-eslint/naming-convention: [\"error\", { ... }]".
The devbase port ignored these, so it kept applying the repository
config to files that override it.

Honor them for Tier 2 and Tier 3 rules the way ESLint does: a comment
applies to its whole file, replaces the rule's options instead of
merging with them, and the last comment for a rule wins. A rule can be
named with or without the "@graphql-eslint/" prefix, and the value is a
severity or a [severity, options] list in YAML flow syntax. Tier 1 rules
cannot be configured, and a file's own "warn" or "error" still reports
at the severity scripts/devbase.yaml gives the rule.

Each distinct override reruns just its rule with that configuration and
keeps the results for the files that declared it, so no rule needs a
per-file configuration of its own.

Assisted-By: claude-sonnet 5.5 via opencode
@malept
malept added this pull request to stack #1261 October 24, 2026 00:22
@getoutreach-ci-1

Copy link
Copy Markdown
Contributor

Link to code coverage report (posted by coverbot 🤖)

@malept
malept marked this pull request as ready for review October 24, 2026 00:33
@malept
malept requested a review from a team as a code owner October 24, 2026 00:33
Comment thread internal/graphql/lint/eslint_config_comments.go
Say in the package comment that inline configuration comments follow
ESLint 8, and list the two ways ESLint 9 differs.

Assisted-By: claude-sonnet 5.5 via opencode
@atlantis-at-outreach

Copy link
Copy Markdown

Plan Error

cannot run "plan": pull request 1259 is currently locked by "plan" for commit 160ff2d.
Wait until the previous command is complete and try again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants