Skip to content

Commit

Permalink
chore: disable some eslint rules
Browse files Browse the repository at this point in the history
  • Loading branch information
victorcg88 committed Nov 26, 2024
1 parent a1f988b commit 14f4e53
Show file tree
Hide file tree
Showing 13 changed files with 306 additions and 298 deletions.
23 changes: 21 additions & 2 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,28 @@ export default empathyco(
},
},
{
files: ['*-icon*.vue', 'logo.vue'],
files: ['src/**/*.{ts,tsx,vue}'],
rules: {
'max-len': 'off',
// Enable the following rules progressively when the project is ready to enforce them
'vue/no-reserved-component-names': 'off',
'vue/valid-v-slot': 'off',
'vue/no-deprecated-v-on-native-modifier': 'off',
'node/prefer-global/process': 'off',
'no-new': 'off',
'ts/no-floating-promises': 'off',
'ts/no-misused-promises': 'off',
'ts/no-unsafe-member-access': 'off',
},
},
{
files: ['tests/**/*.{ts,tsx,vue}'],
rules: {
// Enable the following rules progressively when the project is ready to enforce them
'ts/no-unsafe-call': 'off',
'ts/no-unsafe-argument': 'off',
'ts/no-unsafe-member-access': 'off',
'ts/no-unsafe-return': 'off',
'ts/no-namespace': 'off',
},
},
)
2 changes: 1 addition & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export default defineComponent({
window.InterfaceX?.search()
window.wysiwyg?.setContext({ query: payload.query })
}
} catch (_) {
} catch {
// No error handling
}
})
Expand Down
50 changes: 25 additions & 25 deletions src/adapter/adapter.ts
Original file line number Diff line number Diff line change
@@ -1,53 +1,54 @@
import type {
PlatformRecommendationsRequest,
PlatformResult,
PlatformSemanticQueriesRequest} from '@empathyco/x-adapter-platform';
PlatformSemanticQueriesRequest,
} from '@empathyco/x-adapter-platform'
import type {
ExperienceControlsResponse,
RecommendationsRequest,
Result,
SemanticQueriesRequest
} from '@empathyco/x-types';
SemanticQueriesRequest,
} from '@empathyco/x-types'
import {
experienceControlsResponseSchema,
platformAdapter,
recommendationsRequestSchema,
resultSchema,
semanticQueriesRequestSchema
} from '@empathyco/x-adapter-platform';
semanticQueriesRequestSchema,
} from '@empathyco/x-adapter-platform'

export const adapter = platformAdapter;
export const adapter = platformAdapter

/* Code sample about how to extend the result mapper with more fields. */

interface EmpathyDemoPlatformResult extends PlatformResult {
description: string;
collection: string;
brand: string;
description: string
collection: string
brand: string
}

declare module '@empathyco/x-types' {
export interface Result {
collection: string;
description: string;
brand: string;
collection: string
description: string
brand: string
}
}

resultSchema.$override<EmpathyDemoPlatformResult, Partial<Result>>({
description: 'description',
collection: 'collection',
brand: 'brand',
images: ({ __images }) => (Array.isArray(__images) ? __images.reverse() : [__images])
});
images: ({ __images }) => (Array.isArray(__images) ? __images.reverse() : [__images]),
})

recommendationsRequestSchema.$override<
RecommendationsRequest,
Partial<PlatformRecommendationsRequest>
>({
// TODO Top clicked demo endpoint breaks if it receives the scope parameter
extraParams: ({ extraParams: { scope, ...extraParams } = {} }) => extraParams
});
extraParams: ({ extraParams: { scope, ...extraParams } = {} }) => extraParams,
})

semanticQueriesRequestSchema.$override<
SemanticQueriesRequest,
Expand All @@ -56,12 +57,11 @@ semanticQueriesRequestSchema.$override<
extraParams: ({ extraParams }) => {
return {
extraParams,
filter_ids: 'NOT_ALL_WORDS,NOT_PARTIAL'
};
}
});
filter_ids: 'NOT_ALL_WORDS,NOT_PARTIAL',
}
},
})

// eslint-disable-next-line @typescript-eslint/no-unsafe-call
experienceControlsResponseSchema.$override<
Partial<ExperienceControlsResponse>,
Partial<ExperienceControlsResponse>
Expand All @@ -70,7 +70,7 @@ experienceControlsResponseSchema.$override<
events: {
SemanticQueriesConfigProvided: {
maxItemsToRequest: 'controls.semanticQueries.numberOfCarousels',
resultsPerCarousel: 'controls.semanticQueries.resultsPerCarousels'
}
}
});
resultsPerCarousel: 'controls.semanticQueries.resultsPerCarousels',
},
},
})
59 changes: 29 additions & 30 deletions src/adapter/docker.adapter.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type {
PlatformAdapter} from '@empathyco/x-adapter-platform';
import type { XComponentsAdapter } from '@empathyco/x-types';
import type { PlatformAdapter } from '@empathyco/x-adapter-platform'
import type { XComponentsAdapter } from '@empathyco/x-types'
import {
experienceControlsEndpointAdapter,
identifierResultsEndpointAdapter,
Expand All @@ -10,8 +9,8 @@ import {
recommendationsEndpointAdapter,
relatedTagsEndpointAdapter,
searchEndpointAdapter,
semanticQueriesEndpointAdapter
} from '@empathyco/x-adapter-platform';
semanticQueriesEndpointAdapter,
} from '@empathyco/x-adapter-platform'

