Skip to content

redundant-type-attr

Added in NEXT_DJANGOFMT_VERSION · Related issues · View source

Fix is always available.

What it does

Checks for redundant type attributes on <script> and <style> tags.

Why is this bad?

Since HTML5, <script> defaults to type="text/javascript" and <style> defaults to type="text/css". Specifying these default values is redundant and adds unnecessary noise.

Non-default types (e.g., module, text/less, application/ld+json) are excluded by value comparison; values containing template interpolation are skipped explicitly.

Example

<script type="text/javascript" src="app.js"></script>
<style type="text/css">.foo { color: red; }</style>

Use instead:

<script src="app.js"></script>
<style>.foo { color: red; }</style>

Fix safety

This rule's fix is marked as safe: removing a type attribute whose value matches the HTML5 default for the tag preserves runtime semantics.

References