Skip to content

Latest commit

 

History

History
31 lines (22 loc) · 897 Bytes

require-script-integrity.md

File metadata and controls

31 lines (22 loc) · 897 Bytes

Require integrity attribute at <script> tag (@morgan-stanley/externalincludes/require-script-integrity)

⚠️ This rule warns in the ✅ recommended config.

Valid

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.0/jquery.min.js" integrity_no="sha512-3gJwYpMe3QewGELv8k/BX9vcqhryRdzRMxVfq6ngyWXwo03GFEzjsUm8Q7RZcHPHksttq7/GFoxjCVUjkjvPdw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>

Invalid

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.0/jquery.min.js" crossorigin="anonymous" referrerpolicy="no-referrer"></script>

Options

ignoredDomains

You can provide an array of allowed domains that are ignored.

  rules: {
    "externalincludes/require-script-integrity": [
      "error",
      { ignoreDomains: ["cdnjs.cloudflare.com"] }
    ],
  }