From 24ea366378a50fc9c1f044412863f09cbd507224 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20N=C3=BA=C3=B1ez?= Date: Mon, 9 Aug 2021 10:09:10 +0000 Subject: [PATCH 1/4] Add no-only-tests JS linter rule to detect test.only and suite.only --- .eslintrc.js | 10 ++++++++-- package-lock.json | 16 ++++++++++++++++ package.json | 1 + 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 4f7ea4cb..cdecd440 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -8,13 +8,19 @@ module.exports = { node: true }, extends: [require.resolve('./lib/configs/recommended'), 'plugin:eslint-plugin/all'], - plugins: ['eslint-plugin'], + plugins: ['eslint-plugin', 'no-only-tests'], rules: { 'import/no-commonjs': 'off', 'filenames/match-regex': 'off', 'i18n-text/no-en': 'off', 'eslint-plugin/prefer-placeholders': 'off', 'eslint-plugin/test-case-shorthand-strings': 'off', - 'eslint-plugin/require-meta-docs-url': 'off' + 'eslint-plugin/require-meta-docs-url': 'off', + 'no-only-tests/no-only-tests': [ + 'error', + { + 'block': ['describe', 'it', 'context', 'test', 'tape', 'fixture', 'serial', 'suite'] + } + ] } } diff --git a/package-lock.json b/package-lock.json index 2f5fb9f6..4d7e9039 100644 --- a/package-lock.json +++ b/package-lock.json @@ -27,6 +27,7 @@ "@github/prettier-config": "0.0.4", "eslint": "7.23.0", "eslint-plugin-eslint-plugin": "^2.3.0", + "eslint-plugin-no-only-tests": "^2.6.0", "eslint-visitor-keys": "^2.0.0", "globals": "^13.7.0", "mocha": "^8.3.2" @@ -1050,6 +1051,15 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" }, + "node_modules/eslint-plugin-no-only-tests": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-no-only-tests/-/eslint-plugin-no-only-tests-2.6.0.tgz", + "integrity": "sha512-T9SmE/g6UV1uZo1oHAqOvL86XWl7Pl2EpRpnLI8g/bkJu+h7XBCB+1LnubRZ2CUQXj805vh4/CYZdnqtVaEo2Q==", + "dev": true, + "engines": { + "node": ">=4.0.0" + } + }, "node_modules/eslint-plugin-prettier": { "version": "3.3.1", "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-3.3.1.tgz", @@ -3975,6 +3985,12 @@ } } }, + "eslint-plugin-no-only-tests": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-no-only-tests/-/eslint-plugin-no-only-tests-2.6.0.tgz", + "integrity": "sha512-T9SmE/g6UV1uZo1oHAqOvL86XWl7Pl2EpRpnLI8g/bkJu+h7XBCB+1LnubRZ2CUQXj805vh4/CYZdnqtVaEo2Q==", + "dev": true + }, "eslint-plugin-prettier": { "version": "3.3.1", "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-3.3.1.tgz", diff --git a/package.json b/package.json index 5d22076f..96a55c38 100644 --- a/package.json +++ b/package.json @@ -49,6 +49,7 @@ "@github/prettier-config": "0.0.4", "eslint": "7.23.0", "eslint-plugin-eslint-plugin": "^2.3.0", + "eslint-plugin-no-only-tests": "^2.6.0", "eslint-visitor-keys": "^2.0.0", "globals": "^13.7.0", "mocha": "^8.3.2" From 49b05643c3d8eb2d06476db1cec26e1767b63b83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20N=C3=BA=C3=B1ez?= Date: Mon, 9 Aug 2021 10:15:25 +0000 Subject: [PATCH 2/4] Linter fix. --- .eslintrc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.eslintrc.js b/.eslintrc.js index cdecd440..1bdf5022 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -19,7 +19,7 @@ module.exports = { 'no-only-tests/no-only-tests': [ 'error', { - 'block': ['describe', 'it', 'context', 'test', 'tape', 'fixture', 'serial', 'suite'] + block: ['describe', 'it', 'context', 'test', 'tape', 'fixture', 'serial', 'suite'] } ] } From 9c94c7278d3382fa758aa7751fdda4be176b73bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20N=C3=BA=C3=B1ez?= Date: Mon, 9 Aug 2021 12:18:55 +0000 Subject: [PATCH 3/4] Add to recommended rules, not to this own project linter rules. --- .eslintrc.js | 10 ++-------- lib/configs/recommended.js | 8 +++++++- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 1bdf5022..4f7ea4cb 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -8,19 +8,13 @@ module.exports = { node: true }, extends: [require.resolve('./lib/configs/recommended'), 'plugin:eslint-plugin/all'], - plugins: ['eslint-plugin', 'no-only-tests'], + plugins: ['eslint-plugin'], rules: { 'import/no-commonjs': 'off', 'filenames/match-regex': 'off', 'i18n-text/no-en': 'off', 'eslint-plugin/prefer-placeholders': 'off', 'eslint-plugin/test-case-shorthand-strings': 'off', - 'eslint-plugin/require-meta-docs-url': 'off', - 'no-only-tests/no-only-tests': [ - 'error', - { - block: ['describe', 'it', 'context', 'test', 'tape', 'fixture', 'serial', 'suite'] - } - ] + 'eslint-plugin/require-meta-docs-url': 'off' } } diff --git a/lib/configs/recommended.js b/lib/configs/recommended.js index 56b10324..3797544d 100644 --- a/lib/configs/recommended.js +++ b/lib/configs/recommended.js @@ -8,7 +8,7 @@ module.exports = { env: { es6: true }, - plugins: ['github', 'prettier', 'eslint-comments', 'import', 'filenames', 'i18n-text'], + plugins: ['github', 'prettier', 'eslint-comments', 'import', 'filenames', 'i18n-text', 'no-only-tests'], rules: { 'constructor-super': 'error', 'eslint-comments/disable-enable-pair': 'off', @@ -85,6 +85,12 @@ module.exports = { 'no-new-symbol': 'error', 'no-obj-calls': 'error', 'no-octal': 'error', + 'no-only-tests/no-only-tests': [ + 'error', + { + block: ['describe', 'it', 'context', 'test', 'tape', 'fixture', 'serial', 'suite'] + } + ], 'no-redeclare': 'error', 'no-regex-spaces': 'error', 'no-return-assign': 'error', From fd8d5fb5f98d05cc548eb22de0613565ec3f59e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20N=C3=BA=C3=B1ez?= Date: Mon, 9 Aug 2021 12:22:05 +0000 Subject: [PATCH 4/4] Move package to normal dependency (no dev). --- package-lock.json | 6 ++---- package.json | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 4d7e9039..fd0afca5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,6 +15,7 @@ "eslint-plugin-filenames": "^1.3.2", "eslint-plugin-i18n-text": "^1.0.1", "eslint-plugin-import": "^2.22.1", + "eslint-plugin-no-only-tests": "^2.6.0", "eslint-plugin-prettier": "^3.3.1", "eslint-rule-documentation": ">=1.0.0", "prettier": "^2.2.1", @@ -27,7 +28,6 @@ "@github/prettier-config": "0.0.4", "eslint": "7.23.0", "eslint-plugin-eslint-plugin": "^2.3.0", - "eslint-plugin-no-only-tests": "^2.6.0", "eslint-visitor-keys": "^2.0.0", "globals": "^13.7.0", "mocha": "^8.3.2" @@ -1055,7 +1055,6 @@ "version": "2.6.0", "resolved": "https://registry.npmjs.org/eslint-plugin-no-only-tests/-/eslint-plugin-no-only-tests-2.6.0.tgz", "integrity": "sha512-T9SmE/g6UV1uZo1oHAqOvL86XWl7Pl2EpRpnLI8g/bkJu+h7XBCB+1LnubRZ2CUQXj805vh4/CYZdnqtVaEo2Q==", - "dev": true, "engines": { "node": ">=4.0.0" } @@ -3988,8 +3987,7 @@ "eslint-plugin-no-only-tests": { "version": "2.6.0", "resolved": "https://registry.npmjs.org/eslint-plugin-no-only-tests/-/eslint-plugin-no-only-tests-2.6.0.tgz", - "integrity": "sha512-T9SmE/g6UV1uZo1oHAqOvL86XWl7Pl2EpRpnLI8g/bkJu+h7XBCB+1LnubRZ2CUQXj805vh4/CYZdnqtVaEo2Q==", - "dev": true + "integrity": "sha512-T9SmE/g6UV1uZo1oHAqOvL86XWl7Pl2EpRpnLI8g/bkJu+h7XBCB+1LnubRZ2CUQXj805vh4/CYZdnqtVaEo2Q==" }, "eslint-plugin-prettier": { "version": "3.3.1", diff --git a/package.json b/package.json index 96a55c38..5f8d7985 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,7 @@ "eslint-plugin-filenames": "^1.3.2", "eslint-plugin-i18n-text": "^1.0.1", "eslint-plugin-import": "^2.22.1", + "eslint-plugin-no-only-tests": "^2.6.0", "eslint-plugin-prettier": "^3.3.1", "eslint-rule-documentation": ">=1.0.0", "prettier": "^2.2.1", @@ -49,7 +50,6 @@ "@github/prettier-config": "0.0.4", "eslint": "7.23.0", "eslint-plugin-eslint-plugin": "^2.3.0", - "eslint-plugin-no-only-tests": "^2.6.0", "eslint-visitor-keys": "^2.0.0", "globals": "^13.7.0", "mocha": "^8.3.2"