GithubHelp home page GithubHelp logo

matheusrocha89 / eslint-plugin-jsx-control-statements Goto Github PK

View Code? Open in Web Editor NEW

This project forked from vkbansal/eslint-plugin-jsx-control-statements

0.0 2.0 0.0 57 KB

ESLint plugin for JSX-Control-Statements (https://github.com/AlexGilleran/jsx-control-statements)

JavaScript 100.00%

eslint-plugin-jsx-control-statements's Introduction

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-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
  }
}

List of supported rules

  • jsx-choose-not-empty: Warn when Choose tag is empty or does not have at least one When tag as child.
  • jsx-for-require-each: Warn if For tag is missing each attribute. And also marks the variable as defined.
  • jsx-for-require-of: Warn if For tag is missing of attribute.
  • jsx-if-require-condition: Warn if If tag is missing condition attribute.
  • jsx-otherwise-once-last: Warn when Otherwise tag is used more than once inside Choose and is not last child.
  • jsx-use-if-tag: Use If tag instead of ternary operator.
  • jsx-when-require-condition: Warn if When tag is missing condition attribute.
  • jsx-jcs-no-undef: Replaces the built-in no-undef rule with one that is tolerant of variables expressed in <For> (each and index attributes) and <With>. Note that to stop getting errors from no-undef you have to turn it off and this on.

Credits

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

License

MIT License. Copyright(c) Vivek Kumar Bansal

eslint-plugin-jsx-control-statements's People

Contributors

alexgilleran avatar gabiaxel avatar jurgob avatar martinmacko47 avatar vkbansal avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.