Skip to content
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

Add eslint rule to forbid imports from path containing packages/ from root dir of OSD #1500

Merged
merged 5 commits into from
Jul 19, 2023

Conversation

cwperks
Copy link
Member

@cwperks cwperks commented Jul 3, 2023

Description

Opening a Draft PR with a new eslint rule forbidding imports from ./packages directory of OpenSearch dashboards which is only used for development. I added the rule directly into security-dashboards-plugin to show it working, but it would probably be best to place this directly in OSD. I have not been able to get this working with a rule in OSD core and not quite sure how dashboards plugins inherit rules from the OSD core.

I see the following rule in OSD core which looks like it should have caught the bad import: https://github.com/opensearch-project/OpenSearch-Dashboards/blob/main/.eslintrc.js#L295-L319

Category

Bug fix

Issues Resolved

#1487

Check List

  • New functionality includes testing
  • New functionality has been documented
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Signed-off-by: Craig Perkins <cwperx@amazon.com>
… root dir of OSD

Signed-off-by: Craig Perkins <cwperx@amazon.com>
basePath: __dirname,
zones: [
{
target: ['(public|server)/**/*'],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can these be expanded, maybe .ts/.js files under any path?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@peternied Sorry I did not see this comment last week. This was modeled after eslint rules from OSD core. Example: https://github.com/opensearch-project/OpenSearch-Dashboards/blob/main/.eslintrc.js#L320-L334

I was trying to add this rule to OSD Core instead of this repo to enforce it across all dashboards plugins, but I was not ultimately able to figure out how to.

@codecov
Copy link

codecov bot commented Jul 11, 2023

Codecov Report

Merging #1500 (4f80d20) into main (29a8d9c) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main    #1500   +/-   ##
=======================================
  Coverage   66.06%   66.06%           
=======================================
  Files          93       93           
  Lines        2328     2328           
  Branches      310      310           
=======================================
  Hits         1538     1538           
  Misses        722      722           
  Partials       68       68           

@peternied
Copy link
Member

@DarshitChanpura @RyanL1997 @cliu123 @davidlago Could we get another review on this change?

@davidlago davidlago merged commit 91faa3d into opensearch-project:main Jul 19, 2023
13 checks passed
samuelcostae pushed a commit to samuelcostae/security-dashboards-plugin that referenced this pull request Aug 10, 2023
… root dir of OSD (opensearch-project#1500)

* Add lint rule to forbid imports from packages

Signed-off-by: Craig Perkins <cwperx@amazon.com>

* Add eslint rule to forbid imports from path containing packages/ from root dir of OSD

Signed-off-by: Craig Perkins <cwperx@amazon.com>

---------

Signed-off-by: Craig Perkins <cwperx@amazon.com>
Co-authored-by: Stephen Crawford <65832608+scrawfor99@users.noreply.github.com>
Co-authored-by: Peter Nied <petern@amazon.com>
Signed-off-by: Sam <samuel.costa@eliatra.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants