TS rule 「Deprecated APIs should not be used」 not working

sonarsource.sonarlint-vscode v1.20.1


export interface LanguageService {
   * @deprecated Use getEncodedSyntacticClassifications instead.
  getSyntacticClassifications(fileName: any, span: any): any[];
declare const getLanguageService: () => LanguageService;
const syntacticClassifications = getLanguageService().getSyntacticClassifications(
); // Noncompliant

No error, but it should has a error.

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

This rule is not enabled by default.

You can enable it in the UI:

  • Open the “SonarLint Rules” view
  • In the “…” menu, use the “Find Rule By Key” action
  • Input typescript:S1874
  • Use the “:heavy_check_mark:” icon in the view to enable the rule

See illustration of the process below:

Additionally, you can put the block below in your user settings to enable this rule:

    "sonarlint.rules": {
        "typescript:S1874": {
            "level": "on"

Finally, if you are using SonarCloud or a SonarQube server, you can enable this rule in a quality profile on the server, and use SonarLint’s connected mode to synchronize enabled rules.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.