Update plugins to support standalone components

- ThemedComponent wrappers should always import their base component. This ensures that it's always enough to only import the wrapper when we use it.
- This implies that all themeable components must be standalone

→ added rules to enforce this
→ updated usage rule to improve declaration/import handling
This commit is contained in:
Yury Bondarenko
2024-03-21 10:37:20 +01:00
parent 568574585b
commit e40b6ae612
14 changed files with 835 additions and 55 deletions

View File

@@ -10,6 +10,7 @@ import { Component } from '@angular/core';
@Component({
selector: 'ds-base-test-themeable',
template: '',
standalone: true,
})
export class TestThemeableComponent {
}

View File

@@ -13,6 +13,8 @@ import { TestThemeableComponent } from './test-themeable.component';
@Component({
selector: 'ds-test-themeable',
template: '',
standalone: true,
imports: [TestThemeableComponent],
})
export class ThemedTestThemeableComponent extends ThemedComponent<TestThemeableComponent> {
protected getComponentName(): string {

View File

@@ -0,0 +1,16 @@
/**
* The contents of this file are subject to the license and copyright
* detailed in the LICENSE and NOTICE files at the root of the source
* tree and available online at
*
* http://www.dspace.org/license/
*/
import { Component } from '@angular/core';
@Component({
selector: 'ds-themed-test-themeable',
template: '',
})
export class OtherThemeableComponent {
}

View File

@@ -8,11 +8,13 @@
// @ts-ignore
import { NgModule } from '@angular/core';
import { OtherThemeableComponent } from './app/test/other-themeable.component';
import { TestThemeableComponent } from './app/test/test-themeable.component';
@NgModule({
declarations: [
TestThemeableComponent,
OtherThemeableComponent,
],
})
export class TestModule {

View File

@@ -1,6 +1,7 @@
{
"extends": "../../../tsconfig.json",
"include": [
"src/**/*.ts",
"src/**/*.ts"
],
"exclude": ["dist"]

View File

@@ -20,6 +20,7 @@ import {
themeableComponents.initialize(FIXTURE);
TypeScriptRuleTester.itOnly = fit;
TypeScriptRuleTester.itSkip = xit;
export const tsRuleTester = new TypeScriptRuleTester({
parser: '@typescript-eslint/parser',