mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
Improved ESLint configuration, integrated spellcheck and error fixes (#8931)
* integrate cspell with eslint, improved configuration * core: fix linting errors * core: fix lint warnings * content: lint fixes * process service lint fixes * lint: process services cloud * lint: insights * lint: extensions * [ci:force] lint: cli fixes * [ci:force] comment out dead code * [ci:force] exclude dead code * fix code and tests * rollback some changes * fix testing lib * fix demo shell * minor lint warning fixes * minor lint fixes * fix process services
This commit is contained in:
@@ -94,7 +94,7 @@ export class DynamicColumnComponent implements OnInit, OnChanges, OnDestroy {
|
||||
}
|
||||
|
||||
private updateInstance() {
|
||||
if (this.componentRef && this.componentRef.instance) {
|
||||
if (this.componentRef?.instance) {
|
||||
this.componentRef.instance.context = this.context;
|
||||
}
|
||||
}
|
||||
|
@@ -89,8 +89,9 @@ export class DynamicExtensionComponent implements OnChanges, OnDestroy {
|
||||
}
|
||||
}
|
||||
|
||||
private proxy(lifecycleMethod, ...args) {
|
||||
private proxy(lifecycleMethod: string, ...args: any[]) {
|
||||
if (this.componentCreated() && this.lifecycleHookIsImplemented(lifecycleMethod)) {
|
||||
// eslint-disable-next-line prefer-spread
|
||||
this.componentRef.instance[lifecycleMethod].apply(this.componentRef.instance, args);
|
||||
}
|
||||
}
|
||||
|
@@ -80,7 +80,7 @@ export class DynamicTabComponent implements OnInit, OnChanges, OnDestroy {
|
||||
}
|
||||
|
||||
private updateInstance() {
|
||||
if (this.componentRef && this.componentRef.instance) {
|
||||
if (this.componentRef?.instance) {
|
||||
this.componentRef.instance.node = this.node;
|
||||
}
|
||||
}
|
||||
|
@@ -87,7 +87,7 @@ export class PreviewExtensionComponent implements OnInit, OnChanges, OnDestroy {
|
||||
}
|
||||
|
||||
private updateInstance() {
|
||||
if (this.componentRef && this.componentRef.instance) {
|
||||
if (this.componentRef?.instance) {
|
||||
const instance = this.componentRef.instance;
|
||||
|
||||
instance.url = this.url;
|
||||
|
@@ -135,7 +135,7 @@ export const mergeArrays = (left: any[], right: any[]): any[] => {
|
||||
|
||||
(left || []).forEach((entry) => {
|
||||
const element = entry;
|
||||
if (element && element.hasOwnProperty('id')) {
|
||||
if (element && Object.prototype.hasOwnProperty.call(element, 'id')) {
|
||||
map[element.id] = element;
|
||||
} else {
|
||||
result.push(element);
|
||||
@@ -144,7 +144,7 @@ export const mergeArrays = (left: any[], right: any[]): any[] => {
|
||||
|
||||
(right || []).forEach((entry) => {
|
||||
const element = entry;
|
||||
if (element && element.hasOwnProperty('id') && map[element.id]) {
|
||||
if (element && Object.prototype.hasOwnProperty.call(element, 'id') && map[element.id]) {
|
||||
const merged = mergeObjects(map[element.id], element);
|
||||
map[element.id] = merged;
|
||||
} else {
|
||||
|
@@ -79,7 +79,7 @@ export class AppExtensionService {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (extension.rules && extension.rules.disabled) {
|
||||
if (extension.rules?.disabled) {
|
||||
return this.extensionService.evaluateRule(extension.rules.disabled);
|
||||
}
|
||||
}
|
||||
|
@@ -42,7 +42,7 @@ export class ExtensionLoaderService {
|
||||
config = JSON.parse(override);
|
||||
}
|
||||
|
||||
if (!config.$references || !config.$references.length) {
|
||||
if (!config.$references?.length) {
|
||||
config.$references = this.filterIgnoredExtensions(extensions || [], config.$ignoreReferenceList);
|
||||
} else {
|
||||
config.$references = this.filterIgnoredExtensions(config.$references, config.$ignoreReferenceList);
|
||||
@@ -102,7 +102,7 @@ export class ExtensionLoaderService {
|
||||
}
|
||||
|
||||
getRules(config: ExtensionConfig): Array<RuleRef> {
|
||||
if (config && config.rules) {
|
||||
if (config?.rules) {
|
||||
return config.rules;
|
||||
}
|
||||
return [];
|
||||
@@ -170,10 +170,10 @@ export class ExtensionLoaderService {
|
||||
}
|
||||
|
||||
private filterIgnoredExtensions(extensions: Array<string | ExtensionRef>, ignoreReferenceList: string[]): Array<string | ExtensionRef> {
|
||||
if (!ignoreReferenceList || !ignoreReferenceList.length) {
|
||||
if (!ignoreReferenceList?.length) {
|
||||
return extensions;
|
||||
}
|
||||
|
||||
return extensions.map((file: string) => file.match('(?!.*\/).+')[0]).filter((fileName: string) => !ignoreReferenceList.includes(fileName));
|
||||
return extensions.map((file: string) => file.match('(?!.*/).+')[0]).filter((fileName: string) => !ignoreReferenceList.includes(fileName));
|
||||
}
|
||||
}
|
||||
|
@@ -68,8 +68,8 @@ describe('ExtensionService', () => {
|
||||
}
|
||||
});
|
||||
|
||||
const requestedFeatue = service.getFeature('searchedArrayFeature');
|
||||
expect(requestedFeatue).toEqual(searchedArrayFeature);
|
||||
const requestedFeature = service.getFeature('searchedArrayFeature');
|
||||
expect(requestedFeature).toEqual(searchedArrayFeature);
|
||||
});
|
||||
|
||||
it('should return object if seached feature is an object', async () => {
|
||||
@@ -81,16 +81,16 @@ describe('ExtensionService', () => {
|
||||
}
|
||||
});
|
||||
|
||||
const requestedFeatue = service.getFeature<{ test: string }>('searchedObjectFeature');
|
||||
expect(requestedFeatue).toEqual(searchedObjectFeature);
|
||||
const requestedFeature = service.getFeature<{ test: string }>('searchedObjectFeature');
|
||||
expect(requestedFeature).toEqual(searchedObjectFeature);
|
||||
});
|
||||
|
||||
it('should return default value if feature is not found', async () => {
|
||||
const defaultValue = {};
|
||||
service.setup(blankConfig);
|
||||
|
||||
const requestedFeatue = service.getFeature<{ test: string }>('searchedFeature', defaultValue);
|
||||
expect(requestedFeatue).toEqual(defaultValue);
|
||||
const requestedFeature = service.getFeature<{ test: string }>('searchedFeature', defaultValue);
|
||||
expect(requestedFeature).toEqual(defaultValue);
|
||||
});
|
||||
});
|
||||
|
||||
|
@@ -123,7 +123,7 @@ export class ExtensionService {
|
||||
*/
|
||||
getFeature<T = any[]>(key: string | string[], defaultValue: any = []): T {
|
||||
const properties: string[] = Array.isArray(key) ? key : key.split('.');
|
||||
return properties.reduce((prev, curr) => prev && prev[curr], this.features) || defaultValue;
|
||||
return properties.reduce((prev, curr) => prev?.[curr], this.features) || defaultValue;
|
||||
}
|
||||
|
||||
getElements<T extends ExtensionElement>(key: string, fallback: Array<T> = []): Array<T> {
|
||||
|
@@ -62,7 +62,7 @@ export class RuleService {
|
||||
* @returns RuleEvaluator or null if not found
|
||||
*/
|
||||
getEvaluator(key: string): RuleEvaluator {
|
||||
if (key && key.startsWith('!')) {
|
||||
if (key?.startsWith('!')) {
|
||||
const fn = this.evaluators[key.substring(1)];
|
||||
return (context: RuleContext, ...args: RuleParameter[]): boolean => !fn(context, ...args);
|
||||
}
|
||||
|
Reference in New Issue
Block a user