From 1f1f85482b0d5d5fbdc9c5f5ec5f06ad2ff022cc Mon Sep 17 00:00:00 2001 From: Grace Gao Date: Thu, 19 Dec 2024 07:52:38 -0800 Subject: [PATCH] feat(eslint): add linting rules for testing (#3056) --- .eslintrc.js | 2 +- package-lock.json | 27 +++++++++++++++++++++++++++ package.json | 1 + tools/eslint/config/index.js | 7 +++++++ tools/eslint/config/package.json | 1 + 5 files changed, 37 insertions(+), 1 deletion(-) diff --git a/.eslintrc.js b/.eslintrc.js index b4715585d0..d6689ea7c3 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -35,7 +35,7 @@ module.exports = { caseInsensitive: false } } - ], + ] } }, { diff --git a/package-lock.json b/package-lock.json index ebe47b70df..4672df538e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -82,6 +82,7 @@ "eslint": "^8.57.0", "eslint-plugin-import": "^2.30.0", "eslint-plugin-jasmine": "^4.2.1", + "eslint-plugin-jest": "^28.8.3", "eslint-plugin-jsdoc": "^50.2.2", "eslint-plugin-modules-newlines": "^0.0.7", "eslint-plugin-prefer-arrow": "^1.2.3", @@ -15427,6 +15428,32 @@ "npm": ">=6" } }, + "node_modules/eslint-plugin-jest": { + "version": "28.8.3", + "resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-28.8.3.tgz", + "integrity": "sha512-HIQ3t9hASLKm2IhIOqnu+ifw7uLZkIlR7RYNv7fMcEi/p0CIiJmfriStQS2LDkgtY4nyLbIZAD+JL347Yc2ETQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/utils": "^6.0.0 || ^7.0.0 || ^8.0.0" + }, + "engines": { + "node": "^16.10.0 || ^18.12.0 || >=20.0.0" + }, + "peerDependencies": { + "@typescript-eslint/eslint-plugin": "^6.0.0 || ^7.0.0 || ^8.0.0", + "eslint": "^7.0.0 || ^8.0.0 || ^9.0.0", + "jest": "*" + }, + "peerDependenciesMeta": { + "@typescript-eslint/eslint-plugin": { + "optional": true + }, + "jest": { + "optional": true + } + } + }, "node_modules/eslint-plugin-jsdoc": { "version": "50.2.2", "resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-50.2.2.tgz", diff --git a/package.json b/package.json index a726755f90..a766f648c1 100644 --- a/package.json +++ b/package.json @@ -83,6 +83,7 @@ "eslint": "^8.57.0", "eslint-plugin-import": "^2.30.0", "eslint-plugin-jasmine": "^4.2.1", + "eslint-plugin-jest": "^28.8.3", "eslint-plugin-jsdoc": "^50.2.2", "eslint-plugin-modules-newlines": "^0.0.7", "eslint-plugin-prefer-arrow": "^1.2.3", diff --git a/tools/eslint/config/index.js b/tools/eslint/config/index.js index fe444242c6..900979d162 100644 --- a/tools/eslint/config/index.js +++ b/tools/eslint/config/index.js @@ -2,6 +2,7 @@ module.exports = { plugins: [ 'modules-newlines', 'jasmine', + 'jest', "eslint-plugin-import", "eslint-plugin-jsdoc", "eslint-plugin-prefer-arrow", @@ -241,6 +242,12 @@ module.exports = { "@stylistic/type-annotation-spacing": "error", // custom + "jest/max-nested-describe": [ + "warn", + { + "max": 4 + }, + ], '@typescript-eslint/no-unused-vars': 'off', 'prefer-arrow/prefer-arrow-functions': [ 'error', diff --git a/tools/eslint/config/package.json b/tools/eslint/config/package.json index 273c454ec7..ef8bfcc0c0 100644 --- a/tools/eslint/config/package.json +++ b/tools/eslint/config/package.json @@ -13,6 +13,7 @@ "eslint": "0.0.0-PLACEHOLDER", "eslint-plugin-import": "0.0.0-PLACEHOLDER", "eslint-plugin-jasmine": "0.0.0-PLACEHOLDER", + "eslint-plugin-jest": "0.0.0-PLACEHOLDER", "eslint-plugin-jsdoc": "0.0.0-PLACEHOLDER", "eslint-plugin-modules-newlines": "0.0.0-PLACEHOLDER", "eslint-plugin-prefer-arrow": "0.0.0-PLACEHOLDER"