Socket
Socket
Sign inDemoInstall

eslint-plugin-jsx-control-statements

Package Overview
Dependencies
88
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    eslint-plugin-jsx-control-statements

jsx-control-statements specific linting rules for ESLint


Version published
Weekly downloads
12K
decreased by-20.27%
Maintainers
1
Install size
24.1 kB
Created
Weekly downloads
 

Changelog

Source

v3.0.0

Added

  • Rule for <For/> body prop

Security

  • Updated packages to latest versions.

Readme

Source

ESLint-plugin-JSX-control-statements

NPM version Build Status Dependency Status Coverage Status Code Climate

Installation

Install ESLint either locally or globally.

$ npm install eslint

If you installed ESLint globally, you have to install React plugin globally too. Otherwise, install it locally.

$ npm install eslint-plugin-jsx-control-statements

Configuration (Simple)

Add plugins section and specify ESLint-plugin-JSX-Control-Statements as a plugin and plugin:jsx-control-statements/recommended to "extends"

{
  "plugins": [
    "jsx-control-statements"
  ],
  "extends": ["plugin:jsx-control-statements/recommended"]
}

If it is not already the case you must also configure ESLint to support JSX.

{
  "ecmaFeatures": {
    "jsx": true
  }
}

Configuration (Advanced)

The plugin comes with a number of rules and an environment that sets the control statements (<If>, <For> etc) as global variables:

{
  "rules": {
    "jsx-control-statements/jsx-choose-not-empty": 1,
    "jsx-control-statements/jsx-for-require-each": 1,
    "jsx-control-statements/jsx-for-require-of": 1,
    "jsx-control-statements/jsx-for-require-body": 1,
    "jsx-control-statements/jsx-if-require-condition": 1,
    "jsx-control-statements/jsx-otherwise-once-last": 1,
    "jsx-control-statements/jsx-use-if-tag": 1,
    "jsx-control-statements/jsx-when-require-condition": 1,
    "jsx-control-statements/jsx-jcs-no-undef": 1,
    "no-undef": 0 // Replace this with jsx-jcs-no-undef
  },
  env: {
    "jsx-control-statements/jsx-control-statements": true
  }
}

Important:

After version 7.0.0 of eslint-plugin-react the rule react/jsx-no-undef it's not checking globals by default anymore. So you need to enable this to avoid lint errors telling that "If", "Choose", etc. are not defined. To fix this add to your rules:

 {
   "rules": {
     "react/jsx-no-undef": [2, { "allowGlobals": true }]
   }
    
 }

List of supported rules

Credits

Thanks to @yannickcr for his awesome eslint-plugin-react.

License

MIT License. Copyright(c) Vivek Kumar Bansal

Keywords

FAQs

Last updated on 09 May 2022

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc