Skip to content

Commit 5877cba

Browse files
committed
feat(eslint): add plugin, add expect method call lint rule COMPASS-10060
1 parent 872373b commit 5877cba

File tree

13 files changed

+394
-1
lines changed

13 files changed

+394
-1
lines changed

configs/eslint-config-devtools/common.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ const testRules = {
3636
'mocha/no-setup-in-describe': 'off',
3737
'@typescript-eslint/no-explicit-any': 'off',
3838
'@typescript-eslint/no-empty-function': 'off',
39+
'@mongodb-js/devtools/no-expect-method-without-call': 'error',
3940
};
4041

4142
const jsConfigurations = ['eslint:recommended'];
@@ -124,7 +125,9 @@ const testOverrides = {
124125
],
125126
env: { mocha: true },
126127
extends: [...testConfigurations],
127-
rules: { ...testRules },
128+
rules: {
129+
...testRules,
130+
},
128131
};
129132

130133
module.exports = {

configs/eslint-config-devtools/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ module.exports = {
1010
'react',
1111
'react-hooks',
1212
'filename-rules',
13+
'@mongodb-js/devtools',
1314
],
1415
rules: {
1516
'filename-rules/match': ['error', common.kebabcase],

configs/eslint-config-devtools/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"@babel/eslint-parser": "^7.22.7",
1919
"@babel/preset-env": "^7.22.7",
2020
"@babel/preset-react": "^7.22.5",
21+
"@mongodb-js/eslint-plugin-devtools": "^0.1.0",
2122
"@typescript-eslint/eslint-plugin": "^5.59.0",
2223
"@typescript-eslint/parser": "^5.59.0",
2324
"eslint-config-prettier": "^8.3.0",
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ignores:
2+
- '@mongodb-js/prettier-config-devtools'
3+
- '@mongodb-js/eslint-config-devtools'
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.nyc-output
2+
dist
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
'use strict';
2+
module.exports = {
3+
root: true,
4+
extends: ['@mongodb-js/eslint-config-devtools'],
5+
parserOptions: {
6+
tsconfigRootDir: __dirname,
7+
project: ['./tsconfig-lint.json'],
8+
},
9+
};
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
'use strict';
2+
module.exports = {
3+
...require('@mongodb-js/mocha-config-devtools'),
4+
spec: ['rules/**/*.test.js'],
5+
watchFiles: ['rules/**/*.js'],
6+
};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"@mongodb-js/prettier-config-devtools"
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
'use strict';
2+
module.exports = {
3+
rules: {
4+
'no-expect-method-without-call': require('./rules/no-expect-method-without-call'),
5+
},
6+
};
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"name": "@mongodb-js/eslint-plugin-devtools",
3+
"description": "Custom eslint rules for DevTools",
4+
"homepage": "https://github.com/mongodb-js/devtools-shared",
5+
"version": "0.1.0",
6+
"repository": {
7+
"type": "git",
8+
"url": "https://github.com/mongodb-js/devtools-shared.git"
9+
},
10+
"files": [
11+
"dist"
12+
],
13+
"license": "SSPL",
14+
"main": "index.js",
15+
"scripts": {
16+
"eslint": "eslint",
17+
"prettier": "prettier",
18+
"lint": "npm run eslint . && npm run prettier -- --check .",
19+
"depcheck": "depcheck",
20+
"check": "npm run lint && npm run depcheck",
21+
"check-ci": "npm run check",
22+
"test": "mocha",
23+
"test-cov": "nyc --compact=false --produce-source-map=false -x \"**/*.spec.*\" --reporter=lcov --reporter=text --reporter=html npm run test",
24+
"test-watch": "npm run test -- --watch",
25+
"test-ci": "npm run test-cov",
26+
"reformat": "npm run eslint . -- --fix && npm run prettier -- --write ."
27+
},
28+
"devDependencies": {
29+
"@mongodb-js/mocha-config-devtools": "^1.0.5",
30+
"@mongodb-js/prettier-config-devtools": "^1.0.1",
31+
"depcheck": "^1.4.7",
32+
"eslint": "^7.25.0",
33+
"mocha": "^8.4.0",
34+
"nyc": "^15.1.0"
35+
}
36+
}

0 commit comments

Comments
 (0)