Improved pre-commit and linters config

This commit is contained in:
Antoine Nguyen
2024-02-21 13:30:20 +01:00
parent 692871bedf
commit f1d89bd58f
141 changed files with 10460 additions and 8115 deletions
+16 -14
View File
@@ -4,18 +4,20 @@ import { DateTime } from 'luxon'
const { $gettext } = gettext
export default {
install: (app) => {
app.config.globalProperties.$yesno = (value) => {
return value ? $gettext('yes') : $gettext('no')
}
app.config.globalProperties.$date = (value) => {
return DateTime.fromISO(value)
.setLocale('en')
.toLocaleString(DateTime.DATETIME_MED)
}
app.config.globalProperties.$truncate = (value, length, clamp) => {
clamp = clamp || '...'
return value.length > length ? value.slice(0, length) + clamp : value
}
},
install: (app) => {
app.config.globalProperties.$yesno = (value) => {
return value ? $gettext('yes') : $gettext('no')
}
app.config.globalProperties.$date = (value) => {
return DateTime.fromISO(value)
.setLocale('en')
.toLocaleString(DateTime.DATETIME_MED)
}
app.config.globalProperties.$truncate = (value, length, clamp) => {
clamp = clamp || '...'
return value.length > length
? value.slice(0, length) + clamp
: value
}
},
}
+22 -22
View File
@@ -2,26 +2,26 @@ import { createGettext } from 'vue3-gettext'
import translations from '@/locale/translations.json'
export default createGettext({
availableLanguages: {
en: 'English',
cs: 'Czech',
de: 'German',
br: 'Breton',
el: 'Greek',
es: 'Spain',
fi: 'Finnish',
fr: 'French',
it: 'Italian',
ja: 'Japanese',
nl: 'Dutch',
pl: 'Polish',
pt: 'Portuguese',
ru: 'Russian',
sv: 'Swedish',
tr: 'tr',
zh: 'Chinese',
},
defaultLanguage: 'en',
translations: translations,
silent: true, // stop warnings
availableLanguages: {
en: 'English',
cs: 'Czech',
de: 'German',
br: 'Breton',
el: 'Greek',
es: 'Spain',
fi: 'Finnish',
fr: 'French',
it: 'Italian',
ja: 'Japanese',
nl: 'Dutch',
pl: 'Polish',
pt: 'Portuguese',
ru: 'Russian',
sv: 'Swedish',
tr: 'tr',
zh: 'Chinese',
},
defaultLanguage: 'en',
translations: translations,
silent: true, // stop warnings
})
+6 -7
View File
@@ -13,11 +13,10 @@ import pinia from '@/stores'
import VueApexCharts from 'vue3-apexcharts'
export function registerPlugins(app) {
app
.use(gettext)
.use(vuetify)
.use(pinia)
.use(router)
.use(filters)
.use(VueApexCharts)
app.use(gettext)
.use(vuetify)
.use(pinia)
.use(router)
.use(filters)
.use(VueApexCharts)
}
+28 -27
View File
@@ -3,40 +3,41 @@ import gettext from './gettext'
const { $gettext } = gettext
function validateEmail(email) {
if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email)) {
return $gettext('Not a valid email')
} else {
return true
}
if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email)) {
return $gettext('Not a valid email')
} else {
return true
}
}
function validateNumeric(value) {
if (isNaN(value)) {
return false
}
var x = parseFloat(value)
return (x | 0) === x
if (isNaN(value)) {
return false
}
var x = parseFloat(value)
return (x | 0) === x
}
function samePassword(value, confirmation) {
return value === confirmation
return value === confirmation
}
export default {
required: (value) =>
(value !== '' && value != null) || $gettext('Field is required'),
email: (value) => validateEmail(value),
emailOrNull: (value) => value != null || value !== '' || validateEmail(value),
minLength: (len) => (value) =>
value.length > len ||
$gettext('Minimum length is %{ length }', { length: len }),
numericOrNull: (value) =>
value == null ||
value === '' ||
validateNumeric(value) ||
$gettext('Must be a numeric value or empty'),
samePassword: (value, confirmation) =>
samePassword(value, confirmation) || $gettext('Passwords mismatch'),
portNumber: (value) =>
(value > 0 && value < 65536) || $gettext('Invalid port number'),
required: (value) =>
(value !== '' && value != null) || $gettext('Field is required'),
email: (value) => validateEmail(value),
emailOrNull: (value) =>
value != null || value !== '' || validateEmail(value),
minLength: (len) => (value) =>
value.length > len ||
$gettext('Minimum length is %{ length }', { length: len }),
numericOrNull: (value) =>
value == null ||
value === '' ||
validateNumeric(value) ||
$gettext('Must be a numeric value or empty'),
samePassword: (value, confirmation) =>
samePassword(value, confirmation) || $gettext('Passwords mismatch'),
portNumber: (value) =>
(value > 0 && value < 65536) || $gettext('Invalid port number'),
}
+17 -17
View File
@@ -13,24 +13,24 @@ import { createVuetify } from 'vuetify'
// https://vuetifyjs.com/en/introduction/why-vuetify/#feature-guides
export default createVuetify({
theme: {
themes: {
light: {
colors: {
primary: '#046BF8',
'primary-lighten-1': '#3688F9',
'primary-darken-1': '#0350BA',
secondary: '#F18429',
label: '#616161',
theme: {
themes: {
light: {
colors: {
primary: '#046BF8',
'primary-lighten-1': '#3688F9',
'primary-darken-1': '#0350BA',
secondary: '#F18429',
label: '#616161',
},
},
},
},
},
},
styles: { configFile: 'src/styles/settings.scss' },
defaults: {
VCard: {
class: 'pa-2',
VCardTitle: { class: 'd-flex', style: 'align-items: center;' },
styles: { configFile: 'src/styles/settings.scss' },
defaults: {
VCard: {
class: 'pa-2',
VCardTitle: { class: 'd-flex', style: 'align-items: center;' },
},
},
},
})