Fix lint lint issues

This commit is contained in:
Yury Bondarenko
2024-03-14 15:04:53 +01:00
parent ae50780e28
commit e83a0cd741
13 changed files with 40 additions and 43 deletions

View File

@@ -6,6 +6,7 @@
* http://www.dspace.org/license/
*/
import { ESLintUtils } from '@typescript-eslint/utils';
import { getComponentSelectorNode } from '../../util/angular';
import { stringLiteral } from '../../util/misc';
import {
@@ -23,7 +24,7 @@ export default ESLintUtils.RuleCreator.withoutDocs({
wrongSelectorUnthemedComponent: 'Unthemed version of themeable components should have a selector starting with \'ds-base-\'',
wrongSelectorThemedComponentWrapper: 'Themed component wrapper of themeable components shouldn\'t have a selector starting with \'ds-themed-\'',
wrongSelectorThemedComponentOverride: 'Theme override of themeable component should have a selector starting with \'ds-themed-\'',
}
},
},
defaultOptions: [],
create(context: any): any {
@@ -86,7 +87,7 @@ export default ESLintUtils.RuleCreator.withoutDocs({
} else if (isThemeableComponent(className)) {
enforceBaseSelector(selectorNode);
}
}
},
};
}
},
});

View File

@@ -6,6 +6,7 @@
* http://www.dspace.org/license/
*/
import { ESLintUtils } from '@typescript-eslint/utils';
import { findUsages } from '../../util/misc';
import {
allThemeableComponents,
@@ -50,7 +51,14 @@ export default ESLintUtils.RuleCreator.withoutDocs({
}
function handleThemedSelectorQueriesInTests(node: any) {
context.report({
node,
messageId: 'mustUseThemedWrapper',
fix(fixer: any){
const newSelector = fixSelectors(node.raw);
return fixer.replaceText(node, newSelector);
},
});
}
function handleUnthemedImportsInTypescript(specifierNode: any) {
@@ -98,29 +106,11 @@ export default ESLintUtils.RuleCreator.withoutDocs({
// ignore tests and non-routing modules
if (context.getFilename()?.endsWith('.spec.ts')) {
return {
[`CallExpression[callee.object.name = "By"][callee.property.name = "css"] > Literal:first-child[value = /.*${DISALLOWED_THEME_SELECTORS}.*/]`](node: any) {
context.report({
node,
messageId: 'mustUseThemedWrapper',
fix(fixer: any){
const newSelector = fixSelectors(node.raw);
return fixer.replaceText(node, newSelector);
}
});
},
[`CallExpression[callee.object.name = "By"][callee.property.name = "css"] > Literal:first-child[value = /.*${DISALLOWED_THEME_SELECTORS}.*/]`]: handleThemedSelectorQueriesInTests,
};
} else if (context.getFilename()?.endsWith('.cy.ts')) {
return {
[`CallExpression[callee.object.name = "cy"][callee.property.name = "get"] > Literal:first-child[value = /.*${DISALLOWED_THEME_SELECTORS}.*/]`](node: any) {
context.report({
node,
messageId: 'mustUseThemedWrapper',
fix(fixer: any){
const newSelector = fixSelectors(node.raw);
return fixer.replaceText(node, newSelector);
}
});
},
[`CallExpression[callee.object.name = "cy"][callee.property.name = "get"] > Literal:first-child[value = /.*${DISALLOWED_THEME_SELECTORS}.*/]`]: handleThemedSelectorQueriesInTests,
};
} else if (
context.getFilename()?.match(/(?!routing).module.ts$/)