# no-invalid-integrity
📝 Disallow invalid subresource integrity metadata.
💼 This rule is enabled in the following [configs](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config): ✅ `recommended`, 🌐 `recommended-html`, ☑️ `unopinionated`.
Validates existing `integrity` attributes on HTML and native JSX `
```
```jsx
// ❌
;
// ✅
const integrity = 'sha256-LPJNul+wow4m6DsqxbninhsWHlwfp0JecwQzYpOLmCQ=';
;
```
## Accepted metadata
Recognized entries use lowercase `algorithm-base64` with these unpadded lengths:
| Algorithm | Material | Bytes | Base64 characters, excluding padding |
| --- | --- | --- | --- |
| `sha256` | Digest | 32 | 43 |
| `sha384` | Digest | 48 | 64 |
| `sha512` | Digest | 64 | 86 |
| `ed25519` | Public key | 32 | 43 |
Standard (`+`, `/`) and URL-safe (`-`, `_`) base64 alphabets, including mixtures, are accepted with zero to two trailing `=` characters. Canonical padding and unused trailing bits are not checked.
Separate entries with HTML ASCII whitespace (space, tab, LF, FF, or CR). Empty and whitespace-only values are allowed. An optional `?options` suffix may be empty or contain ASCII `!` through `~`, including additional `?`; options are not interpreted.
Every malformed recognized entry is reported, even beside a valid or stronger hash. Unknown entries are allowed if a recognized algorithm is present; otherwise, nonempty metadata is reported.
Based on the [SRI grammar](https://www.w3.org/TR/sri/#parse-metadata), [CSP base64 grammar](https://w3c.github.io/webappsec-csp/#grammardef-base64-value), and [signature-based integrity metadata](https://wicg.github.io/signature-based-sri/).
## Static values
HTML names are case-insensitive and character references are decoded. Checks the first `integrity` attribute. Ignores markup inside `