diff --git a/lint/src/rules/html/themed-component-usages.ts b/lint/src/rules/html/themed-component-usages.ts
index 160d93326b..df0d775acb 100644
--- a/lint/src/rules/html/themed-component-usages.ts
+++ b/lint/src/rules/html/themed-component-usages.ts
@@ -17,7 +17,7 @@ export default {
schema: [],
messages: {
mustUseThemedWrapperSelector: 'Themeable components should be used via their ThemedComponent wrapper\'s selector',
- }
+ },
},
create(context: any) {
if (context.getFilename().includes('.spec.ts')) {
@@ -36,7 +36,7 @@ export default {
const openTagRange = [
node.startSourceSpan.start.offset + 1,
- node.startSourceSpan.start.offset + 1 + oldSelector.length
+ node.startSourceSpan.start.offset + 1 + oldSelector.length,
];
const ops = [
@@ -47,15 +47,15 @@ export default {
if (node.startSourceSpan.end.offset !== node.endSourceSpan.end.offset) {
const closeTagRange = [
node.endSourceSpan.start.offset + 2,
- node.endSourceSpan.end.offset - 1
+ node.endSourceSpan.end.offset - 1,
];
ops.push(fixer.replaceTextRange(closeTagRange, newSelector));
}
return ops;
- }
+ },
});
},
};
- }
+ },
};
diff --git a/lint/src/rules/ts/themed-component-selectors.ts b/lint/src/rules/ts/themed-component-selectors.ts
index e150bb41a8..cc195efa47 100644
--- a/lint/src/rules/ts/themed-component-selectors.ts
+++ b/lint/src/rules/ts/themed-component-selectors.ts
@@ -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);
}
- }
+ },
};
- }
+ },
});
diff --git a/lint/src/rules/ts/themed-component-usages.ts b/lint/src/rules/ts/themed-component-usages.ts
index 2a3f18bd44..1032b1ef76 100644
--- a/lint/src/rules/ts/themed-component-usages.ts
+++ b/lint/src/rules/ts/themed-component-usages.ts
@@ -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$/)
diff --git a/lint/src/util/theme-support.ts b/lint/src/util/theme-support.ts
index bf7c265e2e..18eed48452 100644
--- a/lint/src/util/theme-support.ts
+++ b/lint/src/util/theme-support.ts
@@ -9,6 +9,7 @@
import { readFileSync } from 'fs';
import { basename } from 'path';
import ts from 'typescript';
+
import {
isClassDeclaration,
isPartOfTypeExpression,
@@ -134,7 +135,7 @@ function resolveLocalPath(path: string, relativeTo: string) {
const parts = relativeTo.split('/');
return [
...parts.slice(0, parts.length - 1),
- path.replace(/^.\//, '')
+ path.replace(/^.\//, ''),
].join('/') + '.ts';
} else {
throw new Error(`Unsupported local path: ${path}`);
diff --git a/lint/test/fixture/src/app/test/test-routing.module.ts b/lint/test/fixture/src/app/test/test-routing.module.ts
index d3a16bb6d6..1ccbccc599 100644
--- a/lint/test/fixture/src/app/test/test-routing.module.ts
+++ b/lint/test/fixture/src/app/test/test-routing.module.ts
@@ -10,5 +10,5 @@ import { ThemedTestThemeableComponent } from './themed-test-themeable.component'
export const ROUTES = [
{
component: ThemedTestThemeableComponent,
- }
+ },
];
diff --git a/lint/test/fixture/src/app/test/test.module.ts b/lint/test/fixture/src/app/test/test.module.ts
index 633ef492fb..a37396ef45 100644
--- a/lint/test/fixture/src/app/test/test.module.ts
+++ b/lint/test/fixture/src/app/test/test.module.ts
@@ -7,8 +7,9 @@
*/
// @ts-ignore
import { NgModule } from '@angular/core';
-import { TestThemeableComponent } from './test-themeable.component';
+
import { TestComponent } from './test.component';
+import { TestThemeableComponent } from './test-themeable.component';
import { ThemedTestThemeableComponent } from './themed-test-themeable.component';
@NgModule({
@@ -16,7 +17,7 @@ import { ThemedTestThemeableComponent } from './themed-test-themeable.component'
TestComponent,
TestThemeableComponent,
ThemedTestThemeableComponent,
- ]
+ ],
})
export class TestModule {
diff --git a/lint/test/fixture/src/app/test/themed-test-themeable.component.ts b/lint/test/fixture/src/app/test/themed-test-themeable.component.ts
index 81eb59d418..a45f89b606 100644
--- a/lint/test/fixture/src/app/test/themed-test-themeable.component.ts
+++ b/lint/test/fixture/src/app/test/themed-test-themeable.component.ts
@@ -6,6 +6,7 @@
* http://www.dspace.org/license/
*/
import { Component } from '@angular/core';
+
import { ThemedComponent } from '../../../../../../src/app/shared/theme-support/themed.component';
import { TestThemeableComponent } from './test-themeable.component';
diff --git a/lint/test/fixture/src/themes/test/app/test/test-themeable.component.ts b/lint/test/fixture/src/themes/test/app/test/test-themeable.component.ts
index 05ba4e3d1b..d2b02ca9f1 100644
--- a/lint/test/fixture/src/themes/test/app/test/test-themeable.component.ts
+++ b/lint/test/fixture/src/themes/test/app/test/test-themeable.component.ts
@@ -6,6 +6,7 @@
* http://www.dspace.org/license/
*/
import { Component } from '@angular/core';
+
import { TestThemeableComponent as BaseComponent } from '../../../../app/test/test-themeable.component';
@Component({
diff --git a/lint/test/fixture/src/themes/test/test.module.ts b/lint/test/fixture/src/themes/test/test.module.ts
index 6d7601bd52..7aac91b07a 100644
--- a/lint/test/fixture/src/themes/test/test.module.ts
+++ b/lint/test/fixture/src/themes/test/test.module.ts
@@ -7,12 +7,13 @@
*/
// @ts-ignore
import { NgModule } from '@angular/core';
+
import { TestThemeableComponent } from './app/test/test-themeable.component';
@NgModule({
declarations: [
TestThemeableComponent,
- ]
+ ],
})
export class TestModule {
diff --git a/lint/test/rules/themed-component-selectors.spec.ts b/lint/test/rules/themed-component-selectors.spec.ts
index 2f2e9786c2..864c41d598 100644
--- a/lint/test/rules/themed-component-selectors.spec.ts
+++ b/lint/test/rules/themed-component-selectors.spec.ts
@@ -7,11 +7,11 @@
*/
+import rule from '../../src/rules/ts/themed-component-selectors';
import {
fixture,
tsRuleTester,
} from '../testing';
-import rule from '../../src/rules/ts/themed-component-selectors';
describe('themed-component-selectors', () => {
tsRuleTester.run('themed-component-selectors', rule as any, {
diff --git a/lint/test/rules/themed-component-usages.spec.ts b/lint/test/rules/themed-component-usages.spec.ts
index 89250cced0..4cbb135684 100644
--- a/lint/test/rules/themed-component-usages.spec.ts
+++ b/lint/test/rules/themed-component-usages.spec.ts
@@ -6,13 +6,13 @@
* http://www.dspace.org/license/
*/
+import htmlRule from '../../src/rules/html/themed-component-usages';
+import tsRule from '../../src/rules/ts/themed-component-usages';
import {
fixture,
htmlRuleTester,
tsRuleTester,
} from '../testing';
-import tsRule from '../../src/rules/ts/themed-component-usages';
-import htmlRule from '../../src/rules/html/themed-component-usages';
describe('themed-component-usages (TypeScript)', () => {
tsRuleTester.run('themed-component-usages', tsRule as any, {
@@ -90,7 +90,7 @@ const config = {
a: ThemedTestThemeableComponent,
b: TestComponent,
}
- `
+ `,
},
{
filename: fixture('src/app/test/test.component.spec.ts'),
@@ -260,6 +260,6 @@ class Test {
`,
},
- ]
+ ],
});
});
diff --git a/lint/test/testing.ts b/lint/test/testing.ts
index 631d956b0b..f9507c00c3 100644
--- a/lint/test/testing.ts
+++ b/lint/test/testing.ts
@@ -6,8 +6,9 @@
* http://www.dspace.org/license/
*/
-import { RuleTester } from 'eslint';
import { RuleTester as TypeScriptRuleTester } from '@typescript-eslint/rule-tester';
+import { RuleTester } from 'eslint';
+
import { themeableComponents } from '../src/util/theme-support';
const FIXTURE = 'lint/test/fixture/';
@@ -29,7 +30,7 @@ export const tsRuleTester = new TypeScriptRuleTester({
},
parserOptions: {
project: fixture('tsconfig.json'),
- }
+ },
});
class HtmlRuleTester extends RuleTester {
diff --git a/package.json b/package.json
index b8f6402cfb..ed2abad2a8 100644
--- a/package.json
+++ b/package.json
@@ -21,9 +21,9 @@
"test": "ng test --source-map=true --watch=false --configuration test",
"test:watch": "nodemon --exec \"ng test --source-map=true --watch=true --configuration test\"",
"test:headless": "ng test --source-map=true --watch=false --configuration test --browsers=ChromeHeadless --code-coverage",
- "test:lint": "yarn build:lint && jasmine --config=lint/jasmine.json",
+ "test:lint": "yarn build:lint && yarn test:lint:nobuild",
"test:lint:nobuild": "jasmine --config=lint/jasmine.json",
- "lint": "yarn build:lint && ng lint",
+ "lint": "yarn build:lint && yarn lint:nobuild",
"lint:nobuild": "ng lint",
"lint-fix": "yarn build:lint && ng lint --fix=true",
"e2e": "cross-env NODE_ENV=production ng e2e",