@shelf/eslint-config 2.23.0 → 2.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -18,4 +18,18 @@ module.exports = {
18
18
  '@typescript-eslint/no-var-requires': 'off',
19
19
  },
20
20
  },
21
+ noCastWithJestMock: {
22
+ files: ['**/*.test.{ts,tsx}', '**/*mock?(s).{ts,tsx}'],
23
+ rules: {
24
+ 'no-restricted-syntax': [
25
+ 'error',
26
+ {
27
+ selector:
28
+ "TSAsExpression[typeAnnotation.typeName.left.name='jest'][typeAnnotation.typeName.right.name='Mock']",
29
+ message:
30
+ "Don't cast to mock type with jest.Mock, use jest.mocked instead: https://jestjs.io/docs/mock-function-api/#jestmockedsource-options",
31
+ },
32
+ ],
33
+ },
34
+ },
21
35
  };
@@ -1,7 +1,11 @@
1
1
  const commonExtends = require('./common/extends.json');
2
2
  const commonPlugins = require('./common/plugins');
3
3
  const tsParser = require('./common/ts-parser');
4
- const {allowRequireInConfigs, noExplicitReturnTypeInTests} = require('./common/overrides');
4
+ const {
5
+ allowRequireInConfigs,
6
+ noExplicitReturnTypeInTests,
7
+ noCastWithJestMock,
8
+ } = require('./common/overrides');
5
9
  const consistentTypeImports = require('./rules/consistent-type-imports.json');
6
10
  const frontendConfig = require('./frontend');
7
11
  const typescriptRules = require('./rules/typescript');
@@ -38,13 +42,14 @@ module.exports = {
38
42
  '@typescript-eslint/consistent-type-assertions': 'warn',
39
43
  // Don`t need for typescript files
40
44
  '@typescript-eslint/no-empty-function': 'off',
41
- '@typescript-eslint/no-unused-vars': ['error', {ignoreRestSiblings: true}],
42
- ...typescriptRules,
43
45
  ...restrictedPackagesImportRules,
46
+ ...typescriptRules,
47
+ '@typescript-eslint/no-unused-vars': ['error', {ignoreRestSiblings: true}],
44
48
  },
45
49
  overrides: [
46
50
  allowRequireInConfigs,
47
51
  noExplicitReturnTypeInTests,
52
+ noCastWithJestMock,
48
53
  {
49
54
  files: ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)'],
50
55
  extends: ['plugin:testing-library/react'],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shelf/eslint-config",
3
- "version": "2.23.0",
3
+ "version": "2.25.0",
4
4
  "description": "ESLint Config for Shelf Projects",
5
5
  "license": "MIT",
6
6
  "repository": "shelfio/eslint-config",
@@ -32,28 +32,28 @@
32
32
  "eslintconfig"
33
33
  ],
34
34
  "dependencies": {
35
- "@babel/eslint-parser": "7.18.9",
36
- "@typescript-eslint/eslint-plugin": "5.31.0",
37
- "@typescript-eslint/parser": "5.31.0",
35
+ "@babel/eslint-parser": "7.19.1",
36
+ "@typescript-eslint/eslint-plugin": "5.42.1",
37
+ "@typescript-eslint/parser": "5.42.1",
38
38
  "eslint-config-next": "12.2.3",
39
39
  "eslint-config-prettier": "8.5.0",
40
40
  "eslint-plugin-babel": "5.3.1",
41
41
  "eslint-plugin-import": "2.26.0",
42
- "eslint-plugin-jest": "26.6.0",
42
+ "eslint-plugin-jest": "27.1.4",
43
43
  "eslint-plugin-jest-formatting": "3.1.0",
44
44
  "eslint-plugin-json-format": "2.0.1",
45
45
  "eslint-plugin-jsx": "0.1.0",
46
46
  "eslint-plugin-node": "11.1.0",
47
47
  "eslint-plugin-prettier": "4.2.1",
48
- "eslint-plugin-react": "7.30.1",
48
+ "eslint-plugin-react": "7.31.10",
49
49
  "eslint-plugin-react-hooks": "4.6.0",
50
50
  "eslint-plugin-sonarjs": "0.14.0",
51
- "eslint-plugin-testing-library": "5.5.1",
51
+ "eslint-plugin-testing-library": "5.9.1",
52
52
  "eslint-plugin-vue": "9.3.0",
53
53
  "eslint-plugin-you-dont-need-lodash-underscore": "6.12.0"
54
54
  },
55
55
  "devDependencies": {
56
- "husky": "8.0.1",
56
+ "husky": "8.0.2",
57
57
  "lint-staged": "13.0.3",
58
58
  "prettier": "2.7.1"
59
59
  },
package/typescript.js CHANGED
@@ -7,12 +7,17 @@ const paddingLineBetweenStatements = require('./rules/padding-line-between-state
7
7
  const preferES6Features = require('./rules/prefer-es6.json');
8
8
  const sortImports = require('./rules/sort-imports.json');
9
9
  const tsParser = require('./common/ts-parser');
10
- const {allowRequireInConfigs, noExplicitReturnTypeInTests} = require('./common/overrides');
10
+ const {
11
+ allowRequireInConfigs,
12
+ noExplicitReturnTypeInTests,
13
+ noCastWithJestMock,
14
+ } = require('./common/overrides');
11
15
  const consistentTypeAssertions = require('./rules/consistent-type-assertions.json');
12
16
  const consistentTypeImports = require('./rules/consistent-type-imports.json');
13
17
  const youDontNeedLodashRules = require('./rules/you-dont-need-lodash.json');
14
18
  const typescriptRules = require('./rules/typescript');
15
19
  const restrictedPackagesImportRules = require('./rules/restricted-packages-import.json');
20
+ const noRestrictedSyntaxRules = require('./rules/no-restricted-syntax.json');
16
21
 
17
22
  module.exports = {
18
23
  extends: [...commonExtends, 'plugin:you-dont-need-lodash-underscore/compatible'],
@@ -50,6 +55,7 @@ module.exports = {
50
55
  '@typescript-eslint/no-non-null-assertion': 'off', // we want to allow using the "!" operator
51
56
  ...typescriptRules,
52
57
  ...restrictedPackagesImportRules,
58
+ ...noRestrictedSyntaxRules,
53
59
  },
54
- overrides: [allowRequireInConfigs, noExplicitReturnTypeInTests],
60
+ overrides: [allowRequireInConfigs, noExplicitReturnTypeInTests, noCastWithJestMock],
55
61
  };