Skip to content

Commit

Permalink
feat: eslint flat config
Browse files Browse the repository at this point in the history
  • Loading branch information
enkot committed Mar 15, 2024
1 parent 9c2cd7f commit 21dcc36
Show file tree
Hide file tree
Showing 55 changed files with 2,533 additions and 1,931 deletions.
2 changes: 0 additions & 2 deletions .eslintignore

This file was deleted.

4 changes: 0 additions & 4 deletions .eslintrc

This file was deleted.

3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ Generate zero-overhead, 100% typed OpenAPI clients for Nuxt.

In other words - `$fetch` and `useFetch` on steroids. Uses awesome [openapi-typescript](https://github.com/drwpow/openapi-typescript) generator under the hood.

> ⚠️ APIs are subject to change.
> ⚠️ APIs are subject to change.
> All ideas/suggestions are welcome! :)

- [ Release Notes](/CHANGELOG.md)
- [📖  Read the documentation](https://nuxt-open-fetch.vercel.app/)
<!-- - [🏀 Online playground](https://stackblitz.com/github/your-org/my-module?file=playground%2Fapp.vue) -->
Expand Down
6 changes: 3 additions & 3 deletions build.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ import { defineBuildConfig } from 'unbuild'

export default defineBuildConfig({
externals: [
'ofetch'
]
})
'ofetch',
],
})
12 changes: 6 additions & 6 deletions docs/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
module.exports = {
root: true,
extends: [
'@nuxt/eslint-config'
'@nuxt/eslint-config',
],
rules: {
// Global
semi: ['error', 'never'],
quotes: ['error', 'single'],
'semi': ['error', 'never'],
'quotes': ['error', 'single'],
'quote-props': ['error', 'as-needed'],
// Vue
'vue/multi-word-component-names': 0,
'vue/max-attributes-per-line': 'off',
'vue/no-v-html': 0
}
}
'vue/no-v-html': 0,
},
}
2 changes: 0 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,7 @@ Add this module to your `nuxt.config.ts`:

