Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eslint config update ignores branch #113

Merged
merged 2 commits into from
May 1, 2024
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
2 changes: 1 addition & 1 deletion components/flow/Header.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
interface Props {
url?: string
url: string | null
title: string
id: string
}
Expand Down
13 changes: 11 additions & 2 deletions composables/adapter/useAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,18 @@ import * as adapters from './adapters'
// Define a type for the adapter functions to improve type safety
type AdapterFunction = (api: API) => Promise<NModule[]>

// 定义一个映射类型来约束 adapters 中的函数
type AdaptersMap = {
[key in keyof typeof adapters]: AdapterFunction;
}

// 确保 adapters 符合这个映射类型
const typedAdapters: AdaptersMap = adapters

export default async function fetchModules(api: API): Promise<NModule[]> {
// Ensure that the adapter function exists and is callable
const adapter: AdapterFunction | undefined = (adapters as any)[api.adapter]
// 使用类型断言替代 any,因为我们已经通过 AdaptersMap 确保了类型安全
const adapter: AdapterFunction | undefined = typedAdapters[api.adapter as keyof typeof typedAdapters]

if (typeof adapter === 'function') {
const items: NModule[] = await adapter(api)
return items
Expand Down
8 changes: 6 additions & 2 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@ export default withNuxt(
// ...
// }
{

files: ['**/*.vue'],
rules: {
'vue/no-v-html': 'off', // 关闭 v-html 指令的 XSS 警告
},
},
{
ignores: ['dist', '**/dist/**', 'public', '**/public/**', 'auto-imports.d.ts', '**/auto-imports.d.ts/**', 'components.d.ts', '**/components.d.ts/**', '.output', '**/.output/**', 'node_modules', '**/node_modules/**', 'components/ui', '**/components/ui/**'],

},
)
2 changes: 1 addition & 1 deletion nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export default defineNuxtConfig({
'pic4.zhimg.com',
'unavatar.io',
'i.dawnlab.me',
'ipfs.crossbell.io'
'ipfs.crossbell.io',
],
},

Expand Down
Loading