Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat(eslint-plugin): [no-unnecessary-condition] enable checkTypePredicates by default#10721

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
mdm317 wants to merge2 commits intotypescript-eslint:main
base:main
Choose a base branch
Loading
frommdm317:10720-checkTypePredicates-by-default
Draft
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -185,7 +185,7 @@ export default createRule<Options, MessageId>({
{
allowConstantLoopConditions: false,
allowRuleToRunWithoutStrictNullChecksIKnowWhatIAmDoing: false,
checkTypePredicates:false,
checkTypePredicates:true,
},
],
create(
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -965,15 +965,13 @@ declare function assert(x: unknown): asserts x;

assert(Math.random() > 0.5);
`,
options: [{ checkTypePredicates: true }],
},
{
code: `
declare function assert(x: unknown, y: unknown): asserts x;

assert(Math.random() > 0.5, true);
`,
options: [{ checkTypePredicates: true }],
},
{
// should not report because option is disabled.
Expand All@@ -993,7 +991,6 @@ class ThisAsserter {
const thisAsserter: ThisAsserter = new ThisAsserter();
thisAsserter.assertThis(true);
`,
options: [{ checkTypePredicates: true }],
},
{
// could be argued that this should report since `thisAsserter` is truthy.
Expand All@@ -1005,22 +1002,19 @@ class ThisAsserter {
const thisAsserter: ThisAsserter = new ThisAsserter();
thisAsserter.assertThis(Math.random());
`,
options: [{ checkTypePredicates: true }],
},
{
code: `
declare function assert(x: unknown): asserts x;
assert(...[]);
`,
options: [{ checkTypePredicates: true }],
},
{
// ok to report if we start unpacking spread params one day.
code: `
declare function assert(x: unknown): asserts x;
assert(...[], {});
`,
options: [{ checkTypePredicates: true }],
},
{
code: `
Expand All@@ -1044,15 +1038,13 @@ isString(a);
declare function assertString(x: unknown): asserts x is string;
assertString('falafel');
`,
options: [{ checkTypePredicates: true }],
},
{
// Technically, this has type 'falafel' and not string.
code: `
declare function isString(x: unknown): x is string;
isString('falafel');
`,
options: [{ checkTypePredicates: true }],
},
`
type A = { [name in Lowercase<string>]?: A };
Expand DownExpand Up@@ -2874,7 +2866,6 @@ assert(true);
messageId: 'alwaysTruthy',
},
],
options: [{ checkTypePredicates: true }],
},
{
code: `
Expand All@@ -2888,7 +2879,6 @@ assert(false);
messageId: 'alwaysFalsy',
},
],
options: [{ checkTypePredicates: true }],
},
{
code: `
Expand All@@ -2903,7 +2893,6 @@ assert(true, Math.random() > 0.5);
messageId: 'alwaysTruthy',
},
],
options: [{ checkTypePredicates: true }],
},
{
code: `
Expand All@@ -2917,7 +2906,6 @@ assert({});
messageId: 'alwaysTruthy',
},
],
options: [{ checkTypePredicates: true }],
},
{
code: `
Expand All@@ -2931,7 +2919,6 @@ assertsString(a);
messageId: 'typeGuardAlreadyIsType',
},
],
options: [{ checkTypePredicates: true }],
},
{
code: `
Expand All@@ -2945,7 +2932,6 @@ isString(a);
messageId: 'typeGuardAlreadyIsType',
},
],
options: [{ checkTypePredicates: true }],
},
{
code: `
Expand All@@ -2959,7 +2945,6 @@ isString('fa' + 'lafel');
messageId: 'typeGuardAlreadyIsType',
},
],
options: [{ checkTypePredicates: true }],
},

// "branded" types
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp