mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
117616: Ported themed-decorators rule
This commit is contained in:
@@ -5,5 +5,6 @@ _______
|
||||
- [`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-decorators`](./rules/themed-decorators.md): Entry components with theme support should declare the correct theme
|
||||
- [`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))
|
||||
- [`dspace-angular-ts/unique-decorators`](./rules/unique-decorators.md): Some decorators must be called with unique arguments (e.g. when they construct a mapping based on the argument values)
|
||||
|
158
docs/lint/ts/rules/themed-decorators.md
Normal file
158
docs/lint/ts/rules/themed-decorators.md
Normal file
@@ -0,0 +1,158 @@
|
||||
[DSpace ESLint plugins](../../../../lint/README.md) > [TypeScript rules](../index.md) > `dspace-angular-ts/themed-decorators`
|
||||
_______
|
||||
|
||||
Entry components with theme support should declare the correct theme
|
||||
|
||||
_______
|
||||
|
||||
[Source code](../../../../lint/src/rules/ts/themed-decorators.ts)
|
||||
|
||||
### Examples
|
||||
|
||||
|
||||
#### Valid code
|
||||
|
||||
##### theme file declares the correct theme in @listableObjectComponent
|
||||
|
||||
Filename: `lint/test/fixture/src/themes/test/app/dynamic-component/dynamic-component.ts`
|
||||
|
||||
```typescript
|
||||
@listableObjectComponent(something, somethingElse, undefined, 'test')
|
||||
export class Something extends SomethingElse {
|
||||
}
|
||||
```
|
||||
|
||||
##### plain file declares no theme in @listableObjectComponent
|
||||
|
||||
Filename: `lint/test/fixture/src/app/dynamic-component/dynamic-component.ts`
|
||||
|
||||
```typescript
|
||||
@listableObjectComponent(something, somethingElse, undefined)
|
||||
export class Something extends SomethingElse {
|
||||
}
|
||||
```
|
||||
|
||||
##### plain file declares explicit undefined theme in @listableObjectComponent
|
||||
|
||||
Filename: `lint/test/fixture/src/app/dynamic-component/dynamic-component.ts`
|
||||
|
||||
```typescript
|
||||
@listableObjectComponent(something, somethingElse, undefined, undefined)
|
||||
export class Something extends SomethingElse {
|
||||
}
|
||||
```
|
||||
|
||||
##### test file declares theme outside of theme directory
|
||||
|
||||
Filename: `lint/test/fixture/src/app/dynamic-component/dynamic-component.spec.ts`
|
||||
|
||||
```typescript
|
||||
@listableObjectComponent(something, somethingElse, undefined, 'test')
|
||||
export class Something extends SomethingElse {
|
||||
}
|
||||
```
|
||||
|
||||
##### only track configured decorators
|
||||
|
||||
Filename: `lint/test/fixture/src/app/dynamic-component/dynamic-component.ts`
|
||||
|
||||
```typescript
|
||||
@something('test')
|
||||
export class Something extends SomethingElse {
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
#### Invalid code & automatic fixes
|
||||
|
||||
##### theme file declares the wrong theme in @listableObjectComponent
|
||||
|
||||
Filename: `lint/test/fixture/src/themes/test/app/dynamic-component/dynamic-component.ts`
|
||||
|
||||
```typescript
|
||||
@listableObjectComponent(something, somethingElse, undefined, 'test-2')
|
||||
export class Something extends SomethingElse {
|
||||
}
|
||||
```
|
||||
Will produce the following error(s):
|
||||
```
|
||||
Wrong theme declaration in decorator
|
||||
```
|
||||
|
||||
Result of `yarn lint --fix`:
|
||||
```typescript
|
||||
@listableObjectComponent(something, somethingElse, undefined, 'test')
|
||||
export class Something extends SomethingElse {
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
##### plain file declares a theme in @listableObjectComponent
|
||||
|
||||
Filename: `lint/test/fixture/src/app/dynamic-component/dynamic-component.ts`
|
||||
|
||||
```typescript
|
||||
@listableObjectComponent(something, somethingElse, undefined, 'test-2')
|
||||
export class Something extends SomethingElse {
|
||||
}
|
||||
```
|
||||
Will produce the following error(s):
|
||||
```
|
||||
There is a theme declaration in decorator, but this file is not part of a theme
|
||||
```
|
||||
|
||||
Result of `yarn lint --fix`:
|
||||
```typescript
|
||||
@listableObjectComponent(something, somethingElse, undefined)
|
||||
export class Something extends SomethingElse {
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
##### theme file declares no theme in @listableObjectComponent
|
||||
|
||||
Filename: `lint/test/fixture/src/themes/test-2/app/dynamic-component/dynamic-component.ts`
|
||||
|
||||
```typescript
|
||||
@listableObjectComponent(something, somethingElse, undefined)
|
||||
export class Something extends SomethingElse {
|
||||
}
|
||||
```
|
||||
Will produce the following error(s):
|
||||
```
|
||||
No theme declaration in decorator
|
||||
```
|
||||
|
||||
Result of `yarn lint --fix`:
|
||||
```typescript
|
||||
@listableObjectComponent(something, somethingElse, undefined, 'test-2')
|
||||
export class Something extends SomethingElse {
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
##### theme file declares explicit undefined theme in @listableObjectComponent
|
||||
|
||||
Filename: `lint/test/fixture/src/themes/test-2/app/dynamic-component/dynamic-component.ts`
|
||||
|
||||
```typescript
|
||||
@listableObjectComponent(something, somethingElse, undefined, undefined)
|
||||
export class Something extends SomethingElse {
|
||||
}
|
||||
```
|
||||
Will produce the following error(s):
|
||||
```
|
||||
No theme declaration in decorator
|
||||
```
|
||||
|
||||
Result of `yarn lint --fix`:
|
||||
```typescript
|
||||
@listableObjectComponent(something, somethingElse, undefined, 'test-2')
|
||||
export class Something extends SomethingElse {
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user