-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(root): Prevent multi-level imports for @novu/*
packages
#6596
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,26 @@ | |
|
||
const compat = new FlatCompat({ baseDirectory: import.meta.dirname }); | ||
|
||
/** | ||
* REUSED RULE CONFIGURATIONS | ||
* | ||
* This is necessary because Eslint doesn't merge rule configurations | ||
* when they are targeting different paths. | ||
*/ | ||
|
||
/** | ||
* This rule ensures that "multi-level" imports are not used for `@novu/*` packages. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm wondering if we should approach this from a different direction, specifically by not allowing the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For packages under our control, I'm of the opinion that we should only allow imports from known
This PR introduces a pattern for exceptions of the rule, namely for multiple entry-point packages. That same pattern can be extended to handle other exceptions we might like to add in the future. I think the benefits of a "by exception" approach outweigh the cons of allowing any multi-level imports right now. |
||
*/ | ||
const noRestrictedImportsMultiLevelNovuPattern = { | ||
group: [ | ||
'@novu/*/**/*', | ||
// These packages have legitimate exports 1 path part below the root level | ||
// This flatmap logic ignores the path 1 below the root level and prevents deeper imports. | ||
rifont marked this conversation as resolved.
Show resolved
Hide resolved
|
||
...['framework', 'js', 'novui'].flatMap((pkg) => [`!@novu/${pkg}/**/*`, `@novu/${pkg}/*/**/*`]), | ||
], | ||
message: "Please import only from the root package entry point. For example, use 'import { Client } from '@novu/node';' instead of 'import { Client } from '@novu/node/src';'", | ||
}; | ||
|
||
export default tsEslint.config( | ||
/* ******************** RECOMMENDED CONFIG ******************** */ | ||
jsEslint.configs.recommended, | ||
|
@@ -155,12 +175,7 @@ | |
'error', | ||
{ | ||
patterns: [ | ||
'@novu/shared/*', | ||
'!@novu/shared/utils', | ||
'@novu/dal/*', | ||
'*../libs/dal/*', | ||
'*../packages/shared/*', | ||
'*../libs/stateless/*', | ||
noRestrictedImportsMultiLevelNovuPattern, | ||
], | ||
}, | ||
], | ||
|
@@ -275,6 +290,7 @@ | |
'error', | ||
{ | ||
patterns: [ | ||
noRestrictedImportsMultiLevelNovuPattern, | ||
{ | ||
/** | ||
* This rule ensures that the overridden Swagger decorators are used, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export { Table } from './Table'; | ||
export type { IExtendedColumn, IExtendedCellProps, IRow } from './Table'; | ||
export type { IExtendedColumn, IExtendedCellProps, IRow, ITableProps } from './Table'; | ||
export { withCellLoading } from './withCellLoading'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't want to raise an EE PR for these, so they are ignored for now.