mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-04-27 18:16:15 -04:00
chore(lint): switched to a better lint config
This commit is contained in:
parent
4d2b037dbe
commit
33c9b6643f
178 changed files with 4105 additions and 3371 deletions
|
@ -1,4 +1,4 @@
|
|||
import { test, expect } from '@playwright/test';
|
||||
import { expect, test } from '@playwright/test';
|
||||
|
||||
test.describe('Tool - Yaml to json', () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
|
|
|
@ -1,3 +1,24 @@
|
|||
<script setup lang="ts">
|
||||
import { parse as parseYaml } from 'yaml';
|
||||
import type { UseValidationRule } from '@/composable/validation';
|
||||
import { isNotThrowing } from '@/utils/boolean';
|
||||
import { withDefaultOnError } from '@/utils/defaults';
|
||||
|
||||
function transformer(value: string) {
|
||||
return withDefaultOnError(() => {
|
||||
const obj = parseYaml(value);
|
||||
return obj ? JSON.stringify(obj, null, 3) : '';
|
||||
}, '');
|
||||
}
|
||||
|
||||
const rules: UseValidationRule<string>[] = [
|
||||
{
|
||||
validator: (value: string) => isNotThrowing(() => parseYaml(value)),
|
||||
message: 'Provided YAML is not valid.',
|
||||
},
|
||||
];
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<format-transformer
|
||||
input-label="Your YAML"
|
||||
|
@ -8,25 +29,3 @@
|
|||
:transformer="transformer"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import type { UseValidationRule } from '@/composable/validation';
|
||||
import { isNotThrowing } from '@/utils/boolean';
|
||||
import { withDefaultOnError } from '@/utils/defaults';
|
||||
import { parse as parseYaml } from 'yaml';
|
||||
|
||||
const transformer = (value: string) =>
|
||||
withDefaultOnError(() => {
|
||||
const obj = parseYaml(value);
|
||||
return obj ? JSON.stringify(obj, null, 3) : '';
|
||||
}, '');
|
||||
|
||||
const rules: UseValidationRule<string>[] = [
|
||||
{
|
||||
validator: (value: string) => isNotThrowing(() => parseYaml(value)),
|
||||
message: 'Provided YAML is not valid.',
|
||||
},
|
||||
];
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped></style>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue