Skip to content

Commit

Permalink
Merge pull request #1519 from dandi/import-type-linting-rule
Browse files Browse the repository at this point in the history
  • Loading branch information
mvandenburgh authored Mar 14, 2023
2 parents 0692aa7 + f602e67 commit 6901385
Show file tree
Hide file tree
Showing 25 changed files with 65 additions and 44 deletions.
1 change: 1 addition & 0 deletions web/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ module.exports = {
},
],
'import/prefer-default-export': 'off',
'@typescript-eslint/consistent-type-imports': 'error',
},
parserOptions: {
parser: '@typescript-eslint/parser',
Expand Down
3 changes: 2 additions & 1 deletion web/src/components/CopyText.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@
</template>

<script lang="ts">
import { defineComponent, Ref, ref } from 'vue';
import type { Ref } from 'vue';
import { defineComponent, ref } from 'vue';
export default defineComponent({
name: 'ApiKeyItem',
Expand Down
5 changes: 3 additions & 2 deletions web/src/components/DLP/DandisetOwnersDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,11 @@ import { debounce } from 'lodash';
import { dandiRest } from '@/rest';
import { useDandisetStore } from '@/stores/dandiset';
import type { Ref } from 'vue';
import {
computed, defineComponent, Ref, ref, watch,
computed, defineComponent, ref, watch,
} from 'vue';
import { User } from '@/types';
import type { User } from '@/types';
export default defineComponent({
name: 'DandisetOwnersDialog',
Expand Down
3 changes: 2 additions & 1 deletion web/src/components/DLP/MetadataCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,9 @@
</template>

<script lang="ts">
import type { PropType } from 'vue';
import {
computed, defineComponent, getCurrentInstance, PropType,
computed, defineComponent, getCurrentInstance,
} from 'vue';
// The maximum amount of columns to show on a metadata card,
Expand Down
5 changes: 3 additions & 2 deletions web/src/components/DandisetList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,13 @@
</template>

<script lang="ts">
import { defineComponent, computed, PropType } from 'vue';
import type { PropType } from 'vue';
import { defineComponent, computed } from 'vue';
import { useRoute } from 'vue-router/composables';
import moment from 'moment';
import filesize from 'filesize';
import { Version } from '@/types';
import type { Version } from '@/types';
import { DANDISETS_PER_PAGE } from '@/utils/constants';
export default defineComponent({
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/DandisetSearchField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

<script lang="ts">
import { defineComponent, ref } from 'vue';
import { RawLocation } from 'vue-router';
import type { RawLocation } from 'vue-router';
import { useRoute } from 'vue-router/composables';
import router from '@/router';
Expand Down
5 changes: 3 additions & 2 deletions web/src/components/DandisetsPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,17 @@
</template>

<script lang="ts">
import type { Ref, ComputedRef } from 'vue';
import {
defineComponent, ref, computed, watch, Ref, watchEffect, ComputedRef,
defineComponent, ref, computed, watch, watchEffect,
} from 'vue';
import omit from 'lodash/omit';
import { useRoute } from 'vue-router/composables';
import DandisetList from '@/components/DandisetList.vue';
import DandisetSearchField from '@/components/DandisetSearchField.vue';
import { dandiRest } from '@/rest';
import { Dandiset, Paginated, Version } from '@/types';
import type { Dandiset, Paginated, Version } from '@/types';
import { sortingOptions, DANDISETS_PER_PAGE } from '@/utils/constants';
import router from '@/router';
Expand Down
6 changes: 4 additions & 2 deletions web/src/components/Meditor/Meditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,9 @@
<script setup lang="ts">
import type { JSONSchema7 } from 'json-schema';

import type { ComputedRef } from 'vue';
import {
ref, computed, ComputedRef, onMounted,
ref, computed, onMounted,
} from 'vue';

import jsYaml from 'js-yaml';
Expand All @@ -239,7 +240,8 @@ import '@koumoul/vjsf/lib/VJsf.css';

import { dandiRest } from '@/rest';
import { useDandisetStore } from '@/stores/dandiset';
import { DandiModel, isJSONSchema } from './types';
import type { DandiModel } from './types';
import { isJSONSchema } from './types';
import { EditorInterface } from './editor';

import {
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/Meditor/VJsfWrapper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ import '@koumoul/vjsf/lib/deps/third-party';
import '@koumoul/vjsf/lib/VJsf.css';
import { isEqual } from 'lodash';
import { DandiModel } from './types';
import type { DandiModel } from './types';
import { editorInterface } from './state';
export default defineComponent({
Expand Down
5 changes: 3 additions & 2 deletions web/src/components/Meditor/editor.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import type { JSONSchema7 } from 'json-schema';

import type { ComputedRef, Ref } from 'vue';
import Vue, {
computed, reactive, ref, ComputedRef, Ref, watch,
computed, reactive, ref, watch,
} from 'vue';
import { cloneDeep } from 'lodash';

// eslint-disable-next-line import/no-cycle
import { setModelLocalStorage } from './localStorage';
import { DandiModel, DandiModelUnion } from './types';
import type { DandiModel, DandiModelUnion } from './types';
import {
computeBasicSchema,
computeComplexSchema,
Expand Down
4 changes: 2 additions & 2 deletions web/src/components/Meditor/localStorage.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { dandiRest } from '@/rest';
import { DandiModel } from './types';
import type { DandiModel } from './types';
// eslint-disable-next-line import/no-cycle
import { MeditorTransaction } from './transactions';
import type { MeditorTransaction } from './transactions';

function getModelLocalStorage(identifier: string) {
const model = localStorage.getItem(`${dandiRest.user?.username}-${identifier}-model`);
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/Meditor/state.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Vue, { computed, ref } from 'vue';
import { EditorInterface } from './editor';
import type { EditorInterface } from './editor';

// NOTE: it would be better to use a single ref here instead of separate state/computed
// variables, but doing so introduces a strange bug where editorInterface.basicModel is
Expand Down
7 changes: 4 additions & 3 deletions web/src/components/Meditor/transactions.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { ref, Ref, watch } from 'vue';
import type { Ref } from 'vue';
import { ref, watch } from 'vue';
import { cloneDeep, isEqual } from 'lodash';
// eslint-disable-next-line import/no-cycle
import {
setTransactionPointerLocalStorage,
setTransactionsLocalStorage,
} from './localStorage';
// eslint-disable-next-line import/no-cycle
import { EditorInterface } from './editor';
import type { EditorInterface } from './editor';
// eslint-disable-next-line import/no-cycle
import { DandiModel } from './types';
import type { DandiModel } from './types';

interface MeditorTransaction {
field: string,
Expand Down
10 changes: 6 additions & 4 deletions web/src/components/Meditor/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@
import type { JSONSchema7 } from 'json-schema';

import { cloneDeep, pickBy } from 'lodash';
import {
isArraySchema,
isBasicEditorSchema,
isComplexEditorSchema,
import type {
DandiModel,
BasicSchema,
BasicArraySchema,
ComplexSchema,
} from './types';
import {
isArraySchema,
isBasicEditorSchema,
isComplexEditorSchema,
} from './types';

export function computeBasicSchema(schema: JSONSchema7): JSONSchema7 {
const newProperties = pickBy(schema.properties, (val): val is BasicSchema | BasicArraySchema => (
Expand Down
3 changes: 2 additions & 1 deletion web/src/components/UserStatusBanner.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@

<script lang="ts">
import { dandiRest } from '@/rest';
import { computed, ComputedRef, defineComponent } from 'vue';
import type { ComputedRef } from 'vue';
import { computed, defineComponent } from 'vue';
interface StatusBanner {
text: string,
Expand Down
7 changes: 4 additions & 3 deletions web/src/rest.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';
import type { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';
import axios from 'axios';
import Vue from 'vue';
import { mapState } from 'pinia';
import OAuthClient from '@girder/oauth-client';
import {
import type {
Asset, Dandiset, Paginated, User, Version, Info, AssetPath, Zarr,
} from '@/types';
import { Dandiset as DandisetMetadata, DandisetContributors, Organization } from '@/types/schema';
import type { Dandiset as DandisetMetadata, DandisetContributors, Organization } from '@/types/schema';
// eslint-disable-next-line import/no-cycle
import { useDandisetStore } from '@/stores/dandiset';

Expand Down
3 changes: 2 additions & 1 deletion web/src/router.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Vue from 'vue';
import Router, { RouteConfig } from 'vue-router';
import type { RouteConfig } from 'vue-router';
import Router from 'vue-router';

import HomeView from '@/views/HomeView/HomeView.vue';
import PublicDandisetsView from '@/views/PublicDandisetsView/PublicDandisetsView.vue';
Expand Down
2 changes: 1 addition & 1 deletion web/src/stores/dandiset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import RefParser from '@apidevtools/json-schema-ref-parser';

// eslint-disable-next-line import/no-cycle
import { dandiRest } from '@/rest';
import { User, Version } from '@/types';
import type { User, Version } from '@/types';
import { draftVersion } from '@/utils/constants';

interface State {
Expand Down
4 changes: 3 additions & 1 deletion web/src/title.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import Vue from 'vue';

import type { DirectiveBinding } from 'vue/types/options';

const TITLE = 'DANDI Archive';

const setPageTitle = (el: HTMLElement, binding: import('vue/types/options').DirectiveBinding) => {
const setPageTitle = (el: HTMLElement, binding: DirectiveBinding) => {
if (binding?.value) {
document.title = `${binding.value} - ${TITLE}`;
} else {
Expand Down
5 changes: 3 additions & 2 deletions web/src/views/DandisetLandingView/DandisetActions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,9 @@
</template>

<script setup lang="ts">
import { computed, ComputedRef } from 'vue';
import { Location } from 'vue-router';
import type { ComputedRef } from 'vue';
import { computed } from 'vue';
import type { Location } from 'vue-router';
import { dandiRest } from '@/rest';
import { useDandisetStore } from '@/stores/dandiset';
Expand Down
2 changes: 1 addition & 1 deletion web/src/views/DandisetLandingView/DandisetLandingView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ import type { NavigationGuardNext, RawLocation, Route } from 'vue-router';
import DandisetSearchField from '@/components/DandisetSearchField.vue';
import Meditor from '@/components/Meditor/Meditor.vue';
import { useDandisetStore } from '@/stores/dandiset';
import { Version } from '@/types';
import type { Version } from '@/types';
import { draftVersion, sortingOptions } from '@/utils/constants';
import { editorInterface } from '@/components/Meditor/state';
import { dandiRest } from '@/rest';
Expand Down
5 changes: 3 additions & 2 deletions web/src/views/DandisetLandingView/DandisetMain.vue
Original file line number Diff line number Diff line change
Expand Up @@ -202,15 +202,16 @@
</template>

<script lang="ts">
import type { ComputedRef } from 'vue';
import {
defineComponent, computed, ComputedRef, ref,
defineComponent, computed, ref,
} from 'vue';
import filesize from 'filesize';
import moment from 'moment';
import { useDandisetStore } from '@/stores/dandiset';
import { AccessInformation, DandisetStats, SubjectMatterOfTheDataset } from '@/types';
import type { AccessInformation, DandisetStats, SubjectMatterOfTheDataset } from '@/types';
import AccessInformationTab from '@/components/DLP/AccessInformationTab.vue';
import AssetSummaryTab from '@/components/DLP/AssetSummaryTab.vue';
Expand Down
9 changes: 5 additions & 4 deletions web/src/views/DandisetLandingView/DandisetPublish.vue
Original file line number Diff line number Diff line change
Expand Up @@ -438,22 +438,23 @@
</template>

<script setup lang="ts">
import type { ComputedRef } from 'vue';
import {
computed, ComputedRef, ref, watchEffect,
computed, ref, watchEffect,
} from 'vue';
import axios from 'axios';
import moment from 'moment';
import type { RawLocation } from 'vue-router';
import { useRoute } from 'vue-router/composables';
import { dandiRest, loggedIn as loggedInFunc, user as userFunc } from '@/rest';
import { useDandisetStore } from '@/stores/dandiset';
import router from '@/router';
import { User, Version } from '@/types';
import type { User, Version } from '@/types';
import { draftVersion, VALIDATION_ICONS } from '@/utils/constants';
import { RawLocation } from 'vue-router';
import { open as openMeditor } from '@/components/Meditor/state';
import { useRoute } from 'vue-router/composables';
const PUBLISH_CHECKLIST = [
'A descriptive title (e.g., <span class="font-italic">Data related to foraging behavior in bees</span> rather than <span class="font-italic">Smith et al 2022</span>)',
Expand Down
2 changes: 1 addition & 1 deletion web/src/views/DandisetLandingView/DandisetSidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
} from 'vue';
import { useDandisetStore } from '@/stores/dandiset';
import { Version } from '@/types';
import type { Version } from '@/types';
import DandisetActions from './DandisetActions.vue';
import DandisetOwners from './DandisetOwners.vue';
Expand Down
7 changes: 4 additions & 3 deletions web/src/views/FileBrowserView/FileBrowser.vue
Original file line number Diff line number Diff line change
Expand Up @@ -241,18 +241,19 @@
</template>

<script setup lang="ts">
import type { Ref } from 'vue';
import {
computed, onMounted, Ref, ref, watch,
computed, onMounted, ref, watch,
} from 'vue';
import { RawLocation } from 'vue-router';
import type { RawLocation } from 'vue-router';
import { useRouter, useRoute } from 'vue-router/composables';
import filesize from 'filesize';
import { trimEnd } from 'lodash';
import axios from 'axios';
import { dandiRest } from '@/rest';
import { useDandisetStore } from '@/stores/dandiset';
import { AssetFile, AssetPath } from '@/types';
import type { AssetFile, AssetPath } from '@/types';
import FileBrowserPagination from '@/components/FileBrowser/FileBrowserPagination.vue';
import FileUploadInstructions from '@/components/FileBrowser/FileUploadInstructions.vue';
Expand Down

0 comments on commit 6901385

Please sign in to comment.