Browse Source

Maintenance: Bring imports closer to standards.

Vladimir Sheremet 1 year ago
parent
commit
3d4226dbaf

+ 8 - 2
.cypress/package.json

@@ -4,7 +4,13 @@
   "devDependencies": {
     "@frsource/cypress-plugin-visual-regression-diff": "^2.3.12",
     "@testing-library/cypress": "^9.0.0",
-    "cypress": "^12.9.0",
+    "cypress": "^12.10.0",
     "cypress-real-events": "^1.7.6"
+  },
+  "imports": {
+    "#tests/*": "../app/frontend/tests/*",
+    "#shared/*": "../app/frontend/shared/*",
+    "#mobile/*": "../app/frontend/apps/mobile/*",
+    "#cy/*": "./*"
   }
-}
+}

+ 1 - 1
.cypress/support/index.js

@@ -1,6 +1,6 @@
 // Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
 
-import '@mobile/styles/main.scss'
+import '#mobile/styles/main.scss'
 import 'virtual:svg-icons-register' // eslint-disable-line import/no-unresolved
 
 import './commands.js'

+ 8 - 8
.cypress/utils/index.ts → .cypress/utils.ts

@@ -1,25 +1,25 @@
 // Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
 
 import { merge } from 'lodash-es'
-import initializeStore from '@shared/stores'
-import initializeGlobalComponents from '@shared/initializer/globalComponents'
-import initializeGlobalProperties from '@shared/initializer/globalProperties'
-import initializeForm from '@mobile/form'
+import initializeStore from '#shared/stores/index.ts'
+import initializeGlobalComponents from '#shared/initializer/globalComponents.ts'
+import initializeGlobalProperties from '#shared/initializer/globalProperties.ts'
+import initializeForm from '#mobile/form/index.ts'
 
 // imported only for types
 // for some reason adding it to tsconfig doesn't work
 import '@testing-library/cypress'
 import 'cypress-real-events'
-import '../types/commands'
+import './types/commands.ts'
 
-import type { FormSchemaField } from '@shared/components/Form/types'
+import type { FormSchemaField } from '#shared/components/Form/types.ts'
 import { FormKit } from '@formkit/vue'
 import type { mount } from 'cypress/vue'
 import { createMemoryHistory, createRouter } from 'vue-router'
 import type { App } from 'vue'
 
-import { cacheInitializerModules } from '@mobile/server/apollo'
-import createCache from '@shared/server/apollo/cache'
+import { cacheInitializerModules } from '#mobile/server/apollo/index.ts'
+import createCache from '#shared/server/apollo/cache.ts'
 
 import { createMockClient } from 'mock-apollo-client'
 import { provideApolloClient } from '@vue/apollo-composable'

+ 14 - 14
.cypress/yarn.lock

@@ -413,10 +413,10 @@ combined-stream@^1.0.6, combined-stream@~1.0.6:
   dependencies:
     delayed-stream "~1.0.0"
 
-commander@^5.1.0:
-  version "5.1.0"
-  resolved "https://registry.yarnpkg.com/commander/-/commander-5.1.0.tgz#46abbd1652f8e059bddaef99bbdcb2ad9cf179ae"
-  integrity sha512-P0CysNDQ7rtVw4QIQtm+MRxV66vKFSvlsQvGYXZWR3qFU0jlMKHZZZgw8e+8DSah4UDKMqnknRDQz+xuQXQ/Zg==
+commander@^6.2.1:
+  version "6.2.1"
+  resolved "https://registry.yarnpkg.com/commander/-/commander-6.2.1.tgz#0792eb682dfbc325999bb2b84fddddba110ac73c"
+  integrity sha512-U7VdrJFnJgo4xjrHpTzu0yrHPGImdsmD95ZlgYSEajAn2JKzDhDTPG9kBTefmObL2w/ngeZnilk+OV9CG3d7UA==
 
 common-tags@^1.8.0:
   version "1.8.2"
@@ -447,10 +447,10 @@ cypress-real-events@^1.7.6:
   resolved "https://registry.yarnpkg.com/cypress-real-events/-/cypress-real-events-1.7.6.tgz#6f17e0b2ceea1d6dc60f6737d8f84cc517bbbb4c"
   integrity sha512-yP6GnRrbm6HK5q4DH6Nnupz37nOfZu/xn1xFYqsE2o4G73giPWQOdu6375QYpwfU1cvHNCgyD2bQ2hPH9D7NMw==
 
