Skip to content

Commit f8b9a47

Browse files
committed
feat: wpi no-unnecessary-condition
1 parent 7399ef7 commit f8b9a47

38 files changed

+3019
-28
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
/tests/fixtures/rules/valid-compile/valid/babel
1212
/tests/fixtures/rules/valid-compile/valid/ts
1313
/tests/fixtures/rules/prefer-style-directive
14+
/tests/fixtures/rules/@typescript-eslint
1415
/.svelte-kit
1516
/svelte.config-dist.js
1617
/build

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,10 +322,11 @@ These rules relate to style guidelines, and are therefore quite subjective:
322322

323323
## Extension Rules
324324

325-
These rules extend the rules provided by ESLint itself to work well in Svelte:
325+
These rules extend the rules provided by ESLint itself, or other plugins to work well in Svelte:
326326

327327
| Rule ID | Description | |
328328
|:--------|:------------|:---|
329+
| [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: |
329330
| [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: |
330331
| [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: |
331332

docs/rules.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,11 @@ These rules relate to style guidelines, and are therefore quite subjective:
7575

7676
## Extension Rules
7777

78-
These rules extend the rules provided by ESLint itself to work well in Svelte:
78+
These rules extend the rules provided by ESLint itself, or other plugins to work well in Svelte:
7979

8080
| Rule ID | Description | |
8181
|:--------|:------------|:---|
82+
| [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: |
8283
| [svelte/no-inner-declarations](./rules/no-inner-declarations.md) | disallow variable or `function` declarations in nested blocks | :star: |
8384
| [svelte/no-trailing-spaces](./rules/no-trailing-spaces.md) | disallow trailing whitespace at the end of lines | :wrench: |
8485

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
pageClass: "rule-details"
3+
sidebarDepth: 0
4+
title: "svelte/@typescript-eslint/no-unnecessary-condition"
5+
description: "disallow conditionals where the type is always truthy or always falsy"
6+
---
7+
8+
# svelte/@typescript-eslint/no-unnecessary-condition
9+
10+
> disallow conditionals where the type is always truthy or always falsy
11+
12+
- :exclamation: <badge text="This rule has not been released yet." vertical="middle" type="error"> **_This rule has not been released yet._** </badge>
13+
- :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.
14+
15+
## :book: Rule Details
16+
17+
This rule reports ???.
18+
19+
<ESLintCodeBlock fix>
20+
21+
<!--eslint-skip-->
22+
23+
```svelte
24+
<script>
25+
/* eslint svelte/@typescript-eslint/no-unnecessary-condition: "error" */
26+
</script>
27+
28+
<!-- ✓ GOOD -->
29+
30+
<!-- ✗ BAD -->
31+
32+
```
33+
34+
</ESLintCodeBlock>
35+
36+
## :wrench: Options
37+
38+
```json
39+
{
40+
"svelte/@typescript-eslint/no-unnecessary-condition": ["error", {
41+
42+
}]
43+
}
44+
```
45+
46+
-
47+
48+
## :books: Further Reading
49+
50+
-
51+
52+
## :mag: Implementation
53+
54+
- [Rule source](https://github.com/ota-meshi/eslint-plugin-svelte/blob/main/src/rules/@typescript-eslint/no-unnecessary-condition.ts)
55+
- [Test source](https://github.com/ota-meshi/eslint-plugin-svelte/blob/main/tests/src/rules/@typescript-eslint/no-unnecessary-condition.ts)
56+
57+
<sup>Taken with ❤️ [from @typescript-eslint/eslint-plugin](https://typescript-eslint.io/rules/no-unnecessary-condition/)</sup>

0 commit comments

Comments
 (0)