Skip to content

Commit

Permalink
Add cypress config
Browse files Browse the repository at this point in the history
  • Loading branch information
burtek committed Jun 22, 2023
1 parent 5f8985f commit 10c58f8
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 55 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ The configuration object can contain following keys:
- lodash
- node
- react
- cypress

### TODO: Docs

<!-- Configuration key | schema | plugins in use | description
Expand Down
35 changes: 35 additions & 0 deletions configs/cypress.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/* eslint no-warning-comments: 1 */
import { defineFlatConfig } from 'eslint-define-config';
import cypress from 'eslint-plugin-cypress';
import globals from 'globals';


const files = ['**/*.cy.{js,cjs,mjs,jsx,ts,cts,mts,tsx}'];

export function prepareConfig() {
return defineFlatConfig([
{
files,
plugins: { cypress: { rules: cypress.rules } },
languageOptions: {
globals: {
...cypress.environments.globals,
...globals.browser,
...globals.mocha
}
},
rules: {
'cypress/no-assigning-return-values': 'error',
'cypress/no-unnecessary-waiting': 'error',
'cypress/assertion-before-screenshot': 'warn',
'cypress/no-force': 'warn',
'cypress/no-async-tests': 'error',
'cypress/no-pause': 'error',
'cypress/unsafe-to-chain-command': 'error',

'no-unused-expressions': 'warn', // TODO: chai-friendly
'@typescript-eslint/no-unused-expressions': 'warn' // TODO: chai-friendly
}
}
]);
}
2 changes: 2 additions & 0 deletions configs/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { defineFlatConfig } from 'eslint-define-config';

