mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
ci: Introduce lint rule no-type-unsafe-event-emitter (no-changelog) (#10254)
This commit is contained in:
@@ -448,6 +448,36 @@ module.exports = {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
'no-type-unsafe-event-emitter': {
|
||||||
|
meta: {
|
||||||
|
type: 'problem',
|
||||||
|
docs: {
|
||||||
|
description: 'Disallow extending from `EventEmitter`, which is not type-safe.',
|
||||||
|
recommended: 'error',
|
||||||
|
},
|
||||||
|
messages: {
|
||||||
|
noExtendsEventEmitter: 'Extend from the type-safe `TypedEmitter` class instead.',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
create(context) {
|
||||||
|
return {
|
||||||
|
ClassDeclaration(node) {
|
||||||
|
if (
|
||||||
|
node.superClass &&
|
||||||
|
node.superClass.type === 'Identifier' &&
|
||||||
|
node.superClass.name === 'EventEmitter' &&
|
||||||
|
node.id.name !== 'TypedEmitter'
|
||||||
|
) {
|
||||||
|
context.report({
|
||||||
|
node: node.superClass,
|
||||||
|
messageId: 'noExtendsEventEmitter',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const isJsonParseCall = (node) =>
|
const isJsonParseCall = (node) =>
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ module.exports = {
|
|||||||
rules: {
|
rules: {
|
||||||
'n8n-local-rules/no-dynamic-import-template': 'error',
|
'n8n-local-rules/no-dynamic-import-template': 'error',
|
||||||
'n8n-local-rules/misplaced-n8n-typeorm-import': 'error',
|
'n8n-local-rules/misplaced-n8n-typeorm-import': 'error',
|
||||||
|
'n8n-local-rules/no-type-unsafe-event-emitter': 'error',
|
||||||
complexity: 'error',
|
complexity: 'error',
|
||||||
|
|
||||||
// TODO: Remove this
|
// TODO: Remove this
|
||||||
@@ -44,6 +45,12 @@ module.exports = {
|
|||||||
'n8n-local-rules/misplaced-n8n-typeorm-import': 'off',
|
'n8n-local-rules/misplaced-n8n-typeorm-import': 'off',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
files: ['./test/**/*.ts'],
|
||||||
|
rules: {
|
||||||
|
'n8n-local-rules/no-type-unsafe-event-emitter': 'off',
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
files: ['./src/decorators/**/*.ts'],
|
files: ['./src/decorators/**/*.ts'],
|
||||||
rules: {
|
rules: {
|
||||||
|
|||||||
@@ -52,6 +52,8 @@ export interface MessageEventBusInitializeOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Service()
|
@Service()
|
||||||
|
// TODO: Convert to TypedEventEmitter
|
||||||
|
// eslint-disable-next-line n8n-local-rules/no-type-unsafe-event-emitter
|
||||||
export class MessageEventBus extends EventEmitter {
|
export class MessageEventBus extends EventEmitter {
|
||||||
private isInitialized = false;
|
private isInitialized = false;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user