Browse Source

Maintenance: Add eslint rule to force import type syntax

Vladimir Sheremet 2 years ago
parent
commit
f1a26343c9

+ 14 - 0
.eslintrc.js

@@ -154,6 +154,20 @@ module.exports = {
         'import/first': 'off',
       },
     },
+    // rules that require type information
+    {
+      files: ['*.ts', '*.tsx', '*.vue'],
+      rules: {
+        '@typescript-eslint/consistent-type-imports': [
+          'error',
+          { prefer: 'type-imports', disallowTypeAnnotations: false },
+        ],
+        '@typescript-eslint/consistent-type-exports': 'error',
+      },
+      parserOptions: {
+        project: ['./tsconfig.json', './app/frontend/cypress/tsconfig.json'],
+      },
+    },
   ],
   settings: {
     'import/resolver': {

+ 3 - 2
app/frontend/apps/mobile/components/CommonConfirmation/composable.ts

@@ -1,7 +1,8 @@
 // Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
 
-import { Ref, ref } from 'vue'
-import { ConfirmationOptions } from './types'
+import type { Ref } from 'vue'
+import { ref } from 'vue'
+import type { ConfirmationOptions } from './types'
 
 const confirmationDialog: Ref<ConfirmationOptions | undefined> = ref()
 

+ 1 - 1
app/frontend/apps/mobile/components/CommonDialog/CommonDialog.stories.ts

@@ -1,7 +1,7 @@
 // Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
 
 import { useDialog } from '@shared/composables/useDialog'
-import { Story } from '@storybook/vue3'
+import type { Story } from '@storybook/vue3'
 import DynamicInitializer from '@shared/components/DynamicInitializer/DynamicInitializer.vue'
 import CommonDialog from './CommonDialog.vue'
 

+ 3 - 2
app/frontend/apps/mobile/components/CommonDialog/CommonDialog.vue

@@ -1,9 +1,10 @@
 <!-- Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/ -->
 
 <script setup lang="ts">
-import { EventHandlers } from '@shared/types/utils'
+import type { EventHandlers } from '@shared/types/utils'
 import { usePointerSwipe } from '@vueuse/core'
-import { Events, ref } from 'vue'
+import type { Events } from 'vue'
+import { ref } from 'vue'
 import { useDialogState } from './composable'
 
 const props = defineProps<{

+ 1 - 1
app/frontend/apps/mobile/components/CommonSectionPopup/CommonSectionPopup.stories.ts

@@ -1,6 +1,6 @@
 // Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
 
-import { Story } from '@storybook/vue3'
+import type { Story } from '@storybook/vue3'
 import { ref } from 'vue'
 import CommonSectionPopup, { type Props } from './CommonSectionPopup.vue'
 

+ 1 - 1
app/frontend/apps/mobile/components/CommonSectionPopup/CommonSectionPopup.vue

@@ -3,7 +3,7 @@
 <script setup lang="ts">
 import { onClickOutside, onKeyUp, useVModel } from '@vueuse/core'
 import { shallowRef } from 'vue'
-import { PopupItem } from './types'
+import type { PopupItem } from './types'
 
 export interface Props {
   items: PopupItem[]

+ 1 - 1
app/frontend/apps/mobile/components/CommonSectionPopup/__tests__/CommonSectionPopup.spec.ts

@@ -4,7 +4,7 @@ import { renderComponent } from '@tests/support/components'
 import { flushPromises } from '@vue/test-utils'
 import { ref } from 'vue'
 import CommonSectionPopup from '../CommonSectionPopup.vue'
-import { PopupItem } from '../types'
+import type { PopupItem } from '../types'
 
 describe('popup behaviour', () => {
   it('renders list', async () => {

+ 1 - 1
app/frontend/apps/mobile/components/CommonSelect/CommonSelect.stories.ts

@@ -1,6 +1,6 @@
 // Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
 
-import { Story } from '@storybook/vue3'
+import type { Story } from '@storybook/vue3'
 import { ref } from 'vue'
 import CommonSelect, { type Props } from './CommonSelect.vue'
 

+ 1 - 1
app/frontend/apps/mobile/components/CommonSelect/CommonSelect.vue

@@ -1,7 +1,7 @@
 <!-- Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/ -->
 
 <script setup lang="ts">
-import { SelectOption } from '@shared/components/Form/fields/FieldSelect/types'
+import type { SelectOption } from '@shared/components/Form/fields/FieldSelect/types'
 import { onClickOutside, onKeyDown, useVModel } from '@vueuse/core'
 import { ref } from 'vue'
 import CommonSelectItem from './CommonSelectItem.vue'

+ 1 - 1
app/frontend/apps/mobile/components/CommonSelect/CommonSelectItem.vue

@@ -1,7 +1,7 @@
 <!-- Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/ -->
 
 <script setup lang="ts">
-import { SelectOption } from '@shared/components/Form/fields/FieldSelect/types'
+import type { SelectOption } from '@shared/components/Form/fields/FieldSelect/types'
 import CommonTicketStateIndicator from '@shared/components/CommonTicketStateIndicator/CommonTicketStateIndicator.vue'
 import { computed } from 'vue'
 import { i18n } from '@shared/i18n'

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