Skip to content

Rule proposal: prefer-extension-over-mime #2914

@RND332

Description

@RND332

Description

If the MIME type is not strictly accurate, suggest using a specific file extension.

Examples

// ❌
<input type="file" accept="image/x-icon" />

// ✅
<input type="file" accept=".ico" />
// ❌
<input type="file" accept="application/x-rar-compressed" />

// ✅
<input type="file" accept=".rar" />
// ❌
<input type="file" accept="application/x-zip-compressed" />

// ✅
<input type="file" accept=".zip" />
// ❌
const input = document.createElement('input');
input.type = 'file';
input.setAttribute('accept', 'image/x-icon');
// Or: input.accept = 'image/x-icon';

// ✅
input.setAttribute('accept', '.ico');
// Or: input.accept = '.ico';

Proposed rule name

prefer-extension-over-mime

Additional Info

example of "bad" MIME type: https://en.wikipedia.org/wiki/ICO_(file_format)#MIME_type

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions