Merge pull request '#8006 - eslint_rules' (!1454) from 8006_eslint_rules into dev
gitea/salix-front/pipeline/head This commit looks good Details

Reviewed-on: #1454
Reviewed-by: Javi Gallego <jgallego@verdnatura.es>
Reviewed-by: Alex Moreno <alexm@verdnatura.es>
This commit is contained in:
Javier Segarra 2025-04-07 10:02:42 +00:00
commit d4053d74d2
9 changed files with 1043 additions and 174 deletions

View File

@ -1,6 +0,0 @@
/dist
/src-capacitor
/src-cordova
/.quasar
/node_modules
.eslintrc.js

View File

@ -1,75 +0,0 @@
export default {
// https://eslint.org/docs/user-guide/configuring#configuration-cascading-and-hierarchy
// This option interrupts the configuration hierarchy at this file
// Remove this if you have an higher level ESLint config file (it usually happens into a monorepos)
root: true,
parserOptions: {
ecmaVersion: '2021', // Allows for the parsing of modern ECMAScript features
},
env: {
node: true,
browser: true,
'vue/setup-compiler-macros': true,
},
// Rules order is important, please avoid shuffling them
extends: [
// Base ESLint recommended rules
'eslint:recommended',
// Uncomment any of the lines below to choose desired strictness,
// but leave only one uncommented!
// See https://eslint.vuejs.org/rules/#available-rules
// 'plugin:vue/vue3-essential', // Priority A: Essential (Error Prevention)
'plugin:vue/vue3-strongly-recommended', // Priority B: Strongly Recommended (Improving Readability)
// 'plugin:vue/vue3-recommended', // Priority C: Recommended (Minimizing Arbitrary Choices and Cognitive Overhead)
// https://github.com/prettier/eslint-config-prettier#installation
// usage with Prettier, provided by 'eslint-config-prettier'.
'prettier',
],
plugins: [
// https://eslint.vuejs.org/user-guide/#why-doesn-t-it-work-on-vue-files
// required to lint *.vue files
'vue',
// https://github.com/typescript-eslint/typescript-eslint/issues/389#issuecomment-509292674
// Prettier has not been included as plugin to avoid performance impact
// add it as an extension for your IDE
],
globals: {
ga: 'readonly', // Google Analytics
cordova: 'readonly',
__statics: 'readonly',
__QUASAR_SSR__: 'readonly',
__QUASAR_SSR_SERVER__: 'readonly',
__QUASAR_SSR_CLIENT__: 'readonly',
__QUASAR_SSR_PWA__: 'readonly',
process: 'readonly',
Capacitor: 'readonly',
chrome: 'readonly',
},
// add your custom rules here
rules: {
'prefer-promise-reject-errors': 'off',
'no-unused-vars': 'warn',
'vue/no-multiple-template-root': 'off',
// allow debugger during development only
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
},
overrides: [
{
files: ['test/cypress/**/*.*'],
extends: [
// Add Cypress-specific lint rules, globals and Cypress plugin
// See https://github.com/cypress-io/eslint-plugin-cypress#rules
'plugin:cypress/recommended',
],
},
],
};

3
.eslintrc.json Normal file
View File

@ -0,0 +1,3 @@
{
"extends": ["plugin:cypress/recommended"]
}

87
eslint.config.js Normal file
View File

@ -0,0 +1,87 @@
import cypress from 'eslint-plugin-cypress';
import eslint from 'eslint-plugin-import';
import globals from 'globals';
import js from '@eslint/js';
import vue from 'eslint-plugin-vue';
export default {
plugins: { vue, eslint, cypress },
languageOptions: {
globals: {
...globals.node,
...globals.browser,
...vue.configs['vue3-strongly-recommended'].globals,
...cypress.environments.globals.globals,
ga: 'readonly',
cordova: 'readonly',
__statics: 'readonly',
__QUASAR_SSR__: 'readonly',
__QUASAR_SSR_SERVER__: 'readonly',
__QUASAR_SSR_CLIENT__: 'readonly',
__QUASAR_SSR_PWA__: 'readonly',
process: 'readonly',
Capacitor: 'readonly',
chrome: 'readonly',
},
ecmaVersion: 2020,
sourceType: 'module',
parserOptions: {
parser: '@babel/eslint-parser',
},
},
rules: {
...vue.rules['flat/strongly-recommended'],
...js.configs.recommended.rules,
semi: 'off',
'generator-star-spacing': 'warn',
'arrow-parens': 'warn',
'no-var': 'error',
'prefer-const': 'error',
'prefer-template': 'warn',
'prefer-destructuring': 'off',
'prefer-spread': 'warn',
'prefer-rest-params': 'warn',
'prefer-object-spread': 'warn',
'prefer-arrow-callback': 'warn',
'prefer-numeric-literals': 'warn',
'prefer-exponentiation-operator': 'warn',
'prefer-regex-literals': 'warn',
'one-var': [
'error',
{
let: 'never',
const: 'never',
},
],
'no-void': 'off',
'prefer-promise-reject-errors': 'error',
'multiline-ternary': 'warn',
'no-restricted-imports': 'warn',
'no-import-assign': 'warn',
'no-duplicate-imports': 'warn',
'no-useless-rename': 'warn',
'eslint/no-named-as-default': 'warn',
'eslint/no-named-as-default-member': 'warn',
'no-unsafe-optional-chaining': 'warn',
'no-undef': 'error',
'no-unused-vars': 'error',
'no-console': 'error',
'no-debugger': 'error',
'no-useless-escape': 'error',
'no-prototype-builtins': 'error',
'no-async-promise-executor': 'error',
'no-irregular-whitespace': 'error',
'no-constant-condition': 'error',
'no-unsafe-finally': 'error',
'no-extend-native': 'error',
},
ignores: [
'/dist',
'/src-capacitor',
'/src-cordova',
'/.quasar',
'/node_modules',
'.eslintrc.js',
],
};

