-
Notifications
You must be signed in to change notification settings - Fork 14k
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
refactor: import value name from root of superset-ui/core #17947
Conversation
Codecov Report
@@ Coverage Diff @@
## master #17947 +/- ##
=======================================
Coverage 67.07% 67.07%
=======================================
Files 1609 1609
Lines 64905 64905
Branches 6868 6868
=======================================
Hits 43537 43537
Misses 19502 19502
Partials 1866 1866
Flags with carried forward coverage won't be shown. Click here to find out more. Continue to review full report at Codecov.
|
superset-frontend/packages/superset-ui-core/test/chart-composition/legend/WithLegend.test.tsx
Outdated
Show resolved
Hide resolved
8377b8a
to
50a694d
Compare
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.
Thanks for cleaning this up, this will ensure a much nicer development experience!
Love it! |
import { LOGIN_GLOB } from '../fixtures/constants'; | ||
import { sankeyFormData } from '../fixtures/formData'; | ||
import { SliceIdAndOrFormData } from '../../../src/chart/clients/ChartClient'; |
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 the packages are self-contained, is there a way to set something in each package.json
or globally to make packages/<package-name>
as the root for each package and avoid the ../../..
imports?
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.
IMO, have to keep a simple and straightforward approach to link modules. We have to consider multiple runtime to alias these module
- Eslint
- Jest
- Webpack
This pattern only keep 1 principle "public variable name import from top level"
What do you think about it?
* chart * index and number-format * char-composition and color * connection * dimension and math-expression * models * query * time-format * residual modules * change config of jest and eslint config * wip update package.json * fix lint * WithLegend import from superset-ui/core
* chart * index and number-format * char-composition and color * connection * dimension and math-expression * models * query * time-format * residual modules * change config of jest and eslint config * wip update package.json * fix lint * WithLegend import from superset-ui/core
SUMMARY
Currently, there are multiple ways to import a
value name
fromsuperset-ui/core
, this confusing import expression makes the codebase difficult to maintain.You can use following approach in
superset-frontend/src
with Webpack, the config at hereimport { ensureIsArray } from '@superset-ui/core'
You can use following approach in
superset-frontend/packages/superset-ui-core/test
with Jest and Eslint, the config at here(Jest) and here(Eslint).import { ensureIsArray } from '@superset-ui/core'
import { ensureIsArray } from '@superset-ui/core/src/utils/ensureIsArray'
import { ensureIsArray } from '../../some/relative/path'
This PR enforces the codebase using unified import expression:
import { ensureIsArray } from '@superset-ui/core'
. If you want to import an internal(private) module from '@superset-ui/core', you should use relative import and export the corresponding value name.after the PR,
eslint
rules will prevent following import expressionimport { ensureIsArray } from '@superset-ui/core/src/some/path
import { testValueName } from '@superset-ui/core/test/some/path
import { valueNameFromLib }
from@superset-ui/core/lib/some/path
after the PR,
eslint
rules will approve following import expressionimport { ensureIsArray } from '@superset-ui/core'
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A
TESTING INSTRUCTIONS
CI
ADDITIONAL INFORMATION