Giter Club home page Giter Club logo

eslint-plugin-react-id-generator's Introduction

eslint-plugin-react-id-generator

Auto generated id values for jsx-expression. This plugin is very useful for writing auto-tests.

Table of contents

Quick start

npm install eslint --save-dev
./node-modules/.bin/eslint --init
npm install eslint-plugin-react-id-generator --save-dev

Status

npm Build Status

Usage

Basic configuration of .eslintrc looks like this

{
  "plugins": {
    "react-id-generator"
  },
  "rules": {
    "react-id-generator/jsx-id": "error"
  }
}

Now all you have to do is add qa-id attribute to required jsx-expression without filling it.

<MyComponent numVal={1} strVal="Michael" qa-id />

Now run ./node_modules/.bin/eslint --fix 'file_or_folder' and you'll get

<MyComponent numVal={1} strVal="Michael" qa-id="qa-id_f5d485d2995609cee081753ec9372b0e" />

The output hash value depends on tag name, attributes names and values and the type of the tag itself (whether it's self-closing or not).

Rule might be customized.

{
  "rules": {
    "jsx-id": [
        "error", 
        {
          "attribute": "my-id",
          "prefix": "pf",
          "divider": "@@@",
          "hashMaxLength": 7
        }
    ]
  }
}

The fix with such configuration will be different.

<MyComponent numVal={1} strVal="Michael" my-id />

After fix.

<MyComponent numVal={1} strVal="Michael" my-id="pf@@@d791bee" />

All of listed parameters can be omitted.

eslint-plugin-react-id-generator's People

Contributors

dependabot[bot] avatar simonharmonicminor avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

iremaksoy14

eslint-plugin-react-id-generator's Issues

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.