Skip to content

Commit

Permalink
fix(eslint-plugin): [no-unused-expressions] ignore import expressions (
Browse files Browse the repository at this point in the history
  • Loading branch information
a-tarasyuk committed May 30, 2020
1 parent dc061ed commit e383691
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/eslint-plugin/src/rules/no-unused-expressions.ts
Expand Up @@ -26,7 +26,8 @@ export default util.createRule<Options, MessageIds>({
ExpressionStatement(node): void {
if (
node.directive ||
node.expression.type === AST_NODE_TYPES.OptionalCallExpression
node.expression.type === AST_NODE_TYPES.OptionalCallExpression ||
node.expression.type === AST_NODE_TYPES.ImportExpression
) {
return;
}
Expand Down
Expand Up @@ -65,6 +65,12 @@ ruleTester.run('no-unused-expressions', rule, {
return null;
}
`,
`
import('./foo');
`,
`
import('./foo').then(() => {});
`,
],
invalid: [
{
Expand Down
3 changes: 2 additions & 1 deletion packages/typescript-estree/src/ts-estree/ts-estree.ts
Expand Up @@ -359,7 +359,8 @@ export type Expression =
| SpreadElement
| TSAsExpression
| TSUnaryExpression
| YieldExpression;
| YieldExpression
| ImportExpression;
export type ExpressionWithTypeArguments =
| TSClassImplements
| TSInterfaceHeritage;
Expand Down

0 comments on commit e383691

Please sign in to comment.