"No tsconfig.json file found, analysis will be stopped" while parsing TypeScript files

Hi all,
I’ve been using SonarLint for quite a while, but recently it started throwing an error every time a type a character in a .ts file. The error is the following:

[Info  - 19:02:41.768] Analyzing file 'file:///path/to/some_file.ts'...
[Error - 19:02:41.861] org.sonarsource.nodejs.NodeCommandException: No tsconfig.json file found, analysis will be stopped.
  at org.sonar.plugins.javascript.eslint.TypeScriptSensor.tsConfigs(TypeScriptSensor.java:167)
  at org.sonar.plugins.javascript.eslint.TypeScriptSensor.analyzeFiles(TypeScriptSensor.java:111)
  at org.sonar.plugins.javascript.eslint.AbstractEslintSensor.execute(AbstractEslintSensor.java:120)
  at org.sonar.plugins.javascript.eslint.TypeScriptSensor.execute(TypeScriptSensor.java:55)
  at org.sonarsource.sonarlint.core.analyzer.sensor.SensorsExecutor.executeSensor(SensorsExecutor.java:80)
  at org.sonarsource.sonarlint.core.analyzer.sensor.SensorsExecutor.execute(SensorsExecutor.java:71)
  at org.sonarsource.sonarlint.core.container.analysis.AnalysisContainer.doAfterStart(AnalysisContainer.java:132)
  at org.sonarsource.sonarlint.core.container.ComponentContainer.startComponents(ComponentContainer.java:126)
  at org.sonarsource.sonarlint.core.container.ComponentContainer.execute(ComponentContainer.java:111)
  at org.sonarsource.sonarlint.core.container.standalone.StandaloneGlobalContainer.analyze(StandaloneGlobalContainer.java:153)
  at org.sonarsource.sonarlint.core.StandaloneSonarLintEngineImpl.analyze(StandaloneSonarLintEngineImpl.java:90)
  at org.sonarsource.sonarlint.ls.AnalysisManager.lambda$analyzeStandalone$5(AnalysisManager.java:325)
  at org.sonarsource.sonarlint.ls.AnalysisManager.analyzeWithTiming(AnalysisManager.java:367)
  at org.sonarsource.sonarlint.ls.AnalysisManager.analyzeStandalone(AnalysisManager.java:325)
  at org.sonarsource.sonarlint.ls.AnalysisManager.analyze(AnalysisManager.java:250)
  at org.sonarsource.sonarlint.ls.AnalysisManager.lambda$analyzeAsync$0(AnalysisManager.java:209)
  at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
  at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
  at java.base/java.lang.Thread.run(Unknown Source)

The error doesn’t appear every time, nor for every file, nor always for the same file. However, once a file has been “errored”, it will keep triggering the error every time until I close it.

Interestingly, SonarLint seems able to report “problems” in the affected files. The main issue is the constant pop up saying that “JS/TS analysis failed” (example below).
image

I can’t even ignore that popup, because it moves the focus to the “output” tab, forcing me to click on the editor every time I type something. I wouldn’t mind the output log, but this “focus stealing” is the most annoying issue, as it prevents me from working. Is there a way to hide/suppress the popup?

Relevant environment information, if it helps:

  • Windows 10 Pro
  • VS Code 1.52.1
  • SonarLint 1.19 (I tried previous versions, just in case, but it didn’t make a difference)
2 Likes

Hello Diego, welcome to the community! And thank you for your question.

While it can happen that the TS analyzer used by SonarLint does not find the right tsconfig.json to use for a file, it is definitely not expected to happen on each analysis.

Could you please set both sonarlint.output.showAnalyzerLogs and sonarlint.output.showVerboseLogs to true in you user settings, and post the full analysis log when it happens?

We’re especially eager to see what happens between those lines:

[Debug - 10:23:12.698] Queuing analysis of file 'file:///path/to/some_file.ts'
/* ... ~ a few tens of lines ... */
[Info  - 10:23:29.850] Found XXX issue(s)

I also agree that the error notification is annoying in this use case of repeated errors. I’m not sure what can be done about it. We could introduce a SonarLint-specific setting (e.g sonarlint.ls.hideAnalyzerFailures) and I believe we should instead find a way to fix the root cause. There is also an open issue on VSCode to allow users to toggle extension notifications at the IDE level.

@JBL_SonarSource sorry for the very late reply. I never got a notification that someone replied to my topic and I forgot about (although the error still occurs).

Here’s a log file generated with the options enabled, as requested:

