Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 28 additions & 29 deletions __tests__/commands/openapi/__snapshots__/inspect.test.ts.snap

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions __tests__/commands/openapi/inspect.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('rdme openapi inspect', () => {
describe('full reports', () => {
it.each([
'@readme/oas-examples/3.0/json/petstore.json',
'@readme/oas-examples/3.0/json/readme.json',
'@readme/oas-examples/3.0/json/readme-legacy.json',
'@readme/oas-examples/3.0/json/readme-extensions.json',
'@readme/oas-examples/3.1/json/train-travel.json',
])('should generate a report for %s', async spec => {
Expand All @@ -30,7 +30,7 @@ describe('rdme openapi inspect', () => {

const cases: { feature: string[]; shouldSoftError?: true; spec: string }[] = [
{
spec: '@readme/oas-examples/3.0/json/readme.json',
spec: '@readme/oas-examples/3.0/json/readme-legacy.json',
feature: ['polymorphism'],
},
{
Expand Down
1 change: 1 addition & 0 deletions bin/dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
async function main() {
const { execute } = await import('@oclif/core');
await execute({ development: true, dir: import.meta.url }).then(msg => {
// biome-ignore lint/nursery/noUnnecessaryConditions: this is a false positive, biome is clowning for this
Copy link
Contributor Author

Choose a reason for hiding this comment

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

there are a handful of false positives with this lint/nursery/noUnnecessaryConditions rule that started cropping up. i decided to individually ignore them since i imagine biome will fix these quirks over time and we can remove these ignore statements once that happens.

Copy link
Member

Choose a reason for hiding this comment

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

I ended up turning this rule off in our shared config because it's so buggy but I haven't shipped a release of that yet.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

cool, i'll leave these as is for now until we do that

if (msg && typeof msg === 'string') {
// biome-ignore lint/suspicious/noConsole: This is in an executable.
console.log(msg);
Expand Down
1 change: 1 addition & 0 deletions bin/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ async function main() {
opts.args = stringArgv(process.env.INPUT_RDME);
}
await execute(opts).then(msg => {
// biome-ignore lint/nursery/noUnnecessaryConditions: this is a false positive, biome is clowning for this
if (msg && typeof msg === 'string') {
// biome-ignore lint/suspicious/noConsole: This is in an executable.
console.log(msg);
Expand Down
6 changes: 3 additions & 3 deletions biome.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
"**/*.{js,ts}",

// Biome's `vcs.useIgnoreFile` config should be able to pick these up but it doesn't.
"!coverage/**",
"!dist/**",
"!dist-gha/**",
"!coverage",
"!dist",
"!dist-gha",
],
},
"linter": {
Expand Down
2,634 changes: 1,301 additions & 1,333 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@
"@commitlint/config-conventional": "^19.0.3",
"@oclif/test": "^4.1.0",
"@readme/better-ajv-errors": "^2.3.2",
"@readme/oas-examples": "^6.1.2",
"@readme/standards": "^1.4.0",
"@readme/oas-examples": "^7.0.0",
"@readme/standards": "^2.1.1",
"@rollup/plugin-commonjs": "^28.0.0",
"@rollup/plugin-json": "^6.0.0",
"@rollup/plugin-node-resolve": "^16.0.0",
Expand Down
2 changes: 1 addition & 1 deletion src/commands/docs/migrate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export default class DocsMigrateCommand extends BaseCommand<typeof DocsMigrateCo

let unsortedFiles = await findPages.call(this, pathInput);

let transformedByHooks = false;
let transformedByHooks: boolean = false;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

for some reason TS thinks this was false without this type instantiation, which caused biome to flag an if-statement further down below. not sure who to blame here (TS or biome), but this fixed it 🤷🏽

Image


const validationHookResults = await this.config.runHook<'pre_markdown_validation', PluginHooks>(
'pre_markdown_validation',
Expand Down
4 changes: 2 additions & 2 deletions src/commands/openapi/resolve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ export default class OpenAPIResolveCommand extends BaseCommand<typeof OpenAPIRes
);
this.replaceCircularRefs(schemas, remainingCircularRefs);

// biome-ignore lint/nursery/noAwaitInLoop: Awaiting here is necessary to ensure we get all of the remaining circular references
// biome-ignore lint/performance/noAwaitInLoops: Awaiting here is necessary to ensure we get all of the remaining circular references
remainingCircularRefs = await this.getCircularRefs(spec);
iterationCount += 1;
}
Expand All @@ -325,7 +325,7 @@ export default class OpenAPIResolveCommand extends BaseCommand<typeof OpenAPIRes
);
this.replaceAllRefsWithObject(schemas, remainingCircularRefs);

// biome-ignore lint/nursery/noAwaitInLoop: Awaiting here is necessary to ensure we get all of the remaining circular references
// biome-ignore lint/performance/noAwaitInLoops: Awaiting here is necessary to ensure we get all of the remaining circular references
remainingCircularRefs = await this.getCircularRefs(spec);
this.debug(
`After iteration ${objectReplacementIterationCount + 1}, remaining circular references: ${remainingCircularRefs.length}`,
Expand Down
2 changes: 1 addition & 1 deletion src/commands/openapi/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export default class OpenAPIUploadCommand extends BaseCommand<typeof OpenAPIUplo
let status: APIUploadStatus = 'pending';

while (this.isStatusPending(status) && count < 10) {
// biome-ignore lint/nursery/noAwaitInLoop: We need to wait between requests to avoid hitting rate limits.
// biome-ignore lint/performance/noAwaitInLoops: We need to wait between requests to avoid hitting rate limits.
await new Promise(resolve => {
// exponential backoff — wait 1s, 2s, 4s, 8s, 16s, 32s, 30s, 30s, 30s, 30s, etc.
setTimeout(resolve, Math.min(isTest() ? 1 : 1000 * 2 ** count, 30000));
Expand Down
2 changes: 1 addition & 1 deletion src/lib/createGHA/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function constructCommandString(commandId: string, args: CommandArg, flags: Comm
.map(flag => {
const val = opts[flag];
// obfuscate the key in a GitHub secret
if (flag === 'key') return `--key=$\{{ secrets.${GITHUB_SECRET_NAME} }}`;
if (flag === 'key') return `--key=\${{ secrets.${GITHUB_SECRET_NAME} }}`;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

biome was flagging this as an unnecessary escape character but i don't think that's true, but this harmless little tweak silenced the error 🤷🏽

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm actually surprised the former works, but I verified that both do

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah i think the updated escape sequencing is technically a bit better

// remove the GitHub flag
if (flag === 'github') return false;
// if a boolean value, return the flag
Expand Down
45 changes: 21 additions & 24 deletions src/lib/getCurrentConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,38 +12,35 @@ export default function getCurrentConfig(this: Hook.Context): {
project?: string;
} {
const apiKey = (() => {
switch (true) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

these switch(true) statements were pretty clunky and unreadable and biome didn't like 'em so i opted to simplify them.

case !!process.env.RDME_API_KEY:
this.debug('using RDME_API_KEY env var for api key');
return process.env.RDME_API_KEY;
case !!process.env.README_API_KEY:
this.debug('using README_API_KEY env var for api key');
return process.env.README_API_KEY;
default:
this.debug('falling back to configstore value for api key');
return configstore.get('apiKey');
if (process.env.RDME_API_KEY) {
this.debug('using RDME_API_KEY env var for api key');
return process.env.RDME_API_KEY;
} else if (process.env.README_API_KEY) {
this.debug('using README_API_KEY env var for api key');
return process.env.README_API_KEY;
} else {
this.debug('falling back to configstore value for api key');
return configstore.get('apiKey');
}
})();

const email = (() => {
switch (true) {
case !!process.env.RDME_EMAIL:
this.debug('using RDME_EMAIL env var for email');
return process.env.RDME_EMAIL;
default:
this.debug('falling back to configstore value for email');
return configstore.get('email');
if (process.env.RDME_EMAIL) {
this.debug('using RDME_EMAIL env var for email');
return process.env.RDME_EMAIL;
} else {
this.debug('falling back to configstore value for email');
return configstore.get('email');
}
})();

const project = (() => {
switch (true) {
case !!process.env.RDME_PROJECT:
this.debug('using RDME_PROJECT env var for project');
return process.env.RDME_PROJECT;
default:
this.debug('falling back to configstore value for project');
return configstore.get('project');
if (process.env.RDME_PROJECT) {
this.debug('using RDME_PROJECT env var for project');
return process.env.RDME_PROJECT;
} else {
this.debug('falling back to configstore value for project');
return configstore.get('project');
}
})();

Expand Down
1 change: 1 addition & 0 deletions src/lib/getPkg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export async function getPkgVersionFromNPM(
*/
npmDistTag?: NPMDistTag,
): Promise<string> {
// biome-ignore lint/nursery/noUnnecessaryConditions: this is a false positive, biome is clowning for this
if (npmDistTag) {
return fetch(registryUrl)
.then(res => res.json() as Promise<{ 'dist-tags': Record<string, string> }>)
Expand Down
1 change: 1 addition & 0 deletions src/lib/pageCommandProperties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export function baseFlags(section: Section) {
// biome-ignore lint/suspicious/noImplicitAnyLet: This has an implicit `any` but we're filling it with constants below.
let items;

// biome-ignore lint/nursery/noUnnecessaryConditions: we're using a switch for type narrowing. biome is clowning here.
switch (section) {
case 'Changelog':
items = 'Changelog entries' as const;
Expand Down
Loading