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): [prefer-nullish-coalescing] change ignoreConditionalTests default to true#8872

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

Merged
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@@ -65,7 +65,7 @@ foo ?? 'a string';

### `ignoreConditionalTests`

Setting this option to `true` will cause the rule toignore any cases that are located within a conditional test. This is set to `false` by default.
Setting this option to `false` will cause the rule toalso check cases that are located within a conditional test. This is set to `true` by default.

Generally expressions within conditional tests intentionally use the falsy fallthrough behavior of the logical or operator, meaning that fixing the operator to the nullish coalesce operator could cause bugs.

Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -100,7 +100,7 @@ export default createRule<Options, MessageIds>({
defaultOptions: [
{
allowRuleToRunWithoutStrictNullChecksIKnowWhatIAmDoing: false,
ignoreConditionalTests:false,
ignoreConditionalTests:true,
ignoreTernaryTests: false,
ignoreMixedLogicalExpressions: false,
ignorePrimitives: {
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -147,35 +147,30 @@ x === null ? x : y;
declare const x: ${type} | ${nullish};
x || 'foo' ? null : null;
`,
options: [{ ignoreConditionalTests: true }],
})),
...nullishTypeValidTest((nullish, type) => ({
code: `
declare const x: ${type} | ${nullish};
if (x || 'foo') {}
`,
options: [{ ignoreConditionalTests: true }],
})),
...nullishTypeValidTest((nullish, type) => ({
code: `
declare const x: ${type} | ${nullish};
do {} while (x || 'foo')
`,
options: [{ ignoreConditionalTests: true }],
})),
...nullishTypeValidTest((nullish, type) => ({
code: `
declare const x: ${type} | ${nullish};
for (;x || 'foo';) {}
`,
options: [{ ignoreConditionalTests: true }],
})),
...nullishTypeValidTest((nullish, type) => ({
code: `
declare const x: ${type} | ${nullish};
while (x || 'foo') {}
`,
options: [{ ignoreConditionalTests: true }],
})),

// ignoreMixedLogicalExpressions
Expand DownExpand Up@@ -706,7 +701,6 @@ declare const x: ${type} | ${nullish};
if (() => x || 'foo') {}
`,
output: null,
options: [{ ignoreConditionalTests: true }],
errors: [
{
messageId: 'preferNullishOverOr',
Expand All@@ -732,7 +726,6 @@ declare const x: ${type} | ${nullish};
if (function werid() { return x || 'foo' }) {}
`,
output: null,
options: [{ ignoreConditionalTests: true }],
errors: [
{
messageId: 'preferNullishOverOr',
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp