feat: refs #8006 eslint migration
gitea/salix-front/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Javier Segarra 2025-02-21 00:35:32 +01:00
parent 95e69ff79b
commit 59ddd2377b
10 changed files with 1242 additions and 71 deletions

View File

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

View File

@ -1,48 +1,18 @@
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)
module.exports = {
root: true,
parserOptions: {
ecmaVersion: '2021', // Allows for the parsing of modern ECMAScript features
ecmaVersion: 'latest',
sourceType: 'module',
},
env: {
node: true,
browser: true,
'vue/setup-compiler-macros': true,
es2024: 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
],
extends: ['eslint:recommended', 'plugin:vue/vue3-strongly-recommended', 'prettier'],
plugins: ['vue'],
globals: {
ga: 'readonly', // Google Analytics
ga: 'readonly',
cordova: 'readonly',
__statics: 'readonly',
__QUASAR_SSR__: 'readonly',
@ -52,18 +22,17 @@ export default {
process: 'readonly',
Capacitor: 'readonly',
chrome: 'readonly',
defineProps: 'readonly',
defineEmits: 'readonly',
defineExpose: 'readonly',
withDefaults: 'readonly',
},
// add your custom rules here
rules: {
// allow async-await
'generator-star-spacing': 'off',
// allow paren-less arrow functions
'arrow-parens': 'off',
'one-var': 'off',
'no-void': 'off',
'multiline-ternary': 'off',
'import/first': 'off',
'import/named': 'error',
'import/namespace': 'error',
@ -72,21 +41,32 @@ export default {
'import/extensions': 'off',
'import/no-unresolved': 'off',
'import/no-extraneous-dependencies': 'off',
'prefer-promise-reject-errors': 'off',
semi: 'off',
'space-before-function-paren': 'off',
'no-undef': 'error',
'no-unused-vars': 'warn',
'vue/no-multiple-template-root': 'off',
// allow debugger during development only
'no-console': 'error',
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'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',
'vue/no-unused-components': 'error',
'vue/no-unused-properties': 'error',
'vue/no-multiple-template-root': 'error',
'vue/no-v-html': 'error',
'vue/no-v-model-argument': 'error',
'vue/no-parsing-error': 'error',
'vue/no-deprecated-slot-attribute': 'error',
'prefer-promise-reject-errors': 'error',
},
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',
],
extends: ['plugin:cypress/recommended'],
rules: {
semi: 'off',
'space-before-function-paren': 'off',

199
eslint.config.js Normal file
View File

@ -0,0 +1,199 @@
import vue from 'eslint-plugin-vue';
import cypress from 'eslint-plugin-cypress';
import importt from 'eslint-plugin-import';
import globals from 'globals';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import js from '@eslint/js';
import { FlatCompat } from '@eslint/eslintrc';
const compat = new FlatCompat({
baseDirectory: import.meta.url,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
});
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)
plugins: { vue: vue, cypress: cypress, importt: importt },
languageOptions: {
globals: {
...globals.node,
...globals.browser,
...vue.environments['setup-compiler-macros']['setup-compiler-macros'],
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: 2018,
sourceType: 'module',
parserOptions: {
parser: '@babel/eslint-parser',
},
},
// files: ['test/cypress/**/*.*'],
// rules: {
// semi: 'error',
// 'space-before-function-paren': 0,
// 'prefer-promise-reject-errors': 0,
// 'vue/no-multiple-template-root': 0,
// },
rules: {
'generator-star-spacing': 'off',
'arrow-parens': 'off',
'one-var': 'off',
'no-void': 'off',
'multiline-ternary': 'off',
'js/first': 'off',
'vue/prefer-import-from-vue': 'error',
'importt/first': 'off',
'importt/dynamic-import-chunkname': 'off',
'importt/named': 'error',
'importt/namespace': 'error',
'importt/default': 'error',
'importt/export': 'error',
'importt/extensions': 'off',
'importt/no-unresolved': 'off',
'importt/no-extraneous-dependencies': 'off',
'importt/no-import-module-exports': 'off',
'importt/no-self-import': 'off',
semi: 'off',
'space-before-function-paren': 'off',
'no-undef': 'error',
'no-unused-vars': 'warn',
'no-console': 'error',
'no-debugger': 'off',
'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',
'vue/no-unused-components': 'error',
'vue/no-unused-properties': 'error',
'vue/no-multiple-template-root': 'error',
'vue/no-v-html': 'error',
'vue/no-v-model-argument': 'error',
'vue/no-parsing-error': 'error',
'vue/no-deprecated-slot-attribute': 'error',
'prefer-promise-reject-errors': 'error',
// },
// {
// },
},
// linterOptions: {
// reportUnusedInlineConfigs: 'error',
// },
ignores: [
'/dist',
'/src-capacitor',
'/src-cordova',
'/.quasar',
'/node_modules',
'.eslintrc.js',
],
// Rules order is important, please avoid shuffling them
// extends: [
// 'standard',
// // 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: {},
// add your custom rules here
// rules: {
// // allow async-await
// 'generator-star-spacing': 'off',
// // allow paren-less arrow functions
// 'arrow-parens': 'off',
// 'one-var': 'off',
// 'no-void': 'off',
// 'multiline-ternary': 'off',
// 'import/first': 'off',
// 'import/named': 'error',
// 'import/namespace': 'error',
// 'import/default': 'error',
// 'import/export': 'error',
// 'import/extensions': 'off',
// 'import/no-unresolved': 'off',
// 'import/no-extraneous-dependencies': 'off',
// semi: 'off',
// 'space-before-function-paren': 'off',
// 'no-undef': 'error',
// 'no-unused-vars': 'warn',
// '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',
// 'vue/no-unused-components': 'error',
// 'vue/no-unused-properties': 'error',
// 'vue/no-multiple-template-root': 'error',
// 'vue/no-v-html': 'error',
// 'vue/no-v-model-argument': 'error',
// 'vue/no-parsing-error': 'error',
// 'vue/no-deprecated-slot-attribute': 'error',
// 'prefer-promise-reject-errors': 'error',
// // 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',
// ],
// rules: {
// semi: 'off',
// 'space-before-function-paren': 'off',
// 'prefer-promise-reject-errors': 'off',
// 'vue/no-multiple-template-root': 'off',
// },
// },
// ],
};

99
eslint.config.mjs Normal file
View File

@ -0,0 +1,99 @@
import vue from "eslint-plugin-vue";
import globals from "globals";
import path from "node:path";
import { fileURLToPath } from "node:url";
import js from "@eslint/js";
import { FlatCompat } from "@eslint/eslintrc";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all
});
export default [...compat.extends(
"standard",
"eslint:recommended",
"plugin:vue/vue3-strongly-recommended",
"prettier",
), {
plugins: {
vue,
},
languageOptions: {
globals: {
...globals.node,
...globals.browser,
...vue.environments["setup-compiler-macros"]["setup-compiler-macros"],
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: 2018,
sourceType: "module",
parserOptions: {
parser: "@babel/eslint-parser",
},
},
rules: {
"generator-star-spacing": "off",
"arrow-parens": "off",
"one-var": "off",
"no-void": "off",
"multiline-ternary": "off",
"import/first": "off",
"import/named": "error",
"import/namespace": "error",
"import/default": "error",
"import/export": "error",
"import/extensions": "off",
"import/no-unresolved": "off",
"import/no-extraneous-dependencies": "off",
semi: "off",
"space-before-function-paren": "off",
"no-undef": "error",
"no-unused-vars": "warn",
"no-console": "error",
"no-debugger": "off",
"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",
"vue/no-unused-components": "error",
"vue/no-unused-properties": "error",
"vue/no-multiple-template-root": "error",
"vue/no-v-html": "error",
"vue/no-v-model-argument": "error",
"vue/no-parsing-error": "error",
"vue/no-deprecated-slot-attribute": "error",
"prefer-promise-reject-errors": "error",
},
}, ...compat.extends("plugin:cypress/recommended").map(config => ({
...config,
files: ["test/cypress/**/*.*"],
})), {
files: ["test/cypress/**/*.*"],
rules: {
semi: "off",
"space-before-function-paren": "off",
"prefer-promise-reject-errors": "off",
"vue/no-multiple-template-root": "off",
},
}];

View File

@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html>
<head>
<title><%= productName %></title>
@ -12,7 +12,12 @@
content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width<% if (ctx.mode.cordova || ctx.mode.capacitor) { %>, viewport-fit=cover<% } %>"
/>
<link rel="icon" type="image/png" sizes="128x128" href="icons/favicon-128x128.png" />
<link
rel="icon"
type="image/png"
sizes="128x128"
href="icons/favicon-128x128.png"
/>
<link rel="icon" type="image/png" sizes="96x96" href="icons/favicon-96x96.png" />
<link rel="icon" type="image/png" sizes="32x32" href="icons/favicon-32x32.png" />
<link rel="icon" type="image/png" sizes="16x16" href="icons/favicon-16x16.png" />

View File

@ -9,7 +9,7 @@
"type": "module",
"scripts": {
"resetDatabase": "cd ../salix && gulp docker",
"lint": "eslint --ext .js,.vue ./",
"lint": "eslint --ext {.js,.vue} ./",
"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",
@ -40,6 +40,8 @@
"devDependencies": {
"@commitlint/cli": "^19.2.1",
"@commitlint/config-conventional": "^19.1.0",
"@eslint/eslintrc": "^3.2.0",
"@eslint/js": "^9.20.0",
"@intlify/unplugin-vue-i18n": "^0.8.2",
"@pinia/testing": "^0.1.2",
"@quasar/app-vite": "^2.0.8",
@ -52,7 +54,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",
"postcss": "^8.4.23",
"prettier": "^3.4.2",

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
/* eslint-disable */
// https://github.com/michael-ciniawsky/postcss-load-config
import autoprefixer from 'autoprefixer';

View File

@ -7,7 +7,6 @@
// Configuration for your app
// https://v2.quasar.dev/quasar-cli-vite/quasar-config-js
import { configure } from 'quasar/wrappers';
import VueI18nPlugin from '@intlify/unplugin-vue-i18n/vite';
import path from 'path';
@ -52,7 +51,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'
@ -77,15 +76,40 @@ export default configure(function (/* ctx */) {
// FIXME: Delete deprecated property polyfillModulePreload
// that is set by Quasar by default
delete viteConf.build.polyfillModulePreload;
viteConf.build.modulePreload = {
polyfill: false,
};
viteConf.build.rollupOptions = {
onwarn(warning, warn) {
throw new Error(warning.message);
viteConf.build = {
...viteConf.build,
modulePreload: {
polyfill: false,
},
};
terserOptions: {
compress: {
drop_console: true,
},
},
// https://vitejs.dev/config/#build
// https://vitejs.dev/config/#build-terserOptions
// https://vitejs.dev/config/#build-rollupOptions
};
// viteConf.build.modulePreload = {
// polyfill: false,
// };
// viteConf.build.terserOptions = {
// compress: {
// drop_console: true,
// },
// };
// }.compress.drop_console = true;
// viteConf.build.rollupOptions = {
// onwarn(warning, warn) {
// throw new Error(warning.message);
// },
// };
viteConf.build.rollupOptions = {
onwarn(warning, warn) {
console.error('\x1b[31m', warning.message);
},
};
},
// viteVuePluginOptions: {},

View File

@ -16,6 +16,9 @@ export default defineConfig({
'src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}',
],
},
server: {
hmr: { overlay: false },
},
plugins: [
vue({
template: {