/**
* Mutates adapter to point to environment context.
Expand All @@ -20,35 +19,35 @@ import {
*/
export function overrideAdapter(adapter: PlatformAdapter): void {
adapter.search = searchEndpointAdapter.extends({
endpoint: ({ extraParams }) => resolveEmpathyEndpoint('search', extraParams!)
});
endpoint: ({ extraParams }) => resolveEmpathyEndpoint('search', extraParams!),
})
adapter.popularSearches = popularSearchesEndpointAdapter.extends({
endpoint: ({ extraParams }) => resolveEmpathyEndpoint('popularSearches', extraParams!)
});
endpoint: ({ extraParams }) => resolveEmpathyEndpoint('popularSearches', extraParams!),
})
adapter.recommendations = recommendationsEndpointAdapter.extends({
endpoint: ({ extraParams }) => resolveEmpathyEndpoint('recommendations', extraParams!)
});
endpoint: ({ extraParams }) => resolveEmpathyEndpoint('recommendations', extraParams!),
})
adapter.nextQueries = nextQueriesEndpointAdapter.extends({
endpoint: ({ extraParams }) => resolveEmpathyEndpoint('nextQueries', extraParams!)
});
endpoint: ({ extraParams }) => resolveEmpathyEndpoint('nextQueries', extraParams!),
})
adapter.querySuggestions = querySuggestionsEndpointAdapter.extends({
endpoint: ({ extraParams }) => resolveEmpathyEndpoint('querySuggestions', extraParams!)
});
endpoint: ({ extraParams }) => resolveEmpathyEndpoint('querySuggestions', extraParams!),
})
adapter.relatedTags = relatedTagsEndpointAdapter.extends({
endpoint: ({ extraParams }) => resolveEmpathyEndpoint('relatedTags', extraParams!)
});
endpoint: ({ extraParams }) => resolveEmpathyEndpoint('relatedTags', extraParams!),
})
adapter.identifierResults = identifierResultsEndpointAdapter.extends({
endpoint: ({ extraParams }) => resolveEmpathyEndpoint('identifierResults', extraParams!)
});
endpoint: ({ extraParams }) => resolveEmpathyEndpoint('identifierResults', extraParams!),
})
adapter.semanticQueries = semanticQueriesEndpointAdapter.extends({
endpoint: ({ extraParams }) => resolveEmpathyEndpoint('semanticQueries', extraParams!)
});
endpoint: ({ extraParams }) => resolveEmpathyEndpoint('semanticQueries', extraParams!),
})
adapter.experienceControls = experienceControlsEndpointAdapter.extends({
endpoint: ({ extraParams }) => resolveEmpathyEndpoint('experienceControls', extraParams!)
});
endpoint: ({ extraParams }) => resolveEmpathyEndpoint('experienceControls', extraParams!),
})
}

type DockerEndpoints = Exclude<keyof XComponentsAdapter, 'tagging'>;
type DockerEndpoints = Exclude<keyof XComponentsAdapter, 'tagging'>

/**
* Function that returns the url for each empathy's endpoints according to the environment context.
Expand All @@ -60,9 +59,9 @@ type DockerEndpoints = Exclude<keyof XComponentsAdapter, 'tagging'>;
* @returns The url for the given endpoint.
*/
function resolveEmpathyEndpoint(endpoint: DockerEndpoints, context: Record<string, any>): string {
const { empathyAPIHost } = context;
const endpointHost: string = empathyAPIHost || 'localhost:8080';
const endpointInstance = 'imdb';
const { empathyAPIHost } = context
const endpointHost = (empathyAPIHost as string) || 'localhost:8080'
const endpointInstance = 'imdb'
const empathyEndpoints: Record<DockerEndpoints, string> = {
search: `http://${endpointHost}/query/${endpointInstance}/search`,
popularSearches: `http://${endpointHost}/query/${endpointInstance}/empathize`,
Expand All @@ -73,7 +72,7 @@ function resolveEmpathyEndpoint(endpoint: DockerEndpoints, context: Record<strin
relatedTags: `https://api.empathy.co/relatedtags/${endpointInstance}`,
identifierResults: `http://${endpointHost}/query/${endpointInstance}/skusearch`,
semanticQueries: `http://${endpointHost}/semantics-api/search_single/${endpointInstance}`,
experienceControls: `http://${endpointHost}/config/v1/public/configs`
};
return empathyEndpoints[endpoint];
experienceControls: `http://${endpointHost}/config/v1/public/configs`,
}
return empathyEndpoints[endpoint]
}
60 changes: 28 additions & 32 deletions src/components/pre-search/custom-query-preview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,38 +39,34 @@
</template>

