Skip to content

Commit 66862f0

Browse files
committed
2 parents 874c51f + 5aaa16f commit 66862f0

32 files changed

+32614
-8817
lines changed

.editorconfig

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
root = true
2+
3+
[*]
4+
insert_final_newline = true
5+
trim_trailing_whitespace = true
6+
charset = utf-8
7+
indent_style = space
8+
9+
[*.{js,cjs,mjs}]
10+
indent_style = space
11+
indent_size = 2
12+
13+
[*.json]
14+
indent_size = 2

.eslintrc.cjs

+221
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,221 @@
1+
module.exports = {
2+
root: true,
3+
parserOptions: {
4+
ecmaVersion: 2021,
5+
sourceType: 'script',
6+
},
7+
env: {
8+
node: true,
9+
},
10+
plugins: [
11+
'promise',
12+
],
13+
extends: [
14+
'eslint:recommended',
15+
'plugin:eslint-plugin/recommended',
16+
'plugin:node/recommended',
17+
'plugin:promise/recommended',
18+
],
19+
ignorePatterns: ['!.eslintrc.cjs'],
20+
rules: {
21+
'array-bracket-newline': [
22+
'error',
23+
'consistent',
24+
],
25+
'array-bracket-spacing': [
26+
'error',
27+
'never',
28+
],
29+
'arrow-parens': [
30+
'error',
31+
'always',
32+
],
33+
'arrow-spacing': 'error',
34+
'block-spacing': 'error',
35+
'brace-style': [
36+
'error',
37+
'1tbs',
38+
{
39+
'allowSingleLine': false,
40+
},
41+
],
42+
'function-paren-newline': [
43+
'error',
44+
'consistent',
45+
],
46+
'comma-dangle': [
47+
'error',
48+
'always-multiline',
49+
],
50+
'comma-spacing': 'error',
51+
'curly': [
52+
'error',
53+
'multi-line',
54+
'consistent',
55+
],
56+
'constructor-super': 'error',
57+
'default-case': 'error',
58+
'eol-last': 'error',
59+
'eqeqeq': [
60+
'error',
61+
'allow-null',
62+
],
63+
'indent': [
64+
'error',
65+
2,
66+
{
67+
// TODO: fix this, we shouldn't need to ignore TemplateLiterals
68+
'ignoredNodes': ['TemplateLiteral'],
69+
'SwitchCase': 1,
70+
'MemberExpression': 0,
71+
},
72+
],
73+
'key-spacing': 'error',
74+
'keyword-spacing': 'error',
75+
'no-buffer-constructor': 'error',
76+
'no-case-declarations': 'error',
77+
'no-class-assign': 'error',
78+
'no-cond-assign': 'error',
79+
'no-console': 'error',
80+
'no-const-assign': 'error',
81+
'no-constant-condition': 'error',
82+
'no-control-regex': 'error',
83+
'no-debugger': 'error',
84+
'no-delete-var': 'error',
85+
'no-dupe-class-members': 'error',
86+
'no-dupe-keys': 'error',
87+
'no-dupe-args': 'error',
88+
'no-duplicate-case': 'error',
89+
'no-duplicate-imports': 'error',
90+
'no-else-return': [
91+
'error',
92+
{
93+
'allowElseIf': false,
94+
},
95+
],
96+
'no-empty': 'error',
97+
'no-empty-character-class': 'error',
98+
'no-empty-pattern': 'error',
99+
'no-ex-assign': 'error',
100+
'no-extra-boolean-cast': 'error',
101+
'no-extra-semi': 'error',
102+
'no-fallthrough': 'error',
103+
'no-func-assign': 'error',
104+
'no-inner-declarations': 'error',
105+
'no-invalid-regexp': 'error',
106+
'no-irregular-whitespace': 'error',
107+
'no-mixed-spaces-and-tabs': 'error',
108+
'no-multiple-empty-lines': [
109+
'error',
110+
{
111+
'max': 1,
112+
'maxEOF': 0,
113+
'maxBOF': 0,
114+
},
115+
],
116+
'no-multi-spaces': 'error',
117+
'no-negated-in-lhs': 'error',
118+
'no-new-symbol': 'error',
119+
'no-obj-calls': 'error',
120+
'no-octal': 'error',
121+
'no-redeclare': 'error',
122+
'no-regex-spaces': 'error',
123+
'no-self-assign': 'error',
124+
'no-spaced-func': 'error',
125+
'no-sparse-arrays': 'error',
126+
'no-this-before-super': 'error',
127+
'no-trailing-spaces': 'error',
128+
'no-undef': 'error',
129+
'no-unexpected-multiline': 'error',
130+
'no-unneeded-ternary': 'error',
131+
'no-unreachable': 'error',
132+
'no-unused-labels': 'error',
133+
'no-unused-vars': ['error', {
134+
argsIgnorePattern: '^_',
135+
ignoreRestSiblings: true,
136+
varsIgnorePattern: '^_',
137+
}],
138+
'no-useless-concat': 'error',
139+
'no-useless-constructor': 'error',
140+
'no-var': 'error',
141+
'no-whitespace-before-property': 'error',
142+
'object-curly-spacing': [
143+
'error',
144+
'always',
145+
],
146+
'object-shorthand': 'error',
147+
'one-var': [
148+
'error',
149+
'never',
150+
],
151+
'padded-blocks': ['error', 'never'],
152+
'padding-line-between-statements': [
153+
'error',
154+
{
155+
'blankLine': 'always',
156+
'prev': '*',
157+
'next': 'return',
158+
},
159+
{
160+
'blankLine': 'always',
161+
'prev': [
162+
'const',
163+
'let',
164+
'var',
165+
'if',
166+
'while',
167+
'export',
168+
'cjs-export',
169+
'import',
170+
'cjs-import',
171+
'multiline-expression',
172+
],
173+
'next': '*',
174+
},
175+
{
176+
'blankLine': 'any',
177+
'prev': [
178+
'const',
179+
'let',
180+
'var',
181+
'import',
182+
'cjs-import',
183+
],
184+
'next': [
185+
'const',
186+
'let',
187+
'var',
188+
'import',
189+
'cjs-import',
190+
],
191+
},
192+
],
193+
'prefer-rest-params': 'error',
194+
'prefer-spread': 'error',
195+
'prefer-template': 'error',
196+
'quotes': [
197+
'error',
198+
'single',
199+
{
200+
'allowTemplateLiterals': true,
201+
},
202+
],
203+
'semi': [
204+
'error',
205+
'never',
206+
],
207+
'semi-spacing': 'error',
208+
'space-before-blocks': 'error',
209+
'space-before-function-paren': 'error',
210+
'space-in-parens': [
211+
'error',
212+
'never',
213+
],
214+
'space-infix-ops': 'error',
215+
'space-unary-ops': 'error',
216+
// TODO: change this back to 'error'
217+
'template-curly-spacing': 'off',
218+
'use-isnan': 'error',
219+
'valid-typeof': 'error',
220+
},
221+
}

