$ yarn add --dev eslint eslint-plugin-jest-extended
Note: If you installed ESLint globally then you must also install
eslint-plugin-jest-extended
globally.
Note
eslint.config.js
is supported, though most of the plugin documentation still
currently uses .eslintrc
syntax.
Refer to the ESLint documentation on the new configuration file format for more.
Add jest-extended
to the plugins section of your .eslintrc
configuration
file. You can omit the eslint-plugin-
prefix:
{
"plugins": ["jest-extended"]
}
Then configure the rules you want to use under the rules section.
{
"rules": {
"jest-extended/prefer-to-be-true": "warn",
"jest-extended/prefer-to-be-false": "error"
}
}
This plugin does not export a recommended configuration, as the rules provided by this plugin are about enforcing usage of preferred matchers for particular patterns, rather than helping to prevent bugs & commonly overlooked traps.
If you want to enable all rules instead of only some you can do so by adding the
all
configuration to your .eslintrc
config file:
{
"extends": ["plugin:jest-extended/all"]
}
To enable this configuration with eslint.config.js
, use
jestExtended.configs['flat/all']
:
const jestExtended = require('eslint-plugin-jest-extended');
module.exports = [
{
files: [
/* glob matching your test files */
],
...jestExtended.configs['flat/all'],
},
];
Note that the all
configuration may change in any release and is thus unsuited
for installations requiring long-term consistency.
π§ Automatically fixable by the
--fix
CLI option.
Name | Description | π§ |
---|---|---|
prefer-to-be-array | Suggest using toBeArray() |
π§ |
prefer-to-be-false | Suggest using toBeFalse() |
π§ |
prefer-to-be-object | Suggest using toBeObject() |
π§ |
prefer-to-be-true | Suggest using toBeTrue() |
π§ |
prefer-to-have-been-called-once | Suggest using toHaveBeenCalledOnce() |
π§ |
This project aims to provide linting rules to aid in writing tests using jest.
https://github.com/jest-community/eslint-plugin-jest
This project aims to provide formatting rules (auto-fixable where possible) to ensure consistency and readability in jest test suites.
https://github.com/dangreenisrael/eslint-plugin-jest-formatting
eslint-plugin-jest-extended's People
Forkers
willemorvetseslint-plugin-jest-extended's Issues
[new rule] prefer `toHaveBeenCalledOnce()` over `toHaveBeenCalledTimes(1)`
// instead of
expect(testSpy).toHaveBeenCalledTimes(1)
// prefer
expect(testSpy).toHaveBeenCalledOnce()
Results of weekly scheduled smoke test
Something went wrong. This is likely an internal error of eslint-remote-tester-run-action
.
Click to expand
TSError: β¨― Unable to compile TypeScript:
error TS6053: File '@tsconfig/node12/tsconfig.json' not found.
at createTSError (/github/workspace/node_modules/ts-node/src/index.ts:859:12)
at reportTSError (/github/workspace/node_modules/ts-node/src/index.ts:863:19)
at createFromPreloadedConfig (/github/workspace/node_modules/ts-node/src/index.ts:874:36)
at create (/github/workspace/node_modules/ts-node/src/index.ts:624:10)
at Object.register (/github/workspace/node_modules/ts-node/src/index.ts:591:15)
at loadTSConfig (/github/workspace/node_modules/eslint-remote-tester/dist/config/load.js:11:56)
at loadConfig (/github/workspace/node_modules/eslint-remote-tester/dist/config/load.js:28:41)
at runTester (/index.js:5935:14)
at /index.js:5992:61
at Object.<anonymous> (/index.js:284:24)
prefer-to-be: Prefer toBeTrue, toBeFalse instead of toBe(true), toBe(false)
prefer-to-be already prefers toBeUndefined instead of toBe(undefined).
I suggest also to prefer toBeTrue, toBeFalse instead of toBe(true), toBe(false).
Setup release workflow (+ do initial release)
While the release workflow exists, it's currently not setup to publish (iirc its not got a token?).
We should get that sorted and release v1 so people can start using this π
(I've not actually got the access writes needed to do this, so @SimenB or @mattphillips could either of you action this?)
Dependency Dashboard
This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.
Warning
These dependencies are deprecated:
Datasource | Name | Replacement PR? |
---|---|---|
npm | eslint-plugin-eslint-comments |
Rate-Limited
These updates are currently rate-limited. Click on a checkbox below to force their creation now.
- chore(deps): replace dependency eslint-plugin-eslint-comments with @eslint-community/eslint-plugin-eslint-comments ^3.2.0
- chore(deps): lock file maintenance
- π Create all rate-limited PRs at once π
Open
These updates have all been created already. Click a checkbox below to force a retry/rebase of any.
- chore(deps): update danger/danger-js action to v12.3.3
- chore(deps): update yarn to v3.8.5
- chore(deps): update ariperkkio/eslint-remote-tester-run-action action to v5
- chore(deps): update codecov/codecov-action action to v4
- chore(deps): update dependency @types/node to v20
- chore(deps): update dependency eslint-plugin-n to v17
- chore(deps): update dependency eslint-remote-tester to v4
- chore(deps): update dependency eslint-remote-tester-repositories to v2
- chore(deps): update dependency semantic-release to v24
- chore(deps): update typescript-eslint monorepo to v8 (major) (
@typescript-eslint/eslint-plugin
,@typescript-eslint/parser
,@typescript-eslint/utils
) - Click on this checkbox to rebase all open PRs at once
Ignored or Blocked
These are blocked by an existing closed PR and will not be recreated unless you click a checkbox below.
- chore(deps): update dependency lint-staged to v15
- chore(deps): update dependency rimraf to v6
- chore(deps): update yarn to v4
Detected dependencies
github-actions
.github/workflows/lint.yml
actions/checkout v4
wagoid/commitlint-github-action v6
actions/checkout v4
danger/danger-js 12.3.0
.github/workflows/markdown-link-check.yml
actions/checkout v4
actions/setup-node v4
.github/workflows/nodejs.yml
actions/checkout v4
actions/setup-node v4
actions/checkout v4
actions/setup-node v4
actions/checkout v4
actions/setup-node v4
codecov/codecov-action v3
actions/checkout v4
actions/setup-node v4
actions/checkout v4
actions/setup-node v4
.github/workflows/prepare-cache.yml
actions/checkout v4
actions/setup-node v4
.github/workflows/smoke-test.yml
actions/checkout v4
actions/setup-node v4
AriPerkkio/eslint-remote-tester-run-action v4
.github/workflows/test.yml
actions/checkout v4
actions/setup-node v4
npm
package.json
@typescript-eslint/utils ^5.10.0
@babel/cli ^7.4.4
@babel/core ^7.4.4
@babel/preset-env ^7.4.4
@babel/preset-typescript ^7.3.3
@commitlint/cli ^19.0.0
@commitlint/config-conventional ^19.0.0
@schemastore/package ^0.0.10
@semantic-release/changelog ^6.0.0
@semantic-release/git ^10.0.0
@tsconfig/node14 ^14.0.0
@types/dedent ^0.7.0
@types/jest ^29.0.0
@types/node ^14.17.0
@typescript-eslint/eslint-plugin ^5.0.0
@typescript-eslint/parser ^5.0.0
babel-jest ^29.0.0
babel-plugin-replace-ts-export-assignment ^0.0.2
dedent ^1.0.0
eslint ^6.0.0 || ^7.0.0 || ^8.0.0 || ^9.0.0
eslint-config-prettier ^9.0.0
eslint-doc-generator ^1.0.0
eslint-plugin-eslint-comments ^3.1.2
eslint-plugin-eslint-plugin ^6.0.0
eslint-plugin-import ^2.18.0
eslint-plugin-n ^15.0.0
eslint-plugin-prettier ^5.0.0
eslint-remote-tester ^3.0.0
eslint-remote-tester-repositories ^1.0.0
husky ^9.0.0
is-ci ^3.0.0
jest ^29.0.0
jest-runner-eslint ^2.0.0
lint-staged ^13.0.3
markdown-link-check ^3.10.3
pinst ^3.0.0
prettier ^3.0.0
rimraf ^5.0.0
semantic-release ^23.0.0
semver ^7.6.0
ts-node ^10.9.1
typescript ^5.0.0
eslint ^7.0.0 || ^8.0.0 || ^9.0.0
node ^14.15.0 || ^16.10.0 || >=18.0.0
@typescript-eslint/experimental-utils ^5.0.0
yarn 3.8.4
- Check this box to trigger a request for Renovate to run again on this repository
More suggestions
It'd be nice to have more suggestions:
expect(typeof x === 'string') -> expect(x).toBeString()
expect(typeof x === 'boolean') -> expect(x).toBeBoolean()
expect(typeof x === 'number') -> expect(x).toBeNumber()
expect(x.includes(y)) -> expect(x).toInclude(y)
And so on.
The automated release is failing π¨
π¨ The automated release from the main
branch failed. π¨
I recommend you give this issue a high priority, so other packages depending on you can benefit from your bug fixes and new features again.
You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. Iβm sure you can fix this πͺ.
Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.
Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the main
branch. You can also manually restart the failed CI job that runs semantic-release.
If you are not sure how to resolve this, here are some links that can help you:
If those donβt help, or if this issue is reporting something you think isnβt right, you can always ask the humans behind semantic-release.
No npm token specified.
An npm token must be created and set in the NPM_TOKEN
environment variable on your CI environment.
Please make sure to create an npm token and to set it in the NPM_TOKEN
environment variable on your CI environment. The token must allow to publish to the registry https://registry.npmjs.org/
.
Good luck with your project β¨
Your semantic-release bot π¦π
Support ESLint v9
ESLint v9 was officially released on the 5th of April. This notably also includes making the new flat config format the default. A migration guide can be found here.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.