Skip to content

Commit

Permalink
style: format with prettier v3
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Aug 30, 2023
1 parent ef3250b commit 4aefefe
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 42 deletions.
4 changes: 1 addition & 3 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{
"extends": [
"eslint-config-unjs"
],
"extends": ["eslint-config-unjs"],
"rules": {
"unicorn/no-null": 0,
"unicorn/prevent-abbreviations": 0
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/autofix.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: autofix.ci # needed to securely identify the workflow
name: autofix.ci # needed to securely identify the workflow

on:
pull_request:
push:
branches: [ "main" ]
branches: ["main"]

permissions:
contents: read
Expand All @@ -24,4 +24,4 @@ jobs:
run: npm run lint:fix
- uses: autofix-ci/action@8caa572fd27b0019a65e4c695447089c8d3138b9
with:
commit-message: 'chore: apply automated lint fixes'
commit-message: "chore: apply automated fixes"
57 changes: 27 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,30 +27,30 @@ First we have to define a reference object that describes types, defaults, and a

```js
const defaultPlanet = {
name: 'earth',
name: "earth",
specs: {
gravity: {
$resolve: val => parseFloat(val),
$default: '9.8'
$resolve: (val) => parseFloat(val),
$default: "9.8",
},
moons: {
$resolve: (val = ['moon']) => [].concat(val),
$resolve: (val = ["moon"]) => [].concat(val),
$schema: {
title: 'planet moons'
}
}
}
}
title: "planet moons",
},
},
},
};
```

## API

### `resolveSchema`

```js
import { resolveSchema } from 'untyped'
import { resolveSchema } from "untyped";

const schema = await resolveSchema(defaultPlanet)
const schema = await resolveSchema(defaultPlanet);
```

Output:
Expand All @@ -70,9 +70,7 @@ Output:
},
"moons": {
"title": "planet moons",
"default": [
"moon"
],
"default": ["moon"],
"type": "array",
"items": [
{
Expand All @@ -87,58 +85,60 @@ Output:
"type": "object"
}
```

### `generateTypes`

```js
import { resolveSchema, generateTypes } from 'untyped'
import { resolveSchema, generateTypes } from "untyped";

const types = generateTypes(await resolveSchema(defaultPlanet))
const types = generateTypes(await resolveSchema(defaultPlanet));
```

Output:

```ts
interface Untyped {
/** @default "earth" */
name: string,
/** @default "earth" */
name: string;

specs: {
/** @default 9.8 */
gravity: number,
gravity: number;

/**
* planet moons
* @default ["moon"]
*/
moons: string[],
},
*/
moons: string[];
};
}
```

### `generateMarkdown`

```js
import { resolveSchema, generateMarkdown } from 'untyped'
import { resolveSchema, generateMarkdown } from "untyped";

const markdown = generateMarkdown(await resolveSchema(defaultPlanet))
const markdown = generateMarkdown(await resolveSchema(defaultPlanet));
```

Output:

```markdown
# `name`

- **Type**: `string`
- **Default**: `"earth"`


# `specs`

## `gravity`

- **Type**: `number`
- **Default**: `9.8`


## `moons`

- **Type**: `array`
- **Default**: `["moon"]`
```
Expand All @@ -159,17 +159,14 @@ Output:
Thanks to [@dominikschreiber](https://github.com/dominikschreiber) for donating package name.

<!-- Badges -->

[npm-version-src]: https://img.shields.io/npm/v/untyped?style=flat-square
[npm-version-href]: https://npmjs.com/package/untyped

[npm-downloads-src]: https://img.shields.io/npm/dm/untyped?style=flat-square
[npm-downloads-href]: https://npmjs.com/package/untyped

[github-actions-src]: https://img.shields.io/github/actions/workflow/status/unjs/untyped/ci.yml?branch-main&style=flat-square
[github-actions-href]: https://github.com/unjs/untyped/actions?query=workflow%3Aci

[codecov-src]: https://img.shields.io/codecov/c/gh/unjs/untyped/main?style=flat-square
[codecov-href]: https://codecov.io/gh/unjs/untyped

[bundle-src]: https://img.shields.io/bundlephobia/minzip/untyped?style=flat-square
[bundle-href]: https://bundlephobia.com/result?p=untyped
4 changes: 1 addition & 3 deletions renovate.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
{
"extends": [
"github>unjs/renovate-config"
]
"extends": ["github>unjs/renovate-config"]
}
6 changes: 3 additions & 3 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { defineConfig } from "vitest/config";
export default defineConfig({
test: {
coverage: {
reporter: ["text", "clover", "json"]
}
}
reporter: ["text", "clover", "json"],
},
},
});

0 comments on commit 4aefefe

Please sign in to comment.