Skip to content

Commit

Permalink
feat!: @typescript-eslint/no-unnecessary-condition
Browse files Browse the repository at this point in the history
  • Loading branch information
mightyiam committed Sep 21, 2024
1 parent 8b68bf3 commit edc29da
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
6 changes: 6 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,12 @@ const rules = {
],
'@typescript-eslint/no-this-alias': ['error', { allowDestructuring: true }],
'@typescript-eslint/no-unnecessary-boolean-literal-compare': ['error'],
'@typescript-eslint/no-unnecessary-condition': [
'error',
{
allowConstantLoopConditions: true,
},
],
'@typescript-eslint/no-unnecessary-type-assertion': ['error'],
'@typescript-eslint/no-unnecessary-type-constraint': ['error'],
'@typescript-eslint/no-unsafe-argument': ['error'],
Expand Down
6 changes: 6 additions & 0 deletions src/test/_expected-exported-value.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,12 @@ export const expectedExportedValue: TSESLint.FlatConfig.Config = {
'error',
{ allow: [], allowAsImport: false },
],
'@typescript-eslint/no-unnecessary-condition': [
'error',
{
allowConstantLoopConditions: true,
},
],
'@typescript-eslint/no-unnecessary-type-assertion': ['error'],
'@typescript-eslint/no-unnecessary-type-constraint': ['error'],
'@typescript-eslint/no-unnecessary-boolean-literal-compare': ['error'],
Expand Down
1 change: 0 additions & 1 deletion src/test/_rules_to_consider.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export const rulesToConsider = [
'@typescript-eslint/no-unnecessary-condition',
'@typescript-eslint/no-unnecessary-parameter-property-assignment',
'@typescript-eslint/no-unnecessary-qualifier',
'@typescript-eslint/no-unnecessary-template-expression',
Expand Down
5 changes: 0 additions & 5 deletions src/test/rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ import { TSESLint } from '@typescript-eslint/utils'
import { intentionallyUnusedRules } from '../_intentionally-unused-rules'
import { rulesToConsider } from './_rules_to_consider'

if (pluginN === undefined) throw new Error()
if (pluginImport === undefined) throw new Error()
if (pluginPromise === undefined) throw new Error()

const eslintRules = new TSESLint.Linter().getRules()

if (pluginN.rules === undefined) throw new Error()
Expand Down Expand Up @@ -105,7 +101,6 @@ test('no deprecated rules', (t) => {
test('JS equivalent rules are off', async (t) => {
if (pluginTseslint.rules === undefined) throw new Error()
const ourRules_: TSESLint.FlatConfig.Rules = ourRules
if (ourRules_ === undefined) throw new Error()

const jsEquivalentRulesThatAreOn = equivalents.filter((ruleName) => {
const baseRuleConfig = ourRules_[ruleName]
Expand Down

0 comments on commit edc29da

Please sign in to comment.