# eslint-plugin-cypress-strict

> Strict & opinionated ESLint rules for writing Cypress tests

Latest version **0.0.14** (published 2019-07-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install eslint-plugin-cypress-strict
pnpm add eslint-plugin-cypress-strict
yarn add eslint-plugin-cypress-strict
bun add eslint-plugin-cypress-strict
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.14 |
| Published | 2019-07-29 |
| First published | 2019-04-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.10.0 |
| Dependencies | 0 |
| Unpacked size | 14.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | strajk |
| Keywords | eslint, eslint-plugin, cypress |

## Links

- npm: https://www.npmjs.com/package/eslint-plugin-cypress-strict
- Repository: https://github.com/kiwicom/eslint-plugin-cypress-strict
- Homepage: https://github.com/kiwicom/eslint-plugin-cypress-strict#readme
- Issues: https://github.com/kiwicom/eslint-plugin-cypress-strict/issues
- npm.io page: https://npm.io/package/eslint-plugin-cypress-strict

## Alternatives

- [eslint-plugin-sonarjs](https://npm.io/package/eslint-plugin-sonarjs.md) — 2.9M weekly downloads
- [eslint-config-expo](https://npm.io/package/eslint-config-expo.md) — 1.5M weekly downloads
- [@matter/protocol](https://npm.io/package/@matter/protocol.md) — 63.5K weekly downloads
- [@eventcatalog/linter](https://npm.io/package/@eventcatalog/linter.md) — 24.8K weekly downloads
- [@pandacss/eslint-plugin](https://npm.io/package/@pandacss/eslint-plugin.md) — 18.7K weekly downloads

## Recent versions

- 0.0.14 (latest) — 2019-07-29
- 0.0.13 — 2019-05-24
- 0.0.12 — 2019-05-23
- 0.0.10 — 2019-05-02
- 0.0.9 — 2019-04-11
- 0.0.7 — 2019-04-11
- 0.0.6 — 2019-04-10
- 0.0.5 — 2019-04-10
- 0.0.4 — 2019-04-10
- 0.0.2 — 2019-04-10

## README

<!-- [![CircleCI](https://circleci.com/gh/strajk/eslint-plugin-cypress-strict.svg?style=svg)](https://circleci.com/gh/strajk/eslint-plugin-cypress-strict) -->
<!-- [![Coverage Status](https://coveralls.io/repos/github/strajk/eslint-plugin-cypress-strict/badge.svg?branch=master)](https://coveralls.io/github/strajk/eslint-plugin-cypress-strict?branch=master) -->

<center>

# eslint-plugin-cypress-strict

🤘 Opinionated ESLint rules for writing [Cypress.io](https://www.cypress.io/) tests 🤘

</center>

## Installation & Setup

**Install**

```bash
# with NPM
npm i -D eslint-plugin-cypress-strict

# or Yarn
yarn add -D eslint-plugin-cypress-strict
```
**Setup** – adjust your `.eslintrc`

Option A: Via extends – this will add the plugin and use all the rules automatically

```
"extends": [ "plugin:cypress-strict/recommended" ]
```

Option B: Add the plugin and list individual rules manually

```
plugins: [ "cypress-strict" ]
rules: {
  "cypress-strict/»rule name«": "error"
}
```

## Supported Rules

### CSS selectors over commands `cypress-strict/selectors-over-commands`

Prefer whole selectors directly inside `cy.get(»selector«)` instead of using Cypress commands.

**Why?**
When whole selector is in one string, it's easier to copy-paste it and debug it in Cypress playground / Dev Tools.

| 😐                                    | 🤩                                |
| ------------------------------------- | --------------------------------- |
| `cy.get("button").first()`            | `cy.get("button:first")`          |
| `cy.get("button").eq(3)`              | `cy.get("button:eq(3)")`          |
| `cy.get("button").not(".unwanted")`   | `cy.get("button:not(.unwanted)")` |
| `cy.get("»modal«").find(»close btn«)` | `cy.get("»modal« »close btn«")`   |
| `cy.get("tr").filter(".odd")`         | `cy.get("tr.odd")`                |


### Subject-less commands chained directly on cy `cypress-strict/subjectless-commands-directly-on-cy`

**Why?**
Chained commands can cause impression that they are working with previous results.

`cy.get(".parent").get(".child")` – Looks like it's selecting `.child` inside `.parent`

`cy.get("…").wait(5000)` - Looks like it's waiting 5s for the element...

### "Should be" instead of "should to be" `cypress-strict/no-should-to-be`

**Why?**
Should to be is [incorrect](https://www.oxfordlearnersdictionaries.com/us/definition/american_english/should) 


---

## Contributing

🙏 🙏 🙏 Issues/PRs/gratitude is welcome 🙏 🙏 🙏


#### Development tips

##### Publish

```
npx pack publish
```

##### Link locally

In this project

```
npx pack build
cd pkg
yarn link 
cd ..
# after changes
npx pack build
```

In dependant projects

```
yarn link "eslint-plugin-cypress-strict"
```

---
_Source: https://npm.io/package/eslint-plugin-cypress-strict · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
