From 8a948ccc0db4eea61b80382c726e0c53411d5216 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Mon, 2 Nov 2020 12:25:30 +0200 Subject: [PATCH 1/3] Add `eslint-plugin-jasmine` --- js/tests/unit/.eslintrc.json | 19 ++++++++----------- package-lock.json | 6 ++++++ package.json | 1 + 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/js/tests/unit/.eslintrc.json b/js/tests/unit/.eslintrc.json index e7f8d5d2a..6f5964ba9 100644 --- a/js/tests/unit/.eslintrc.json +++ b/js/tests/unit/.eslintrc.json @@ -1,16 +1,13 @@ { "root": true, - "extends": [ - "../../../.eslintrc.json" + "env": { + "jasmine": true + }, + "plugins": [ + "jasmine" ], - "overrides": [ - { - "files": [ - "**/*.spec.js" - ], - "env": { - "jasmine": true - } - } + "extends": [ + "../../../.eslintrc.json", + "plugin:jasmine/recommended" ] } diff --git a/package-lock.json b/package-lock.json index caa899ea1..31ee9bd01 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4048,6 +4048,12 @@ } } }, + "eslint-plugin-jasmine": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-jasmine/-/eslint-plugin-jasmine-4.1.1.tgz", + "integrity": "sha512-uS7kvt7RPUB/gLDwhJ/Ax0APrmkj7In8VJWkiZLYHafz2Ix74mMRJx82YZZ3zHRa/YOuTL+ig6dW/aKwdNzUuw==", + "dev": true + }, "eslint-plugin-unicorn": { "version": "23.0.0", "resolved": "https://registry.npmjs.org/eslint-plugin-unicorn/-/eslint-plugin-unicorn-23.0.0.tgz", diff --git a/package.json b/package.json index b4545406c..f0d37dc64 100644 --- a/package.json +++ b/package.json @@ -106,6 +106,7 @@ "eslint": "^7.14.0", "eslint-config-xo": "^0.33.1", "eslint-plugin-import": "^2.22.1", + "eslint-plugin-jasmine": "^4.1.1", "eslint-plugin-unicorn": "^23.0.0", "find-unused-sass-variables": "^3.0.0", "glob": "^7.1.6", From 57ee20ea1cad70c6c22fc600cf55238ce0aa155c Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Mon, 2 Nov 2020 12:33:50 +0200 Subject: [PATCH 2/3] Disable a few rules * `jasmine/expect-single-argument` since it wrongfully flags `expect().nothing()` * `jasmine/new-line-before-expect` * `jasmine/no-spec-dupes` * `jasmine/prefer-toHaveBeenCalledWith` --- js/tests/unit/.eslintrc.json | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/js/tests/unit/.eslintrc.json b/js/tests/unit/.eslintrc.json index 6f5964ba9..796c82e03 100644 --- a/js/tests/unit/.eslintrc.json +++ b/js/tests/unit/.eslintrc.json @@ -9,5 +9,11 @@ "extends": [ "../../../.eslintrc.json", "plugin:jasmine/recommended" - ] + ], + "rules": { + "jasmine/expect-single-argument": "off", + "jasmine/new-line-before-expect": "off", + "jasmine/no-spec-dupes": "off", + "jasmine/prefer-toHaveBeenCalledWith": "off" + } } From c7ea9f83d19894fc47accd0069ad5a3a1d0286a6 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Tue, 3 Nov 2020 15:56:17 +0200 Subject: [PATCH 3/3] Explicitly enable the rules --- js/tests/unit/.eslintrc.json | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/js/tests/unit/.eslintrc.json b/js/tests/unit/.eslintrc.json index 796c82e03..806dcf8a0 100644 --- a/js/tests/unit/.eslintrc.json +++ b/js/tests/unit/.eslintrc.json @@ -11,9 +11,27 @@ "plugin:jasmine/recommended" ], "rules": { + "jasmine/expect-matcher": "error", "jasmine/expect-single-argument": "off", + "jasmine/missing-expect": [ + "error", + "expect()", + "testElementIsActiveAfterScroll()" + ], + "jasmine/named-spy": "off", "jasmine/new-line-before-expect": "off", + "jasmine/new-line-between-declarations": "error", + "jasmine/no-disabled-tests": "error", + "jasmine/no-expect-in-setup-teardown": "error", + "jasmine/no-focused-tests": "error", + "jasmine/no-global-setup": "error", + "jasmine/no-pending-tests": "error", + "jasmine/no-promise-without-done-fail": "error", "jasmine/no-spec-dupes": "off", + "jasmine/no-suite-callback-args": "error", + "jasmine/no-suite-dupes": "error", + "jasmine/no-unsafe-spy": "error", + "jasmine/prefer-jasmine-matcher": "error", "jasmine/prefer-toHaveBeenCalledWith": "off" } }