eslint-config-typed 4.3.1 → 4.4.1

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.
Files changed (80) hide show
  1. package/dist/plugins/immer-coding-style/rules/prefer-curried-produce.d.mts.map +1 -1
  2. package/dist/plugins/immer-coding-style/rules/prefer-curried-produce.mjs +1 -2
  3. package/dist/plugins/immer-coding-style/rules/prefer-curried-produce.mjs.map +1 -1
  4. package/dist/plugins/react-coding-style/rules/import-style.mjs +2 -2
  5. package/dist/plugins/react-coding-style/rules/import-style.mjs.map +1 -1
  6. package/dist/plugins/react-coding-style/rules/props-type-annotation-style.d.mts.map +1 -1
  7. package/dist/plugins/react-coding-style/rules/props-type-annotation-style.mjs +2 -4
  8. package/dist/plugins/react-coding-style/rules/props-type-annotation-style.mjs.map +1 -1
  9. package/dist/plugins/react-coding-style/rules/react-memo-props-argument-name.d.mts.map +1 -1
  10. package/dist/plugins/react-coding-style/rules/react-memo-props-argument-name.mjs +1 -2
  11. package/dist/plugins/react-coding-style/rules/react-memo-props-argument-name.mjs.map +1 -1
  12. package/dist/plugins/total-functions/rules/common.d.mts +3 -1
  13. package/dist/plugins/total-functions/rules/common.d.mts.map +1 -1
  14. package/dist/plugins/total-functions/rules/no-enums.d.mts +3 -1
  15. package/dist/plugins/total-functions/rules/no-enums.d.mts.map +1 -1
  16. package/dist/plugins/total-functions/rules/no-hidden-type-assertions.d.mts +3 -1
  17. package/dist/plugins/total-functions/rules/no-hidden-type-assertions.d.mts.map +1 -1
  18. package/dist/plugins/total-functions/rules/no-nested-fp-ts-effects.d.mts +3 -1
  19. package/dist/plugins/total-functions/rules/no-nested-fp-ts-effects.d.mts.map +1 -1
  20. package/dist/plugins/total-functions/rules/no-partial-array-reduce.d.mts +3 -1
  21. package/dist/plugins/total-functions/rules/no-partial-array-reduce.d.mts.map +1 -1
  22. package/dist/plugins/total-functions/rules/no-partial-division.d.mts +3 -1
  23. package/dist/plugins/total-functions/rules/no-partial-division.d.mts.map +1 -1
  24. package/dist/plugins/total-functions/rules/no-partial-string-normalize.d.mts +3 -1
  25. package/dist/plugins/total-functions/rules/no-partial-string-normalize.d.mts.map +1 -1
  26. package/dist/plugins/total-functions/rules/no-partial-url-constructor.d.mts +3 -1
  27. package/dist/plugins/total-functions/rules/no-partial-url-constructor.d.mts.map +1 -1
  28. package/dist/plugins/total-functions/rules/no-partial-url-constructor.mjs +3 -6
  29. package/dist/plugins/total-functions/rules/no-partial-url-constructor.mjs.map +1 -1
  30. package/dist/plugins/total-functions/rules/no-premature-fp-ts-effects.d.mts +3 -1
  31. package/dist/plugins/total-functions/rules/no-premature-fp-ts-effects.d.mts.map +1 -1
  32. package/dist/plugins/total-functions/rules/no-unsafe-enum-assignment.d.mts +3 -1
  33. package/dist/plugins/total-functions/rules/no-unsafe-enum-assignment.d.mts.map +1 -1
  34. package/dist/plugins/total-functions/rules/no-unsafe-mutable-readonly-assignment.d.mts +3 -1
  35. package/dist/plugins/total-functions/rules/no-unsafe-mutable-readonly-assignment.d.mts.map +1 -1
  36. package/dist/plugins/total-functions/rules/no-unsafe-optional-property-assignment.d.mts +3 -1
  37. package/dist/plugins/total-functions/rules/no-unsafe-optional-property-assignment.d.mts.map +1 -1
  38. package/dist/plugins/total-functions/rules/no-unsafe-readonly-mutable-assignment.d.mts +3 -1
  39. package/dist/plugins/total-functions/rules/no-unsafe-readonly-mutable-assignment.d.mts.map +1 -1
  40. package/dist/plugins/total-functions/rules/no-unsafe-type-assertion.d.mts +3 -1
  41. package/dist/plugins/total-functions/rules/no-unsafe-type-assertion.d.mts.map +1 -1
  42. package/dist/plugins/total-functions/rules/require-strict-mode.d.mts +3 -1
  43. package/dist/plugins/total-functions/rules/require-strict-mode.d.mts.map +1 -1
  44. package/dist/plugins/total-functions/rules/rules.d.mts +42 -14
  45. package/dist/plugins/total-functions/rules/rules.d.mts.map +1 -1
  46. package/dist/plugins/ts-data-forge/rules/prefer-range-for-loop.d.mts.map +1 -1
  47. package/dist/plugins/ts-data-forge/rules/prefer-range-for-loop.mjs +2 -4
  48. package/dist/plugins/ts-data-forge/rules/prefer-range-for-loop.mjs.map +1 -1
  49. package/dist/plugins/ts-restrictions/rules/check-destructuring-completeness.d.mts.map +1 -1
  50. package/dist/plugins/ts-restrictions/rules/check-destructuring-completeness.mjs +8 -0
  51. package/dist/plugins/ts-restrictions/rules/check-destructuring-completeness.mjs.map +1 -1
  52. package/dist/rules/eslint-jest-rules.d.mts +1 -0
  53. package/dist/rules/eslint-jest-rules.d.mts.map +1 -1
  54. package/dist/rules/eslint-jest-rules.mjs +1 -0
  55. package/dist/rules/eslint-jest-rules.mjs.map +1 -1
  56. package/dist/rules/eslint-vitest-rules.d.mts +1 -0
  57. package/dist/rules/eslint-vitest-rules.d.mts.map +1 -1
  58. package/dist/rules/eslint-vitest-rules.mjs +1 -0
  59. package/dist/rules/eslint-vitest-rules.mjs.map +1 -1
  60. package/dist/types/rules/eslint-jest-rules.d.mts +87 -70
  61. package/dist/types/rules/eslint-jest-rules.d.mts.map +1 -1
  62. package/dist/types/rules/eslint-vitest-rules.d.mts +18 -0
  63. package/dist/types/rules/eslint-vitest-rules.d.mts.map +1 -1
  64. package/dist/types/rules/typescript-eslint-rules.d.mts +0 -1
  65. package/dist/types/rules/typescript-eslint-rules.d.mts.map +1 -1
  66. package/package.json +14 -14
  67. package/src/plugins/immer-coding-style/rules/prefer-curried-produce.mts +1 -2
  68. package/src/plugins/react-coding-style/rules/import-style.mts +2 -2
  69. package/src/plugins/react-coding-style/rules/props-type-annotation-style.mts +2 -8
  70. package/src/plugins/react-coding-style/rules/react-memo-props-argument-name.mts +1 -4
  71. package/src/plugins/strict-dependencies/rules/resolve-import-path.test.mts +3 -3
  72. package/src/plugins/total-functions/rules/no-partial-url-constructor.mts +3 -6
  73. package/src/plugins/ts-data-forge/rules/prefer-range-for-loop.mts +2 -4
  74. package/src/plugins/ts-restrictions/rules/check-destructuring-completeness.mts +14 -0
  75. package/src/plugins/ts-restrictions/rules/check-destructuring-completeness.test.mts +32 -0
  76. package/src/rules/eslint-jest-rules.mts +1 -0
  77. package/src/rules/eslint-vitest-rules.mts +1 -0
  78. package/src/types/rules/eslint-jest-rules.mts +88 -70
  79. package/src/types/rules/eslint-vitest-rules.mts +19 -0
  80. package/src/types/rules/typescript-eslint-rules.mts +0 -1
