mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
117616: Fix rule creator call & add structure test case
This commit is contained in:

committed by
Alexandre Vryghem

parent
01c8c60624
commit
8ff5a23c40
@@ -1,5 +1,6 @@
|
||||
import {
|
||||
AST_NODE_TYPES,
|
||||
ESLintUtils,
|
||||
TSESLint,
|
||||
TSESTree,
|
||||
} from '@typescript-eslint/utils';
|
||||
@@ -30,6 +31,9 @@ export const info: DSpaceESLintRuleInfo = {
|
||||
properties: {
|
||||
decorators: {
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -44,7 +48,7 @@ export const info: DSpaceESLintRuleInfo = {
|
||||
],
|
||||
};
|
||||
|
||||
export const rule = {
|
||||
export const rule = ESLintUtils.RuleCreator.withoutDocs({
|
||||
...info,
|
||||
create(context: TSESLint.RuleContext<Message, unknown[]>, options: any) {
|
||||
const decoratorCalls: Map<string, Set<string>> = new Map();
|
||||
@@ -75,7 +79,7 @@ export const rule = {
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
export const tests: NamedTests = {
|
||||
plugin: info.name,
|
||||
|
@@ -6,6 +6,8 @@
|
||||
* http://www.dspace.org/license/
|
||||
*/
|
||||
|
||||
import { RuleMetaData } from '@typescript-eslint/utils/ts-eslint';
|
||||
|
||||
import { default as html } from '../src/rules/html';
|
||||
import { default as ts } from '../src/rules/ts';
|
||||
|
||||
@@ -69,6 +71,16 @@ describe('plugin structure', () => {
|
||||
expect(ruleExports.tests.valid.length).toBeGreaterThan(0);
|
||||
expect(ruleExports.tests.invalid.length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it('should contain a valid ESLint rule', () => {
|
||||
// we don't have a better way to enforce this, but it's something at least
|
||||
expect((ruleExports.rule as any).name).toBeUndefined(
|
||||
'Rules should be passed to RuleCreator, omitting info.name since it is not part of the RuleWithMeta interface',
|
||||
);
|
||||
|
||||
expect(ruleExports.rule.create).toBeTruthy();
|
||||
expect(ruleExports.rule.meta).toEqual(ruleExports.info.meta as RuleMetaData<string, []>);
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
Reference in New Issue
Block a user