Coder Social home page Coder Social logo

dongcx / eslint-plugin-test-id Goto Github PK

View Code? Open in Web Editor NEW

This project forked from prashantswami/eslint-plugin-test-id

0.0 0.0 0.0 148 KB

This is rule of eslint plugin for vue templates which checks element with model has `data-test-id`

Home Page: https://prashantswami.github.io/eslint-plugin-test-id/

License: MIT License

JavaScript 100.00%

eslint-plugin-test-id's Introduction

status

eslint-plugin-test-id

This checks is data-test-id prop is present, on some tags which are useful for e2e testing

Installation

You'll first need to install ESLint:

$ npm i eslint --save-dev

Next, install @dongcx0319/eslint-plugin-testid:

$ npm install @dongcx0319/eslint-plugin-testid --save-dev

Usage

Add test-id to the plugins section of your .eslintrc configuration file. You can omit the eslint-plugin- prefix:

{
    "plugins": [
        "test-id"
    ]
}

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

{
    "rules": {
        "test-id/data-test-id": 'error'
    }
}

You can also enable all the recommended rules at once:

{
  "extends": [
    "plugin:test-id/recommended"
  ]
}

Rule Details

This rule aims to...

Examples of incorrect code for this rule:

<input v-model="someModel">

Examples of correct code for this rule:

<input data-test-id="someUniqueString" v-model="someModel">

How Fix will work

Scenario 1

<template><custom v-model="test" /></template>

will fix to

<template><input data-test-id="test" v-model="test"></template>

Scenario 2

<template><input v-model="test.again.src"></template>

will fix to

<template><custom data-test-id="test.again.src" v-model="test.again.src" /></template>

Scenario 3

<template><custom v-model="test.again" /></template>

will fix to

<template><custom data-test-id="test.again" v-model="test.again" /></template>

Scenario 4

<template><custom v-model="test['again']" /></template>

will fix to

<template><custom data-test-id="test.again" v-model="test['again']" /></template>

Scenario 5

<template><custom v-model="test[5]" /></template>

will fix to

<template><custom data-test-id="test.5" v-model="test[5]" /></template>

Scenario 5

<template><custom v-model="test[5]['val']" /></template>

will fix to

<template><custom data-test-id="test.5.val" v-model="test[5]['val']" /></template>

eslint-plugin-test-id's People

Contributors

prashantswami avatar dependabot[bot] avatar dependabot-preview[bot] avatar rwpswami avatar dongcx 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.