-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
245 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { validateVersion } from '../utils/semver.mjs'; | ||
|
||
/** | ||
* Checks if any change version is invalid. | ||
* | ||
* @param {ApiDocMetadataEntry} entry | ||
* @returns {Array<import('../types').LintIssue>} | ||
*/ | ||
export const invalidChangeVersion = entry => { | ||
if (entry.changes.length === 0) { | ||
return []; | ||
} | ||
|
||
const allVersions = entry.changes | ||
.filter(change => change.version) | ||
.flatMap(change => | ||
Array.isArray(change.version) ? change.version : [change.version] | ||
); | ||
|
||
const invalidVersions = allVersions.filter( | ||
version => !validateVersion(version.substring(1)) // Trim the leading 'v' from the version string | ||
); | ||
|
||
return invalidVersions.map(version => ({ | ||
level: 'warn', | ||
message: `Invalid version number: ${version}`, | ||
location: { | ||
path: entry.api_doc_source, | ||
line: entry.yaml_position.start.line, | ||
column: entry.yaml_position.start.column, | ||
}, | ||
})); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* Checks if any change version is missing. | ||
* | ||
* @param {ApiDocMetadataEntry} entry | ||
* @returns {Array<import('../types').LintIssue>} | ||
*/ | ||
export const missingChangeVersion = entry => { | ||
if (entry.changes.length === 0) { | ||
return []; | ||
} | ||
|
||
return entry.changes | ||
.filter(change => !change.version) | ||
.map(() => ({ | ||
level: 'warn', | ||
message: 'Missing change version', | ||
location: { | ||
path: entry.api_doc_source, | ||
line: entry.yaml_position.start.line, | ||
column: entry.yaml_position.start.column, | ||
}, | ||
})); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/** | ||
* Checks if `introduced_in` field is missing in the API doc entry. | ||
* | ||
* @param {ApiDocMetadataEntry} entry | ||
* @returns {Array<import('../types.d.ts').LintIssue>} | ||
*/ | ||
export const missingIntroducedIn = entry => { | ||
// Early return if not a top-level heading or if introduced_in exists | ||
if (entry.heading.depth !== 1 || entry.introduced_in) { | ||
return []; | ||
} | ||
|
||
return [ | ||
{ | ||
level: 'info', | ||
message: 'Missing `introduced_in` field in the API doc entry', | ||
location: { | ||
path: entry.api_doc_source, | ||
// line: entry.yaml_position.start, | ||
// column: entry.yaml_position.end, | ||
}, | ||
}, | ||
]; | ||
}; |
Oops, something went wrong.