sveltejs / eslint-plugin-svelte

ESLint plugin for Svelte using AST
https://sveltejs.github.io/eslint-plugin-svelte/
MIT License
298 stars 36 forks source link

Add rule to disallow inline styles #603

Closed marekdedic closed 11 months ago

marekdedic commented 11 months ago

Motivation

When using CSP, you often want to disallow inline styles (to not have style-src: 'unsafe-inline'), I'd like to add a rule that checks this automatically

Description

The rule would look for any directive producing inline styles and error on them.

Additionaly, using svelte transitions generates inline styles (although that may change in the future if/when svelte migrates to teh web animations - see sveltejs/svelte#6662), so this rule should probably ban using them altogether (gated with a configuration option probably?)

Examples

<!-- ✗ BAD -->
<div style="anything" />
<div style:anything={true} />
<div transition:anything />

Additional comments

No response

ota-meshi commented 11 months ago

Thank you for suggesting new rules! That rule sounds good to me!