Skip to content

Commit

Permalink
Return no-unused-expressions linting in typescript files (#461)
Browse files Browse the repository at this point in the history
  • Loading branch information
BPScott authored Feb 2, 2025
1 parent 039e352 commit b1b449c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .changeset/spicy-toes-punch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@shopify/eslint-plugin': patch
---

Add `@typescript-eslint/no-unused-expressions` to typescript ruleset

In v46 in, we enabled `no-unused-expressions` in the core js config, then disabled it and replaced it with `@babel/no-unused-expressions` in esnext config. In typescript files we turn off `no-unused-expressions` but left `@babel/no-unused-expressions` enabled - which seems like an oversight given that `@typescript-eslint/no-unused-expressions` existed. In v47.0.0 we removed configuration of `@babel/no-unused-expressions` entirely, which meant that there was no linting of unused-expressions. This change brings back unused expression linting to typescript files.
2 changes: 2 additions & 0 deletions packages/eslint-plugin/lib/config/typescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ module.exports = [
'@typescript-eslint/consistent-indexed-object-style': 'error',
// Disallows unnecessary constraints on generic types
'@typescript-eslint/no-unnecessary-type-constraint': 'error',
// Disallow unused expressions
'@typescript-eslint/no-unused-expressions': 'error',

// Handled by TypeScript itself
'no-undef': 'off',
Expand Down

0 comments on commit b1b449c

Please sign in to comment.