feat(new tool): TOML Linter

Fix #1408
This commit is contained in:
ShareVB committed 2025-08-20 19:21:06 +02:00
1 parent 03e6e208ec
commit 4dc9dcfe91
2 files changed
+59

No files matched your search

+13
View File
@@ -0,0 +1,13 @@
import { defineTool } from '../tool';
import BracketIcon from '~icons/mdi/code-brackets';
export const tool = defineTool({
name: 'TOML Linter',
path: '/toml-linter',
description: 'Lint and check TOML content',
keywords: ['toml', 'linter'],
component: () => import('./toml-linter.vue'),
icon: BracketIcon,
createdAt: new Date('2025-08-15'),
category: 'TOML',
});
+46
View File
@@ -0,0 +1,46 @@
<script setup lang="ts">
import { parse as parseToml } from 'smol-toml';
const tomlContent = ref('');
const lintErrors = computed(() => {
try {
parseToml(tomlContent.value);
return '';
}
catch (e: any) {
return e.toString().trim();
}
});
const MONACO_EDITOR_OPTIONS = {
automaticLayout: true,
formatOnType: true,
formatOnPaste: true,
};
</script>
<template>
<div>
<n-card title="Your TOML Content:" mb-2>
<div relative w-full>
<c-monaco-editor
v-model:value="tomlContent"
theme="vs-dark"
height="250px"
:options="MONACO_EDITOR_OPTIONS"
/>
</div>
</n-card>
<div v-if="lintErrors">
<n-alert type="error" title="Linting Error" :show-icon="true">
<pre>{{ lintErrors }}</pre>
</n-alert>
</div>
<div v-else-if="tomlContent">
<n-alert type="success" title="Valid TOML" :show-icon="true">
No errors found. Your TOML is valid!
</n-alert>
</div>
</div>
</template>