diff --git a/.eslintrc.js b/.eslintrc.js index 17e19978..0395226b 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -89,6 +89,11 @@ module.exports = { ] }, rules: { + // Todo: Figure out why this is not enough to disable warning + // for examples + // Used in examples of assert-close.js plugin + 'mocha-cleanup/no-assertions-outside-it': 'off', + 'eol-last': ['off'], 'no-console': ['off'], 'no-undef': ['off'], @@ -245,8 +250,11 @@ module.exports = { extends: [ 'plugin:cypress/recommended', 'plugin:mocha/recommended', - 'plugin:chai-friendly/recommended', - 'plugin:chai-expect/recommended' + 'plugin:mocha-cleanup/recommended-no-limits', + 'plugin:@fintechstudios/chai-as-promised/recommended', + 'plugin:chai-expect-keywords/recommended', + 'plugin:chai-expect/recommended', + 'plugin:chai-friendly/recommended' ], env: { node: true @@ -264,6 +272,11 @@ module.exports = { ] }, rules: { + 'chai-expect-keywords/no-unsupported-keywords': [ + 'error', { + allowChaiDOM: true + } + ], // Would be good but seems necessary due to some bugs in Cypress // in detecting visibility // 'cypress/no-force': 0, @@ -272,11 +285,18 @@ module.exports = { // 'cypress/require-data-selectors': 0, 'cypress/assertion-before-screenshot': 2, + // Conflicts with Cypress `should` + 'mocha-cleanup/invalid-assertions': 0, + + // Might see about working around, but convenient + 'mocha-cleanup/no-expressions-in-assertions': 0, + // Too oppressive when planning to extend a section 'mocha/no-hooks-for-single-case': 0, // Would be good to enable but needs some refactoring 'mocha/no-setup-in-describe': 0, + 'mocha-cleanup/no-outside-declaration': 0, // Useful to ensure allowing `this.timeout()`, etc., but a little oppressive 'mocha/no-mocha-arrows': 0, diff --git a/CHANGES.md b/CHANGES.md index 1d917d58..012bdfaa 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -67,6 +67,9 @@ - Linting (ESLint): Check hidden rc files - Linting (ESLint): Add linting plugins (mocha, chai-expect, chai-friendly, cypress) +- Linting (ESLint): Add `@fintechstudieos/eslint-plugin-chai-as-promised`, + `eslint-plugin-chai-expect-keywords`, and `eslint-plugin-mocha-cleanup` + plugins - Testing: Switch to Cypress with code coverage for UI testing; use ESM version for faster debugging - Testing: Add map file for underscore diff --git a/cypress/support/assert-close.js b/cypress/support/assert-close.js index f5947f2d..e0639480 100644 --- a/cypress/support/assert-close.js +++ b/cypress/support/assert-close.js @@ -1,3 +1,4 @@ +/* eslint-disable jsdoc/check-examples */ import assertionWrapper from './assertion-wrapper.js'; /** diff --git a/package-lock.json b/package-lock.json index d2a0d138..82bbc2ed 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1259,6 +1259,12 @@ } } }, + "@fintechstudios/eslint-plugin-chai-as-promised": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@fintechstudios/eslint-plugin-chai-as-promised/-/eslint-plugin-chai-as-promised-2.0.0.tgz", + "integrity": "sha512-fA69N990J5LWkqbtU2C/yW208IThVD5acPCMltoGbMd9WDNdZIcK1Cwb40H/5miZxdXkpdk7V62XIa24p/kmjA==", + "dev": true + }, "@istanbuljs/load-nyc-config": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.0.0.tgz", @@ -4513,6 +4519,12 @@ "integrity": "sha512-rd0/4mjMV6c3i0o4DKkWI4uaFN9DK707kW+/fDphaDI6HVgxXnhML9Xgt5vHnTXmSSnDhupuCFBgsEAEpchXmQ==", "dev": true }, + "eslint-plugin-chai-expect-keywords": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-chai-expect-keywords/-/eslint-plugin-chai-expect-keywords-2.0.1.tgz", + "integrity": "sha512-FemUdTwTKoyZoayxJsgQ+i0iqld1l9davDIjIqZJ6Ord972AI5uBVknAJKKCRnZ+Xo/5CImZNWuZ0WNOIoZ6LQ==", + "dev": true + }, "eslint-plugin-chai-friendly": { "version": "0.5.0", "resolved": "https://registry.npmjs.org/eslint-plugin-chai-friendly/-/eslint-plugin-chai-friendly-0.5.0.tgz", @@ -4717,6 +4729,14 @@ } } }, + "eslint-plugin-mocha-cleanup": { + "version": "git+https://github.com/brettz9/eslint-plugin-mocha-cleanup.git#56eea0ae5cb7d2d4b8c19117a162aa5c3b888279", + "from": "git+https://github.com/brettz9/eslint-plugin-mocha-cleanup.git#coverage", + "dev": true, + "requires": { + "requireindex": "~1.2.0" + } + }, "eslint-plugin-no-unsanitized": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/eslint-plugin-no-unsanitized/-/eslint-plugin-no-unsanitized-3.0.2.tgz", @@ -11330,6 +11350,12 @@ "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==", "dev": true }, + "requireindex": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/requireindex/-/requireindex-1.2.0.tgz", + "integrity": "sha512-L9jEkOi3ASd9PYit2cwRfyppc9NoABujTP8/5gFcbERmo5jUoAKovIC3fsF17pkTnGsrByysqX+Kxd2OTNI1ww==", + "dev": true + }, "requizzle": { "version": "0.2.3", "resolved": "https://registry.npmjs.org/requizzle/-/requizzle-0.2.3.tgz", diff --git a/package.json b/package.json index 36c62698..762a92a5 100644 --- a/package.json +++ b/package.json @@ -143,6 +143,7 @@ "@babel/register": "^7.8.3", "@cypress/code-coverage": "^1.12.2", "@cypress/fiddle": "^1.4.2", + "@fintechstudios/eslint-plugin-chai-as-promised": "^2.0.0", "@mysticatea/eslint-plugin": "^13.0.0", "axe-core": "^3.5.1", "babel-plugin-transform-object-rest-spread": "^7.0.0-beta.3", @@ -159,6 +160,7 @@ "eslint-config-standard": "^14.1.0", "eslint-plugin-array-func": "^3.1.3", "eslint-plugin-chai-expect": "^2.1.0", + "eslint-plugin-chai-expect-keywords": "^2.0.1", "eslint-plugin-chai-friendly": "^0.5.0", "eslint-plugin-compat": "^3.5.1", "eslint-plugin-cypress": "^2.10.3", @@ -168,6 +170,7 @@ "eslint-plugin-jsdoc": "^21.0.0", "eslint-plugin-markdown": "^1.0.1", "eslint-plugin-mocha": "^6.3.0", + "eslint-plugin-mocha-cleanup": "https://github.com/brettz9/eslint-plugin-mocha-cleanup#coverage", "eslint-plugin-no-unsanitized": "^3.0.2", "eslint-plugin-no-use-extend-native": "^0.4.1", "eslint-plugin-node": "^11.0.0",