Skip to content

require-sri

Reports a <script src> and a <link rel="stylesheet" href> with no integrity attribute.

A file loaded from a CDN or another server can change after the page was written, and the page then runs or applies the changed file without noticing.

To fix, add integrity with the hash of the file and crossorigin="anonymous".

Reported
<!DOCTYPE html>
<title>x</title>
<script src="https://cdn.example/a.js"></script>
<script src="https://cdn.example/b.js" integrity="sha384-x" crossorigin="anonymous"></script>
<script src="a.js"></script>
<link rel="stylesheet" href="https://cdn.example/a.css">
<link rel="stylesheet" href="a.css">
<link rel="icon" href="https://cdn.example/a.png">
angular:
lint:
rules:
require-sri: warn # off (default), warn, error
html:
lint:
rules:
require-sri: warn # off (default), warn, error
svelte:
lint:
rules:
require-sri: warn # off (default), warn, error
vue:
lint:
rules:
require-sri: warn # off (default), warn, error

Suppress one line with sudsy-disable-next-line require-sri in a comment of the file’s language.

The same check in other tools. full: Sudsy reports what the upstream rule reports; partial: only part of it, as the last column says.

Tool Rule Match What differs
html-validate require-sri partial no target, include and exclude options