-cypress@^12.9.0:
-  version "12.9.0"
-  resolved "https://registry.yarnpkg.com/cypress/-/cypress-12.9.0.tgz#e6ab43cf329fd7c821ef7645517649d72ccf0a12"
-  integrity sha512-Ofe09LbHKgSqX89Iy1xen2WvpgbvNxDzsWx3mgU1mfILouELeXYGwIib3ItCwoRrRifoQwcBFmY54Vs0zw7QCg==
+cypress@^12.10.0:
+  version "12.10.0"
+  resolved "https://registry.yarnpkg.com/cypress/-/cypress-12.10.0.tgz#b6264f77c214d63530ebac2b33c4d099bd40b715"
+  integrity sha512-Y0wPc221xKKW1/4iAFCphkrG2jNR4MjOne3iGn4mcuCaE7Y5EtXL83N8BzRsAht7GYfWVjJ/UeTqEdDKHz39HQ==
   dependencies:
     "@cypress/request" "^2.88.10"
     "@cypress/xvfb" "^1.2.4"
@@ -466,7 +466,7 @@ cypress@^12.9.0:
     check-more-types "^2.24.0"
     cli-cursor "^3.1.0"
     cli-table3 "~0.6.1"
-    commander "^5.1.0"
+    commander "^6.2.1"
     common-tags "^1.8.0"
     dayjs "^1.10.4"
     debug "^4.3.4"
@@ -484,7 +484,7 @@ cypress@^12.9.0:
     listr2 "^3.8.3"
     lodash "^4.17.21"
     log-symbols "^4.0.0"
-    minimist "^1.2.6"
+    minimist "^1.2.8"
     ospath "^1.2.2"
     pretty-bytes "^5.6.0"
     proxy-from-env "1.0.0"
@@ -985,10 +985,10 @@ minimist@^1.2.0, minimist@^1.2.3:
   resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.7.tgz#daa1c4d91f507390437c6a8bc01078e7000c4d18"
   integrity sha512-bzfL1YUZsP41gmu/qjrEk0Q6i2ix/cVeAhbCbqH9u3zYutS1cLg00qhrD0M2MVdCcx4Sc0UpP2eBWo9rotpq6g==
 
-minimist@^1.2.6:
-  version "1.2.6"
-  resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.6.tgz#8637a5b759ea0d6e98702cfb3a9283323c93af44"
-  integrity sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==
+minimist@^1.2.8:
+  version "1.2.8"
+  resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.8.tgz#c1a464e7693302e082a075cee0c057741ac4772c"
+  integrity sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==
 
 mkdirp-classic@^0.5.2, mkdirp-classic@^0.5.3:
   version "0.5.3"

+ 1 - 1
.eslint-plugin-zammad/tests/lib/rules/zammad-copyright.js

@@ -10,7 +10,7 @@
 //------------------------------------------------------------------------------
 
 const { RuleTester } = require('eslint')
-const rule = require('../../../lib/rules/zammad-copyright')
+const rule = require('../../../lib/rules/zammad-copyright.js')
 
 //------------------------------------------------------------------------------
 // Tests

+ 1 - 1
.eslint-plugin-zammad/tests/lib/rules/zammad-detect-translatable-string.js

@@ -10,7 +10,7 @@
 //------------------------------------------------------------------------------
 
 const { RuleTester } = require('eslint')
-const rule = require('../../../lib/rules/zammad-detect-translatable-string')
+const rule = require('../../../lib/rules/zammad-detect-translatable-string.js')
 
 //------------------------------------------------------------------------------
 // Tests

+ 1 - 1
.eslint-plugin-zammad/tests/lib/rules/zammad-tailwind-ltr.js

@@ -10,7 +10,7 @@
 //------------------------------------------------------------------------------
 
 const { RuleTester } = require('eslint')
-const rule = require('../../../lib/rules/zammad-tailwind-ltr')
+const rule = require('../../../lib/rules/zammad-tailwind-ltr.js')
 
 //------------------------------------------------------------------------------
 // Tests

+ 9 - 33
.eslintrc.js

@@ -74,18 +74,7 @@ module.exports = {
       },
     ],
 
-    // Adding typescript file types, because airbnb doesn't allow this by default.
-    'import/extensions': [
-      'error',
-      'ignorePackages',
-      {
-        js: 'never',
-        mjs: 'never',
-        jsx: 'never',
-        ts: 'never',
-        tsx: 'never',
-      },
-    ],
+    'import/extensions': ['error', 'ignorePackages'],
 
     'import/prefer-default-export': 'off',
 
