Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/npm_and_yarn/mocha-11.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
achingbrain authored Dec 5, 2024
2 parents 1968e8b + e66cd39 commit b7d6f8a
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 3 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## [45.0.8](https://github.com/ipfs/aegir/compare/v45.0.7...v45.0.8) (2024-12-05)

### Bug Fixes

* ignore module-not-found errors in doc-check ([#1701](https://github.com/ipfs/aegir/issues/1701)) ([41726f8](https://github.com/ipfs/aegir/commit/41726f83bee4603dafd6a387ff789be5468a4804))

### Trivial Changes

* Update .github/workflows/stale.yml [skip ci] ([9bb06f9](https://github.com/ipfs/aegir/commit/9bb06f982d069f36354743051d5813d379ee3368))

## [45.0.7](https://github.com/ipfs/aegir/compare/v45.0.6...v45.0.7) (2024-11-28)

### Bug Fixes
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "aegir",
"version": "45.0.7",
"version": "45.0.8",
"description": "JavaScript project management",
"license": "Apache-2.0 OR MIT",
"homepage": "https://github.com/ipfs/aegir#readme",
Expand Down
5 changes: 5 additions & 0 deletions src/build/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ const tasks = new Listr([
if (ctx.bundlesize) {
const gzip = await gzipSize(outfile)
const maxsize = bytes(ctx.bundlesizeMax)

if (maxsize == null) {
throw new Error(`Could not parse bytes from "${ctx.bundlesizeMax}"`)
}

const diff = gzip - maxsize

task.output = 'Use https://esbuild.github.io/analyze/ to load "./dist/stats.json".'
Expand Down
29 changes: 28 additions & 1 deletion src/document-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,16 @@ import { formatCode, formatError, fromRoot, hasTsconfig, readJson } from './util
* @typedef {import("./types").GlobalOptions} GlobalOptions
* @typedef {import("./types").DocsVerifierOptions} DocsVerifierOptions
* @typedef {import("listr").ListrTaskWrapper} Task
* @typedef {import("ts-node").TSError} TSError
*/

/**
* A list of tsc errors to ignore when compiling code snippets in documentation.
*/
const TS_ERRORS_TO_SUPRESS = [
2307 // Cannot find module '...' or its corresponding type declarations
]

const tasks = new Listr(
[
{
Expand Down Expand Up @@ -54,7 +62,8 @@ const tasks = new Listr(
target: 'esnext',
module: 'esnext',
noImplicitAny: true,
noEmit: true
noEmit: true,
skipLibCheck: true
}
}
])
Expand All @@ -64,6 +73,15 @@ const tasks = new Listr(

results.forEach((result) => {
if (result.error) {
// ignore some diagnostic codes
if (isTSError(result.error)) {
const diagnosticCodes = result.error?.diagnosticCodes?.filter(code => !TS_ERRORS_TO_SUPRESS.includes(code))

if (diagnosticCodes.length === 0) {
return
}
}

process.exitCode = 1
console.log(kleur.red().bold(`Error compiling example code block ${result.index} in file ${result.file}:`))
console.log(formatError(result.error))
Expand All @@ -89,3 +107,12 @@ const tasks = new Listr(
)

export default tasks

/**
*
* @param {*} err
* @returns {err is TSError}
*/
function isTSError (err) {
return Array.isArray(err.diagnosticCodes)
}
7 changes: 6 additions & 1 deletion test/fixtures/document-check/pass/GOODREADME.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
```ts
export const a = 1;
import { foo } from 'dep-we-do-not-have'

// should not cause an error because we ignore TS2307
foo()

export const a = 1
```

0 comments on commit b7d6f8a

Please sign in to comment.