mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
117616: Ported themed-wrapper-no-input-defaults rule
This commit is contained in:
@@ -5,3 +5,4 @@ _______
|
||||
- [`dspace-angular-ts/themed-component-classes`](./rules/themed-component-classes.md): Formatting rules for themeable component classes
|
||||
- [`dspace-angular-ts/themed-component-selectors`](./rules/themed-component-selectors.md): Themeable component selectors should follow the DSpace convention
|
||||
- [`dspace-angular-ts/themed-component-usages`](./rules/themed-component-usages.md): Themeable components should be used via their `ThemedComponent` wrapper class
|
||||
- [`dspace-angular-ts/themed-wrapper-no-input-defaults`](./rules/themed-wrapper-no-input-defaults.md): ThemedComponent wrappers should not declare input defaults (see [DSpace Angular #2164](https://github.com/DSpace/dspace-angular/pull/2164))
|
||||
|
82
docs/lint/ts/rules/themed-wrapper-no-input-defaults.md
Normal file
82
docs/lint/ts/rules/themed-wrapper-no-input-defaults.md
Normal file
@@ -0,0 +1,82 @@
|
||||
[DSpace ESLint plugins](../../../../lint/README.md) > [TypeScript rules](../index.md) > `dspace-angular-ts/themed-wrapper-no-input-defaults`
|
||||
_______
|
||||
|
||||
ThemedComponent wrappers should not declare input defaults (see [DSpace Angular #2164](https://github.com/DSpace/dspace-angular/pull/2164))
|
||||
|
||||
_______
|
||||
|
||||
[Source code](../../../../lint/src/rules/ts/themed-wrapper-no-input-defaults.ts)
|
||||
|
||||
### Examples
|
||||
|
||||
|
||||
#### Valid code
|
||||
|
||||
##### ThemedComponent wrapper defines an input without a default value
|
||||
|
||||
```typescript
|
||||
export class TTest extends ThemedComponent<Test> {
|
||||
|
||||
@Input()
|
||||
test;
|
||||
}
|
||||
```
|
||||
|
||||
##### Regular class defines an input with a default value
|
||||
|
||||
```typescript
|
||||
export class Test {
|
||||
|
||||
@Input()
|
||||
test = 'test';
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
#### Invalid code
|
||||
|
||||
##### ThemedComponent wrapper defines an input with a default value
|
||||
|
||||
```typescript
|
||||
export class TTest extends ThemedComponent<Test> {
|
||||
|
||||
@Input()
|
||||
test1 = 'test';
|
||||
|
||||
@Input()
|
||||
test2 = true;
|
||||
|
||||
@Input()
|
||||
test2: number = 123;
|
||||
|
||||
@Input()
|
||||
test3: number[] = [1,2,3];
|
||||
}
|
||||
```
|
||||
Will produce the following error(s):
|
||||
```
|
||||
ThemedComponent wrapper declares inputs with defaults
|
||||
ThemedComponent wrapper declares inputs with defaults
|
||||
ThemedComponent wrapper declares inputs with defaults
|
||||
ThemedComponent wrapper declares inputs with defaults
|
||||
```
|
||||
|
||||
|
||||
##### ThemedComponent wrapper defines an input with an undefined default value
|
||||
|
||||
```typescript
|
||||
export class TTest extends ThemedComponent<Test> {
|
||||
|
||||
@Input()
|
||||
test = undefined;
|
||||
}
|
||||
```
|
||||
Will produce the following error(s):
|
||||
```
|
||||
ThemedComponent wrapper declares inputs with defaults
|
||||
```
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user