claude-skills/

Anthropic公式スキル・プラグインの日本語ディレクトリ

last sync 22h ago
スキルOfficialdevelopment

🔧fix-component-async

プラグイン
ui5-modernization

説明

UI5 linterが検出するものの自動修正できない、`Component.js`の非同期設定に関する問題を修正します。 次のような場合に使用: linterが以下のルール違反を出力したとき: - `async-component-flags` — `IAsyncContentCreation`インターフェースの欠落、manifestの宣言漏れ、冗長な非同期フラグ、`async:false`エラーに対応 - `no-removed-manifest-property` — インラインmanifest v2における非同期フラグに対応 非同期ロード・`IAsyncContentCreation`・manifest宣言に関するエラーを含む`Component.js`ファイルで実行してください。 `IAsyncContentCreation`インターフェースの追加と、manifestの適切な設定を自動的に行います。

原文を表示

Fix Component.js async configuration issues that UI5 linter reports but cannot auto-fix. Use this skill when linter outputs these rules: - `async-component-flags` - For missing IAsyncContentCreation interface, missing manifest declaration, redundant async flags, async:false errors - `no-removed-manifest-property` - For async flags in inline manifest v2 Trigger on Component.js files with errors about async loading, IAsyncContentCreation, manifest declaration. Automatically adds the IAsyncContentCreation interface and configures manifest properly.

ユースケース

  • async-component-flagsルール違反を修正するとき
  • no-removed-manifest-propertyエラーを解決するとき
  • IAsyncContentCreationインターフェースを追加するとき
  • Component.jsの非同期設定を正規化するとき

本文(日本語訳)

Component.js 非同期設定の修正

このスキルは、UI5 リンターが検出しても自動修正できない Component.js の非同期設定の問題を修正します。自動修正が難しい理由は、コンポーネントのローディング動作への理解が必要なためです。


対象リンタールール

ルール ID メッセージパターン このスキルの対処
async-component-flags Component is not configured for asynchronous loading IAsyncContentCreation インターフェースを追加
async-component-flags Component does not specify that it uses the descriptor via the manifest.json file manifest: "json" を追加
async-component-flags Component implements the sap.ui.core.IAsyncContentCreation interface. The redundant 'async' flag ... should be removed manifest から async フラグを削除
async-component-flags The 'async' property at '...' must be removed async: false を削除
no-removed-manifest-property Property '...' has been removed in Manifest Version 2 async プロパティを削除

次のような場合に使用

次のようなリンター出力が確認できる場合に、このスキルを適用してください:

Component.js:5:1 error Component is not configured for asynchronous loading.  async-component-flags
Component.js:5:1 warning Component does not specify that it uses the descriptor via the manifest.json file  async-component-flags
Component.js:10:5 warning Component implements the sap.ui.core.IAsyncContentCreation interface. The redundant 'async' flag at '/sap.ui5/rootView/async' should be removed  async-component-flags
manifest.json:25:9 error The 'async' property at '/sap.ui5/rootView/async' must be removed  async-component-flags

完全なモダナイゼーションワークフローにおける重要事項: リンターが async-component-flags を検出していない場合でも、すべての Component.js に対して無条件にこのスキルを適用してください。 リンターが「インターフェースが存在しない」エラーを検出できるのは、manifest.json から冗長な async: true フラグが削除されたのみです。そのため、モダナイゼーションの初期フェーズではエラーが表示されないことがあります。IAsyncContentCreation は常に予防的に追加してください。


重要ルール

IAsyncContentCreation をインポートしてはならない

IAsyncContentCreationマーカーインターフェースです。UI5 ランタイムは interfaces 配列内の文字列としてその名前を確認します。 モジュール依存関係としてインポートしてはなりませんsap.ui.define の依存関係配列に追加すると、sap/ui/core/IAsyncContentCreation はロード可能なモジュールではないため、ランタイムエラーが発生します。

// 誤り — インポートしないこと
sap.ui.define([
  "sap/ui/core/UIComponent",
  "sap/ui/core/IAsyncContentCreation"  // ← 誤り: ランタイムエラーになる
], function(UIComponent, IAsyncContentCreation) {
  ...
});

// 正しい — interfaces 内で文字列として参照するのみ
sap.ui.define([
  "sap/ui/core/UIComponent"
], function(UIComponent) {
  return UIComponent.extend("my.app.Component", {
    metadata: {
      manifest: "json",
      interfaces: ["sap.ui.core.IAsyncContentCreation"]  // ← 文字列参照のみ
    }
  });
});

既存の依存関係配列に "sap/ui/core/IAsyncContentCreation" が含まれている場合は、それと対応する関数パラメーターを削除してください。


interfaces の正しい配置場所

interfacesmetadata オブジェクトのプロパティです。必ず metadata: { }内側にネストする必要があります。 UIComponent.extend() の設定オブジェクトには 2 つの階層があります:

UIComponent.extend("name", {
  metadata: {          ← レベル 1: コンポーネント設定
    manifest: "json",  ← レベル 2: metadata プロパティ
    interfaces: [...]  ← レベル 2: interfaces はここに置く
  },
  init: function() {}  ← レベル 1: コンポーネント設定
});

UI5 ランタイムが interfaces を読み取るのは metadata オブジェクト内のみです。 レベル 1(metadata の兄弟要素)に配置してしまうと、エラーなく無視されてしまい、コンポーネントが非同期として認識されません。

編集後に確認してください: interfacesmetadata: より 1 段深くインデントされていますか? そうなっていない場合、配置場所が誤っています。


修正方針

1. async-component-flags — IAsyncContentCreation インターフェースの追加

IAsyncContentCreation インターフェースは、コンポーネントが非同期でコンテンツをロードすることを宣言するモダンな方法です。

正しい例 — interfacesmetadata 内にネスト:

// 修正前
sap.ui.define([
  "sap/ui/core/UIComponent"
], function(UIComponent) {
  "use strict";

  return UIComponent.extend("my.app.Component", {
    metadata: {
      manifest: "json"
    }
  });
});

// 修正後
sap.ui.define([
  "sap/ui/core/UIComponent"
], function(UIComponent) {
  "use strict";

  return UIComponent.extend("my.app.Component", {
    metadata: {
      manifest: "json",
      interfaces: ["sap.ui.core.IAsyncContentCreation"]
    }
  });
});

誤った例 — interfaces のネストレベルが間違っている:

// 誤り — interfaces が metadata の兄弟要素になっている(レベル 2 ではなくレベル 1)
return UIComponent.extend("my.app.Component", {
  interfaces: ["sap.ui.core.IAsyncContentCreation"],  // ← 誤り: metadata の外にある
  metadata: {
    manifest: "json"
  }
});

2. async-component-flags — manifest 宣言の追加

コンポーネントが manifest の使用を宣言していない場合、metadata に manifest: "json" を追加します。

// 修正前
metadata: {
  // manifest の宣言なし
}

// 修正後
metadata: {
  manifest: "json"
}

3. async-component-flags — 冗長な async フラグの削除

IAsyncContentCreation インターフェースが実装されている場合、manifest.json 内の async フラグは冗長になるため削除します。

manifest.json での対応:

// 修正前
{
  "sap.ui5": {
    "rootView": {
      "viewName": "my.app.view.Main",
      "type": "XML",
      "async": true
    },
    "routing": {
      "config": {
        "async": true,
        ...
      }
    }
  }
}

// 修正後
{
  "sap.ui5": {
    "rootView": {
      "viewName": "my.app.view.Main",
      "type": "XML"
    },
    "routing": {
      "config": {
        ...
      }
    }
  }
}

4. async-component-flagsasync: false の削除

async: false が明示的に設定されている場合、非同期ローディングを妨げるため削除する必要があります。


5. Component.js 内のインライン manifest の対応

manifest が別ファイルの manifest.json ではなく Component.js にインラインで定義されている場合、同様の修正をインライン manifest オブジェクトに適用します。 なお、この場合も interfacesmetadata 内に配置します。インライン manifest プロパティと兄弟関係となり、両方とも metadata 配下にネストされます:

// 修正前
metadata: {
  manifest: {
    "sap.ui5": {
      "rootView": {
        "async": true,
        ...
      }
    }
  }
}

// 修正後
metadata: {
  manifest: {
    "sap.ui5": {
      "rootView": {
        ...
      }
    }
  },
  interfaces: ["sap.ui.core.IAsyncContentCreation"]  // ← metadata の内側に配置
}

実装手順

  1. Component.js ファイルを読み込む
  2. 構文スタイルを確認する(sap.ui.define または ES6 クラス)
  3. async-component-flags エラーへの対応:
    • IAsyncContentCreation インターフェースがすでに宣言されているか確認
    • 宣言されていない場合、interfaces: ["sap.ui.core.IAsyncContentCreation"]metadata: { } オブジェクト内のプロパティとして追加する(manifest の兄弟要素として配置し、metadata 自体の兄弟要素にしないこと)
    • manifest: "json" が宣言されているか確認し、なければ追加
  4. 配置を確認: interfacesmetadata: より 1 段深くインデントされているか確認し、同じレベルにある場合は誤り
  5. manifest.json(またはインライン manifest)に冗長な async フラグがないか確認
  6. rootView および routing/config から async プロパティを削除
  7. 更新したファイルを書き込む
  8. ゲートスクリプトを実行して検証する: node <skill-dir>/scripts/verify-component.js <project-root> — 終了コード 0 で終わること

修正例

以下のリンター出力が得られた場合:

Component.js:5:1 error Component is not configured for asynchronous loading.  async-component-flags

Component.js の変換:

// 修正前
sap.ui.define([
  "sap/ui/core/UIComponent",
  "sap/ui/model/json/JSONModel"
], function(UIComponent, JSONModel) {
  "use strict";

  return UIComponent.extend("my.app.Component", {
    metadata: {
      manifest: "json"
    },

    init: function() {
      UIComponent.prototype.init.apply(this, arguments);
      // ...
    }
  });
});

// 修正後 — interfaces は metadata の内側に配置し、init や metadata の兄弟要素にしないこと
sap.ui.define([
  "sap/ui/core/UIComponent",
  "sap/ui/model/json/JSONModel"
], function(UIComponent, JSONModel) {
  "use strict";

  return UIComponent.extend("my.app.Component", {
    metadata: {
      manifest: "json",
      interfaces: ["sap.ui.core.IAsyncContentCreation"]
    },

    init: function() {
      UIComponent.prototype.init.apply(this, arguments);
      // ...
    }
  });
});

備考

  • IAsyncContentCreation インターフェースは UI5 1.89 で導入されました。minUI5Version が互換性を満たしていることを確認してください。
  • インターフェースを追加する際は、適切な非同期ローディングのために manifest: "json" も存在することを確認してください。
  • このインターフェースを追加すると async: true フラグは冗長になり、安全に削除できます。
  • UIComponent(Component だけでなく)を継承するコンポーネントでも IAsyncContentCreation を使用できます。
  • カスタムベースコンポーネントを継承しており、そのベースコンポーネントがすでに IAsyncContentCreation を実装している場合は変更不要です。
  • IAsyncContentCreation と manifest v2 の関係: これらは独立した事項です。manifest の _version"2.0.0" に更新しても、非同期コンテンツ作成は自動的に有効になりません。Component.js に IAsyncContentCreation を明示的に実装する必要があります。逆に、IAsyncContentCreation を追加しても manifest v2 は必須ではありません。

関連スキル

  • fix-manifest-json: IAsyncContentCreation を追加した場合、manifest.json の async フラグが冗長になります。_version の更新、async プロパティの削除、ルーティング設定のリネームには fix-manifest-json を使用してください。
  • fix-js-globals: Component.js がグローバルアクセスパターン(例: sap.ui.getCore())を使用している場合、fix-js-globals を使用して適切なモジュールインポートに変換してください。
原文(English)を表示

Fix Component.js Async Configuration

This skill fixes Component.js async configuration issues that the UI5 linter detects but cannot auto-fix because they may require understanding of the component's loading behavior.

Linter Rules Handled

Rule ID Message Pattern This Skill's Action
async-component-flags Component is not configured for asynchronous loading Add IAsyncContentCreation interface
async-component-flags Component does not specify that it uses the descriptor via the manifest.json file Add manifest: "json"
async-component-flags Component implements the sap.ui.core.IAsyncContentCreation interface. The redundant 'async' flag ... should be removed Remove async flag from manifest
async-component-flags The 'async' property at '...' must be removed Remove async: false
no-removed-manifest-property Property '...' has been removed in Manifest Version 2 Remove async property

When to Use

Apply this skill when you see linter output like:

Component.js:5:1 error Component is not configured for asynchronous loading.  async-component-flags
Component.js:5:1 warning Component does not specify that it uses the descriptor via the manifest.json file  async-component-flags
Component.js:10:5 warning Component implements the sap.ui.core.IAsyncContentCreation interface. The redundant 'async' flag at '/sap.ui5/rootView/async' should be removed  async-component-flags
manifest.json:25:9 error The 'async' property at '/sap.ui5/rootView/async' must be removed  async-component-flags

Important during full modernization workflows: Also apply this skill unconditionally to every Component.js, even if the linter did not flag async-component-flags. The linter can only detect the missing interface AFTER redundant async: true flags are removed from manifest.json — so in early modernization phases the error won't appear yet. Always add IAsyncContentCreation proactively.

Critical Rules

Never Import IAsyncContentCreation

IAsyncContentCreation is a marker interface — the UI5 runtime checks for its name as a string in the interfaces array. It must NOT be imported as a module dependency. Adding it to the sap.ui.define dependency array causes a runtime error because sap/ui/core/IAsyncContentCreation is not a loadable module.

// WRONG — do NOT import it
sap.ui.define([
  "sap/ui/core/UIComponent",
  "sap/ui/core/IAsyncContentCreation"  // ← WRONG: will fail at runtime
], function(UIComponent, IAsyncContentCreation) {
  ...
});

// CORRECT — only reference it as a string in interfaces
sap.ui.define([
  "sap/ui/core/UIComponent"
], function(UIComponent) {
  return UIComponent.extend("my.app.Component", {
    metadata: {
      manifest: "json",
      interfaces: ["sap.ui.core.IAsyncContentCreation"]  // ← string reference only
    }
  });
});

If you see "sap/ui/core/IAsyncContentCreation" in an existing dependency array, remove it and its corresponding function parameter.

Correct Placement of interfaces

interfaces is a property of the metadata object — it must be nested inside metadata: { }. The UIComponent.extend() config object has two levels:

UIComponent.extend("name", {
  metadata: {          ← level 1: component config
    manifest: "json",  ← level 2: metadata properties
    interfaces: [...]  ← level 2: THIS IS WHERE interfaces GOES
  },
  init: function() {}  ← level 1: component config
});

The UI5 runtime only reads interfaces from the metadata object. Placing it at level 1 (as a sibling of metadata) silently fails — the component will not be recognized as async.

After writing your edit, verify: is interfaces indented one level deeper than metadata:? If not, you put it in the wrong place.

Fix Strategy

1. async-component-flags - Add IAsyncContentCreation Interface

The IAsyncContentCreation interface is the modern way to declare that a component loads content asynchronously.

Correct — interfaces nested inside metadata:

// Before
sap.ui.define([
  "sap/ui/core/UIComponent"
], function(UIComponent) {
  "use strict";

  return UIComponent.extend("my.app.Component", {
    metadata: {
      manifest: "json"
    }
  });
});

// After
sap.ui.define([
  "sap/ui/core/UIComponent"
], function(UIComponent) {
  "use strict";

  return UIComponent.extend("my.app.Component", {
    metadata: {
      manifest: "json",
      interfaces: ["sap.ui.core.IAsyncContentCreation"]
    }
  });
});

WRONG — interfaces at the wrong nesting level:

// WRONG — interfaces as a sibling of metadata (level 1 instead of level 2)
return UIComponent.extend("my.app.Component", {
  interfaces: ["sap.ui.core.IAsyncContentCreation"],  // ← WRONG: outside metadata
  metadata: {
    manifest: "json"
  }
});

2. async-component-flags - Add Manifest Declaration

If the component doesn't declare it uses a manifest, add manifest: "json" to the metadata.

// Before
metadata: {
  // no manifest declaration
}

// After
metadata: {
  manifest: "json"
}

3. async-component-flags - Remove Redundant Async Flags

When IAsyncContentCreation interface is implemented, the async flags in manifest.json become redundant and should be removed.

In manifest.json:

// Before
{
  "sap.ui5": {
    "rootView": {
      "viewName": "my.app.view.Main",
      "type": "XML",
      "async": true
    },
    "routing": {
      "config": {
        "async": true,
        ...
      }
    }
  }
}

// After
{
  "sap.ui5": {
    "rootView": {
      "viewName": "my.app.view.Main",
      "type": "XML"
    },
    "routing": {
      "config": {
        ...
      }
    }
  }
}

4. async-component-flags - Remove async: false

If async: false is explicitly set, this must be removed as it prevents asynchronous loading.

5. Handle Inline Manifest in Component.js

If the manifest is defined inline in Component.js (not in a separate manifest.json), apply the same fixes to the inline manifest object. Note that interfaces still goes inside metadata — it is a sibling of the inline manifest property, both nested under metadata:

// Before
metadata: {
  manifest: {
    "sap.ui5": {
      "rootView": {
        "async": true,
        ...
      }
    }
  }
}

// After
metadata: {
  manifest: {
    "sap.ui5": {
      "rootView": {
        ...
      }
    }
  },
  interfaces: ["sap.ui.core.IAsyncContentCreation"]  // ← still INSIDE metadata
}

Implementation Steps

  1. Read the Component.js file
  2. Determine the syntax style (sap.ui.define or ES6 class)
  3. For async-component-flags errors:
    • Check if IAsyncContentCreation interface is already declared
    • If not, add interfaces: ["sap.ui.core.IAsyncContentCreation"] as a property inside the metadata: { } object (sibling of manifest, NOT sibling of metadata itself)
    • Check if manifest: "json" is declared, add if missing
  4. Verify placement: interfaces must be indented one level deeper than metadata: — if it's at the same level, it's wrong
  5. Check the manifest.json (or inline manifest) for redundant async flags
  6. Remove async properties from rootView and routing/config
  7. Write the updated files
  8. Run the gate script to verify: node <skill-dir>/scripts/verify-component.js <project-root> — must exit 0

Example Fix

Given linter output:

Component.js:5:1 error Component is not configured for asynchronous loading.  async-component-flags

Component.js transformation:

// Before
sap.ui.define([
  "sap/ui/core/UIComponent",
  "sap/ui/model/json/JSONModel"
], function(UIComponent, JSONModel) {
  "use strict";

  return UIComponent.extend("my.app.Component", {
    metadata: {
      manifest: "json"
    },

    init: function() {
      UIComponent.prototype.init.apply(this, arguments);
      // ...
    }
  });
});

// After — interfaces goes INSIDE metadata, not next to init/metadata
sap.ui.define([
  "sap/ui/core/UIComponent",
  "sap/ui/model/json/JSONModel"
], function(UIComponent, JSONModel) {
  "use strict";

  return UIComponent.extend("my.app.Component", {
    metadata: {
      manifest: "json",
      interfaces: ["sap.ui.core.IAsyncContentCreation"]
    },

    init: function() {
      UIComponent.prototype.init.apply(this, arguments);
      // ...
    }
  });
});

Notes

  • The IAsyncContentCreation interface was introduced in UI5 1.89 - ensure minUI5Version is compatible
  • When adding the interface, also ensure manifest: "json" is present for proper async loading
  • The interface makes async: true flags redundant - they can be safely removed
  • Components that extend UIComponent (not just Component) can use IAsyncContentCreation
  • If the component inherits from a custom base component that already implements IAsyncContentCreation, no changes are needed
  • IAsyncContentCreation vs manifest v2: These are independent concerns. Updating manifest _version to "2.0.0" does NOT automatically enable async content creation — IAsyncContentCreation must still be explicitly implemented in Component.js. Conversely, adding IAsyncContentCreation does not require manifest v2.

Related Skills

  • fix-manifest-json: When adding IAsyncContentCreation, the manifest.json async flags become redundant — use fix-manifest-json to update _version, remove async properties, and rename routing configuration
  • fix-js-globals: If Component.js uses global access patterns (e.g., sap.ui.getCore()), use fix-js-globals to convert them to proper module imports

原文・著作権は Anthropic および各プラグイン作者に帰属します。日本語訳は Claude API による自動翻訳です。