
Research
PyPI Package Disguised as Instagram Growth Tool Harvests User Credentials
A deceptive PyPI package posing as an Instagram growth tool collects user credentials and sends them to third-party bot services.
eslint-plugin-no-only-tests
Advanced tools
The eslint-plugin-no-only-tests package is an ESLint plugin that helps developers avoid committing tests that are marked as 'only'. This is useful to ensure that all tests are run and none are accidentally skipped during continuous integration or other automated testing processes.
Disallow 'only' in test cases
This feature disallows the use of 'only' in test cases, which can be used to run a single test or a subset of tests. By setting this rule to 'error', any test cases that use 'only' will cause ESLint to throw an error, ensuring that all tests are run.
module.exports = {
"plugins": ["no-only-tests"],
"rules": {
"no-only-tests/no-only-tests": "error"
}
};
eslint-plugin-jest is an ESLint plugin for Jest testing framework. It includes a rule 'jest/no-focused-tests' that disallows the use of 'only' in test cases, similar to eslint-plugin-no-only-tests. However, eslint-plugin-jest offers a broader range of rules and configurations specifically for Jest.
eslint-plugin-mocha is an ESLint plugin for Mocha testing framework. It includes a rule 'mocha/no-exclusive-tests' that disallows the use of 'only' in test cases, similar to eslint-plugin-no-only-tests. This plugin is tailored for Mocha and provides additional rules for Mocha-specific best practices.
ESLint rule for .only
tests in Mocha, Jest, Jasmine, Mocha Cakes 2 and other JS testing libraries.
The following test blocks are matched by default: describe
, it
, context
, tape
, test
, fixture
, serial
, Feature
, Scenario
, Given
, And
, When
and Then
.
Designed to prevent you from committing focused (.only
) tests to CI, which may prevent your entire test suite from running.
If the testing framework you use doesn't use .only
to focus tests, you can override the matchers with options.
Install ESLint if you haven't done so already, then install eslint-plugin-no-only-tests
:
npm install --save-dev eslint-plugin-no-only-tests
# or
yarn add --dev eslint-plugin-no-only-tests
Note: If you installed ESLint globally (using the
-g
flag) then you must also installeslint-plugin-no-only-tests
globally.
Add no-only-tests
to the plugins section of your .eslintrc
configuration file. You can omit the eslint-plugin-
prefix:
"plugins": [
"no-only-tests"
]
Then add the rule to the rules section of your .eslintrc
:
"rules": {
"no-only-tests/no-only-tests": "error"
}
If you use a testing framework that uses a test block name that isn't present in the defaults, or a different way of focusing test (something other than .only
) you can specify an array of blocks and focus methods to match in the options.
"rules": {
"no-only-tests/no-only-tests": [
"error", {
"block": ["test", "it", "assert"],
"focus": ["only", "focus"]
}
]
}
The above example will catch any uses of test.only
, test.focus
, it.only
, it.focus
, assert.only
and assert.focus
.
This rule supports opt-in autofixing when the fix
option is set to true
to avoid changing runtime code unintentionally when configured in an editor.
"rules": {
"no-only-tests/no-only-tests": ["error", {"fix": true}]
}
Option | Type | Description |
---|---|---|
block | string[] | Specify the block names that your testing framework uses. Add a * to the end of any string to enable prefix matching (ie. test* will match testExample.only )Defaults to ["describe", "it", "context", "test", "tape", "fixture", "serial", "Feature", "Scenario", "Given", "And", "When", "Then"] |
focus | string[] | Specify the focus scope that your testing framework uses. Defaults to ["only"] |
functions | string[] | Specify not permitted functions. Good examples are fit or xit .Defaults to [] (disabled) |
fix | boolean | Enable this rule to auto-fix violations, useful for a pre-commit hook, not recommended for users with auto-fixing enabled in their editor. Defaults to false |
FAQs
ESLint rule for .only blocks in mocha tests
The npm package eslint-plugin-no-only-tests receives a total of 1,458,806 weekly downloads. As such, eslint-plugin-no-only-tests popularity was classified as popular.
We found that eslint-plugin-no-only-tests demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
A deceptive PyPI package posing as an Instagram growth tool collects user credentials and sends them to third-party bot services.
Product
Socket now supports pylock.toml, enabling secure, reproducible Python builds with advanced scanning and full alignment with PEP 751's new standard.
Security News
Research
Socket uncovered two npm packages that register hidden HTTP endpoints to delete all files on command.