Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@hint/hint-no-inline-styles

Package Overview
Dependencies
Maintainers
5
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hint/hint-no-inline-styles

Invalidate the use of CSS inline styles in HTML

  • 1.0.19
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
18K
decreased by-7.61%
Maintainers
5
Weekly downloads
 
Created
Source

No Inline CSS Styles

This hint checks if the HTML is using inline CSS styles.

Why is this important?

The use of inline CSS styles prevent the reuse of the styles anywhere else. The html markup of the page becomes hard to read for the naked eye. The inline CSS styles are hard to maintain and does not provide consistency since they are not stored in a single place. The inline styles are repeated downloaded by the client on every request since it does not provide you with browser cache advantage. Inline styles take precedence of external stylesheets, this could accidentally override styles that you did not intend to overwrite.

What does the hint check?

This hint checks if the HTML is using inline CSS styles.

Examples of inline CSS styles

<div style="color: blue;"></div>

<style></style>

It checks that no element has the attribute style. It also checks that no internal styles <style> is used.

Examples that trigger the hint

The hint will trigger if any element have the attribute style

<div style="color: blue;"></div>

The hint will trigger if you use internal styles, this is disabled by default

<style>
    div {
        color: blue;
    }
</style>

Examples that pass the hint

No inline style in the element

<!DOCTYPE html>
<html lang="en">
    <head>
        ...
    </head>
    <body>
        ...
        <div>Hi styles</div>
    </body>
</html>

Can the hint be configured?

requireNoStyleElement can be set to true to disallow and require the use of no style tag.

In the .hintrc file:

{
    "connector": {...},
    "formatters": [...],
    "hints": {
        "no-inline-styles": [ "warning", {
            "requireNoStyleElement": true
        }],
        ...
    },
    ...
}

How to use this hint?

Install this hint with:

npm install @hint/hint-no-inline-styles --save-dev

To use it, activate it via the .hintrc configuration file:

{
    "connector": {...},
    "formatters": [...],
    "parsers": [...],
    "hints": {
        "no-inline-styles": "error",
        ...
    },
    ...
}

Further Reading

Keywords

FAQs

Package last updated on 29 Aug 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc