Coder Social home page Coder Social logo

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

View Code? Open in Web Editor NEW
11.0 11.0 2.0 214 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 eslint-plugin eslint-plugin-vue javascript lint vuejs

eslint-plugin-test-id's Introduction

Hello ๐Ÿ‘‹

eslint-plugin-test-id's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar prashantswami avatar rwpswami avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

dongcx mattlaurie

eslint-plugin-test-id's Issues

Prefer `id` for unique selectors

There are a number of cases where having a unique id on an HTML element can be beneficial or downright necessary for accessibility. In general, it's a best-practice to include id on elements that you might want to link to (header elements) and interactive elements (form controls).

In these cases where we already have a unique id on an element, it shouldn't be necessary to include data-test-id (since we can reliably select the element by id instead). My main concern is driving the right behavior - we should make sure that we're including id when necessary and not relying on a data- attribute to identity those elements. This plugin wouldn't necessarily force you to include an id, but if you already had it, you just wouldn't hit this rule. Secondary, extra data- attributes do add some bloat to the code / bundle. If there are places where we don't need them, it would be great to not have to include them. Kent C. Dodds also suggests only using a "test id" attribute when other options are exhausted (in his case, Testing Library queries, but that advice can apply to any method of selecting).

My proposal is to add some logic to the plugin to ignore elements that already have an id attribute/prop, and not require data-test-id on those. Curious how others feel about this - let me know your thoughts!

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.