Skip to content

Commit ea508a5

Browse files
committed
fix: disabled svelte/@typescript-eslint/no-unnecessary-condition rule
1 parent 9a9ba19 commit ea508a5

File tree

7 files changed

+46
-15
lines changed

7 files changed

+46
-15
lines changed

README.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,6 @@ These rules extend the rules provided by ESLint itself, or other plugins to work
327327

328328
| Rule ID | Description | |
329329
|:--------|:------------|:---|
330-
| [svelte/@typescript-eslint/no-unnecessary-condition](https://ota-meshi.github.io/eslint-plugin-svelte/rules/@typescript-eslint/no-unnecessary-condition/) | disallow conditionals where the type is always truthy or always falsy | :wrench: |
331330
| [svelte/no-inner-declarations](https://ota-meshi.github.io/eslint-plugin-svelte/rules/no-inner-declarations/) | disallow variable or `function` declarations in nested blocks | :star: |
332331
| [svelte/no-trailing-spaces](https://ota-meshi.github.io/eslint-plugin-svelte/rules/no-trailing-spaces/) | disallow trailing whitespace at the end of lines | :wrench: |
333332

@@ -340,6 +339,15 @@ These rules relate to this plugin works:
340339
| [svelte/comment-directive](https://ota-meshi.github.io/eslint-plugin-svelte/rules/comment-directive/) | support comment-directives in HTML template | :star: |
341340
| [svelte/system](https://ota-meshi.github.io/eslint-plugin-svelte/rules/system/) | system rule for working this plugin | :star: |
342341

342+
## Deprecated
343+
344+
- :warning: We're going to remove deprecated rules in the next major release. Please migrate to successor/new rules.
345+
- :innocent: We don't fix bugs which are in deprecated rules since we don't have enough resources.
346+
347+
| Rule ID | Replaced by |
348+
|:--------|:------------|
349+
| [svelte/@typescript-eslint/no-unnecessary-condition](https://ota-meshi.github.io/eslint-plugin-svelte/rules/@typescript-eslint/no-unnecessary-condition/) | This rule is no longer needed when using svelte-eslint-parser>=v0.19.0. |
350+
343351
<!--RULES_TABLE_END-->
344352
<!--RULES_SECTION_END-->
345353
<!-- prettier-ignore-end -->

docs/rules.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ These rules extend the rules provided by ESLint itself, or other plugins to work
8080

8181
| Rule ID | Description | |
8282
|:--------|:------------|:---|
83-
| [svelte/@typescript-eslint/no-unnecessary-condition](./rules/@typescript-eslint/no-unnecessary-condition.md) | disallow conditionals where the type is always truthy or always falsy | :wrench: |
8483
| [svelte/no-inner-declarations](./rules/no-inner-declarations.md) | disallow variable or `function` declarations in nested blocks | :star: |
8584
| [svelte/no-trailing-spaces](./rules/no-trailing-spaces.md) | disallow trailing whitespace at the end of lines | :wrench: |
8685

@@ -92,3 +91,12 @@ These rules relate to this plugin works:
9291
|:--------|:------------|:---|
9392
| [svelte/comment-directive](./rules/comment-directive.md) | support comment-directives in HTML template | :star: |
9493
| [svelte/system](./rules/system.md) | system rule for working this plugin | :star: |
94+
95+
## Deprecated
96+
97+
- :warning: We're going to remove deprecated rules in the next major release. Please migrate to successor/new rules.
98+
- :innocent: We don't fix bugs which are in deprecated rules since we don't have enough resources.
99+
100+
| Rule ID | Replaced by |
101+
|:--------|:------------|
102+
| [svelte/@typescript-eslint/no-unnecessary-condition](./rules/@typescript-eslint/no-unnecessary-condition.md) | This rule is no longer needed when using svelte-eslint-parser>=v0.19.0. |

docs/rules/@typescript-eslint/no-unnecessary-condition.md

+3
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@ since: "v2.9.0"
1010

1111
> disallow conditionals where the type is always truthy or always falsy
1212
13+
- :warning: This rule was **deprecated**. This rule is no longer needed when using svelte-eslint-parser>=v0.19.0.
1314
- :wrench: The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.
1415

1516
## :book: Rule Details
1617

18+
**This rule is no longer needed when using svelte-eslint-parser>=v0.19.0.**
19+
1720
This rule extends the base `@typescript-eslint`'s [@typescript-eslint/no-unnecessary-condition] rule.
1821
The [@typescript-eslint/no-unnecessary-condition] rule does not understand reactive or rerendering of Svelte components and has false positives when used with Svelte components. This rule understands reactive and rerendering of Svelte components.
1922

src/rules/@typescript-eslint/no-unnecessary-condition.ts

+4
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,10 @@ export default createRule("@typescript-eslint/no-unnecessary-condition", {
144144
"This rule requires the `strictNullChecks` compiler option to be turned on to function correctly.",
145145
},
146146
type: "suggestion", // "problem", or "layout",
147+
deprecated: true,
148+
replacedBy: {
149+
note: "This rule is no longer needed when using svelte-eslint-parser>=v0.19.0.",
150+
},
147151
},
148152
create(context) {
149153
const {

src/types.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export interface RuleMetaData {
7777
hasSuggestions?: boolean
7878
schema: JSONSchema4 | JSONSchema4[]
7979
deprecated?: boolean
80-
replacedBy?: string[]
80+
replacedBy?: string[] | { note: string }
8181
type: "problem" | "suggestion" | "layout"
8282
}
8383

@@ -112,7 +112,7 @@ export interface PartialRuleMetaData {
112112
hasSuggestions?: boolean
113113
schema: JSONSchema4 | JSONSchema4[]
114114
deprecated?: boolean
115-
replacedBy?: string[]
115+
replacedBy?: string[] | { note: string }
116116
type: "problem" | "suggestion" | "layout"
117117
}
118118

tools/render-rules.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,11 @@ export default function renderRulesTableContent(
6868
rule.meta.docs.ruleName || "",
6969
)})`
7070
const replacedRules = rule.meta.replacedBy || []
71-
const replacedBy = replacedRules
72-
.map((name) => `[svelte/${name}](${buildRulePath(name)})`)
73-
.join(", ")
71+
const replacedBy = Array.isArray(replacedRules)
72+
? replacedRules
73+
.map((name) => `[svelte/${name}](${buildRulePath(name)})`)
74+
.join(", ")
75+
: replacedRules.note
7476

7577
return `| ${link} | ${replacedBy || "(no replacement)"} |`
7678
}

tools/update-docs.ts

+14-8
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,20 @@ class DocFile {
8080

8181
if (deprecated) {
8282
if (replacedBy) {
83-
const replacedRules = replacedBy.map(
84-
(name) => `[svelte/${name}](${name}.md) rule`,
85-
)
86-
notes.push(
87-
`- :warning: This rule was **deprecated** and replaced by ${formatItems(
88-
replacedRules,
89-
)}.`,
90-
)
83+
if (Array.isArray(replacedBy)) {
84+
const replacedRules = replacedBy.map(
85+
(name) => `[svelte/${name}](${name}.md) rule`,
86+
)
87+
notes.push(
88+
`- :warning: This rule was **deprecated** and replaced by ${formatItems(
89+
replacedRules,
90+
)}.`,
91+
)
92+
} else {
93+
notes.push(
94+
`- :warning: This rule was **deprecated**. ${replacedBy.note}`,
95+
)
96+
}
9197
} else {
9298
notes.push("- :warning: This rule was **deprecated**.")
9399
}

0 commit comments

Comments
 (0)