Skip to content

Commit 73f30a2

Browse files
committed
Feat(eslint-config-jest): Introduce eslint jest preset #10
1 parent 6dc1237 commit 73f30a2

6 files changed

Lines changed: 197 additions & 0 deletions

File tree

.commitlintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ module.exports = {
1616
'eslint-config-lmc',
1717
'eslint-config-graphql',
1818
'eslint-config-react',
19+
'eslint-config-jest',
1920
// Use when commiting changes/additions/removals to packages in context
2021
'eslint',
2122
'rule',

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ This monorepo contains shareable configurations for various coding-style/best pr
1818
| ESLint | [@lmc-eu/eslint-config-base](packages/eslint-config-base) | [![@lmc-eu/eslint-config-base][slc-badge]][ec-base-npm] |
1919
| ESLint | [@lmc-eu/eslint-config-graphql](packages/eslint-config-graphql) | [![@lmc-eu/eslint-config-graphql][ec-gql-badge]][ec-gql-npm] |
2020
| ESLint | [@lmc-eu/eslint-config-react](packages/eslint-config-react) | [![@lmc-eu/eslint-config-react][ec-react-badge]][ec-react-npm] |
21+
| ESLint | [@lmc-eu/eslint-config-jest](packages/eslint-config-jest) | [![@lmc-eu/eslint-config-jest][ec-jest-badge]][ec-jest-npm] |
2122

2223
## License
2324

@@ -48,4 +49,6 @@ We got a lot of inspiration from similar project at [STRV][strv-github]. Thank y
4849
[ec-gql-badge]: https://img.shields.io/npm/v/%40lmc-eu/eslint-config-graphql.svg?style=flat-square
4950
[ec-react-npm]: https://www.npmjs.com/package/@lmc-eu/eslint-config-react
5051
[ec-react-badge]: https://img.shields.io/npm/v/%40lmc-eu/eslint-config-react.svg?style=flat-square
52+
[ec-jest-npm]: https://www.npmjs.com/package/@lmc-eu/eslint-config-jest
53+
[ec-jest-badge]: https://img.shields.io/npm/v/%40lmc-eu/eslint-config-jest.svg?style=flat-square
5154
[strv-github]: https://github.com/strvcom/code-quality-tools
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# @lmc-eu/eslint-config-jest
2+
3+
> LMC's ESLint config for projects using Jest as test runner
4+
5+
These configuration files are suitable to lint Jest test files.
6+
7+
## Install
8+
9+
```bash
10+
npm install @lmc-eu/eslint-config-jest -D
11+
```
12+
13+
or
14+
15+
```bash
16+
yarn add @lmc-eu/eslint-config-jest -D
17+
```
18+
19+
## Usage
20+
21+
Create a _.eslintrc.js_ file with the following contents:
22+
23+
```js
24+
module.exports = {
25+
extends: [
26+
// ... (base eslint config)
27+
'@lmc-eu/eslint-config-jest',
28+
],
29+
};
30+
```
31+
32+
The shareable config can be customized in your [**eslint** configuration file](https://eslint.org/docs/user-guide/configuring).
33+
34+
Use this ruleset to configure ESLint to lint your Jest test files. Jest test files are by default identified by `*.test.*` or `*.spec.*` filenames or by being in the _test/_ directory in your project root or by using `__test__/` directories near your tested files.
35+
36+
> ⚠️ You can use this environment ruleset in combination with any of the existing environment rulesets. Just make sure this one comes in as the last one.
37+
38+
## Plugins
39+
40+
This configuration uses the following plugins:
41+
42+
- [eslint-plugin-jest](https://github.com/jest-community/eslint-plugin-jest)
43+
- [eslint-plugin-jest-formatting](https://github.com/dangreenisrael/eslint-plugin-jest-formatting)
44+
45+
### Rules
46+
47+
For available rules see [ESLint plugin Jest](https://github.com/jest-community/eslint-plugin-jest/tree/main/docs/rules) and [ESLint plugin Jest Formatting](https://github.com/dangreenisrael/eslint-plugin-jest-formatting/tree/master/docs/rules)
48+
49+
## License
50+
51+
See the [LICENSE](LICENSE) file for information.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
const globs = require('@lmc-eu/eslint-config-base/globs');
2+
3+
module.exports = {
4+
overrides: [
5+
{
6+
files: globs.tests,
7+
8+
plugins: ['jest', 'jest-formatting'],
9+
10+
env: {
11+
mocha: true,
12+
},
13+
14+
extends: ['plugin:jest/recommended', 'plugin:jest/style', 'plugin:jest-formatting/recommended'],
15+
16+
rules: {},
17+
},
18+
],
19+
};
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"name": "@lmc-eu/eslint-config-jest",
3+
"version": "1.0.0",
4+
"description": "LMC's ESlint configuration for projects using Jest as test runner",
5+
"keywords": [
6+
"eslint",
7+
"config",
8+
"lmc",
9+
"jest"
10+
],
11+
"author": "Tomáš Litera <tomas.litera@lmc.eu>",
12+
"homepage": "https://github.com/lmc-eu/code-quality-tools#readme",
13+
"license": "MIT",
14+
"publishConfig": {
15+
"access": "public"
16+
},
17+
"engines": {
18+
"node": "^14 || >=16"
19+
},
20+
"repository": {
21+
"type": "git",
22+
"url": "git+https://github.com/lmc-eu/code-quality-tools.git",
23+
"directory": "packages/eslint-config-jest"
24+
},
25+
"bugs": {
26+
"url": "https://github.com/lmc-eu/code-quality-tools/issues"
27+
},
28+
"dependencies": {
29+
"@lmc-eu/eslint-config-base": "^1.1.1",
30+
"eslint-plugin-jest": "^25.3.0",
31+
"eslint-plugin-jest-formatting": "^3.1.0"
32+
},
33+
"peerDependencies": {
34+
"eslint": "^8.1.0"
35+
}
36+
}

yarn.lock

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2104,6 +2104,11 @@
21042104
dependencies:
21052105
"@types/istanbul-lib-report" "*"
21062106

2107+
"@types/json-schema@^7.0.9":
2108+
version "7.0.9"
2109+
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.9.tgz#97edc9037ea0c38585320b28964dde3b39e4660d"
2110+
integrity sha512-qcUXuemtEu+E5wZSJHNxUXeCZhAfXKQ41D+duX+VYPde7xyEVZci+/oXKJL13tnRs9lR2pr4fod59GT6/X1/yQ==
2111+
21072112
"@types/json5@^0.0.29":
21082113
version "0.0.29"
21092114
resolved "https://registry.yarnpkg.com/@types/json5/-/json5-0.0.29.tgz#ee28707ae94e11d2b827bcbe5270bcea7f3e71ee"
@@ -2175,6 +2180,52 @@
21752180
dependencies:
21762181
"@types/yargs-parser" "*"
21772182

2183+
"@typescript-eslint/experimental-utils@^5.0.0":
2184+
version "5.7.0"
2185+
resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-5.7.0.tgz#2b1633e6613c3238036156f70c32634843ad034f"
2186+
integrity sha512-u57eZ5FbEpzN5kSjmVrSesovWslH2ZyNPnaXQMXWgH57d5+EVHEt76W75vVuI9qKZ5BMDKNfRN+pxcPEjQjb2A==
2187+
dependencies:
2188+
"@types/json-schema" "^7.0.9"
2189+
"@typescript-eslint/scope-manager" "5.7.0"
2190+
"@typescript-eslint/types" "5.7.0"
2191+
"@typescript-eslint/typescript-estree" "5.7.0"
2192+
eslint-scope "^5.1.1"
2193+
eslint-utils "^3.0.0"
2194+
2195+
"@typescript-eslint/scope-manager@5.7.0":
2196+
version "5.7.0"
2197+
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.7.0.tgz#70adf960e5a58994ad50438ba60d98ecadd79452"
2198+
integrity sha512-7mxR520DGq5F7sSSgM0HSSMJ+TFUymOeFRMfUfGFAVBv8BR+Jv1vHgAouYUvWRZeszVBJlLcc9fDdktxb5kmxA==
2199+
dependencies:
2200+
"@typescript-eslint/types" "5.7.0"
2201+
"@typescript-eslint/visitor-keys" "5.7.0"
2202+
2203+
"@typescript-eslint/types@5.7.0":
2204+
version "5.7.0"
2205+
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.7.0.tgz#2d4cae0105ba7d08bffa69698197a762483ebcbe"
2206+
integrity sha512-5AeYIF5p2kAneIpnLFve8g50VyAjq7udM7ApZZ9JYjdPjkz0LvODfuSHIDUVnIuUoxafoWzpFyU7Sqbxgi79mA==
2207+
2208+
"@typescript-eslint/typescript-estree@5.7.0":
2209+
version "5.7.0"
2210+
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.7.0.tgz#968fad899050ccce4f08a40cd5fabc0798525006"
2211+
integrity sha512-aO1Ql+izMrTnPj5aFFlEJkpD4jRqC4Gwhygu2oHK2wfVQpmOPbyDSveJ+r/NQo+PWV43M6uEAeLVbTi09dFLhg==
2212+
dependencies:
2213+
"@typescript-eslint/types" "5.7.0"
2214+
"@typescript-eslint/visitor-keys" "5.7.0"
2215+
debug "^4.3.2"
2216+
globby "^11.0.4"
2217+
is-glob "^4.0.3"
2218+
semver "^7.3.5"
2219+
tsutils "^3.21.0"
2220+
2221+
"@typescript-eslint/visitor-keys@5.7.0":
2222+
version "5.7.0"
2223+
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.7.0.tgz#e05164239eb7cb8aa9fa06c516ede480ce260178"
2224+
integrity sha512-hdohahZ4lTFcglZSJ3DGdzxQHBSxsLVqHzkiOmKi7xVAWC4y2c1bIMKmPJSrA4aOEoRUPOKQ87Y/taC7yVHpFg==
2225+
dependencies:
2226+
"@typescript-eslint/types" "5.7.0"
2227+
eslint-visitor-keys "^3.0.0"
2228+
21782229
"@zkochan/cmd-shim@^3.1.0":
21792230
version "3.1.0"
21802231
resolved "https://registry.yarnpkg.com/@zkochan/cmd-shim/-/cmd-shim-3.1.0.tgz#2ab8ed81f5bb5452a85f25758eb9b8681982fd2e"
@@ -4106,6 +4157,18 @@ eslint-plugin-import@^2.25.2:
41064157
resolve "^1.20.0"
41074158
tsconfig-paths "^3.11.0"
41084159

4160+
eslint-plugin-jest-formatting@^3.1.0:
4161+
version "3.1.0"
4162+
resolved "https://registry.yarnpkg.com/eslint-plugin-jest-formatting/-/eslint-plugin-jest-formatting-3.1.0.tgz#b26dd5a40f432b642dcc880021a771bb1c93dcd2"
4163+
integrity sha512-XyysraZ1JSgGbLSDxjj5HzKKh0glgWf+7CkqxbTqb7zEhW7X2WHo5SBQ8cGhnszKN+2Lj3/oevBlHNbHezoc/A==
4164+
4165+
eslint-plugin-jest@^25.3.0:
4166+
version "25.3.0"
4167+
resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-25.3.0.tgz#6c04bbf13624a75684a05391a825b58e2e291950"
4168+
integrity sha512-79WQtuBsTN1S8Y9+7euBYwxIOia/k7ykkl9OCBHL3xuww5ecursHy/D8GCIlvzHVWv85gOkS5Kv6Sh7RxOgK1Q==
4169+
dependencies:
4170+
"@typescript-eslint/experimental-utils" "^5.0.0"
4171+
41094172
eslint-plugin-jsdoc@^37.1.0:
41104173
version "37.1.0"
41114174
resolved "https://registry.yarnpkg.com/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-37.1.0.tgz#88ccd4a70453f0660f0e14e9a67b91a324c32cfd"
@@ -4970,6 +5033,18 @@ globby@11.0.3:
49705033
merge2 "^1.3.0"
49715034
slash "^3.0.0"
49725035

5036+
globby@^11.0.4:
5037+
version "11.0.4"
5038+
resolved "https://registry.yarnpkg.com/globby/-/globby-11.0.4.tgz#2cbaff77c2f2a62e71e9b2813a67b97a3a3001a5"
5039+
integrity sha512-9O4MVG9ioZJ08ffbcyVYyLOJLk5JQ688pJ4eMGLpdWLHq/Wr1D9BlriLQyL0E+jbkuePVZXYFj47QM/v093wHg==
5040+
dependencies:
5041+
array-union "^2.1.0"
5042+
dir-glob "^3.0.1"
5043+
fast-glob "^3.1.1"
5044+
ignore "^5.1.4"
5045+
merge2 "^1.3.0"
5046+
slash "^3.0.0"
5047+
49735048
globby@^9.2.0:
49745049
version "9.2.0"
49755050
resolved "https://registry.yarnpkg.com/globby/-/globby-9.2.0.tgz#fd029a706c703d29bdd170f4b6db3a3f7a7cb63d"
@@ -9321,6 +9396,11 @@ tsconfig-paths@^3.11.0:
93219396
minimist "^1.2.0"
93229397
strip-bom "^3.0.0"
93239398

9399+
tslib@^1.8.1:
9400+
version "1.14.1"
9401+
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00"
9402+
integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==
9403+
93249404
tslib@^1.9.0:
93259405
version "1.13.0"
93269406
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.13.0.tgz#c881e13cc7015894ed914862d276436fa9a47043"
@@ -9346,6 +9426,13 @@ tslib@~2.2.0:
93469426
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.2.0.tgz#fb2c475977e35e241311ede2693cee1ec6698f5c"
93479427
integrity sha512-gS9GVHRU+RGn5KQM2rllAlR3dU6m7AcpJKdtH8gFvQiC4Otgk98XnmMU+nZenHt/+VhnBPWwgrJsyrdcw6i23w==
93489428

9429+
tsutils@^3.21.0:
9430+
version "3.21.0"
9431+
resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.21.0.tgz#b48717d394cea6c1e096983eed58e9d61715b623"
9432+
integrity sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==
9433+
dependencies:
9434+
tslib "^1.8.1"
9435+
93499436
tunnel-agent@^0.6.0:
93509437
version "0.6.0"
93519438
resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.6.0.tgz#27a5dea06b36b04a0a9966774b290868f0fc40fd"

0 commit comments

Comments
 (0)