-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Updated doc-check to generate config + format errors (#1255)
Closes #1273 Related: libp2p/js-libp2p#1505
- Loading branch information
Showing
10 changed files
with
158 additions
and
20 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
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,41 @@ | ||
/* eslint-env mocha */ | ||
|
||
import { createRequire } from 'module' | ||
import path from 'path' | ||
import { fileURLToPath } from 'url' | ||
import { execa } from 'execa' | ||
import { expect } from '../utils/chai.js' | ||
|
||
const require = createRequire(import.meta.url) | ||
const __dirname = path.dirname(fileURLToPath(import.meta.url)) | ||
const bin = require.resolve('../src/index.js') | ||
const isWindows = process.platform === 'win32' | ||
|
||
describe('document check', () => { | ||
// Skip tests on windows until https://github.com/bbc/typescript-docs-verifier/issues/26 is resolved | ||
if (!isWindows) { | ||
it('should fail for errant typescript in docs', async () => { | ||
const cwd = path.join(__dirname, 'fixtures/document-check/ts-fail') | ||
|
||
await expect(execa(bin, ['doc-check', '--inputFiles', `${cwd}/*.md`, '--tsConfigPath', `${cwd}`])) | ||
.to.eventually.be.rejected() | ||
.with.property('stdout') | ||
.that.include('Error compiling example code block 1') | ||
}) | ||
|
||
it('should pass for correct typescript in docs', async () => { | ||
const cwd = path.join(__dirname, 'fixtures/document-check/pass') | ||
|
||
await expect(execa(bin, ['doc-check', '--inputFiles', `${cwd}/*.md`])).to.eventually.be.fulfilled() | ||
}) | ||
|
||
it('should fail for missing tsconfig.json', async () => { | ||
const cwd = path.join(__dirname, 'fixtures/document-check/tsconfig-fail') | ||
|
||
await expect(execa(bin, ['doc-check', '--inputFiles', `${cwd}/*.md`, '--tsConfigPath', `${cwd}`])) | ||
.to.eventually.be.rejected() | ||
.with.property('stderr') | ||
.that.include('no such file or directory') | ||
}) | ||
} | ||
}) |
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,3 @@ | ||
```ts | ||
export const a = 1; | ||
``` |
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,14 @@ | ||
{ | ||
"extends": "./../../../../src/config/tsconfig.aegir.json", | ||
"compilerOptions": { | ||
"outDir": "dist", | ||
"emitDeclarationOnly": true, | ||
"isolatedModules": true | ||
}, | ||
"include": [ | ||
"package.json", | ||
"src", | ||
"test", | ||
"utils" | ||
] | ||
} |
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,3 @@ | ||
```typescript | ||
still.bad.code | ||
``` |
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,3 @@ | ||
```typescript | ||
wrong.code() | ||
``` |
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,13 @@ | ||
{ | ||
"extends": "./../../../../src/config/tsconfig.aegir.json", | ||
"compilerOptions": { | ||
"outDir": "dist", | ||
"emitDeclarationOnly": true | ||
}, | ||
"include": [ | ||
"package.json", | ||
"src", | ||
"test", | ||
"utils" | ||
] | ||
} |
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,3 @@ | ||
```ts | ||
export const a = 1; | ||
``` |
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