@@ -181,10 +170,8 @@ module.exports = {
     {
       files: ['*.ts', '*.tsx', '*.vue'],
       rules: {
-        '@typescript-eslint/consistent-type-imports': [
-          'error',
-          { prefer: 'type-imports', disallowTypeAnnotations: false },
-        ],
+        // handled by typescript itself with "verbatimModuleSyntax"
+        '@typescript-eslint/consistent-type-imports': 'off',
         '@typescript-eslint/consistent-type-exports': 'error',
         'security/detect-object-injection': 'off',
         'security/detect-non-literal-fs-filename': 'off',
@@ -197,19 +184,15 @@ module.exports = {
   ],
   settings: {
     'import/core-modules': ['virtual:pwa-register'],
+    'import/parsers': {
+      '@typescript-eslint/parser': ['.ts', '.tsx'],
+    },
     'import/resolver': {
+      typescript: {
+        alwaysTryTypes: true,
+      },
       alias: {
         map: [
-          ['@', path.resolve(__dirname, './app/frontend')],
-          ['@mobile', path.resolve(__dirname, './app/frontend/apps/mobile')],
-          ['@shared', path.resolve(__dirname, './app/frontend/shared')],
-          ['@tests', path.resolve(__dirname, './app/frontend/tests')],
-          ['@stories', path.resolve(__dirname, './app/frontend/stories')],
-          ['@cy', path.resolve(__dirname, './.cypress')],
-          [
-            'vitest',
-            path.resolve(__dirname, 'node_modules/vitest/dist/index.mjs'),
-          ],
           [
             'vue-easy-lightbox/dist/external-css/vue-easy-lightbox.css',
             path.resolve(
@@ -217,13 +200,6 @@ module.exports = {
               'node_modules/vue-easy-lightbox/dist/external-css/vue-easy-lightbox.css',
             ),
           ],
-          [
-            'histoire',
-            path.resolve(
-              __dirname,
-              './node_modules/histoire/dist/node/index.js',
-            ),
-          ],
         ],
         extensions: ['.js', '.jsx', '.ts', '.tsx', '.vue'],
       },

+ 16 - 16
app/frontend/apps/mobile/App.vue

@@ -3,22 +3,22 @@
 <script setup lang="ts">
 import { onBeforeUnmount, onMounted, watch } from 'vue'
 import { useRouter } from 'vue-router'
-import CommonNotifications from '@shared/components/CommonNotifications/CommonNotifications.vue'
-import { useApplicationStore } from '@shared/stores/application'
-import { useAuthenticationStore } from '@shared/stores/authentication'
-import useMetaTitle from '@shared/composables/useMetaTitle'
-import emitter from '@shared/utils/emitter'
-import useAppMaintenanceCheck from '@shared/composables/useAppMaintenanceCheck'
-import usePushMessages from '@shared/composables/usePushMessages'
-import { useLocaleStore } from '@shared/stores/locale'
-import useFormKitConfig from '@shared/composables/form/useFormKitConfig'
-import { useAppTheme } from '@shared/composables/useAppTheme'
-import useAuthenticationChanges from '@shared/composables/useAuthenticationUpdates'
-import DynamicInitializer from '@shared/components/DynamicInitializer/DynamicInitializer.vue'
-import CommonImageViewer from '@shared/components/CommonImageViewer/CommonImageViewer.vue'
-import { useSessionStore } from '@shared/stores/session'
-import CommonConfirmation from '@mobile/components/CommonConfirmation/CommonConfirmation.vue'
-import { useTicketOverviewsStore } from './entities/ticket/stores/ticketOverviews'
+import CommonNotifications from '#shared/components/CommonNotifications/CommonNotifications.vue'
+import { useApplicationStore } from '#shared/stores/application.ts'
+import { useAuthenticationStore } from '#shared/stores/authentication.ts'
+import useMetaTitle from '#shared/composables/useMetaTitle.ts'
+import emitter from '#shared/utils/emitter.ts'
+import useAppMaintenanceCheck from '#shared/composables/useAppMaintenanceCheck.ts'
+import usePushMessages from '#shared/composables/usePushMessages.ts'
+import { useLocaleStore } from '#shared/stores/locale.ts'
+import useFormKitConfig from '#shared/composables/form/useFormKitConfig.ts'
+import { useAppTheme } from '#shared/composables/useAppTheme.ts'
+import useAuthenticationChanges from '#shared/composables/useAuthenticationUpdates.ts'
+import DynamicInitializer from '#shared/components/DynamicInitializer/DynamicInitializer.vue'
+import CommonImageViewer from '#shared/components/CommonImageViewer/CommonImageViewer.vue'
+import { useSessionStore } from '#shared/stores/session.ts'
+import CommonConfirmation from '#mobile/components/CommonConfirmation/CommonConfirmation.vue'
+import { useTicketOverviewsStore } from './entities/ticket/stores/ticketOverviews.ts'
 
 const router = useRouter()
 

+ 2 - 2
app/frontend/apps/mobile/components/CommonBackButton/CommonBackButton.vue

@@ -3,8 +3,8 @@
 <script setup lang="ts">
 import { computed } from 'vue'
 import type { RouteLocationRaw } from 'vue-router'
-import { useLocaleStore } from '@shared/stores/locale'
-import { useWalker } from '@shared/router/walker'
+import { useLocaleStore } from '#shared/stores/locale.ts'
+import { useWalker } from '#shared/router/walker.ts'
 
 interface Props {
   fallback: RouteLocationRaw

Some files were not shown because too many files changed in this diff