View File

@ -9,7 +9,8 @@
"type": "module",
"scripts": {
"resetDatabase": "cd ../salix && gulp docker",
"lint": "eslint --ext .js,.vue ./",
"lint": "eslint \"**/*.{vue,js}\" ",
"lint:fix": "eslint \"**/*.{vue,js}\" --fix ",
"format": "prettier --write \"**/*.{js,vue,scss,html,md,json}\" --ignore-path .gitignore",
"test:e2e": "cypress open",
"test:e2e:ci": "npm run resetDatabase && cd ../salix-front && cypress run",
@ -36,13 +37,15 @@
"quasar": "^2.17.7",
"validator": "^13.9.0",
"vue": "^3.5.13",
"vue-i18n": "^9.3.0",
"vue-i18n": "^9.4.0",
"vue-router": "^4.2.5"
},
"devDependencies": {
"@commitlint/cli": "^19.2.1",
"@commitlint/config-conventional": "^19.1.0",
"@intlify/unplugin-vue-i18n": "^0.8.2",
"@eslint/eslintrc": "^3.2.0",
"@eslint/js": "^9.20.0",
"@intlify/unplugin-vue-i18n": "^4.0.0",
"@pinia/testing": "^0.1.2",
"@quasar/app-vite": "^2.0.8",
"@quasar/quasar-app-extension-qcalendar": "^4.0.2",
@ -54,7 +57,9 @@
"eslint": "^9.18.0",
"eslint-config-prettier": "^10.0.1",
"eslint-plugin-cypress": "^4.1.0",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-vue": "^9.32.0",
"globals": "^16.0.0",
"husky": "^8.0.0",
"junit-merge": "^2.0.0",
"mocha": "^11.1.0",

File diff suppressed because it is too large Load Diff

View File

@ -53,7 +53,7 @@ export default configure(function (/* ctx */) {
build: {
target: {
browser: ['es2022', 'edge88', 'firefox78', 'chrome87', 'safari13.1'],
node: 'node18',
node: 'node20',
},
vueRouterMode: 'hash', // available values: 'hash', 'history'
@ -92,6 +92,7 @@ export default configure(function (/* ctx */) {
vitePlugins: [
[
VueI18nPlugin({
strictMessage: false,
runtimeOnly: false,
include: [
path.resolve(__dirname, './src/i18n/locale/**'),

View File

@ -1,3 +1,4 @@
/* eslint-disable eslint/export */
export * from './defaults/qTable';
export * from './defaults/qInput';
export * from './defaults/qSelect';

View File

@ -5,12 +5,11 @@ import jsconfigPaths from 'vite-jsconfig-paths';
import VueI18nPlugin from '@intlify/unplugin-vue-i18n/vite';
import path from 'path';
let reporters,
outputFile;
let reporters, outputFile;
if (process.env.CI) {
reporters = ['junit', 'default'];
outputFile = {junit: './junit/vitest.xml'};
outputFile = { junit: './junit/vitest.xml' };
} else {
reporters = 'default';
}
@ -28,6 +27,9 @@ export default defineConfig({
'src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}',
],
},
server: {
hmr: { overlay: false },
},
plugins: [
vue({
template: {
@ -39,8 +41,11 @@ export default defineConfig({
sassVariables: 'src/quasar-variables.scss',
}),
VueI18nPlugin({
strictMessage: false,
runtimeOnly: false,
include: [
path.resolve(__dirname, 'src/i18n/**'),
path.resolve(__dirname, 'src/i18n/locale/**'),
path.resolve(__dirname, 'src/pages/**/locale/**'),
],
}),