diff --git a/packages/eslint-plugin/docs/rules/consistent-type-assertions.md b/packages/eslint-plugin/docs/rules/consistent-type-assertions.md
index 43e67b755b5..899647636cb 100644
--- a/packages/eslint-plugin/docs/rules/consistent-type-assertions.md
+++ b/packages/eslint-plugin/docs/rules/consistent-type-assertions.md
@@ -74,13 +74,14 @@ function foo(): T {
Examples of **correct** code for `{ assertionStyle: 'as', objectLiteralTypeAssertions: 'allow-as-parameter' }`.
-```ts
+```tsx
const x: T = { ... };
const y = { ... } as any;
const z = { ... } as unknown;
foo({ ... } as T);
new Clazz({ ... } as T);
function foo() { throw { bar: 5 } as Foo }
+const foo = ;
```
## When Not To Use It
diff --git a/packages/eslint-plugin/src/rules/consistent-type-assertions.ts b/packages/eslint-plugin/src/rules/consistent-type-assertions.ts
index adc88dc965a..3b431b80675 100644
--- a/packages/eslint-plugin/src/rules/consistent-type-assertions.ts
+++ b/packages/eslint-plugin/src/rules/consistent-type-assertions.ts
@@ -140,7 +140,8 @@ export default util.createRule({
(node.parent.type === AST_NODE_TYPES.NewExpression ||
node.parent.type === AST_NODE_TYPES.CallExpression ||
node.parent.type === AST_NODE_TYPES.ThrowStatement ||
- node.parent.type === AST_NODE_TYPES.AssignmentPattern)
+ node.parent.type === AST_NODE_TYPES.AssignmentPattern ||
+ node.parent.type === AST_NODE_TYPES.JSXExpressionContainer)
) {
return;
}
diff --git a/packages/eslint-plugin/tests/rules/consistent-type-assertions.test.ts b/packages/eslint-plugin/tests/rules/consistent-type-assertions.test.ts
index 010bb894ad7..1711e4450c3 100644
--- a/packages/eslint-plugin/tests/rules/consistent-type-assertions.test.ts
+++ b/packages/eslint-plugin/tests/rules/consistent-type-assertions.test.ts
@@ -112,6 +112,20 @@ ruleTester.run('consistent-type-assertions', rule, {
},
],
},
+ {
+ code: 'const bar = ;',
+ parserOptions: {
+ ecmaFeatures: {
+ jsx: true,
+ },
+ },
+ options: [
+ {
+ assertionStyle: 'as',
+ objectLiteralTypeAssertions: 'allow-as-parameter',
+ },
+ ],
+ },
],
invalid: [
...batchedSingleLineTests({
@@ -342,5 +356,24 @@ ruleTester.run('consistent-type-assertions', rule, {
},
],
}),
+ {
+ code: 'const foo = ;',
+ parserOptions: {
+ ecmaFeatures: {
+ jsx: true,
+ },
+ },
+ options: [
+ {
+ assertionStyle: 'never',
+ },
+ ],
+ errors: [
+ {
+ messageId: 'never',
+ line: 1,
+ },
+ ],
+ },
],
});