[Debug - 21:28:56.295] Start analysis
[Info  - 21:28:56.296] Index files
[Debug - 21:28:56.330] Language of file 'file:///c:/Users/<user name>/Documents/Projects/Customers/Product_Manager/Plugins/customer-external-service-integration/src/js/admin/products/src/classes/class.edit-product.ts' is set to 'TypeScript'
[Info  - 21:28:56.331] 1 file indexed
[Debug - 21:28:56.334] 'JavaSquidSensor' skipped because there is no related file in current project
[Debug - 21:28:56.334] 'PHP sensor' skipped because there is no related file in current project
[Debug - 21:28:56.335] 'Analyzer for "php.ini" files' skipped because there is no related file in current project
[Debug - 21:28:56.335] 'Python Sensor' skipped because there is no related file in current project
[Debug - 21:28:56.335] Execute Sensor: JavaXmlSensor
[Debug - 21:28:56.335] Execute Sensor: HTML
[Debug - 21:28:56.335] 'JavaScript analysis' skipped because there is no related file in current project
[Debug - 21:28:56.335] Execute Sensor: TypeScript analysis
[Debug - 21:28:56.336] eslint-bridge server is up, no need to start.
[Debug - 21:28:56.339] initializing linter with sonar-no-fallthrough,new-operator-misuse,non-existent-operator,no-inverted-boolean-check,no-all-duplicated-branches,no-identical-conditions,no-small-switch,no-weak-cipher,file-uploads,xml-parser-xxe,default-param-last,no-global-this,no-delete-var,encryption-secure-mode,no-array-delete,no-alphabetical-sort,no-useless-intersection,no-unsafe-finally,prefer-while,no-sequences,no-unsafe-negation,max-switch-cases,no-octal,no-extra-semi,comma-or-logical-or-case,no-one-iteration-loop,label-position,no-multi-str,conditional-indentation,no-undefined-argument,function-inside-loop,no-use-of-empty-return-value,session-regeneration,super-invocation,no-associative-arrays,use-isnan,no-weak-keys,no-try-promise,no-shadow,weak-ssl,no-duplicate-in-composite,generator-without-yield,no-useless-increment,no-same-line-conditional,no-ignored-return,no-duplicated-branches,no-redundant-parentheses,no-redundant-optional,call-argument-line,no-unenclosed-multiline-block,no-element-overwrite,no-equals-in-for-termination,no-sparse-arrays,post-message,bitwise-operators,no-identical-expressions,no-unreachable,no-useless-catch,no-redeclare,no-unthrown-error,no-globals-shadowing,unverified-hostname,unused-import,no-collection-size-mischeck,unverified-certificate,no-empty-collection,for-loop-increment-sign,no-accessor-field-mismatch,index-of-compare-to-positive-number,no-unused-collection,file-name-differ-from-class,no-primitive-wrappers,no-invariant-returns,no-case-label-in-switch,prefer-default-last,no-unnecessary-type-assertion,no-empty-pattern,no-gratuitous-expressions,insecure-jwt-token,no-dead-store,no-self-assign,no-misused-new,no-invalid-await,no-misleading-array-reverse,no-redundant-assignments,no-empty,no-unused-expressions
[Info  - 21:28:56.344] Found 0 tsconfig.json file(s): []
[Warn  - 21:28:56.344] Generating temporary tsconfig is not supported in SonarLint context.
[Error - 21:28:56.344] No tsconfig.json file found, analysis will be stopped.
[Error - 21:28:56.344] org.sonarsource.nodejs.NodeCommandException: No tsconfig.json file found, analysis will be stopped.
	at org.sonar.plugins.javascript.eslint.TypeScriptSensor.tsConfigs(TypeScriptSensor.java:167)
	at org.sonar.plugins.javascript.eslint.TypeScriptSensor.analyzeFiles(TypeScriptSensor.java:111)
	at org.sonar.plugins.javascript.eslint.AbstractEslintSensor.execute(AbstractEslintSensor.java:120)
	at org.sonar.plugins.javascript.eslint.TypeScriptSensor.execute(TypeScriptSensor.java:55)
	at org.sonarsource.sonarlint.core.analyzer.sensor.SensorsExecutor.executeSensor(SensorsExecutor.java:80)
	at org.sonarsource.sonarlint.core.analyzer.sensor.SensorsExecutor.execute(SensorsExecutor.java:71)
	at org.sonarsource.sonarlint.core.container.analysis.AnalysisContainer.doAfterStart(AnalysisContainer.java:132)
	at org.sonarsource.sonarlint.core.container.ComponentContainer.startComponents(ComponentContainer.java:126)
	at org.sonarsource.sonarlint.core.container.ComponentContainer.execute(ComponentContainer.java:111)
	at org.sonarsource.sonarlint.core.container.standalone.StandaloneGlobalContainer.analyze(StandaloneGlobalContainer.java:153)
	at org.sonarsource.sonarlint.core.StandaloneSonarLintEngineImpl.analyze(StandaloneSonarLintEngineImpl.java:90)
	at org.sonarsource.sonarlint.ls.AnalysisManager.lambda$analyzeStandalone$5(AnalysisManager.java:325)
	at org.sonarsource.sonarlint.ls.AnalysisManager.analyzeWithTiming(AnalysisManager.java:367)
	at org.sonarsource.sonarlint.ls.AnalysisManager.analyzeStandalone(AnalysisManager.java:325)
	at org.sonarsource.sonarlint.ls.AnalysisManager.analyze(AnalysisManager.java:250)
	at org.sonarsource.sonarlint.ls.AnalysisManager.lambda$analyzeAsync$0(AnalysisManager.java:209)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.base/java.lang.Thread.run(Unknown Source)

