fix: enhance linting process to preserve existing files#2716
fix: enhance linting process to preserve existing files#2716harshit078 wants to merge 10 commits intoRedocly:mainfrom
Conversation
🦋 Changeset detectedLatest commit: f7df653 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
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 |
|
Thank you for your contribution, @harshit078! 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 ignore-bar.yaml:
no-empty-servers:
- '#/servers'
ignore-foo.yaml:
no-empty-servers:
- '#/servers' |
|
@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 |
tatomyr
left a comment
There was a problem hiding this comment.
Left a couple of suggestions for improvement. Could you also check if the corresponding docs need to be updated?
tatomyr
left a comment
There was a problem hiding this comment.
Please do consider updating the corresponding docs in docs/@v2/commands/lint.md.
packages/cli/src/commands/lint.ts
Outdated
|
|
||
| // TODO: use shared externalRef resolver, blocked by preprocessors now as they can mutate documents | ||
| for (const { path, alias } of apis) { | ||
| for (const { path: apiPath, alias } of apis) { |
There was a problem hiding this comment.
What's the need for renaming path? Could you revert that so there's fewer changes?
packages/cli/src/commands/lint.ts
Outdated
| totals.ignored += fileTotals.ignored; | ||
|
|
||
| if (argv['generate-ignore-file']) { | ||
| const apiAbsRef = isAbsoluteUrl(apiPath) ? apiPath : resolvePath(apiPath); |
There was a problem hiding this comment.
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.
.changeset/rotten-wombats-cry.md
Outdated
| "@redocly/cli": minor | ||
| --- | ||
|
|
||
| redocly lint api1.yaml --generate-ignore-file updates only entries related to api1.yaml and its referenced files |
There was a problem hiding this comment.
| redocly lint api1.yaml --generate-ignore-file updates only entries related to api1.yaml and its referenced files | |
| Changed lint behavior with the `--generate-ignore-file` option — now it updates only the entries related to the file being linted, leaving other files' entries untouched. |
What/Why/How?
redocly lint api1.yaml --generate-ignore-fileupdates only entries related to api1.yaml and its referenced filesReference
lintcommand--generate-ignore-fileoption override previously generated ignore file #2652Testing
Screenshots (optional)
Check yourself
Security