Fixed lint errors

This commit is contained in:
Isaiah 2023-11-27 16:59:56 -05:00
parent 84934504c7
commit 4f69621a9d
4 changed files with 37 additions and 37 deletions

View file

@ -140,7 +140,7 @@ export const toolsByCategory: ToolCategory[] = [
chmodCalculator,
dockerRunToDockerComposeConverter,
xmlFormatter,
yamlViewer
yamlViewer,
],
},
{

View file

@ -2,11 +2,11 @@ import { AlignJustified } from '@vicons/tabler';
import { defineTool } from '../tool';
export const tool = defineTool({
name: 'YAML prettify and format',
path: '/yaml-prettify',
description: 'Prettify your YAML string to a human friendly readable format.',
keywords: ['yaml', 'viewer', 'prettify', 'format'],
component: () => import('./yaml-viewer.vue'),
icon: AlignJustified,
redirectFrom: ['/yaml-viewer'],
name: 'YAML prettify and format',
path: '/yaml-prettify',
description: 'Prettify your YAML string to a human friendly readable format.',
keywords: ['yaml', 'viewer', 'prettify', 'format'],
component: () => import('./yaml-viewer.vue'),
icon: AlignJustified,
redirectFrom: ['/yaml-viewer'],
});

View file

@ -1,24 +1,24 @@
import { type MaybeRef, get } from '@vueuse/core';
import yaml from "js-yaml";
import yaml from 'js-yaml';
export { formatYaml };
function formatYaml({
rawYaml,
sortKeys = false,
indentSize = 2,
}: {
rawYaml: MaybeRef<string>
sortKeys?: MaybeRef<boolean>
indentSize?: MaybeRef<number>
rawYaml,
sortKeys = false,
indentSize = 2,
}: {
rawYaml: MaybeRef<string>
sortKeys?: MaybeRef<boolean>
indentSize?: MaybeRef<number>
}) {
const parsedYaml = yaml.load(get(rawYaml));
const parsedYaml = yaml.load(get(rawYaml));
const formattedYAML = yaml.dump(parsedYaml, {
sortKeys: get(sortKeys),
indent: get(indentSize)
});
const formattedYAML = yaml.dump(parsedYaml, {
sortKeys: get(sortKeys),
indent: get(indentSize),
});
return formattedYAML
return formattedYAML;
}

View file

@ -1,5 +1,5 @@
<script setup lang="ts">
import yaml from 'js-yaml'
import yaml from 'js-yaml';
import { useStorage } from '@vueuse/core';
import { formatYaml } from './yaml-models';
import { withDefaultOnError } from '@/utils/defaults';
@ -12,7 +12,7 @@ const rawYaml = useStorage('yaml-prettify:raw-yaml', '');
const indentSize = useStorage('yaml-prettify:indent-size', 2);
const sortKeys = useStorage('yaml-prettify:sort-keys', false);
const cleanYaml = computed(() => withDefaultOnError(() => formatYaml({ rawYaml: rawYaml, indentSize, sortKeys }), ''));
const cleanYaml = computed(() => withDefaultOnError(() => formatYaml({ rawYaml, indentSize, sortKeys }), ''));
const rawYamlValidation = useValidation({
source: rawYaml,
@ -38,21 +38,21 @@ const rawYamlValidation = useValidation({
</div>
<n-form-item
label="Your raw YAML"
:feedback="rawYamlValidation.message"
:validation-status="rawYamlValidation.status"
label="Your raw YAML"
:feedback="rawYamlValidation.message"
:validation-status="rawYamlValidation.status"
>
<c-input-text
ref="inputElement"
v-model:value="rawYaml"
placeholder="Paste your raw YAML here..."
rows="20"
multiline
autocomplete="off"
autocorrect="off"
autocapitalize="off"
spellcheck="false"
monospace
ref="inputElement"
v-model:value="rawYaml"
placeholder="Paste your raw YAML here..."
rows="20"
multiline
autocomplete="off"
autocorrect="off"
autocapitalize="off"
spellcheck="false"
monospace
/>
</n-form-item>
<n-form-item label="Prettified version of your YAML">