Skip to content

Commit

Permalink
chore: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Yizack committed Jun 21, 2024
1 parent 12e09b2 commit cee148c
Show file tree
Hide file tree
Showing 15 changed files with 154 additions and 150 deletions.
77 changes: 42 additions & 35 deletions .config/eslint.mjs
Original file line number Diff line number Diff line change
@@ -1,38 +1,45 @@
import withNuxt from "../.nuxt/eslint.config.mjs";

export default withNuxt([{
files: ["**/*.vue", "**/*.js", "**/*.ts", "**/*.mjs"],
ignores: [
"node_modules/**/*",
".nuxt/**/*",
"dist/**/*",
".output/**/*",
"public/**/*"
],
rules: {
"camelcase": "off",
"no-console": ["error", { allow: ["info", "warn"] }],
"@stylistic/indent": ["error", 2, { SwitchCase: 1 }],
"@stylistic/linebreak-style": ["error", process.platform === "win32" ? "windows" : "unix"],
"@stylistic/quotes": ["error", "double"],
"@stylistic/semi": ["error", "always"],
"@stylistic/no-extra-semi": "error",
"@stylistic/comma-dangle": ["error", "never"],
"@stylistic/space-before-function-paren": ["error", "always"],
"@stylistic/multiline-ternary": ["error", "never"],
"@stylistic/member-delimiter-style": ["error", { multiline: { delimiter: "semi" }, singleline: { delimiter: "comma" } }],
"@stylistic/arrow-spacing": ["error", { before: true, after: true }],
"@stylistic/brace-style": ["error", "stroustrup", { allowSingleLine: true }],
"@stylistic/no-multi-spaces": "error",
"@stylistic/space-before-blocks": "error",
"@stylistic/no-trailing-spaces": "error",
"nuxt/prefer-import-meta": "error",
"vue/first-attribute-linebreak": ["error", { singleline: "ignore", multiline: "ignore" }],
"vue/max-attributes-per-line": ["error", { singleline: 100 }],
"vue/singleline-html-element-content-newline": ["off"],
"vue/no-multiple-template-root": ["off"],
"vue/html-closing-bracket-spacing": ["error", { selfClosingTag: "always" }],
"vue/html-indent": ["error", 2],
"vue/multiline-html-element-content-newline": ["error", { ignores: [] }]
export default withNuxt([
{
ignores: [
"node_modules/**/*",
".nuxt/**/*",
"dist/**/*",
".output/**/*",
"public/**/*",
"android/**/*",
"tests/**/*"
]
},
{
files: ["**/*.vue", "**/*.js", "**/*.ts", "**/*.mjs"],
rules: {
"no-undef": "off",
"camelcase": "off",
"no-console": ["error", { allow: ["info", "warn"] }],
"@stylistic/indent": ["error", 2, { SwitchCase: 1 }],
"@stylistic/linebreak-style": ["error", process.platform === "win32" ? "windows" : "unix"],
"@stylistic/quotes": ["error", "double"],
"@stylistic/semi": ["error", "always"],
"@stylistic/no-extra-semi": "error",
"@stylistic/comma-dangle": ["error", "never"],
"@stylistic/space-before-function-paren": ["error", "always"],
"@stylistic/multiline-ternary": ["error", "never"],
"@stylistic/member-delimiter-style": ["error", { multiline: { delimiter: "semi" }, singleline: { delimiter: "comma" } }],
"@stylistic/arrow-spacing": ["error", { before: true, after: true }],
"@stylistic/brace-style": ["error", "stroustrup", { allowSingleLine: true }],
"@stylistic/no-multi-spaces": "error",
"@stylistic/space-before-blocks": "error",
"@stylistic/no-trailing-spaces": "error",
"nuxt/prefer-import-meta": "error",
"vue/first-attribute-linebreak": ["error", { singleline: "ignore", multiline: "ignore" }],
"vue/max-attributes-per-line": ["error", { singleline: 100 }],
"vue/singleline-html-element-content-newline": ["off"],
"vue/no-multiple-template-root": ["off"],
"vue/html-closing-bracket-spacing": ["error", { selfClosingTag: "always" }],
"vue/html-indent": ["error", 2],
"vue/multiline-html-element-content-newline": ["error", { ignores: [] }]
}
}
}]);
]);
1 change: 1 addition & 0 deletions .config/nuxt.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export default defineNuxtConfig({
"~/assets/css/nav.css"
],
modules: [
"@nuxt/eslint",
"nuxt-icons",
"@pinia/nuxt"
],
Expand Down
4 changes: 3 additions & 1 deletion .config/stylelint.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
"../.nuxt/**/*",
"../dist/**/*",
"../.output/**/*",
"../public/**/*"
"../public/**/*",
"../android/**/*",
"../tests/**/*"
]
}
26 changes: 11 additions & 15 deletions components/CardInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,12 @@ export default {
this.dialog = t("editando");
showModal("progress-dialog");
const nombre_trimmed = this.form.nombre.trim();
const { error, error_key } = !Auth().isGuest
? await API.updateTarjeta({
email: Auth().user.email,
token: Auth().user.token,
numero: this.tarjeta.numero,
nombre: nombre_trimmed
})
: { error: false };
const { error, error_key } = !Auth().isGuest ? await API.updateTarjeta({
email: Auth().user.email,
token: Auth().user.token,
numero: this.tarjeta.numero,
nombre: nombre_trimmed
}) : { error: false };
const { changes } = await DB.updateNombreTarjeta(this.tarjeta.numero, nombre_trimmed);
Expand All @@ -186,13 +184,11 @@ export default {
if (confirm) {
this.dialog = t("eliminando");
showModal("progress-dialog");
const { error, error_key } = !Auth().isGuest
? await API.deleteTarjeta({
email: Auth().user.email,
token: Auth().user.token,
numero: this.tarjeta.numero
})
: { error: false };
const { error, error_key } = !Auth().isGuest ? await API.deleteTarjeta({
email: Auth().user.email,
token: Auth().user.token,
numero: this.tarjeta.numero
}) : { error: false };
const { changes } = await DB.deleteTarjeta(this.tarjeta.numero);
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
"release:patch": "pnpm changelogen --bump --patch && node scripts/newRelease.js && pnpm changelogen gh release",
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js --verbose --coverage",
"lint": "npm run lint:eslint && npm run lint:stylelint",
"lint:eslint": "eslint --ext .ts,.js,.vue --fix --ignore-path .gitignore .",
"lint:stylelint": "stylelint \"**/*.css\" --fix",
"lint:eslint": "eslint --fix --config .config/eslint.mjs",
"lint:stylelint": "stylelint \"**/*.css\" --fix --config .config/stylelint.json",
"dev:build": "pnpm app:mibus && pnpm generate && pnpm app:clean && pnpm sync"
},
"devDependencies": {
Expand Down Expand Up @@ -96,4 +96,4 @@
}
},
"packageManager": "[email protected]"
}
}
7 changes: 4 additions & 3 deletions pages/app/direcciones.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script setup>
import { Loader } from "@googlemaps/js-api-loader";
import { OpenStreetMapProvider } from "leaflet-geosearch";
definePageMeta({ layout: "main" });
</script>

