mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[AAE-7100] migrate ADF projects to eslint (#7483)
* migrate content services to eslint * migrate insights to eslint * migrate extensions to eslint * migrate testing lib to eslint * migrate CLI to eslint * migrate process-services to eslint * migrate process-services-cloud to eslint * remove cli analytics [ci:force]
This commit is contained in:
110
lib/extensions/.eslintrc.json
Normal file
110
lib/extensions/.eslintrc.json
Normal file
@@ -0,0 +1,110 @@
|
||||
{
|
||||
"extends": "../../.eslintrc.json",
|
||||
"ignorePatterns": [
|
||||
"!**/*"
|
||||
],
|
||||
"overrides": [
|
||||
{
|
||||
"files": [
|
||||
"*.ts"
|
||||
],
|
||||
"parserOptions": {
|
||||
"project": [
|
||||
"lib/extensions/tsconfig.lib.json",
|
||||
"lib/extensions/tsconfig.spec.json"
|
||||
],
|
||||
"createDefaultProgram": true
|
||||
},
|
||||
"plugins": [
|
||||
"eslint-plugin-unicorn",
|
||||
"eslint-plugin-rxjs"
|
||||
],
|
||||
"rules": {
|
||||
"jsdoc/newline-after-description": "warn",
|
||||
"@typescript-eslint/naming-convention": "warn",
|
||||
"@typescript-eslint/consistent-type-assertions": "warn",
|
||||
"@typescript-eslint/prefer-for-of": "warn",
|
||||
"no-underscore-dangle": "warn",
|
||||
"no-shadow": "warn",
|
||||
"quote-props": "warn",
|
||||
"object-shorthand": "warn",
|
||||
"prefer-const": "warn",
|
||||
"arrow-body-style": "warn",
|
||||
"@angular-eslint/no-output-native": "warn",
|
||||
"space-before-function-paren": "warn",
|
||||
|
||||
"@angular-eslint/component-selector": [
|
||||
"error",
|
||||
{
|
||||
"type": "element",
|
||||
"prefix": [
|
||||
"adf",
|
||||
"app"
|
||||
],
|
||||
"style": "kebab-case"
|
||||
}
|
||||
],
|
||||
"@angular-eslint/directive-selector": [
|
||||
"error",
|
||||
{
|
||||
"type": [
|
||||
"element",
|
||||
"attribute"
|
||||
],
|
||||
"prefix": [
|
||||
"adf",
|
||||
"app"
|
||||
],
|
||||
"style": "kebab-case"
|
||||
}
|
||||
],
|
||||
"@angular-eslint/no-host-metadata-property": "off",
|
||||
"@angular-eslint/no-input-prefix": "error",
|
||||
"@typescript-eslint/consistent-type-definitions": "error",
|
||||
"@typescript-eslint/dot-notation": "off",
|
||||
"@typescript-eslint/explicit-member-accessibility": [
|
||||
"off",
|
||||
{
|
||||
"accessibility": "explicit"
|
||||
}
|
||||
],
|
||||
"@typescript-eslint/no-floating-promises": "off",
|
||||
"@typescript-eslint/no-inferrable-types": "off",
|
||||
"@typescript-eslint/no-require-imports": "off",
|
||||
"@typescript-eslint/no-var-requires": "error",
|
||||
"brace-style": [
|
||||
"error",
|
||||
"1tbs"
|
||||
],
|
||||
"comma-dangle": "error",
|
||||
"default-case": "error",
|
||||
"import/order": "off",
|
||||
"max-len": [
|
||||
"error",
|
||||
{
|
||||
"code": 240
|
||||
}
|
||||
],
|
||||
"no-bitwise": "off",
|
||||
"no-duplicate-imports": "error",
|
||||
"no-multiple-empty-lines": "error",
|
||||
"no-redeclare": "error",
|
||||
"no-return-await": "error",
|
||||
"rxjs/no-create": "error",
|
||||
"rxjs/no-subject-unsubscribe": "error",
|
||||
"rxjs/no-subject-value": "error",
|
||||
"rxjs/no-unsafe-takeuntil": "error",
|
||||
"unicorn/filename-case": "error"
|
||||
}
|
||||
},
|
||||
{
|
||||
"files": [
|
||||
"*.html"
|
||||
],
|
||||
"rules": {
|
||||
"@angular-eslint/template/no-autofocus": "error",
|
||||
"@angular-eslint/template/no-positive-tabindex": "error"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
@@ -15,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/* tslint:disable:component-selector */
|
||||
/* eslint-disable @angular-eslint/component-selector */
|
||||
|
||||
import {
|
||||
Component,
|
||||
|
@@ -102,7 +102,7 @@ export function reduceEmptyMenus(
|
||||
return acc.concat(el);
|
||||
}
|
||||
|
||||
export function mergeObjects(...objects: object[]): any {
|
||||
export function mergeObjects(...objects: any[]): any {
|
||||
const result = {};
|
||||
|
||||
objects.forEach((source) => {
|
||||
|
@@ -23,16 +23,16 @@ export interface ExtensionComponent {
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class ComponentRegisterService {
|
||||
components: { [key: string]: Type<{}> } = {};
|
||||
components: { [key: string]: Type<any> } = {};
|
||||
|
||||
setComponents(values: { [key: string]: Type<{}> }) {
|
||||
setComponents(values: { [key: string]: Type<any> }) {
|
||||
if (values) {
|
||||
this.components = Object.assign({}, this.components, values);
|
||||
}
|
||||
}
|
||||
|
||||
getComponentById<T>(id: string): Type<T> {
|
||||
return <Type<T>> this.components[id];
|
||||
return this.components[id];
|
||||
}
|
||||
|
||||
hasComponentById(id: string): boolean {
|
||||
|
@@ -57,7 +57,7 @@ export class ExtensionService {
|
||||
routes: Array<RouteRef> = [];
|
||||
actions: Array<ActionRef> = [];
|
||||
features: Array<any> = [];
|
||||
authGuards: { [key: string]: Type<{}> } = {};
|
||||
authGuards: { [key: string]: Type<any> } = {};
|
||||
|
||||
protected onSetup$ = new BehaviorSubject<ExtensionConfig>(this.config);
|
||||
setup$ = this.onSetup$.asObservable();
|
||||
@@ -72,6 +72,7 @@ export class ExtensionService {
|
||||
|
||||
/**
|
||||
* Loads and registers an extension config file and plugins (specified by path properties).
|
||||
*
|
||||
* @returns The loaded config data
|
||||
*/
|
||||
async load(): Promise<ExtensionConfig> {
|
||||
@@ -86,6 +87,7 @@ export class ExtensionService {
|
||||
|
||||
/**
|
||||
* Registers extensions from a config object.
|
||||
*
|
||||
* @param config Object with config data
|
||||
*/
|
||||
setup(config: ExtensionConfig) {
|
||||
@@ -112,6 +114,7 @@ export class ExtensionService {
|
||||
|
||||
/**
|
||||
* Gets features by key.
|
||||
*
|
||||
* @param key Key string, using dot notation
|
||||
* @returns Features array found by key
|
||||
*/
|
||||
@@ -126,6 +129,7 @@ export class ExtensionService {
|
||||
|
||||
/**
|
||||
* Adds one or more new rule evaluators to the existing set.
|
||||
*
|
||||
* @param values The new evaluators to add
|
||||
*/
|
||||
setEvaluators(values: { [key: string]: RuleEvaluator }) {
|
||||
@@ -134,9 +138,10 @@ export class ExtensionService {
|
||||
|
||||
/**
|
||||
* Adds one or more new auth guards to the existing set.
|
||||
*
|
||||
* @param values The new auth guards to add
|
||||
*/
|
||||
setAuthGuards(values: { [key: string]: Type<{}> }) {
|
||||
setAuthGuards(values: { [key: string]: Type<any> }) {
|
||||
if (values) {
|
||||
this.authGuards = Object.assign({}, this.authGuards, values);
|
||||
}
|
||||
@@ -144,14 +149,16 @@ export class ExtensionService {
|
||||
|
||||
/**
|
||||
* Adds one or more new components to the existing set.
|
||||
*
|
||||
* @param values The new components to add
|
||||
*/
|
||||
setComponents(values: { [key: string]: Type<{}> }) {
|
||||
setComponents(values: { [key: string]: Type<any> }) {
|
||||
this.componentRegister.setComponents(values);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a route using its ID value.
|
||||
*
|
||||
* @param id The ID value to look for
|
||||
* @returns The route or null if not found
|
||||
*/
|
||||
@@ -161,10 +168,11 @@ export class ExtensionService {
|
||||
|
||||
/**
|
||||
* Retrieves one or more auth guards using an array of ID values.
|
||||
*
|
||||
* @param ids Array of ID value to look for
|
||||
* @returns Array of auth guards or empty array if none were found
|
||||
*/
|
||||
getAuthGuards(ids: string[]): Array<Type<{}>> {
|
||||
getAuthGuards(ids: string[]): Array<Type<any>> {
|
||||
return (ids || [])
|
||||
.map((id) => this.authGuards[id])
|
||||
.filter((guard) => guard);
|
||||
@@ -172,6 +180,7 @@ export class ExtensionService {
|
||||
|
||||
/**
|
||||
* Retrieves an action using its ID value.
|
||||
*
|
||||
* @param id The ID value to look for
|
||||
* @returns Action or null if not found
|
||||
*/
|
||||
@@ -181,6 +190,7 @@ export class ExtensionService {
|
||||
|
||||
/**
|
||||
* Retrieves a RuleEvaluator function using its key name.
|
||||
*
|
||||
* @param key Key name to look for
|
||||
* @returns RuleEvaluator or null if not found
|
||||
*/
|
||||
@@ -190,6 +200,7 @@ export class ExtensionService {
|
||||
|
||||
/**
|
||||
* Evaluates a rule.
|
||||
*
|
||||
* @param ruleId ID of the rule to evaluate
|
||||
* @param context Custom rule execution context.
|
||||
* @returns True if the rule passed, false otherwise
|
||||
@@ -200,6 +211,7 @@ export class ExtensionService {
|
||||
|
||||
/**
|
||||
* Retrieves a registered extension component using its ID value.
|
||||
*
|
||||
* @param id The ID value to look for
|
||||
* @returns The component or null if not found
|
||||
*/
|
||||
@@ -209,6 +221,7 @@ export class ExtensionService {
|
||||
|
||||
/**
|
||||
* Retrieves a rule using its ID value.
|
||||
*
|
||||
* @param id The ID value to look for
|
||||
* @returns The rule or null if not found
|
||||
*/
|
||||
@@ -218,11 +231,12 @@ export class ExtensionService {
|
||||
|
||||
/**
|
||||
* Runs a lightweight expression stored in a string.
|
||||
*
|
||||
* @param value String containing the expression or literal value
|
||||
* @param context Parameter object for the expression with details of app state
|
||||
* @returns Result of evaluated expression, if found, or the literal value otherwise
|
||||
*/
|
||||
runExpression(value: string | {} , context?: any) {
|
||||
runExpression(value: string | any , context?: any) {
|
||||
if (typeof value === 'string' ) {
|
||||
return this.evaluateExpression(value, context);
|
||||
} else {
|
||||
|
@@ -17,6 +17,6 @@
|
||||
|
||||
import { AppExtensionService } from './app-extension.service';
|
||||
|
||||
export function setupExtensions(appExtensionService: AppExtensionService): Function {
|
||||
export function setupExtensions(appExtensionService: AppExtensionService) {
|
||||
return () => appExtensionService.load();
|
||||
}
|
||||
|
Reference in New Issue
Block a user