Skip to content

Commit 62b84ba

Browse files
Ignore some more tsc warnings (#292)
This cleans the DEBUG log a lot as these tsc warnings are of no use for us at all. For: https://shiftleftinc.atlassian.net/browse/SEN-1361
1 parent c5c18e5 commit 62b84ba

File tree

6 files changed

+24
-18
lines changed

6 files changed

+24
-18
lines changed

src/main/scala/io/shiftleft/js2cpg/core/Config.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ case class Config(
9191
s"""
9292
|\t- Source project: '$srcDir'
9393
|\t- package.json location: '${createPathForPackageJson()}'
94-
|\t- Module mode: '${moduleMode.getOrElse(TypescriptTranspiler.DEFAULT_MODULE)}'
94+
|\t- Module mode: '${moduleMode.getOrElse(TypescriptTranspiler.DefaultModule)}'
9595
|\t- Optimize dependencies: $optimizeDependencies
9696
|\t- Fixed transpilations dependencies: $fixedTranspilationDependencies
9797
|\t- Typescript transpiling: $tsTranspiling

src/main/scala/io/shiftleft/js2cpg/core/Js2cpgArgumentsParser.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ class Js2cpgArgumentsParser {
200200
.hidden()
201201
opt[String](MODULE_MODE)
202202
.text(
203-
s"set the module mode for transpiling (default is '${TypescriptTranspiler.DEFAULT_MODULE}', alternatives are e.g., esnext or es2015)"
203+
s"set the module mode for transpiling (default is '${TypescriptTranspiler.DefaultModule}', alternatives are e.g., esnext or es2015)"
204204
)
205205
.action((module, c) => c.copy(moduleMode = Some(module)))
206206
.hidden()

src/main/scala/io/shiftleft/js2cpg/parser/FreshJsonParser.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ object FreshJsonParser {
3434
val objectMapper = new ObjectMapper
3535
FileUtils
3636
.getFileTree(Paths.get(config.srcDir), config, List(".json"))
37-
.filter(_.endsWith(TypescriptTranspiler.DENO_CONFIG))
37+
.filter(_.endsWith(TypescriptTranspiler.DenoConfig))
3838
.flatMap { file =>
3939
val packageJson = objectMapper.readTree(IOUtils.readLinesInFile(file).mkString)
4040
Option(packageJson.path("importMap").asText()).map(file.resolveSibling)

src/main/scala/io/shiftleft/js2cpg/preprocessing/TypescriptTranspiler.scala

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import io.shiftleft.js2cpg.io.FileDefaults.TS_SUFFIX
88
import io.shiftleft.js2cpg.io.{ExternalCommand, FileUtils}
99
import io.shiftleft.js2cpg.parser.PackageJsonParser
1010
import io.shiftleft.js2cpg.parser.TsConfigJsonParser
11-
import io.shiftleft.js2cpg.preprocessing.TypescriptTranspiler.DEFAULT_MODULE
12-
import io.shiftleft.js2cpg.preprocessing.TypescriptTranspiler.DENO_CONFIG
11+
import io.shiftleft.js2cpg.preprocessing.TypescriptTranspiler.DefaultModule
12+
import io.shiftleft.js2cpg.preprocessing.TypescriptTranspiler.DenoConfig
1313
import io.shiftleft.utils.IOUtils
1414
import org.slf4j.LoggerFactory
1515
import org.apache.commons.io.{FileUtils => CommonsFileUtils}
@@ -19,12 +19,22 @@ import scala.util.{Failure, Success, Try}
1919

2020
object TypescriptTranspiler {
2121

22-
val DEFAULT_MODULE: String = "commonjs"
22+
val DefaultModule: String = "commonjs"
2323

24-
private val tscTypingWarnings =
25-
List("error TS", ".d.ts", "The file is in the program because", "Entry point of type library")
24+
private val TscTypingWarnings = List(
25+
"error TS",
26+
".d.ts",
27+
"The file is in the program because",
28+
"Entry point of type library",
29+
"does not exist on type",
30+
"properties from type",
31+
"are incompatible",
32+
"was found on type",
33+
"not assignable to",
34+
"Overload "
35+
)
2636

27-
val DENO_CONFIG: String = "deno.json"
37+
val DenoConfig: String = "deno.json"
2838

2939
}
3040

@@ -39,7 +49,7 @@ class TypescriptTranspiler(override val config: Config, override val projectPath
3949
private def hasTsFiles: Boolean =
4050
FileUtils.getFileTree(projectPath, config, List(TS_SUFFIX)).nonEmpty
4151

42-
private def isFreshProject: Boolean = (File(projectPath) / DENO_CONFIG).exists
52+
private def isFreshProject: Boolean = (File(projectPath) / DenoConfig).exists
4353

4454
private def isTsProject: Boolean =
4555
(File(projectPath) / "tsconfig.json").exists || isFreshProject
@@ -108,7 +118,7 @@ class TypescriptTranspiler(override val config: Config, override val projectPath
108118
}
109119

110120
private def isCleanTrace(exception: Throwable): Boolean =
111-
exception.getMessage.linesIterator.forall(l => TypescriptTranspiler.tscTypingWarnings.exists(l.contains))
121+
exception.getMessage.linesIterator.forall(l => TypescriptTranspiler.TscTypingWarnings.exists(l.contains))
112122

113123
override protected def transpile(tmpTranspileDir: Path): Boolean = {
114124
if (installTsPlugins()) {
@@ -131,7 +141,7 @@ class TypescriptTranspiler(override val config: Config, override val projectPath
131141
"" :: Nil
132142
}
133143

134-
val module = config.moduleMode.getOrElse(DEFAULT_MODULE)
144+
val module = config.moduleMode.getOrElse(DefaultModule)
135145
val outDir = subDir.map(s => File(tmpTranspileDir.toString, s.toString)).getOrElse(File(tmpTranspileDir))
136146

137147
for (proj <- projects) {

src/main/scala/io/shiftleft/js2cpg/preprocessing/VueTranspiler.scala

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,7 @@ class VueTranspiler(override val config: Config, override val projectPath: Path)
4141

4242
private def nodeOptions(): Map[String, String] = {
4343
// TODO: keep this until https://github.com/webpack/webpack/issues/14532 is fixed.
44-
// This hack is not required on MacOS.
45-
if (
46-
!scala.util.Properties.isMac &&
47-
nodeVersion().exists(v => v.startsWith("v17") || v.startsWith("v18") || v.startsWith("v19"))
48-
) {
44+
if (nodeVersion().exists(v => v.startsWith("v17") || v.startsWith("v18") || v.startsWith("v19"))) {
4945
Map("NODE_OPTIONS" -> "--openssl-legacy-provider")
5046
} else {
5147
Map.empty

src/test/scala/io/shiftleft/js2cpg/passes/DependenciesPassTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ class DependenciesPassTest extends AbstractPassTest {
105105
| "envalid": "https://deno.land/x/[email protected]/mod.ts"
106106
|}}""".stripMargin
107107
),
108-
(TypescriptTranspiler.DENO_CONFIG, """{"importMap": "./import_map.json"}""")
108+
(TypescriptTranspiler.DenoConfig, """{"importMap": "./import_map.json"}""")
109109
)
110110
) { cpg =>
111111
val deps = getDependencies(cpg).l

0 commit comments

Comments
 (0)