Skip to content

fix: enhance linting process to preserve existing files#2716

Merged
tatomyr merged 13 commits intoRedocly:mainfrom
harshit078:fix-cli-command-override-file
Apr 8, 2026
Merged

fix: enhance linting process to preserve existing files#2716
tatomyr merged 13 commits intoRedocly:mainfrom
harshit078:fix-cli-command-override-file

Conversation

@harshit078
Copy link
Copy Markdown
Contributor

@harshit078 harshit078 commented Apr 3, 2026

What/Why/How?

  • redocly lint api1.yaml --generate-ignore-file updates only entries related to api1.yaml and its referenced files

Reference

Testing

Screenshots (optional)

Check yourself

  • Code follows the contributing guide
  • All new/updated code is covered by tests
  • Core code changed? - Tested with other Redocly products (internal contributions only)
  • New package installed? - Tested in different environments (browser/node)
  • Documentation update has been considered

Security

  • The security impact of the change has been considered
  • Code follows company security practices and guidelines

@harshit078 harshit078 requested a review from a team as a code owner April 3, 2026 12:40
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 3, 2026

🦋 Changeset detected

Latest commit: c7cad69

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@redocly/cli Minor
@redocly/openapi-core Minor
@redocly/respect-core Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@tatomyr
Copy link
Copy Markdown
Collaborator

tatomyr commented Apr 3, 2026

Thank you for your contribution, @harshit078!
Will this clean up other ignored entries related to that API file?
Could you add a test with ignored rules for two files, and then re-generate the entries only for one file, assuming that one of the problems in this file has been resolved, so when ignoring, it only adds entries that are relevant to the new version of the linted file.

Say, the starting ignore file:

ignore-bar.yaml:
  no-empty-servers:
    - '#/servers'
  operation-summary:
    - '#/paths/~1items/get/summary'
ignore-foo.yaml:
  no-empty-servers:
    - '#/servers'

Then you fix the operation-summary rule in ignore-bar.yaml and re-generate the ignore file only for it.
What you should get is this (the ignore entry for foo is preserved, and bar is updated):

ignore-bar.yaml:
  no-empty-servers:
    - '#/servers'
ignore-foo.yaml:
  no-empty-servers:
    - '#/servers'

@harshit078
Copy link
Copy Markdown
Contributor Author

@tatomyr Yes, it will clean up entries for the linted API file but only for files that still have problems in current run. Got it, I'll add the test

@harshit078 harshit078 requested a review from a team as a code owner April 6, 2026 13:20
Copy link
Copy Markdown
Collaborator

@tatomyr tatomyr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a couple of suggestions for improvement. Could you also check if the corresponding docs need to be updated?

@harshit078 harshit078 requested a review from tatomyr April 6, 2026 16:30
Copy link
Copy Markdown
Collaborator

@tatomyr tatomyr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do consider updating the corresponding docs in docs/@v2/commands/lint.md.

totals.ignored += fileTotals.ignored;

if (argv['generate-ignore-file']) {
const apiAbsRef = isAbsoluteUrl(apiPath) ? apiPath : resolvePath(apiPath);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check seems incorrect. The ref should align with mappedDefinitionName from Config.saveIgnore. I believe it would be cleaner to move this and the following lines into a new cleanup method next to saveIgnore and use it here.

@tatomyr tatomyr force-pushed the fix-cli-command-override-file branch from 7c1dde5 to 034532a Compare April 8, 2026 13:18
@tatomyr
Copy link
Copy Markdown
Collaborator

tatomyr commented Apr 8, 2026

@harshit078, your tests are failing. Could you fix that?

@harshit078
Copy link
Copy Markdown
Contributor Author

@tatomyr pushed a fix for the failing test. thanks !

Copy link
Copy Markdown
Collaborator

@tatomyr tatomyr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@tatomyr tatomyr merged commit fa20dc3 into Redocly:main Apr 8, 2026
38 checks passed
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.

3 participants