目录

@compatibility/deprecate-api-check

Avoid using deprecated APIs during development.

Rule Configuration

// code-linter.json5
{
  "rules": {
    "@compatibility/deprecate-api-check": "suggestion"
  }
}

Options

This rule is not configurable.

Example of Correct Code

import media from '@ohos.multimedia.media';

function nonDeprecatedApi(): void {
  media.createAVPlayer().then((avPlayer) => {
    avPlayer.on('stateChange', () => {});
    avPlayer.play();
  });
}

Example of Incorrect Code

import { media } from '@kit.MediaKit';

function deprecatedApi(): void {
  let audioPlayer: media.AudioPlayer = media.createAudioPlayer ();
  audioPlayer.src = 'https://example.com/audio.mp3';
  audioPlayer.play ();
  audioPlayer.release ();
}

Rule Set

plugin:@compatibility/all

For details about how to configure Code Linter check rules, see Code Linter.