import { prepareConfig as base } from './base.js';
import { prepareConfig as cypress } from './cypress.js';
import { prepareConfig as jest } from './jest.js';
import { prepareConfig as json } from './json.js';
import { prepareConfig as lodash } from './lodash.js';
Expand All @@ -10,6 +11,7 @@ import { prepareConfig as react } from './react.js';
/** @satisfies {Record<string, (config?: any) => import('eslint-define-config').FlatESLintConfig[]>} */
export const configs = {
base,
cypress,
jest,
json,
lodash,
Expand Down
21 changes: 21 additions & 0 deletions import-types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,24 @@ declare module 'eslint-plugin-security-node' {

export default plugin;
}

declare module 'eslint-plugin-cypress' {
import type { Rule } from 'eslint';
import type { LanguageOptions } from 'eslint-define-config';
import type { Severity } from 'eslint-define-config/src/rules/rule-severity.js';


const plugin: {
configs: {
recommended: {
rules: Record<string, Severity>;
};
};
environments: {
globals: LanguageOptions['globals'];
};
rules: Record<string, Rule.RuleModule>;
};

export default plugin;
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"@typescript-eslint/parser": "^5.59.6",
"eslint-define-config": "^1.20.0",
"eslint-import-resolver-typescript": "^3.5.5",
"eslint-plugin-cypress": "^2.13.3",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jest": "^27.2.1",
"eslint-plugin-jest-formatting": "^3.1.0",
Expand Down
74 changes: 19 additions & 55 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@
resolved "https://registry.yarnpkg.com/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz#b520529ec21d8e5945a1851dfd1c32e94e39ff45"
integrity sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==

"@next/eslint-plugin-next@^12.2.3":
version "12.3.4"
resolved "https://registry.yarnpkg.com/@next/eslint-plugin-next/-/eslint-plugin-next-12.3.4.tgz#e7dc00e2e89ed361f111d687b8534483ec15518b"
integrity sha512-BFwj8ykJY+zc1/jWANsDprDIu2MgwPOIKxNVnrKvPs+f5TPegrVnem8uScND+1veT4B7F6VeqgaNLFW1Hzl9Og==
"@next/eslint-plugin-next@^13.4.2":
version "13.4.7"
resolved "https://registry.yarnpkg.com/@next/eslint-plugin-next/-/eslint-plugin-next-13.4.7.tgz#7efeff2af76be0d9a176a957da21e3710b2e79cf"
integrity sha512-ANEPltxzXbyyG7CvqxdY4PmeM5+RyWdAJGufTHnU+LA/i3J6IDV2r8Z4onKwskwKEhwqzz5lMaSYGGXLyHX+mg==
dependencies:
glob "7.1.7"

Expand Down Expand Up @@ -154,14 +154,6 @@
"@typescript-eslint/typescript-estree" "5.59.6"
debug "^4.3.4"

"@typescript-eslint/scope-manager@5.59.5":
version "5.59.5"
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.59.5.tgz#33ffc7e8663f42cfaac873de65ebf65d2bce674d"
integrity sha512-jVecWwnkX6ZgutF+DovbBJirZcAxgxC0EOHYt/niMROf8p4PwxxG32Qdhj/iIQQIuOflLjNkxoXyArkcIP7C3A==
dependencies:
"@typescript-eslint/types" "5.59.5"
"@typescript-eslint/visitor-keys" "5.59.5"

"@typescript-eslint/scope-manager@5.59.6":
version "5.59.6"
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.59.6.tgz#d43a3687aa4433868527cfe797eb267c6be35f19"
Expand All @@ -180,29 +172,11 @@
debug "^4.3.4"
tsutils "^3.21.0"

"@typescript-eslint/types@5.59.5":
version "5.59.5"
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.59.5.tgz#e63c5952532306d97c6ea432cee0981f6d2258c7"
integrity sha512-xkfRPHbqSH4Ggx4eHRIO/eGL8XL4Ysb4woL8c87YuAo8Md7AUjyWKa9YMwTL519SyDPrfEgKdewjkxNCVeJW7w==

"@typescript-eslint/types@5.59.6":
version "5.59.6"
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.59.6.tgz#5a6557a772af044afe890d77c6a07e8c23c2460b"
integrity sha512-tH5lBXZI7T2MOUgOWFdVNUILsI02shyQvfzG9EJkoONWugCG77NDDa1EeDGw7oJ5IvsTAAGVV8I3Tk2PNu9QfA==

"@typescript-eslint/typescript-estree@5.59.5":
version "5.59.5"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.59.5.tgz#9b252ce55dd765e972a7a2f99233c439c5101e42"
integrity sha512-+XXdLN2CZLZcD/mO7mQtJMvCkzRfmODbeSKuMY/yXbGkzvA9rJyDY5qDYNoiz2kP/dmyAxXquL2BvLQLJFPQIg==
dependencies:
"@typescript-eslint/types" "5.59.5"
"@typescript-eslint/visitor-keys" "5.59.5"
debug "^4.3.4"
globby "^11.1.0"
is-glob "^4.0.3"
semver "^7.3.7"
tsutils "^3.21.0"

"@typescript-eslint/typescript-estree@5.59.6":
version "5.59.6"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.59.6.tgz#2fb80522687bd3825504925ea7e1b8de7bb6251b"
Expand All @@ -216,7 +190,7 @@
semver "^7.3.7"
tsutils "^3.21.0"

"@typescript-eslint/utils@5.59.6":
"@typescript-eslint/utils@5.59.6", "@typescript-eslint/utils@^5.10.0":
version "5.59.6"
resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.59.6.tgz#82960fe23788113fc3b1f9d4663d6773b7907839"
integrity sha512-vzaaD6EXbTS29cVH0JjXBdzMt6VBlv+hE31XktDRMX1j3462wZCJa7VzO2AxXEXcIl8GQqZPcOPuW/Z1tZVogg==
Expand All @@ -230,28 +204,6 @@
eslint-scope "^5.1.1"
semver "^7.3.7"

"@typescript-eslint/utils@^5.10.0":
version "5.59.5"
resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.59.5.tgz#15b3eb619bb223302e60413adb0accd29c32bcae"
integrity sha512-sCEHOiw+RbyTii9c3/qN74hYDPNORb8yWCoPLmB7BIflhplJ65u2PBpdRla12e3SSTJ2erRkPjz7ngLHhUegxA==
dependencies:
"@eslint-community/eslint-utils" "^4.2.0"
"@types/json-schema" "^7.0.9"
"@types/semver" "^7.3.12"
"@typescript-eslint/scope-manager" "5.59.5"
"@typescript-eslint/types" "5.59.5"
"@typescript-eslint/typescript-estree" "5.59.5"
eslint-scope "^5.1.1"
semver "^7.3.7"

"@typescript-eslint/visitor-keys@5.59.5":
version "5.59.5"
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.59.5.tgz#ba5b8d6791a13cf9fea6716af1e7626434b29b9b"
integrity sha512-qL+Oz+dbeBRTeyJTIy0eniD3uvqU7x+y1QceBismZ41hd4aBSRh8UAw4pZP0+XzLuPZmx4raNMq/I+59W2lXKA==
dependencies:
"@typescript-eslint/types" "5.59.5"
eslint-visitor-keys "^3.3.0"

"@typescript-eslint/visitor-keys@5.59.6":
version "5.59.6"
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.59.6.tgz#673fccabf28943847d0c8e9e8d008e3ada7be6bb"
Expand Down Expand Up @@ -723,6 +675,13 @@ eslint-module-utils@^2.7.4:
dependencies:
debug "^3.2.7"

eslint-plugin-cypress@^2.13.3:
version "2.13.3"
resolved "https://registry.yarnpkg.com/eslint-plugin-cypress/-/eslint-plugin-cypress-2.13.3.tgz#5fc1afdc939aaa7daa9181f651f2f35429733ff2"
integrity sha512-nAPjZE5WopCsgJwl3vHm5iafpV+ZRO76Z9hMyRygWhmg5ODXDPd+9MaPl7kdJ2azj+sO87H3P1PRnggIrz848g==
dependencies:
globals "^11.12.0"

eslint-plugin-es-x@^6.1.0:
version "6.1.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-es-x/-/eslint-plugin-es-x-6.1.0.tgz#d7b97f34775c34117a0f3dc256b74c3a1543d37c"
Expand Down Expand Up @@ -826,7 +785,7 @@ eslint-plugin-react-hooks@^4.5.0:
resolved "https://registry.yarnpkg.com/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-4.6.0.tgz#4c3e697ad95b77e93f8646aaa1630c1ba607edd3"
integrity sha512-oFc7Itz9Qxh2x4gNHStv3BqJq54ExXmfC+a1NjAta66IAN87Wu0R/QArgIS9qKzX3dXKPI9H5crl9QchNMY9+g==

eslint-plugin-react@^7.30.1:
eslint-plugin-react@^7.32.2:
version "7.32.2"
resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-7.32.2.tgz#e71f21c7c265ebce01bcbc9d0955170c55571f10"
integrity sha512-t2fBMa+XzonrrNkyVirzKlvn5RXzzPwRHtMvLAtVZrt8oxgnTQaYbU6SXTOO1mwQgp1y5+toMSKInnzGr0Knqg==
Expand Down Expand Up @@ -1157,6 +1116,11 @@ glob@^7.1.3:
once "^1.3.0"
path-is-absolute "^1.0.0"

globals@^11.12.0:
version "11.12.0"
resolved "https://registry.yarnpkg.com/globals/-/globals-11.12.0.tgz#ab8795338868a0babd8525758018c2a7eb95c42e"
integrity sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==

globals@^13.19.0, globals@^13.20.0:
version "13.20.0"
resolved "https://registry.yarnpkg.com/globals/-/globals-13.20.0.tgz#ea276a1e508ffd4f1612888f9d1bad1e2717bf82"
Expand Down Expand Up @@ -1552,7 +1516,7 @@ json5@^1.0.2:
dependencies:
minimist "^1.2.0"

jsonc-eslint-parser@^2.0.4, jsonc-eslint-parser@^2.2.0:
jsonc-eslint-parser@^2.0.4, jsonc-eslint-parser@^2.3.0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/jsonc-eslint-parser/-/jsonc-eslint-parser-2.3.0.tgz#7c2de97d01bff7227cbef2f25d1025d42a36198b"
integrity sha512-9xZPKVYp9DxnM3sd1yAsh/d59iIaswDkai8oTxbursfKYbg/ibjX0IzFt35+VZ8iEW453TVTXztnRvYUQlAfUQ==
Expand Down

0 comments on commit 10c58f8

Please sign in to comment.