Skip to content

Rule proposal: vue/no-inline-styles #826

@cde06

Description

@cde06

Please describe what the rule should do:

This rule detect inline styles in components.
It's (subjectively) a good practice to separate styles from the view layout, when possible. This rule detects static inline style objects when they contain literal values. v-bind:style and :style are acceptable because it's sometimes necessary to set styles based on data, computed property or methods result.

What category should the rule belong to?

  • Enforces code style
  • Warns about a potential error
  • Suggests an alternate way of doing something
  • Other (please specify:)

Provide 2-3 code examples that this rule should warn about:

The following pattern is considered a warning:

<span style="background-color: #FFF">Hello {{ name }}</span>;

The following patterns are not considered a warning::

<span :style="background-color: color }">Hello {{ name }}</span>;
<span v-bind:style="background-color: color }">Hello {{ name }}</span>;

Additional context
The rule enforce team members to use SFC <style scope> instead of inline style attributes.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions