Gathering detailed insights and metrics for eslint-plugin-mocha-no-only
Gathering detailed insights and metrics for eslint-plugin-mocha-no-only
Gathering detailed insights and metrics for eslint-plugin-mocha-no-only
Gathering detailed insights and metrics for eslint-plugin-mocha-no-only
npm install eslint-plugin-mocha-no-only
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
13 Stars
27 Commits
3 Forks
1 Watching
1 Branches
4 Contributors
Updated on 16 May 2024
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
-30.1%
3,768
Compared to previous day
Last week
0%
25,734
Compared to previous week
Last month
5.8%
118,194
Compared to previous month
Last year
-1.7%
1,244,864
Compared to previous year
1
1
This package contains an ESLint rule which throws an error (or warning) when the only()
method is called on describe
, context
, it
, specify
, suite
and test
Mocha test keywords.
only()
is a useful Mocha feature that lets the test runner run one specific part of a test suite. Often, developers may end up forgetting to remove the only()
method before commiting and pushing their code. This results in the CI tool running only one specific test in the suite which may end up in a false-positive build.
By having ESLint throw an error in such cases, you can rest assured your CI tool runs all your test suites.
You'll first need to install ESLint:
$ npm i eslint --save-dev
Next, install eslint-plugin-mocha-no-only
:
$ npm install eslint-plugin-mocha-no-only --save-dev
Note: If you installed ESLint globally (using the -g
flag) then you must also install eslint-plugin-mocha-no-only
globally.
Enable the eslint-plugin-mocha-no-only
plugin and rules in your eslint.config.js
file.
1import globals from "globals"; 2import pluginJs from "@eslint/js"; 3import mochaNoOnly from "eslint-plugin-mocha-no-only" 4 5 6export default [ 7 { 8 languageOptions: { globals: globals.browser }, 9 plugins: { mochaNoOnly }, 10 rules: { "mochaNoOnly/mocha-no-only": ["error"] } 11 }, 12 pluginJs.configs.recommended, 13]; 14
Note: You may want to only enable this rule for files in your tests suite. This can be done by adding an additional config object with a files
key.
1import globals from "globals"; 2import pluginJs from "@eslint/js"; 3import mochaNoOnly from "eslint-plugin-mocha-no-only" 4 5 6export default [ 7 { 8 languageOptions: { globals: globals.browser }, 9 plugins: { ... }, 10 rules: { ... } 11 }, 12 { 13 files: ["test/**.js"], 14 plugins: { mochaNoOnly }, 15 rules: { "mochaNoOnly/mocha-no-only": ["error"] } 16 }, 17 pluginJs.configs.recommended, 18]; 19
1describe("foobar", function() { 2 var foo; 3 beforeEach(function() { 4 foo = new Foo(); 5 }); 6 7 it.only("should do things", function() { 8 expect(foo).to.do.things; 9 }); 10});
1describe("foobar", function() { 2 var foo; 3 beforeEach(function() { 4 foo = new Foo(); 5 }); 6 7 it("should do things", function() { 8 expect(foo).to.do.things; 9 }); 10});
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
Found 3/20 approved changesets -- score normalized to 1
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
license file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More