Skip to content

Commit

Permalink
fix: move prettier-ignore statement so it works (#729)
Browse files Browse the repository at this point in the history
  • Loading branch information
HookyGV committed May 1, 2024
1 parent c0e66f3 commit e0d37b0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 19 deletions.
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
? `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

0 comments on commit e0d37b0

Please sign in to comment.