Skip to content

Commit

Permalink
Do not add type alias suppress in target file for top-level granularity
Browse files Browse the repository at this point in the history
  • Loading branch information
sgrishchenko committed Jun 28, 2023
1 parent e795d25 commit cd344c8
Show file tree
Hide file tree
Showing 15 changed files with 9 additions and 45 deletions.
10 changes: 7 additions & 3 deletions src/structure/createTargetFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,24 @@ export function createTargetFile(
configuration: Configuration,
) {
const {
fileName,
package: packageChunks,
moduleName,
qualifier,
hasRuntime,
} = item

const packageName = createPackageName(item.package)
const granularity = configuration.granularity ?? "file"

const outputFileName = packageToOutputFileName(item.package, item.fileName, configuration)
const packageName = createPackageName(packageChunks)

const outputFileName = packageToOutputFileName(packageChunks, fileName, configuration)

const imports = generateImports(outputFileName, configuration)

const jsModule = hasRuntime ? `@file:JsModule("${moduleName}")` : ""
const jsQualifier = hasRuntime && qualifier !== undefined ? `@file:JsQualifier("${qualifier}")` : ""
const typeAliasSuppress = `
const typeAliasSuppress = granularity === "top-level" ? "" : `
@file:Suppress(
"NON_EXTERNAL_DECLARATION_IN_INAPPROPRIATE_FILE",
)
Expand Down
3 changes: 0 additions & 3 deletions test/sandbox/namespace/generated/index.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@

@file:JsModule("sandbox-namespace/index")
@file:Suppress(
"NON_EXTERNAL_DECLARATION_IN_INAPPROPRIATE_FILE",
)

package sandbox.namespace

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@

@file:JsModule("package-namespace")
@file:Suppress(
"NON_EXTERNAL_DECLARATION_IN_INAPPROPRIATE_FILE",
)

package `package`.namespace

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@

@file:JsModule("package-namespace")
@file:JsQualifier("NestedNamespace")
@file:Suppress(
"NON_EXTERNAL_DECLARATION_IN_INAPPROPRIATE_FILE",
)

package `package`.namespace.nestednamespace

Expand Down
3 changes: 0 additions & 3 deletions test/sandbox/namespace/generated/was/mapped/main/namespace.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@

@file:JsModule("will-be-mapped")
@file:Suppress(
"NON_EXTERNAL_DECLARATION_IN_INAPPROPRIATE_FILE",
)

package was.mapped.main

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@

@file:JsModule("will-be-mapped")
@file:JsQualifier("AndThis")
@file:Suppress(
"NON_EXTERNAL_DECLARATION_IN_INAPPROPRIATE_FILE",
)

package was.mapped.nested

Expand Down
3 changes: 0 additions & 3 deletions test/sandbox/top-level/generated/MyClass.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@

@file:JsModule("sandbox-top-level")
@file:Suppress(
"NON_EXTERNAL_DECLARATION_IN_INAPPROPRIATE_FILE",
)

package sandbox.top.level

Expand Down
3 changes: 0 additions & 3 deletions test/sandbox/top-level/generated/MyClassWithTypeLiteral.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@

@file:JsModule("sandbox-top-level")
@file:Suppress(
"NON_EXTERNAL_DECLARATION_IN_INAPPROPRIATE_FILE",
)

package sandbox.top.level

Expand Down
3 changes: 0 additions & 3 deletions test/sandbox/top-level/generated/MyEnum.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@

@file:JsModule("sandbox-top-level")
@file:Suppress(
"NON_EXTERNAL_DECLARATION_IN_INAPPROPRIATE_FILE",
)

package sandbox.top.level

Expand Down
4 changes: 1 addition & 3 deletions test/sandbox/top-level/generated/MyInterface.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@

@file:Suppress(
"NON_EXTERNAL_DECLARATION_IN_INAPPROPRIATE_FILE",
)


package sandbox.top.level

Expand Down
4 changes: 1 addition & 3 deletions test/sandbox/top-level/generated/MyTypeAlias.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@

@file:Suppress(
"NON_EXTERNAL_DECLARATION_IN_INAPPROPRIATE_FILE",
)


package sandbox.top.level

Expand Down
3 changes: 0 additions & 3 deletions test/sandbox/top-level/generated/createMemoryRouter.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@

@file:JsModule("sandbox-top-level")
@file:Suppress(
"NON_EXTERNAL_DECLARATION_IN_INAPPROPRIATE_FILE",
)

package sandbox.top.level

Expand Down
3 changes: 0 additions & 3 deletions test/sandbox/top-level/generated/index.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@

@file:JsModule("sandbox-top-level")
@file:Suppress(
"NON_EXTERNAL_DECLARATION_IN_INAPPROPRIATE_FILE",
)

package sandbox.top.level

Expand Down
3 changes: 0 additions & 3 deletions test/sandbox/top-level/generated/myFunction1.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@

@file:JsModule("sandbox-top-level")
@file:Suppress(
"NON_EXTERNAL_DECLARATION_IN_INAPPROPRIATE_FILE",
)

package sandbox.top.level

Expand Down
3 changes: 0 additions & 3 deletions test/sandbox/top-level/generated/myFunction2.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@

@file:JsModule("sandbox-top-level")
@file:Suppress(
"NON_EXTERNAL_DECLARATION_IN_INAPPROPRIATE_FILE",
)

package sandbox.top.level

Expand Down

0 comments on commit cd344c8

Please sign in to comment.