[Error - 21:28:56.344] org.sonarsource.nodejs.NodeCommandException: No tsconfig.json file found, analysis will be stopped.
	at org.sonar.plugins.javascript.eslint.TypeScriptSensor.tsConfigs(TypeScriptSensor.java:167)
	at org.sonar.plugins.javascript.eslint.TypeScriptSensor.analyzeFiles(TypeScriptSensor.java:111)
	at org.sonar.plugins.javascript.eslint.AbstractEslintSensor.execute(AbstractEslintSensor.java:120)
	at org.sonar.plugins.javascript.eslint.TypeScriptSensor.execute(TypeScriptSensor.java:55)
	at org.sonarsource.sonarlint.core.analyzer.sensor.SensorsExecutor.executeSensor(SensorsExecutor.java:80)
	at org.sonarsource.sonarlint.core.analyzer.sensor.SensorsExecutor.execute(SensorsExecutor.java:71)
	at org.sonarsource.sonarlint.core.container.analysis.AnalysisContainer.doAfterStart(AnalysisContainer.java:132)
	at org.sonarsource.sonarlint.core.container.ComponentContainer.startComponents(ComponentContainer.java:126)
	at org.sonarsource.sonarlint.core.container.ComponentContainer.execute(ComponentContainer.java:111)
	at org.sonarsource.sonarlint.core.container.standalone.StandaloneGlobalContainer.analyze(StandaloneGlobalContainer.java:153)
	at org.sonarsource.sonarlint.core.StandaloneSonarLintEngineImpl.analyze(StandaloneSonarLintEngineImpl.java:90)
	at org.sonarsource.sonarlint.ls.AnalysisManager.lambda$analyzeStandalone$5(AnalysisManager.java:325)
	at org.sonarsource.sonarlint.ls.AnalysisManager.analyzeWithTiming(AnalysisManager.java:367)
	at org.sonarsource.sonarlint.ls.AnalysisManager.analyzeStandalone(AnalysisManager.java:325)
	at org.sonarsource.sonarlint.ls.AnalysisManager.analyze(AnalysisManager.java:250)
	at org.sonarsource.sonarlint.ls.AnalysisManager.lambda$analyzeAsync$0(AnalysisManager.java:209)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.base/java.lang.Thread.run(Unknown Source)

[Info  - 21:28:56.346] Found 0 issue(s)

Please note that the exactly same file is analysed correctly some times, and throws an error other times. I would exclude an issue like too many files, or memory errors, because this is the second file in the project, the first being a simple interface file.

I also don’t think that found 0 tsconfig.ts is correct, as the file is right there, and it’s loaded normally in some cases.

Hey @Diego_Aelia, thanks again for the details.

We are working on a fix for the annoying notification that kills the UX, sorry for the inconvenience.

I am not sure about why tsconfig.json is not found. Could it be located outside of the folder(s) open in VSCode?

As a workaround, you can try to configure manually the correct path to use for a given folder, e.g in ${folder}/.vscode/settings.json:

{
  "sonarlint.analyzerProperties": {
    "sonar.typescript.tsconfigPath": "/path/to/tsconfig.json"
  }
}

Thanks for your reply. I couldn’t say why SonarLint can’t find the tsconfig.json. It’s definitely in the correct folder and, in fact, SonarLint can find it in most cases. From time to time, it “loses” the file and goes nuts.

Additional note: there can be multiple tsconfig.json files, e.g. in sub-modules folders. Usually, that doesn’t seem to cause any issue, because SonarLint doesn’t pick up the wrong file, but, perhaps, it might have something to do with the “tsconfig not found” error?

This thread is open for quite some time, and we were not able to reproduce nor understand the issue. If people can still reproduce with latest version of SonarLint, that would help to share with us a small reproducer (sample project on GitHub for example).

I come across this issue on a daily basis, with SonarLint 1.21.0. I get dozens of notifications, then VS Code displays the last three. I can easily spend five minutes clicking “close” on all of them. :grinning_face_with_smiling_eyes:

Unfortunately, I don’t have a sample project that I can share. All the products I work on are commercial, therefore I can’t share their source code. I also lack the time to create an ad-hoc project, because the issue seems to occur with projects of a certain complexity. In my case, it’s dozens files and folders, in PHP, JavaScript, CSS and TypeScript, so not something I could put together quickly.

I don’t think the issue come from the source code, but more likely the project structure, so might be interesting to try if you can reproduce on a copy of your project, after removing all source code but one single file (utility code, something not sensitive).
Again, without a reproducer, there is little chance we manage to move forward.