@@ -84,8 +84,8 @@ export const importStyleRule: TSESLint.RuleModule<MessageIds, Options> = {
84
84
  const [firstSpecifier] = node.specifiers;
85
85
 
86
86
  if (
87
- firstSpecifier === undefined ||
88
- firstSpecifier.type !== AST_NODE_TYPES.ImportNamespaceSpecifier ||
87
+ firstSpecifier?.type !==
88
+ AST_NODE_TYPES.ImportNamespaceSpecifier ||
89
89
  node.specifiers.length !== 1
90
90
  ) {
91
91
  context.report({
@@ -31,19 +31,13 @@ export const propsTypeAnnotationStyleRule: TSESLint.RuleModule<MessageIds> = {
31
31
 
32
32
  const arrowFunction = getReactMemoArrowFunction(node);
33
33
 
34
- if (
35
- arrowFunction === undefined ||
36
- arrowFunction.body.type !== AST_NODE_TYPES.BlockStatement
37
- ) {
34
+ if (arrowFunction?.body.type !== AST_NODE_TYPES.BlockStatement) {
38
35
  return;
39
36
  }
40
37
 
41
38
  const [firstParam] = arrowFunction.params;
42
39
 
43
- if (
44
- firstParam === undefined ||
45
- firstParam.type !== AST_NODE_TYPES.Identifier
46
- ) {
40
+ if (firstParam?.type !== AST_NODE_TYPES.Identifier) {
47
41
  return;
48
42
  }
49
43
 
@@ -36,10 +36,7 @@ export const reactMemoPropsArgumentNameRule: TSESLint.RuleModule<MessageIds> = {
36
36
  const arrowFunction = getReactMemoArrowFunction(node);
37
37
 
38
38
  // Detect `React.memo<Props>(({ prop1, prop2 }) => { ... })`
39
- if (
40
- arrowFunction === undefined ||
41
- arrowFunction.body.type !== AST_NODE_TYPES.BlockStatement
42
- ) {
39
+ if (arrowFunction?.body.type !== AST_NODE_TYPES.BlockStatement) {
43
40
  return;
44
41
  }
45
42
 
@@ -118,13 +118,13 @@ const useFixture = (fixtureName: FixtureName | undefined): void => {
118
118
 
119
119
  const compilerOptions = compilerOptionsByFixture[fixtureName];
120
120
 
121
- mockFindConfigFile.mockImplementation(() => 'tsconfig.json');
121
+ mockFindConfigFile.mockReturnValue('tsconfig.json');
122
122
 
123
- mockGetParsedCommandLine.mockImplementation(() => ({
123
+ mockGetParsedCommandLine.mockReturnValue({
124
124
  options: { ...compilerOptions },
125
125
  fileNames: [],
126
126
  errors: [],
127
- }));
127
+ });
128
128
  };
129
129
 
130
130
  const aliasCases = [
@@ -49,8 +49,7 @@ export const noPartialUrlConstructor = createRule({
49
49
  ) {
50
50
  if (
51
51
  node.arguments.length === 1 &&
52
- node.arguments[0] !== undefined &&
53
- node.arguments[0].type === AST_NODE_TYPES.Literal &&
52
+ node.arguments[0]?.type === AST_NODE_TYPES.Literal &&
54
53
  typeof node.arguments[0].value === 'string'
55
54
  ) {
56
55
  if (!isValidUrl(node.arguments[0].value)) {
@@ -65,11 +64,9 @@ export const noPartialUrlConstructor = createRule({
65
64
 
66
65
  if (
67
66
  node.arguments.length === 2 &&
68
- node.arguments[0] !== undefined &&
69
- node.arguments[0].type === AST_NODE_TYPES.Literal &&
67
+ node.arguments[0]?.type === AST_NODE_TYPES.Literal &&
70
68
  typeof node.arguments[0].value === 'string' &&
71
- node.arguments[1] !== undefined &&
72
- node.arguments[1].type === AST_NODE_TYPES.Literal &&
69
+ node.arguments[1]?.type === AST_NODE_TYPES.Literal &&
73
70
  typeof node.arguments[1].value === 'string'
74
71
  ) {
75
72
  if (!isValidUrl(node.arguments[0].value, node.arguments[1].value)) {
@@ -48,8 +48,7 @@ export const preferRangeForLoop: TSESLint.RuleModule<MessageIds, Options> = {
48
48
  ForStatement: (node) => {
49
49
  // Check init: let i = begin
50
50
  if (
51
- node.init === null ||
52
- node.init.type !== AST_NODE_TYPES.VariableDeclaration ||
51
+ node.init?.type !== AST_NODE_TYPES.VariableDeclaration ||
53
52
  node.init.kind !== 'let' ||
54
53
  !Arr.isArrayOfLength(node.init.declarations, 1)
55
54
  ) {
@@ -71,8 +70,7 @@ export const preferRangeForLoop: TSESLint.RuleModule<MessageIds, Options> = {
71
70
 
72
71
  // Check test: i < end
73
72
  if (
74
- node.test === null ||
75
- node.test.type !== AST_NODE_TYPES.BinaryExpression ||
73
+ node.test?.type !== AST_NODE_TYPES.BinaryExpression ||
76
74
  node.test.operator !== '<' ||
77
75
  node.test.left.type !== AST_NODE_TYPES.Identifier ||
78
76
  node.test.left.name !== varName
@@ -161,6 +161,13 @@ export const checkDestructuringCompleteness: TSESLint.RuleModule<
161
161
 
162
162
  if (!shouldCheck) return;
163
163
 
164
+ // If rest element is used, skip completeness check
165
+ const hasRestElement = node.id.properties.some(
166
+ (prop) => prop.type === AST_NODE_TYPES.RestElement,
167
+ );
168
+
169
+ if (hasRestElement) return;
170
+
164
171
  // eslint-disable-next-line total-functions/no-unsafe-type-assertion
165
172
  const tsNode = esTreeNodeToTSNodeMap.get(node.init as never);
166
173
 
@@ -207,6 +214,13 @@ export const checkDestructuringCompleteness: TSESLint.RuleModule<
207
214
 
208
215
  for (const param of node.params) {
209
216
  if (param.type === AST_NODE_TYPES.ObjectPattern) {
217
+ // If rest element is used, skip completeness check
218
+ const hasRestElement = param.properties.some(
219
+ (prop) => prop.type === AST_NODE_TYPES.RestElement,
220
+ );
221
+
222
+ if (hasRestElement) continue;
223
+
210
224
  // eslint-disable-next-line total-functions/no-unsafe-type-assertion
211
225
  const tsNode = esTreeNodeToTSNodeMap.get(param as never);
212
226
 
@@ -93,6 +93,38 @@ describe('check-destructuring-completeness', () => {
93
93
  };
94
94
  `,
95
95
  },
96
+ {
97
+ name: 'allows rest parameter without directive comment',
98
+ code: dedent`
99
+ const obj = { a: 1, b: 2, c: 3 };
100
+ const { a, ...rest } = obj;
101
+ `,
102
+ },
103
+ {
104
+ name: 'allows rest parameter with directive comment',
105
+ code: dedent`
106
+ const obj = { a: 1, b: 2, c: 3 };
107
+ // @check-destructuring-completeness
108
+ const { a, ...rest } = obj;
109
+ `,
110
+ },
111
+ {
112
+ name: 'allows rest parameter in React component props',
113
+ code: dedent`
114
+ type Props = { a: number; b: string; c: boolean };
115
+ const MyComponent = ({ a, ...rest }: Props) => <div>{a}</div>;
116
+ `,
117
+ },
118
+ {
119
+ name: 'allows rest parameter in internal destructuring',
120
+ code: dedent`
121
+ type Props = { a: number; b: string; c: boolean };
122
+ const MyComponent = (props: Props) => {
123
+ const { a, ...rest } = props;
124
+ return <div>{a}</div>;
125
+ };
126
+ `,
127
+ },
96
128
  {
97
129
  name: 'does not check React component props when disabled - parameter',
98
130
  code: dedent`
@@ -60,6 +60,7 @@ export const eslintJestRules = {
60
60
  'jest/prefer-snapshot-hint': withDefaultOption('error'),
61
61
  'jest/prefer-spy-on': 'error',
62
62
  'jest/prefer-todo': 'error',
63
+ 'jest/prefer-mock-return-shorthand': 'error',
63
64
 
64
65
  /* eslint-plugin-jest specific rules */
65
66
 
@@ -61,6 +61,7 @@ export const eslintVitestRules = {
61
61
  'vitest/prefer-snapshot-hint': withDefaultOption('error'),
62
62
  'vitest/prefer-spy-on': 'error',
63
63
  'vitest/prefer-todo': 'error',
64
+ 'vitest/prefer-mock-return-shorthand': 'error',
64
65
 
65
66
  /* eslint-plugin-vitest specific rules */
66
67