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

eslint-plugin-no-inline-styles

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-no-inline-styles

ESLint for no inline styles allowed

  • 1.0.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
43K
increased by12.89%
Maintainers
1
Weekly downloads
 
Created
Source

ESLinting to avoid inline styles

Installation

You'll first need to install ESLint:

$ npm i eslint --save-dev

Next, install npm i eslint-plugin-no-inline-styles:

$ npm install eslint-plugin-no-inline-styles --save-dev

Note: If you installed ESLint globally (using the -g flag) then you must also install npm i eslint-plugin-no-inline-styles globally.

Usage

Add eslint-plugin-no-inline-styles to the plugins section of your .eslintrc configuration file. You can omit the eslint-plugin- prefix:

{
    "plugins": [
        "eslint-plugin-no-inline-styles"
    ]
}

Then configure the rules you want to use under the rules section.

{
    "rules": {
        "no-inline-styles/no-inline-styles": 2
    }
}

You can change rule from 2 to 1 which is worning or you can disable with zero.

Checks inline styles for React app

@no-inline-styles

This is a rule to dissallow inline styling.

Rule Details

This rule aims to dissallow inline styling where it appear in style attribute in react app.

Examples oforf incorrect code for this rule:

class Component extends React.Component {
  render() {
    <div>
      <span style={{ height: 40 }}>I am having style attribute</span>
    </div>;
  }
}

Examples for correct code for this rule:

class Component extends React.Component {
  render() {
    <div>
      <span className="classname">I don't have style attribute</span>
    </div>;
  }
}

Examples for hack the rule: use the string literals

class Component extends React.Component {
  render() {
    <div>
      <span style={{ "width": "50%" }}>I am having style attribute but I can render now</span>
    </div>;
  }
}

Keywords

FAQs

Package last updated on 11 Dec 2019

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