vue/no-unsandboxed-iframe
iframe に sandbox 属性を指定します。
| 既定の重大度 | プリセット | 自動修正 | オプション |
|---|---|---|---|
warning |
happy-path, nuxt, ecosystem, opinionated |
なし | なし |
適用範囲:Vue SFC のテンプレートと各ブロック。ルールに必要な script の文脈も例に含めています。
悪い例
iframe に sandbox がなく、機能の制限を指定していません。
<template>
<iframe src="/embed"></iframe>
</template>
良い例
sandbox で制限し、script が必要な場合にだけ allow-scripts を明示します。
<template>
<iframe src="/embed" sandbox></iframe>
<iframe src="/embed" sandbox="allow-scripts"></iframe>
</template>
設定(Vite+)
import { defineConfig } from "@vizejs/vite-plugin/vite-plus";
export default defineConfig({}).withVue({
linter: {
"preset": "incremental",
"rules": {
"vue/no-unsandboxed-iframe": "warn"
}
},
});
設定したら vp run lint を実行します。