@taiga-ui/eslint-plugin-experience-next 0.506.0 → 0.507.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +37 -0
- package/index.d.ts +3 -0
- package/index.esm.js +488 -435
- package/package.json +1 -1
- package/rules/recommended/prefer-conditional-return.d.ts +5 -0
package/README.md
CHANGED
|
@@ -108,6 +108,7 @@ from third-party plugins. The exact severities and file globs live in
|
|
|
108
108
|
| [no-useless-untracked](https://github.com/taiga-family/toolkit/tree/main/projects/eslint-plugin-experience-next/docs/no-useless-untracked.md) | Disallow provably useless `untracked()` wrappers in reactive callbacks | ✅ | 🔧 | |
|
|
109
109
|
| [object-single-line](https://github.com/taiga-family/toolkit/tree/main/projects/eslint-plugin-experience-next/docs/object-single-line.md) | Enforce single-line formatting for single-property objects when it fits `printWidth` | ✅ | 🔧 | |
|
|
110
110
|
| [prefer-combined-if-control-flow](https://github.com/taiga-family/toolkit/tree/main/projects/eslint-plugin-experience-next/docs/prefer-combined-if-control-flow.md) | Combine consecutive `if` statements that use the same `return`, `break`, `continue`, or `throw` | ✅ | 🔧 | |
|
|
111
|
+
| [prefer-conditional-return](https://github.com/taiga-family/toolkit/tree/main/projects/eslint-plugin-experience-next/docs/prefer-conditional-return.md) | Prefer a conditional return over an adjacent `if` branch and fallback `return` | ✅ | 🔧 | |
|
|
111
112
|
| [prefer-deep-imports](https://github.com/taiga-family/toolkit/tree/main/projects/eslint-plugin-experience-next/docs/prefer-deep-imports.md) | Allow deep imports of Taiga UI packages | | 🔧 | |
|
|
112
113
|
| [prefer-loose-null-check](https://github.com/taiga-family/toolkit/tree/main/projects/eslint-plugin-experience-next/docs/prefer-loose-null-check.md) | Prefer loose null checks over paired strict comparisons against `null` and `undefined` | ✅ | 🔧 | |
|
|
113
114
|
| [prefer-multi-arg-push](https://github.com/taiga-family/toolkit/tree/main/projects/eslint-plugin-experience-next/docs/prefer-multi-arg-push.md) | Combine consecutive `.push()` calls on the same array into a single multi-argument call | ✅ | 🔧 | |
|
|
@@ -125,3 +126,39 @@ from third-party plugins. The exact severities and file globs live in
|
|
|
125
126
|
| [single-line-variable-spacing](https://github.com/taiga-family/toolkit/tree/main/projects/eslint-plugin-experience-next/docs/single-line-variable-spacing.md) | Group consecutive single-line variables and separate multiline ones with a blank line | ✅ | 🔧 | |
|
|
126
127
|
| [standalone-imports-sort](https://github.com/taiga-family/toolkit/tree/main/projects/eslint-plugin-experience-next/docs/standalone-imports-sort.md) | Auto sort names inside Angular decorators | ✅ | 🔧 | |
|
|
127
128
|
| [strict-tui-doc-example](https://github.com/taiga-family/toolkit/tree/main/projects/eslint-plugin-experience-next/docs/strict-tui-doc-example.md) | If you use the addon-doc, there will be a hint that you are importing something incorrectly | | 🔧 | |
|
|
129
|
+
|
|
130
|
+
## prefer-conditional-return
|
|
131
|
+
|
|
132
|
+
Prefer a single conditional return when an `if` statement returns one expression and the immediately following statement
|
|
133
|
+
returns the fallback expression. The rule skips branches with comments, `else`, empty returns, intervening statements,
|
|
134
|
+
or a return expression that is already a conditional expression.
|
|
135
|
+
|
|
136
|
+
```ts
|
|
137
|
+
// ❌ error
|
|
138
|
+
if (index < count) {
|
|
139
|
+
return {value: index++, done: false};
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
return {value: undefined, done: true};
|
|
143
|
+
|
|
144
|
+
// ✅ after autofix
|
|
145
|
+
return index < count ? {value: index++, done: false} : {value: undefined, done: true};
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
```ts
|
|
149
|
+
// not changed: if branch return is already conditional
|
|
150
|
+
if (condition) {
|
|
151
|
+
return first ? second : third;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return fallback;
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
```ts
|
|
158
|
+
// not changed: fallback return is already conditional
|
|
159
|
+
if (condition) {
|
|
160
|
+
return value;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
return first ? second : third;
|
|
164
|
+
```
|
package/index.d.ts
CHANGED
|
@@ -142,6 +142,9 @@ declare const plugin: {
|
|
|
142
142
|
'prefer-combined-if-control-flow': import("@typescript-eslint/utils/ts-eslint").RuleModule<"preferCombinedIfControlFlow", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
143
143
|
name: string;
|
|
144
144
|
};
|
|
145
|
+
'prefer-conditional-return': import("@typescript-eslint/utils/ts-eslint").RuleModule<"preferConditionalReturn", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
146
|
+
name: string;
|
|
147
|
+
};
|
|
145
148
|
'prefer-deep-imports': import("@typescript-eslint/utils/ts-eslint").RuleModule<"prefer-deep-imports", [{
|
|
146
149
|
importFilter: string[] | string;
|
|
147
150
|
strict?: boolean;
|