-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[New platform] Restrict import internals of plugins & core services in ts files #33562
[New platform] Restrict import internals of plugins & core services in ts files #33562
Conversation
Pinging @elastic/kibana-platform |
@@ -18,6 +18,7 @@ | |||
*/ | |||
|
|||
import Hapi from 'hapi'; | |||
// tslint:disable-next-line:no-import-zones |
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.
shouldn't we provide server factory / builder for testing purposes?
similar test https://github.com/elastic/kibana/blob/master/x-pack/plugins/security/server/routes/api/public/roles/put.test.js
This comment has been minimized.
This comment has been minimized.
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.
no-import-zones seems really powerful 👍
I've made some comments about how we choose to expose types, but that's perhaps a meta issues that doesn't have to block this PR.
I just realised that plugins still can import from sibling folders. - target: src/plugins/**/public/**/*
from:
- src/core/server/**/*
- src/core/public/**/*
- src/plugins/**/server/**/*
|
const { findImports, ImportKind } = require('tsutils'); | ||
|
||
function traverseToTopFolder(src, pattern) { | ||
while(src && mm([src], pattern).length) { |
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 think it's okay to have a local fork of the no-import-zones rule
, we can port some logic to eslint as well (if we want ofc).
the only problem that I see right now - we don't have tests and it's not in written in ts anymore.
This comment has been minimized.
This comment has been minimized.
24eb4c7
to
d939b45
Compare
|
||
let newPlatformInjectedVars: InjectedMetadataStart; | ||
let newPlatformInjectedVars: InjectedMetadata.InjectedMetadataStart; |
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'm fine with having domain name as a prefix for start contract, it's useful for manual search
InjectedMetadataParams, | ||
InjectedMetadataStart, | ||
} from './injected_metadata_service'; | ||
export * from './injected_metadata_service'; |
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 made changes to improve "Go to definition" work. Otherwise, ts resolves this place as a definition. Potential problem: we don't see what file exports. Sometimes it can export some functionality only for testing, which is also bad imho (because it's not public interface).
This comment has been minimized.
This comment has been minimized.
d939b45
to
2fbfd00
Compare
* under the License. | ||
*/ | ||
|
||
/* @notice |
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.
What should we do when use software licensed under MIT? Included a note as per https://github.com/elastic/kibana/blob/master/webpackShims/childnode-remove-polyfill.js
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.
This is how we comply with The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
, but you should include /* eslint-disable @kbn/license-header/require-license-header */
too, since this isn't Apache 2.0 code.
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.
since this isn't Apache 2.0 code.
you mean only this file is not Apache 2.0 anymore because of MIT license? or it's not needed to be licensed under Apache 2.0 at all?
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.
you mean only this file is not Apache 2.0 anymore because of MIT license?
correct
This comment has been minimized.
This comment has been minimized.
💚 Build Succeeded |
Adding @elastic/kibana-operations to evaluate tslint rule. |
@restrry I'm working on this branch https://github.com/mistic/kibana/tree/migrate-from-tslint |
@mistic ok, sounds good 👍 |
@restrry awesome! I'll let you know as soon as I feel we are ready to start porting this 😃 |
I close PR. when #33826 is merged we need to check eslint lints |
Summary
Issue #33444
The full description is in the issue.
Added
import-zones
rule for tslint restricting import from core and plugins sub-folders.Although, import restriction shouldn't be applied to the same folder, descendent folders, so I have to enhance
import-zones
with this functionality. Also we are in process of migration from tslint to eslint, until this process is done I put the PR on hold. Afterwards this plugin will be ported to eslintBlocked by #33826
Checklist
Use
strikethroughsto remove checklist items you don't feel are applicable to this PR.[ ] This was checked for cross-browser compatibility, including a check against IE11[ ] Any text added follows EUI's writing guidelines, uses sentence case text and includes i18n support[ ] Documentation was added for features that require explanation or tutorials[ ] Unit or functional tests were updated or added to match the most common scenarios[ ] This was checked for keyboard-only and screenreader accessibilityFor maintainers
[ ] This was checked for breaking API changes and was labeled appropriately[ ] This includes a feature addition or change that requires a release note and was labeled appropriately