refactor(lint): linter auto fix

This commit is contained in:
Corentin Thomasset 2022-04-22 23:31:40 +02:00
parent 8e29a97404
commit 086d31eab5
No known key found for this signature in database
GPG key ID: DBD997E935996158
54 changed files with 1122 additions and 1503 deletions

View file

@ -6,11 +6,7 @@
:feedback="cronValidation.message"
:validation-status="cronValidation.status"
>
<n-input
v-model:value="cron"
size="large"
placeholder="* * * * *"
/>
<n-input v-model:value="cron" size="large" placeholder="* * * * *" />
</n-form-item>
<div class="cron-string">
{{ cronString }}
@ -19,11 +15,7 @@
<n-divider />
<n-space justify="center">
<n-form
:show-feedback="false"
label-width="170"
label-placement="left"
>
<n-form :show-feedback="false" label-width="170" label-placement="left">
<n-form-item label="Verbose">
<n-switch v-model:value="cronstrueConfig.verbose" />
</n-form-item>
@ -36,7 +28,7 @@
</n-form>
</n-space>
</n-card>
<br>
<br />
<n-card>
<pre>
[optional] seconds (0 - 59)
@ -46,62 +38,39 @@
| | | | month (1 - 12) OR jan,feb,mar,apr ...
| | | | | day of week (0 - 6, sunday=0) OR sun,mon ...
| | | | | |
* * * * * * command</pre>
* * * * * * command</pre
>
<n-space
v-if="styleStore.isSmallScreen"
vertical
>
<n-card
v-for="{symbol, meaning, example, equivalent} in helpers"
:key="symbol"
embedded
:bordered="false"
>
<div>Symbol: <strong>{{ symbol }}</strong></div>
<div>Meaning: <strong>{{ meaning }}</strong></div>
<div>Example: <strong><code>{{ example }}</code></strong></div>
<div>Equivalent: <strong>{{ equivalent }}</strong></div>
<n-space v-if="styleStore.isSmallScreen" vertical>
<n-card v-for="{ symbol, meaning, example, equivalent } in helpers" :key="symbol" embedded :bordered="false">
<div>
Symbol: <strong>{{ symbol }}</strong>
</div>
<div>
Meaning: <strong>{{ meaning }}</strong>
</div>
<div>
Example:
<strong
><code>{{ example }}</code></strong
>
</div>
<div>
Equivalent: <strong>{{ equivalent }}</strong>
</div>
</n-card>
</n-space>
<n-table
v-else
size="small"
>
<n-table v-else size="small">
<thead>
<tr>
<th
class="text-left"
scope="col"
>
Symbol
</th>
<th
class="text-left"
scope="col"
>
Meaning
</th>
<th
class="text-left"
scope="col"
>
Example
</th>
<th
class="text-left"
scope="col"
>
Equivalent
</th>
<th class="text-left" scope="col">Symbol</th>
<th class="text-left" scope="col">Meaning</th>
<th class="text-left" scope="col">Example</th>
<th class="text-left" scope="col">Equivalent</th>
</tr>
</thead>
<tbody>
<tr
v-for="{symbol, meaning, example, equivalent} in helpers"
:key="symbol"
>
<tr v-for="{ symbol, meaning, example, equivalent } in helpers" :key="symbol">
<td>{{ symbol }}</td>
<td>{{ meaning }}</td>
<td>
@ -115,116 +84,117 @@
</template>
<script setup lang="ts">
import cronstrue from 'cronstrue'
import { isValidCron } from 'cron-validator'
import cronstrue from 'cronstrue';
import { isValidCron } from 'cron-validator';
import { computed, reactive, ref } from 'vue';
import { useValidation } from '@/composable/validation';
import { useStyleStore } from '@/stores/style.store';
function isCronValid(v: string) {
return isValidCron(v, { allowBlankDay: true, alias: true, seconds: true })
return isValidCron(v, { allowBlankDay: true, alias: true, seconds: true });
}
const styleStore = useStyleStore()
const styleStore = useStyleStore();
const cron = ref('40 * * * *')
const cron = ref('40 * * * *');
const cronstrueConfig = reactive({
verbose: true,
dayOfWeekStartIndexZero: true,
use24HourTimeFormat: true,
throwExceptionOnParseError: true
})
throwExceptionOnParseError: true,
});
const helpers = [
{
"symbol": "*",
"meaning": "Any value",
"example": "* * * *",
"equivalent": "Every minute"
},
{
"symbol": "-",
"meaning": "Range of values",
"example": "1-10 * * *",
"equivalent": "Minutes 1 through 10"
},
{
"symbol": ",",
"meaning": "List of values",
"example": "1,10 * * *",
"equivalent": "At minutes 1 and 10"
},
{
"symbol": "/",
"meaning": "Step values",
"example": "*/10 * * *",
"equivalent": "Every 10 minutes"
},
{
"symbol": "@yearly",
"meaning": "Once every year at midnight of 1 January",
"example": "@yearly",
"equivalent": "0 0 1 1 *"
},
{
"symbol": "@annually",
"meaning": "Same as @yearly",
"example": "@annually",
"equivalent": "0 0 1 1 *"
},
{
"symbol": "@monthly",
"meaning": "Once a month at midnight on the first day",
"example": "@monthly",
"equivalent": "0 0 1 * *"
},
{
"symbol": "@weekly",
"meaning": "Once a week at midnight on Sunday morning",
"example": "@weekly",
"equivalent": "0 0 * * 0"
},
{
"symbol": "@daily",
"meaning": "Once a day at midnight",
"example": "@daily",
"equivalent": "0 0 * * *"
},
{
"symbol": "@midnight",
"meaning": "Same as @daily",
"example": "@midnight",
"equivalent": "0 0 * * *"
},
{
"symbol": "@hourly",
"meaning": "Once an hour at the beginning of the hour",
"example": "@hourly",
"equivalent": "0 * * * *"
},
{
"symbol": "@reboot",
"meaning": "Run at startup",
"example": "",
"equivalent": ""
}
]
{
symbol: '*',
meaning: 'Any value',
example: '* * * *',
equivalent: 'Every minute',
},
{
symbol: '-',
meaning: 'Range of values',
example: '1-10 * * *',
equivalent: 'Minutes 1 through 10',
},
{
symbol: ',',
meaning: 'List of values',
example: '1,10 * * *',
equivalent: 'At minutes 1 and 10',
},
{
symbol: '/',
meaning: 'Step values',
example: '*/10 * * *',
equivalent: 'Every 10 minutes',
},
{
symbol: '@yearly',
meaning: 'Once every year at midnight of 1 January',
example: '@yearly',
equivalent: '0 0 1 1 *',
},
{
symbol: '@annually',
meaning: 'Same as @yearly',
example: '@annually',
equivalent: '0 0 1 1 *',
},
{
symbol: '@monthly',
meaning: 'Once a month at midnight on the first day',
example: '@monthly',
equivalent: '0 0 1 * *',
},
{
symbol: '@weekly',
meaning: 'Once a week at midnight on Sunday morning',
example: '@weekly',
equivalent: '0 0 * * 0',
},
{
symbol: '@daily',
meaning: 'Once a day at midnight',
example: '@daily',
equivalent: '0 0 * * *',
},
{
symbol: '@midnight',
meaning: 'Same as @daily',
example: '@midnight',
equivalent: '0 0 * * *',
},
{
symbol: '@hourly',
meaning: 'Once an hour at the beginning of the hour',
example: '@hourly',
equivalent: '0 * * * *',
},
{
symbol: '@reboot',
meaning: 'Run at startup',
example: '',
equivalent: '',
},
];
const cronString = computed(() => {
if (isCronValid(cron.value)) {
return cronstrue.toString(cron.value, cronstrueConfig)
return cronstrue.toString(cron.value, cronstrueConfig);
}
return ' '
})
return ' ';
});
const cronValidation = useValidation({
source: cron,
rules: [{
validator: (value) => isCronValid(value),
message: 'This cron is invalid'
}]
})
rules: [
{
validator: (value) => isCronValid(value),
message: 'This cron is invalid',
},
],
});
</script>
<style lang="less" scoped>
@ -239,7 +209,6 @@ const cronValidation = useValidation({
font-size: 30px;
font-family: monospace;
padding: 5px;
}
}

View file

@ -5,7 +5,21 @@ export const tool: ITool = {
name: 'Crontab generator',
path: '/crontab-generator',
description: 'Validate and generate crontab and get the human readable description of the cron schedule.',
keywords: ['crontab', 'generator', 'cronjob', 'cron', 'schedule', 'parse', 'expression', 'year', 'month', 'week', 'day', 'minute', 'second'],
keywords: [
'crontab',
'generator',
'cronjob',
'cron',
'schedule',
'parse',
'expression',
'year',
'month',
'week',
'day',
'minute',
'second',
],
component: () => import('./crontab-generator.vue'),
icon: Alarm,
};