Skip to content

Commit

Permalink
✨ add support strict boolean expression (#48)
Browse files Browse the repository at this point in the history
resolved #45
  • Loading branch information
woohm402 authored Jul 22, 2024
1 parent f04731c commit a9c8ece
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/base/__tests__/base.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ describe('@woohm402/eslint-config-base', function () {
it('wrong', async function () {
const [result] = await eslint.lintFiles([`${__dirname}/wrong.ts`]);

expect(result.errorCount).toBe(5);
expect(result.errorCount).toBe(6);
});
});
7 changes: 5 additions & 2 deletions packages/base/__tests__/wrong.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ function b() {
}

const c: number = 1;
const d = `aa ${c || null}`;
const d = `aa ${c === 1 || null}`;

const e: boolean | null = false;
const f = e && 'asdf';

// below is correct
console.debug(a, d);
console.debug(a, d, f);
b();
14 changes: 14 additions & 0 deletions packages/base/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,20 @@ const baseRules: ConfigWithExtends = {
allowNever: false,
},
],
'@typescript-eslint/strict-boolean-expressions': [
'error',
{
allowString: false,
allowNumber: false,
allowNullableObject: false,
allowNullableBoolean: false,
allowNullableString: false,
allowNullableNumber: false,
allowNullableEnum: false,
allowAny: false,
allowRuleToRunWithoutStrictNullChecksIKnowWhatIAmDoing: false,
},
],
},
};

Expand Down

0 comments on commit a9c8ece

Please sign in to comment.