.eslintrc.json

-8
This file was deleted.

.github/CODEOWNERS

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Each line is a file pattern followed by one or more owners.
2+
#
3+
# Order is important. The last matching pattern has the most precedence.
4+
# So if a pull request only touches javascript files, only these owners
5+
# will be requested to review.
6+
* @DamienCassou

.github/dependabot.yml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "npm"
4+
directory: "/"
5+
open-pull-requests-limit: 1000 # we don't want to limit PRs
6+
schedule:
7+
interval: "weekly"

.github/workflows/test.yml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Test
2+
3+
on:
4+
pull_request:
5+
branches: [ master ]
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
strategy:
11+
matrix:
12+
node-version: [lts/*]
13+
steps:
14+
- uses: actions/checkout@v3
15+
- name: Use Node.js ${{ matrix.node-version }}
16+
uses: actions/setup-node@v3
17+
with:
18+
node-version: ${{ matrix.node-version }}
19+
cache: 'npm'
20+
- run: npm install
21+
- run: npm run lint
22+
- run: npm run test
23+
- run: npm run test:v7

.ignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.git

README.md

+15-13
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Cypress ESLint Plugin [![CircleCI](https://circleci.com/gh/cypress-io/eslint-plugin-cypress/tree/master.svg?style=svg)](https://circleci.com/gh/cypress-io/eslint-plugin-cypress/tree/master)
1+
# Cypress ESLint Plugin [![Test](https://github.com/foretagsplatsen/eslint-plugin-cypress/actions/workflows/test.yml/badge.svg)](https://github.com/foretagsplatsen/eslint-plugin-cypress/actions/workflows/test.yml)
22

33
An [ESLint](https://eslint.org) plugin for your [Cypress](https://cypress.io) tests.
44

@@ -114,17 +114,18 @@ These rules enforce some of the [best practices recommended for using Cypress](h
114114

115115
Rules with a check mark (✅) are enabled by default while using the `plugin:cypress/recommended` config.
116116

117-
**NOTE**: These rules currently require eslint 5.0 or greater. If you would like support added for eslint 4.x, please 👍 [this issue](https://github.com/cypress-io/eslint-plugin-cypress/issues/14).
118-
119-
| | Rule ID | Description |
120-
| :-- | :------------------------------------------------------------------------- | :-------------------------------------------------------------- |
121-
|| [no-assigning-return-values](./docs/rules/no-assigning-return-values.md) | Prevent assigning return values of cy calls |
122-
|| [no-unnecessary-waiting](./docs/rules/no-unnecessary-waiting.md) | Prevent waiting for arbitrary time periods |
123-
|| [no-async-tests](./docs/rules/no-async-tests.md) | Prevent using async/await in Cypress test case |
124-
| | [no-force](./docs/rules/no-force.md) | Disallow using `force: true` with action commands |
125-
| | [assertion-before-screenshot](./docs/rules/assertion-before-screenshot.md) | Ensure screenshots are preceded by an assertion |
126-
| | [require-data-selectors](./docs/rules/require-data-selectors.md) | Only allow data-\* attribute selectors (require-data-selectors) |
127-
| | [no-pause](./docs/rules/no-pause.md) | Disallow `cy.pause()` parent command |
117+
| | Rule ID | Description |
118+
|:---|:-----------------------------------------------------------------------------------------|:----------------------------------------------------------------|
119+
|| [no-assigning-return-values](./docs/rules/no-assigning-return-values.md) | Prevent assigning return values of cy calls |
120+
|| [no-unnecessary-waiting](./docs/rules/no-unnecessary-waiting.md) | Prevent waiting for arbitrary time periods |
121+
|| [no-async-tests](./docs/rules/no-async-tests.md) | Prevent using async/await in Cypress test case |
122+
| | [no-force](./docs/rules/no-force.md) | Disallow using `force: true` with action commands |
123+
| | [assertion-before-screenshot](./docs/rules/assertion-before-screenshot.md) | Ensure screenshots are preceded by an assertion |
124+
| | [require-data-selectors](./docs/rules/require-data-selectors.md) | Only allow data-\* attribute selectors (require-data-selectors) |
125+
| | [no-pause](./docs/rules/no-pause.md) | Disallow `cy.pause()` parent command |
126+
| | [no-single-expect-in-then-or-should](./docs/rules/no-single-expect-in-then-or-should.md) | Simplify tests by avoiding lonely expect() |
127+
| | [no-expect-for-stub](./docs/rules/no-expect-for-stub.md) | Avoid expect(stub)… |
128+
| | [no-useless-then-or-should](./docs/rules/no-useless-then-or-should.md) | Avoid `.should()` and `.then()` when only wrapping commands |
128129

129130
## Chai and `no-unused-expressions`
130131

@@ -161,7 +162,8 @@ Or you can simply add its `recommended` config:
161162

162163
To add a new rule:
163164
* Fork and clone this repository
164-
* Generate a new rule (a [yeoman generator](https://github.com/eslint/generator-eslint) is available)
165+
* Install dependencies with `npm install`
166+
* Generate a new rule with `npm run make-rule`
165167
* Run `yarn start` or `npm start`
166168
* Write test scenarios then implement logic
167169
* Describe the rule in the generated `docs` file

0 commit comments

Comments
 (0)