mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
117616: Allow CallExpressions like forwardRef in the standalone imports array as well
This commit is contained in:
@@ -101,12 +101,12 @@ export const rule = ESLintUtils.RuleCreator.withoutDocs({
|
|||||||
create(context: TSESLint.RuleContext<Message, unknown[]>, [{ locale, maxItems, indent, trailingComma }]: any) {
|
create(context: TSESLint.RuleContext<Message, unknown[]>, [{ locale, maxItems, indent, trailingComma }]: any) {
|
||||||
return {
|
return {
|
||||||
['ClassDeclaration > Decorator > CallExpression[callee.name="Component"] > ObjectExpression > Property[key.name="imports"] > ArrayExpression']: (node: TSESTree.ArrayExpression) => {
|
['ClassDeclaration > Decorator > CallExpression[callee.name="Component"] > ObjectExpression > Property[key.name="imports"] > ArrayExpression']: (node: TSESTree.ArrayExpression) => {
|
||||||
const identifiers = node.elements.filter(TSESLintASTUtils.isIdentifier);
|
const elements = node.elements.filter((element) => element !== null && (TSESLintASTUtils.isIdentifier(element) || element?.type === TSESTree.AST_NODE_TYPES.CallExpression));
|
||||||
const sortedNames: string[] = identifiers
|
const sortedNames: string[] = elements
|
||||||
.map((identifier) => identifier.name)
|
.map((element) => context.sourceCode.getText(element!))
|
||||||
.sort((a: string, b: string) => a.localeCompare(b, locale));
|
.sort((a: string, b: string) => a.localeCompare(b, locale));
|
||||||
|
|
||||||
const isSorted: boolean = identifiers.every((identifier, index) => identifier.name === sortedNames[index]);
|
const isSorted: boolean = elements.every((identifier, index) => context.sourceCode.getText(identifier!) === sortedNames[index]);
|
||||||
|
|
||||||
const requiresMultiline: boolean = maxItems < node.elements.length;
|
const requiresMultiline: boolean = maxItems < node.elements.length;
|
||||||
const isMultiline: boolean = /\n/.test(context.sourceCode.getText(node));
|
const isMultiline: boolean = /\n/.test(context.sourceCode.getText(node));
|
||||||
|
Reference in New Issue
Block a user