Skip to content

JS-1597 support GraphQL near-operation-file outputs#7133

Open
francois-mora-sonarsource wants to merge 13 commits into
fix/generated-code-detection-01-suppression-apifrom
fix/generated-code-detection-02-graphql-foundation
Open

JS-1597 support GraphQL near-operation-file outputs#7133
francois-mora-sonarsource wants to merge 13 commits into
fix/generated-code-detection-01-suppression-apifrom
fix/generated-code-detection-02-graphql-foundation

Conversation

@francois-mora-sonarsource
Copy link
Copy Markdown
Contributor

@francois-mora-sonarsource francois-mora-sonarsource commented May 29, 2026

What

  • preserve GraphQL generate target metadata so near-operation-file outputs can be handled precisely
  • treat near-operation-file directory outputs as generated companion matches instead of recursively tagging the whole directory
  • guard missing AST properties when reading generate target config so ordinary GraphQL outputs are still detected

Why

The new GraphQL follow-up needs to distinguish generated companion files from handwritten sibling files. While adding that support, the AST helper for optional config properties could throw on a missing property, which caused GraphQL output parsing to fall back to an empty result.

Validation

  • npx tsx --tsconfig packages/tsconfig.test.json --test packages/analysis/tests/common/file-kinds.test.ts packages/analysis/tests/jsts/project-metadata/generated-sources.test.ts packages/analysis/tests/dependency-manifests.test.ts packages/analysis/tests/generate-eslint-meta-source.test.ts packages/analysis/tests/jsts/linter/filter-generated-source.test.ts packages/analysis/tests/source-files.test.ts packages/analysis/tests/file-stores.test.ts packages/analysis/tests/common/configuration.test.ts
  • npx tsc -p packages/tsconfig.json --noEmit --pretty false
  • npx prettier --check packages/analysis/src/jsts/rules/helpers/generated-sources/detectors/graphql-codegen.ts packages/analysis/tests/jsts/project-metadata/generated-sources.test.ts
  • git diff --check

Summary by Gitar

  • Refined GraphQL configuration discovery:
    • Separated auto-discovered configs from explicit configuration files to prevent over-eager detection.
    • Updated graphql-codegen.ts to strictly require task invocations for codegen.config.* files.
  • Improved path resolution logic:
    • Resolved generated outputs relative to packageDir instead of the configuration file location.
    • Simplified watchOnlyGraphqlDirectoryOutput to resolve paths consistently from the package root.
  • Expanded config support:
    • Added common codegen.* variants to the watch list and fallback detection logic.
  • Enhanced test coverage:
    • Added verification for workspace-root-relative paths, explicit flag usage, and negative tests for auto-discovery.

This will update automatically on new commits.

@hashicorp-vault-sonar-prod
Copy link
Copy Markdown

hashicorp-vault-sonar-prod Bot commented May 29, 2026

JS-1597

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 29, 2026

Ruling Report

No changes to ruling expected issues in this PR

Comment thread packages/analysis/src/file-stores/source-files.ts
@francois-mora-sonarsource francois-mora-sonarsource marked this pull request as ready for review May 29, 2026 17:00
@sonarqube-next
Copy link
Copy Markdown

@gitar-bot
Copy link
Copy Markdown

gitar-bot Bot commented May 29, 2026

Code Review ✅ Approved 1 resolved / 1 findings

Implements precise detection for GraphQL near-operation-file outputs and fixes early execution of getAnalyzableFilesConfigKey. Refined resolution logic ensures generated files are correctly identified without recursive directory tagging.

✅ 1 resolved
Performance: getAnalyzableFilesConfigKey computed eagerly before cheap checks

📄 packages/analysis/src/file-stores/source-files.ts:76-84 📄 packages/analysis/src/file-stores/generated-sources.ts:73-87
In both SourceFileStore.dirtyCachesIfNeeded and GeneratedSourceStore.dirtyCachesIfNeeded, getAnalyzableFilesConfigKey(configuration) (which calls getShouldIgnoreParams, getFilterPathParams, and JSON.stringify) is always invoked before the cheap reference-equality checks on baseDir and canAccessFileSystem. When the cheap checks would already trigger a cache clear, the expensive serialization is wasted work. This is called on every isInitialized invocation for each store.

Options

Auto-apply is off → Gitar will not commit updates to this branch.
Display: compact → Showing less information.

Comment with these commands to change:

Auto-apply Compact
gitar auto-apply:on         
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

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.

1 participant