Expand All @@ -9,7 +10,7 @@ definePageMeta({ layout: "main" });
<form class="mb-2" @submit.prevent="getDirections">
<div class="position-relative">
<div class="input-group mb-1 shadow-sm rounded position-relative">
<span class="text-primary-emphasis input-group-text border border-end-0" :class="{'bg-disabled' : directions.routes.length}">
<span class="text-primary-emphasis input-group-text border border-end-0" :class="{ 'bg-disabled': directions.routes.length }">
<Icon name="location" size="sm" />
</span>
<div class="form-floating">
Expand All @@ -19,7 +20,7 @@ definePageMeta({ layout: "main" });
<AutocompleteList v-if="search.origin && !search.destination" :text="form.origin" :loading="loading" :array="autocomplete" prop="label" @select="selectResult($event, 'origin')" />
</div>
<div class="input-group shadow-sm rounded position-relative">
<span class="text-primary-emphasis input-group-text border border-end-0" :class="{'bg-disabled' : directions.routes.length}">
<span class="text-primary-emphasis input-group-text border border-end-0" :class="{ 'bg-disabled': directions.routes.length }">
<Icon name="destination" size="sm" />
</span>
<div class="form-floating">
Expand Down Expand Up @@ -64,7 +65,7 @@ definePageMeta({ layout: "main" });
<img class="travel-icon" :src="step.transit.line.vehicle.icon" width="20" height="20">
<div v-if="step.transit">
<div class="my-2 small">
<span class="px-1 rounded shadow-sm" :style="{backgroundColor: step.transit.line.color, color: step.transit.line.text_color }">{{ step.transit.line.short_name }}</span>
<span class="px-1 rounded shadow-sm" :style="{ backgroundColor: step.transit.line.color, color: step.transit.line.text_color }">{{ step.transit.line.short_name }}</span>
</div>
</div>
</div>
Expand Down
14 changes: 6 additions & 8 deletions pages/app/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,12 @@ export default {
tarjeta.fecha_added = new Date().toISOString().replace("T", " ").replace("Z", "");
const tarjetaExists = await DB.tarjetaExists(tarjeta.numero);
if (!tarjetaExists) {
const { error, error_key } = !Auth().isGuest
? await API.addTarjeta({
nombre: tarjeta.nombre,
numero: tarjeta.numero,
email: Auth().user.email,
token: Auth().user.token
})
: { error: false };
const { error, error_key } = !Auth().isGuest ? await API.addTarjeta({
nombre: tarjeta.nombre,
numero: tarjeta.numero,
email: Auth().user.email,
token: Auth().user.token
}) : { error: false };
const { changes } = await DB.insertTarjeta(tarjeta);
if (changes > 0 && !error) {
await DB.insertMovimientos(tarjeta);
Expand Down
6 changes: 3 additions & 3 deletions pages/app/mibus/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ definePageMeta({ layout: "main" });
<div id="accordionFlushRutas" class="accordion accordion-flush bg-body-tertiary border rounded shadow">
<div v-for="(tipo, i) in tiposFiltered" :key="i" class="accordion-item">
<h2 class="accordion-header">
<button class="accordion-button" :class="{'collapsed': !buscar.input}" type="button" data-bs-toggle="collapse" :data-bs-target="`#flush-collapse${i}`" :aria-expanded="Boolean(buscar.input)" :aria-controls="`flush-collapse${i}`">
<button class="accordion-button" :class="{ collapsed: !buscar.input }" type="button" data-bs-toggle="collapse" :data-bs-target="`#flush-collapse${i}`" :aria-expanded="Boolean(buscar.input)" :aria-controls="`flush-collapse${i}`">
<b>{{ tipo.nombre }}</b>
</button>
</h2>
<div :id="`flush-collapse${i}`" class="accordion-collapse collapse" :class="{'show': buscar.input}">
<div :id="`flush-collapse${i}`" class="accordion-collapse collapse" :class="{ show: buscar.input }">
<div v-if="tipo.rutas.length === 0" class="text-center p-2 border-top">
<p class="m-0">{{ t("results_notfound") }}</p>
</div>
<div v-for="ruta in tipo.rutas" :key="ruta.route_id" class="border-top">
<div class="d-flex align-items-center p-2 hover" role="button" @click="openRoute(ruta.route_id)">
<p class="p-2 m-0 text-white rounded small text-center fw-bold shadow-sm" :style="{ backgroundColor: `#${ruta.route_color}`, minWidth: '3.7rem'} ">{{ ruta.route_short_name }}</p>
<p class="p-2 m-0 text-white rounded small text-center fw-bold shadow-sm" :style="{ backgroundColor: `#${ruta.route_color}`, minWidth: '3.7rem' } ">{{ ruta.route_short_name }}</p>
<div class="p-2">
<p class="text-muted mb-0"><small>{{ ruta.route_type }}</small></p>
<p class="mb-0 fw-bold">{{ ruta.route_long_name }}</p>
Expand Down
6 changes: 3 additions & 3 deletions pages/app/perfil.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,18 @@ definePageMeta({ layout: "main" });
<div class="m-2">
<form novalidate @submit.prevent="updatePass()">
<div class="mb-3 position-relative form-floating">
<input ref="current" class="form-control" :class="{ 'is-invalid': form.error}" type="password" autocomplete="password" :placeholder="t('current_pass')" :value="form.current_password" required @input="form.current_password = $event.target.value" @keyup="form.error = false">
<input ref="current" class="form-control" :class="{ 'is-invalid': form.error }" type="password" autocomplete="password" :placeholder="t('current_pass')" :value="form.current_password" required @input="form.current_password = $event.target.value" @keyup="form.error = false">
<label>{{ t("current_pass") }}</label>
<div class="invalid-tooltip">
{{ t("pass_error") }}
</div>
</div>
<div class="mb-3 form-floating">
<input class="form-control" :class="{'is-valid': isPasswordValid}" type="password" autocomplete="new-password" :placeholder="t('new_pass')" :value="form.new_password" required @input="form.new_password = $event.target.value">
<input class="form-control" :class="{ 'is-valid': isPasswordValid }" type="password" autocomplete="new-password" :placeholder="t('new_pass')" :value="form.new_password" required @input="form.new_password = $event.target.value">
<label>{{ t("new_pass") }}</label>
</div>
<div class="mb-3 form-floating">
<input class="form-control" :class="{'is-valid': isPasswordCheckValid}" type="password" autocomplete="off" :placeholder="t('password_check')" :value="form.password_check" required @input="form.password_check = $event.target.value">
<input class="form-control" :class="{ 'is-valid': isPasswordCheckValid }" type="password" autocomplete="off" :placeholder="t('password_check')" :value="form.password_check" required @input="form.password_check = $event.target.value">
<label>{{ t("password_check") }}</label>
</div>
<div class="d-grid">
Expand Down
8 changes: 4 additions & 4 deletions pages/registro.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@ definePageMeta({ layout: "back", nav_title: "registrate" });
</div>
<form ref="registro" novalidate @submit.prevent="registro()">
<div class="mb-3 form-floating">
<input class="form-control" :class="{'is-valid': isNombreValid}" type="text" :placeholder="t('nombre')" required @input="form.nombre = $event.target.value">
<input class="form-control" :class="{ 'is-valid': isNombreValid }" type="text" :placeholder="t('nombre')" required @input="form.nombre = $event.target.value">
<label>{{ t("nombre") }}</label>
</div>
<div class="mb-3 position-relative form-floating">
<input ref="email" class="form-control" :class="{'is-valid': isEmailValid, 'is-invalid': form.error}" type="email" :placeholder="t('correo')" autocomplete="email" required @input="form.email = $event.target.value" @keyup="form.error = false">
<input ref="email" class="form-control" :class="{ 'is-valid': isEmailValid, 'is-invalid': form.error }" type="email" :placeholder="t('correo')" autocomplete="email" required @input="form.email = $event.target.value" @keyup="form.error = false">
<label>{{ t("correo") }}</label>
<div v-if="form.error" class="invalid-tooltip">
{{ t("correo_existe") }}
</div>
</div>
<div class="mb-3 form-floating">
<input class="form-control" :class="{'is-valid': isPasswordValid}" type="password" :placeholder="t('password')" autocomplete="new-password" required @input="form.password = $event.target.value">
<input class="form-control" :class="{ 'is-valid': isPasswordValid }" type="password" :placeholder="t('password')" autocomplete="new-password" required @input="form.password = $event.target.value">
<label>{{ t("password") }}</label>
</div>
<div class="mb-3 form-floating">
<input class="form-control" :class="{'is-valid': isPasswordCheckValid}" type="password" :placeholder="t('password_check')" autocomplete="off" required @input="form.password_check = $event.target.value">
<input class="form-control" :class="{ 'is-valid': isPasswordCheckValid }" type="password" :placeholder="t('password_check')" autocomplete="off" required @input="form.password_check = $event.target.value">
<label>{{ t("password_check") }}</label>
</div>
<div class="d-grid mt-4">
Expand Down
2 changes: 1 addition & 1 deletion utils/api.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class SaldometrobusAPI {
constructor () {
this.base = process.dev ? "http://localhost:5173" : "https://saldometrobus.yizack.com";
this.base = import.meta.dev ? "http://localhost:5173" : "https://saldometrobus.yizack.com";
this.version = "v2";
this.baseAPI = `${this.base}/api/${this.version}`;
this.baseDB = `${this.base}/database/${this.version}`;
Expand Down
18 changes: 9 additions & 9 deletions utils/capacitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,15 @@ class CapacitorPlugins {

addFlexibleListener () {
AppUpdate.addListener("onFlexibleUpdateStateChange", async ({ installStatus }) => {
switch(installStatus) {
case FlexibleUpdateInstallStatus.DOWNLOADED:
await AppUpdate.removeAllListeners();
await this.completeFlexibleUpdate();
break;
case FlexibleUpdateInstallStatus.FAILED:
this.showToast(t("error_update"));
await AppUpdate.removeAllListeners();
break;
switch (installStatus) {
case FlexibleUpdateInstallStatus.DOWNLOADED:
await AppUpdate.removeAllListeners();
await this.completeFlexibleUpdate();
break;
case FlexibleUpdateInstallStatus.FAILED:
this.showToast(t("error_update"));
await AppUpdate.removeAllListeners();
break;
}
});
}
Expand Down
40 changes: 19 additions & 21 deletions utils/chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,25 @@ export class Chart {
render (style) {
const { reduce, color, color_area, title, monotone, tension, stepped, subtitle, text_color, tick_color } = style;

const dataset = reduce
? this.dataset.reduce((a, b) => {
const index = a.findIndex(d => d.x === b.x);
if (index < 0) {
a.push({ x: b.x, y: b.y });
}
else {
a[index].y += b.y;
}
return a;
}, [])
: this.dataset.reduce((a, b) => {
const index = a.findIndex(d => d.x === b.x);
if (index < 0) {
a.push({ x: b.x, y: b.y });
}
else {
a[index].y = b.y;
}
return a;
}, []);
const dataset = reduce ? this.dataset.reduce((a, b) => {
const index = a.findIndex(d => d.x === b.x);
if (index < 0) {
a.push({ x: b.x, y: b.y });
}
else {
a[index].y += b.y;
}
return a;
}, []) : this.dataset.reduce((a, b) => {
const index = a.findIndex(d => d.x === b.x);
if (index < 0) {
a.push({ x: b.x, y: b.y });
}
else {
a[index].y = b.y;
}
return a;
}, []);

const total = reduce ? dataset.reduce((a, b) => a + b.y, 0) : dataset[dataset.length - 1].y;

Expand Down
Loading

0 comments on commit cee148c

Please sign in to comment.