Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: move prettier-ignore statement so it works #729

Merged
merged 1 commit into from May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 4 additions & 10 deletions src/core/declaration.ts
Expand Up @@ -114,20 +114,14 @@ export function getDeclaration(ctx: Context, filepath: string, originalImports?:
directive: stringifyDeclarationImports({ ...originalImports?.directive, ...imports.directive }),
}

const head = ctx.options.version === 2.7
Copy link
Contributor Author

@HookyGV HookyGV Jan 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that both paths here resolve to the same string, so this check is no longer required.

? `export {}

declare module 'vue' {`
: `export {}

declare module 'vue' {`

let code = `/* eslint-disable */
/* prettier-ignore */
// @ts-nocheck
// Generated by unplugin-vue-components
// Read more: https://github.com/vuejs/core/pull/3399
${head}`
export {}

/* prettier-ignore */
declare module 'vue' {`

if (Object.keys(declarations.component).length > 0) {
code += `
Expand Down
12 changes: 6 additions & 6 deletions test/__snapshots__/dts.test.ts.snap
Expand Up @@ -2,12 +2,12 @@

exports[`dts > components only 1`] = `
"/* eslint-disable */
/* prettier-ignore */
// @ts-nocheck
// Generated by unplugin-vue-components
// Read more: https://github.com/vuejs/core/pull/3399
export {}

/* prettier-ignore */
declare module 'vue' {
export interface GlobalComponents {
RouterLink: typeof import('vue-router')['RouterLink']
Expand All @@ -20,12 +20,12 @@ declare module 'vue' {

exports[`dts > directive only 1`] = `
"/* eslint-disable */
/* prettier-ignore */
// @ts-nocheck
// Generated by unplugin-vue-components
// Read more: https://github.com/vuejs/core/pull/3399
export {}

/* prettier-ignore */
declare module 'vue' {
export interface ComponentCustomProperties {
vLoading: typeof import('test/directive/Loading')['default']
Expand All @@ -36,12 +36,12 @@ declare module 'vue' {

exports[`dts > getDeclaration 1`] = `
"/* eslint-disable */
/* prettier-ignore */
// @ts-nocheck
// Generated by unplugin-vue-components
// Read more: https://github.com/vuejs/core/pull/3399
export {}

/* prettier-ignore */
declare module 'vue' {
export interface GlobalComponents {
RouterLink: typeof import('vue-router')['RouterLink']
Expand Down Expand Up @@ -94,12 +94,12 @@ exports[`dts > parseDeclaration 1`] = `

exports[`dts > vue 2.7 components only 1`] = `
"/* eslint-disable */
/* prettier-ignore */
// @ts-nocheck
// Generated by unplugin-vue-components
// Read more: https://github.com/vuejs/core/pull/3399
export {}

/* prettier-ignore */
declare module 'vue' {
export interface GlobalComponents {
RouterLink: typeof import('vue-router')['RouterLink']
Expand All @@ -112,12 +112,12 @@ declare module 'vue' {

exports[`dts > writeDeclaration - keep unused 1`] = `
"/* eslint-disable */
/* prettier-ignore */
// @ts-nocheck
// Generated by unplugin-vue-components
// Read more: https://github.com/vuejs/core/pull/3399
export {}

/* prettier-ignore */
declare module 'vue' {
export interface GlobalComponents {
RouterLink: typeof import('vue-router')['RouterLink']
Expand All @@ -136,12 +136,12 @@ declare module 'vue' {

exports[`dts > writeDeclaration 1`] = `
"/* eslint-disable */
/* prettier-ignore */
// @ts-nocheck
// Generated by unplugin-vue-components
// Read more: https://github.com/vuejs/core/pull/3399
export {}

/* prettier-ignore */
declare module 'vue' {
export interface GlobalComponents {
RouterLink: typeof import('vue-router')['RouterLink']
Expand Down
6 changes: 3 additions & 3 deletions test/dts.test.ts
Expand Up @@ -124,12 +124,12 @@ const _directive_loading = _resolveDirective("loading")`
test('parseDeclaration', async () => {
const code = `
/* eslint-disable */
/* prettier-ignore */
// generated by unplugin-vue-components
// We suggest you to commit this file into source control
// Read more: https://github.com/vuejs/core/pull/3399
export {}

/* prettier-ignore */
declare module 'vue' {
export interface GlobalComponents {
ComponentA: typeof import('./src/components/ComponentA.vue')['default']
Expand All @@ -145,12 +145,12 @@ declare module 'vue' {
test('parseDeclaration - has icon component like <IMdi:diceD12>', async () => {
const code = `
/* eslint-disable */
/* prettier-ignore */
// generated by unplugin-vue-components
// We suggest you to commit this file into source control
// Read more: https://github.com/vuejs/core/pull/3399
export {}

/* prettier-ignore */
declare module 'vue' {
export interface GlobalComponents {
ComponentA: typeof import('./src/components/ComponentA.vue')['default']
Expand All @@ -166,12 +166,12 @@ declare module 'vue' {
test('parseDeclaration - with directives', async () => {
const code = `
/* eslint-disable */
/* prettier-ignore */
// generated by unplugin-vue-components
// We suggest you to commit this file into source control
// Read more: https://github.com/vuejs/core/pull/3399
export {}

/* prettier-ignore */
declare module 'vue' {
export interface GlobalComponents {
ComponentA: typeof import('./src/components/ComponentA.vue')['default']
Expand Down