```ts
export default defineNuxtConfig({
...
modules: [
...
'@nuxthq/studio'
]
})
Expand Down
42 changes: 21 additions & 21 deletions docs/app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ export default defineAppConfig({
footer: {
bottom: {
left: 'text-sm text-gray-500 dark:text-gray-400',
wrapper: 'border-t border-gray-200 dark:border-gray-800'
}
}
wrapper: 'border-t border-gray-200 dark:border-gray-800',
},
},
},
seo: {
siteName: 'Nuxt Open Fetch',
Expand All @@ -16,31 +16,31 @@ export default defineAppConfig({
logo: {
alt: '',
light: '',
dark: ''
dark: '',
},
search: true,
colorMode: true,
links: [{
icon: 'i-simple-icons-github',
to: 'https://github.com/enkot/nuxt-open-fetch',
target: '_blank',
'aria-label': 'Nuxt Open Fetch'
}]
'icon': 'i-simple-icons-github',
'to': 'https://github.com/enkot/nuxt-open-fetch',
'target': '_blank',
'aria-label': 'Nuxt Open Fetch',
}],
},
footer: {
credits: 'Copyright © 2024',
colorMode: false,
links: [{
icon: 'i-simple-icons-nuxtdotjs',
to: 'https://nuxt.com',
target: '_blank',
'aria-label': 'Nuxt Website'
'icon': 'i-simple-icons-nuxtdotjs',
'to': 'https://nuxt.com',
'target': '_blank',
'aria-label': 'Nuxt Website',
}, {
icon: 'i-simple-icons-github',
to: 'https://github.com/enkot/nuxt-open-fetch',
target: '_blank',
'aria-label': 'Nuxt Open Fetch'
}]
'icon': 'i-simple-icons-github',
'to': 'https://github.com/enkot/nuxt-open-fetch',
'target': '_blank',
'aria-label': 'Nuxt Open Fetch',
}],
},
toc: {
title: 'Table of Contents',
Expand All @@ -61,7 +61,7 @@ export default defineAppConfig({
label: 'Nuxt Website',
to: 'https://nuxt.com',
target: '_blank',
}]
}
}
}],
},
},
})
12 changes: 6 additions & 6 deletions docs/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,24 @@ const { seo } = useAppConfig()
const { data: navigation } = await useAsyncData('navigation', () => fetchContentNavigation())
const { data: files } = useLazyFetch<ParsedContent[]>('/api/search.json', {
default: () => [],
server: false
server: false,
})
useHead({
meta: [
{ name: 'viewport', content: 'width=device-width, initial-scale=1' }
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
],
link: [
{ rel: 'icon', href: '/favicon.ico' }
{ rel: 'icon', href: '/favicon.ico' },
],
htmlAttrs: {
lang: 'en'
}
lang: 'en',
},
})
useSeoMeta({
ogSiteName: seo?.siteName,
twitterCard: 'summary_large_image'
twitterCard: 'summary_large_image',
})
provide('navigation', navigation)
Expand Down
2 changes: 0 additions & 2 deletions docs/components/Logo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,3 @@
<path d="M628.157 72.9999V21.1599H637.373V42.7599C638.573 40.7919 640.181 39.2559 642.197 38.1519C644.261 36.9999 646.613 36.4239 649.253 36.4239C653.669 36.4239 657.077 37.8159 659.477 40.5999C661.925 43.3839 663.149 47.4639 663.149 52.8399V72.9999H654.005V53.7039C654.005 50.6319 653.381 48.2799 652.133 46.6479C650.933 45.0159 649.013 44.1999 646.373 44.1999C643.781 44.1999 641.621 45.1119 639.893 46.9359C638.213 48.7599 637.373 51.3039 637.373 54.5679V72.9999H628.157Z" fill="#00DD82" />
</svg>
</template>


8 changes: 4 additions & 4 deletions docs/components/OgImage/OgImageDocs.vue
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<script lang="ts" setup>
defineOptions({
inheritAttrs: false
inheritAttrs: false,
})
defineProps({
title: {
type: String,
required: true
required: true,
},
description: {
type: String,
required: true
}
required: true,
},
})
</script>

Expand Down
3 changes: 1 addition & 2 deletions docs/content/1.setup/1.quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: "Quick start"
description: "100% typed OpenAPI fetch for Nuxt"
---

**NuxtOpenFetch** creates zero-overhead wrappers around `$fetch` and `useFetch`, with types generated from your [OpenAPI](https://www.openapis.org/) schema.
**NuxtOpenFetch** creates zero-overhead wrappers around `$fetch` and `useFetch`, with types generated from your [OpenAPI](https://www.openapis.org/) schema.
It uses awesome [openapi-typescript](https://github.com/drwpow/openapi-typescript) generator under the hood.

## Installation
Expand Down Expand Up @@ -80,4 +80,3 @@ Correct: `/pets/{petId}`
::alert{type="danger"}
Incorrect: `[...pathParts].join("/") + "{petId}"`
::

5 changes: 1 addition & 4 deletions docs/content/1.setup/2.configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,17 @@ title: "Configuration"
description: "Learn how to configure NuxtOpenFetch"
---


```ts twoslash [nuxt.config.ts]
// @noErrors
export default defineNuxtConfig({
modules: ['nuxt-open-fetch'],

openFetch: {
openFetch: {
clients: {}
}
})
```


| **Key** | **Type** | **Default** | **Description** |
| ---------------------------- | ---------- | --------------------- | ---------------------------------------------------------------------------------------------------- |
| `openAPITS` | `OpenAPITSOptions` | | OpenAPI TS [options](https://openapi-ts.pages.dev/node/#options) |
Expand Down Expand Up @@ -51,4 +49,3 @@ or:
NUXT_PUBLIC_OPEN_FETCH_PETS_SCHEMA=https://petstore3.swagger.io/api/v3/openapi.json
NUXT_PUBLIC_OPEN_FETCH_PETS_BASE_URL=https://petstore3.swagger.io/api/v3/
```

2 changes: 1 addition & 1 deletion docs/content/1.setup/3.schemas.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default defineNuxtConfig({
clients: {
pets: {
baseURL: 'https://petstore3.swagger.io/api/v3/'
}
}
}
}
})
Expand Down
6 changes: 3 additions & 3 deletions docs/content/1.setup/4.proxy.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@ export default defineNuxtConfig({
})
```

You can also use [ProxyOptions](https://www.jsdocs.io/package/h3#ProxyOptions) object to configure proxy behaviour.
You can also use [ProxyOptions](https://www.jsdocs.io/package/h3#ProxyOptions) object to configure proxy behaviour.

F.e, remove `domain` attributes in the `set-cookie` headers:

```ts twoslash [nuxt.config.ts]
export default defineNuxtConfig({
routeRules: {
'/petsProxy/**': {
'/petsProxy/**': {
proxy: {
to: 'https://petstore3.swagger.io/api/v3/**',
cookieDomainRewrite: {
"*": "",
'*': '',
},
}
}
Expand Down
3 changes: 1 addition & 2 deletions docs/content/2.composables/1.use[Client].md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: "use[Client]"
description: "Generated fetch composable"
---

Composables are generated for each OpenAPI client specified in the `openFetch` section of Nuxt config and provide a convenient wrapper around `useFetch`.
Composables are generated for each OpenAPI client specified in the `openFetch` section of Nuxt config and provide a convenient wrapper around `useFetch`.

It has the same API as Nuxt's [useFetch](https://nuxt.com/docs/api/composables/use-fetch) composable with additional `path` option, which is used to replace params in the pathname.

Expand All @@ -21,4 +21,3 @@ const { data } = await usePets('/pet/{petId}', {
<h1>{{ data?.name }}</h1>
</template>
```

3 changes: 1 addition & 2 deletions docs/content/2.composables/2.useLazy[Client].md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: "useLazy[Client]"
description: "Generated fetch composable"
---

Composables are generated for each OpenAPI client specified in the `openFetch` section of Nuxt config and provide a convenient wrapper around `useLazyFetch`.
Composables are generated for each OpenAPI client specified in the `openFetch` section of Nuxt config and provide a convenient wrapper around `useLazyFetch`.

It has the same API as Nuxt's [useLazyFetch](https://nuxt.com/docs/api/composables/use-lazy-fetch) composable with additional `path` option, which is used to replace params in the pathname.

Expand All @@ -21,4 +21,3 @@ const { data } = useLazyPets('/pet/{petId}', {
<h1>{{ data?.name }}</h1>
</template>
```

2 changes: 1 addition & 1 deletion docs/content/2.composables/_dir.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
title: 'Composables'
title: Composables
icon: heroicons-outline:bookmark-alt
3 changes: 1 addition & 2 deletions docs/content/3.utils/1.$[client].md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: "$[client]"
description: "Generated fetch client"
---

Cliens are generated for each OpenAPI client specified in the `openFetch` section of Nuxt config and provide a convenient wrapper around `$fetch`.
Cliens are generated for each OpenAPI client specified in the `openFetch` section of Nuxt config and provide a convenient wrapper around `$fetch`.

You can access clients from the Vue context using `useNuxtApp()`.

Expand All @@ -24,4 +24,3 @@ const data = await $pets('/pet/{petId}', {
<h1>{{ data?.name }}</h1>
</template>
```

2 changes: 1 addition & 1 deletion docs/content/3.utils/_dir.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
title: 'Utils'
title: Utils
icon: heroicons-outline:bookmark-alt
4 changes: 2 additions & 2 deletions docs/content/4.advanced/1.custom-client.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ For example if you need to add logging on each request:
export default defineNuxtPlugin({
enforce: 'pre', // clients will be ready to use by other plugins, Pinia stores etc.
setup() {
const { public: { openFetch: clients }} = useRuntimeConfig()
const { public: { openFetch: clients } } = useRuntimeConfig()

return {
provide: Object.fromEntries(Object.entries(clients).map(([name, options]) => [
name,
createOpenFetch((localOptions) => ({
createOpenFetch(localOptions => ({
...options,
...localOptions,
onRequest(ctx) {
Expand Down
2 changes: 1 addition & 1 deletion docs/content/4.advanced/_dir.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
title: 'Advanced'
title: Advanced
icon: heroicons-outline:bookmark-alt
34 changes: 17 additions & 17 deletions docs/content/index.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
title: 'Nuxt Open Fetch'
title: Nuxt Open Fetch
description: 'Generate zero-overhead, 100% typed OpenAPI fetch for Nuxt'
navigation: false
hero:
title: 'OpenAPI fetch for Nuxt'
title: OpenAPI fetch for Nuxt
description: 'Generate zero-overhead, 100% typed OpenAPI fetch clients'
orientation: horizontal
links:
- label: Get started
icon: i-heroicons-arrow-right-20-solid
trailing: true
to: '/setup/quick-start'
to: /setup/quick-start
size: lg
- label: View on GitHub
icon: i-simple-icons-github
Expand All @@ -22,7 +22,7 @@ hero:
```ts twoslash
// @noErrors
const { data } = useLazyPets('/pet/{petId}', {
// ^|
// ^|
path: {
petId: 2
},
Expand All @@ -38,18 +38,18 @@ hero:
```
features:
items:
- title: 'Full type safety'
- title: Full type safety
description: 'All parameters, request bodies, and responses are type-checked and 100% match your schema'
icon: 'i-simple-icons-typescript'
- title: 'OpenAPI'
description: 'Supports OpenAPI 3.0 and 3.1 (including advanced features like discriminators)'
icon: 'i-simple-icons-openapiinitiative'
- title: 'YAML or JSON'
icon: i-simple-icons-typescript
- title: OpenAPI
description: Supports OpenAPI 3.0 and 3.1 (including advanced features like discriminators)
icon: i-simple-icons-openapiinitiative
- title: YAML or JSON
description: 'Load schemas from YAML or JSON, locally or remotely'
icon: 'i-simple-icons-json'
- title: 'Runtime-free'
description: 'Generate runtime-free types that outperform old school codegen'
- title: 'Fast'
description: 'Generate types for even huge schemas within milliseconds'
- title: 'Layers'
description: 'Works with Nuxt Layers'
icon: i-simple-icons-json
- title: Runtime-free
description: Generate runtime-free types that outperform old school codegen
- title: Fast
description: Generate types for even huge schemas within milliseconds
- title: Layers
description: Works with Nuxt Layers
Loading

0 comments on commit 21dcc36

Please sign in to comment.