<script lang="ts">
import type { QueryFeature} from '@empathyco/x-components';
import type {
QueryPreviewInfo} from '@empathyco/x-components/queries-preview';
import type { PropType } from 'vue';
import { ArrowRightIcon } from '@empathyco/x-components';
import {
QueryPreviewButton,
QueryPreviewList
} from '@empathyco/x-components/queries-preview';
import { defineComponent } from 'vue';
import CustomSlidingPanel from '../custom-sliding-panel.vue';
import { default as Result } from '../results/result.vue';
import DisplayClickProvider from '../search/display-click-provider.vue';
import type { QueryFeature } from '@empathyco/x-components'
import type { QueryPreviewInfo } from '@empathyco/x-components/queries-preview'
import type { PropType } from 'vue'
import { ArrowRightIcon } from '@empathyco/x-components'
import { QueryPreviewButton, QueryPreviewList } from '@empathyco/x-components/queries-preview'
import { defineComponent } from 'vue'
import CustomSlidingPanel from '../custom-sliding-panel.vue'
import Result from '../results/result.vue'
import DisplayClickProvider from '../search/display-click-provider.vue'
export default defineComponent({
components: {
CustomSlidingPanel,
DisplayClickProvider,
Result,
ArrowRightIcon,
QueryPreviewList,
QueryPreviewButton
export default defineComponent({
components: {
CustomSlidingPanel,
DisplayClickProvider,
Result,
ArrowRightIcon,
QueryPreviewList,
QueryPreviewButton,
},
props: {
queryFeature: {
type: String as PropType<QueryFeature>,
default: 'customer',
},
queriesPreviewInfo: {
type: Array as PropType<QueryPreviewInfo[]>,
default: () => [],
},
props: {
queryFeature: {
type: String as PropType<QueryFeature>,
default: 'customer'
},
queriesPreviewInfo: {
type: Array as PropType<QueryPreviewInfo[]>,
default: () => []
}
}
});
},
})
</script>
41 changes: 22 additions & 19 deletions src/composables/use-has-scroll-past-threshold.composable.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,37 @@
import type { Ref } from 'vue';
import { useState } from '@empathyco/x-components';
import { computed, ref, watch } from 'vue';
import type { ScrollComponentState } from '@empathyco/x-components/types'
import type { Ref } from 'vue'
import { useState } from '@empathyco/x-components'
import { computed, ref, watch } from 'vue'

export const useHasScrollPastThreshold = (): { hasScrolledPastThreshold: Ref<boolean> } => {
const hasScrolledPastThresholdFlag = ref(false);
const scrollOffset = 100;
const { data: scrollPositionsMap } = useState('scroll', ['data']);
const mainScrollPosition = computed(() => scrollPositionsMap.value['main-scroll']?.position);
const hasScrolledPastThresholdFlag = ref(false)
const scrollOffset = 100
const { data: scrollPositionsMap } = useState('scroll', ['data'])
const mainScrollPosition = computed(
() => scrollPositionsMap.value['main-scroll']?.position as number,
)

const hasScrolledPastThreshold = computed(() => hasScrolledPastThresholdFlag.value);
const hasScrolledPastThreshold = computed(() => hasScrolledPastThresholdFlag.value)

watch(mainScrollPosition, () => {
const mainScrollData = scrollPositionsMap.value['main-scroll'];
const mainScrollData = scrollPositionsMap.value['main-scroll'] as ScrollComponentState

if (mainScrollData?.hasReachedStart) {
hasScrolledPastThresholdFlag.value = false;
return;
hasScrolledPastThresholdFlag.value = false
return
} else {
hasScrolledPastThresholdFlag.value = true;
hasScrolledPastThresholdFlag.value = true
}

const isScrollingUp = mainScrollData?.direction === 'UP';
const isScrollingUp = mainScrollData?.direction === 'UP'
if (isScrollingUp || mainScrollPosition.value < scrollOffset) {
hasScrolledPastThresholdFlag.value = false;
hasScrolledPastThresholdFlag.value = false
} else if (!isScrollingUp && mainScrollPosition.value > scrollOffset) {
hasScrolledPastThresholdFlag.value = true;
hasScrolledPastThresholdFlag.value = true
}
});
})

return {
hasScrolledPastThreshold
};
};
hasScrolledPastThreshold,
}
}
14 changes: 6 additions & 8 deletions src/i18n/messages/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@
// export { default as es } from './es.messages.json';

// Example of how to make the spanish messages be lazy loaded, only when the locale is set to `es`
/* eslint-disable @typescript-eslint/explicit-function-return-type */
export const de = async () => import('./de.messages.json');
export const es = async () => import('./es.messages.json');
export const en = async () => import('./en.messages.json');
export const fr = async () => import('./fr.messages.json');
export const pt = async () => import('./pt.messages.json');
export const it = async () => import('./it.messages.json');
/* eslint-enable @typescript-eslint/explicit-function-return-type */
export const de = async () => import('./de.messages.json')
export const es = async () => import('./es.messages.json')
export const en = async () => import('./en.messages.json')
export const fr = async () => import('./fr.messages.json')
export const pt = async () => import('./pt.messages.json')
export const it = async () => import('./it.messages.json')
Loading

0 comments on commit 14f4e53

Please sign in to comment.