-
Notifications
You must be signed in to change notification settings - Fork 31
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
fix: Restrict @adobe/spectrum imports #2179
fix: Restrict @adobe/spectrum imports #2179
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2179 +/- ##
==========================================
- Coverage 46.67% 46.66% -0.01%
==========================================
Files 692 692
Lines 38620 38629 +9
Branches 9625 9751 +126
==========================================
+ Hits 18025 18028 +3
+ Misses 20584 20548 -36
- Partials 11 53 +42
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
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 ends up removing the no import from deephaven packages rules
I think you need to combine the spectrum and self-package imports. With this config, you can do import { IrisGrid } from '@deephaven/iris-grid';
inside of IrisGrid
.
This also disables the self import check from the ignored paths even if the other rules are combined. Not sure the best way around that. You might be able to combine another |
Not completely sure what can be done here, I have been experimenting with different configurations, but ultimately, because of the way overrides work, we can only disable the Gonna keep experimenting but nothing super promising so far |
I believe it should be good now @mattrunyon |
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.
It's hard for me to comment on just the certain parts, but the config should be this
- Prevents importing from own package everywhere including spectrum components
- Prevents importing from @adobe/react-spectrum everywhere except spectrum components
const buildPackageManifest = require('./packageManifest');
const { packageNames, packageManifest } = buildPackageManifest();
module.exports = {
root: true,
extends: ['@deephaven/eslint-config'],
ignorePatterns: ['packages/golden-layout/*', 'jest.config.*'],
overrides: [
{
files: ['**/*.@(ts|tsx)'],
parserOptions: {
project: ['./tsconfig.eslint.json', './packages/*/tsconfig.json'],
tsconfigRootDir: __dirname,
},
},
...packageNames.map(packageName => ({
files: [`packages/${packageManifest.get(packageName)}/**/*.@(ts|tsx)`],
rules: {
'no-restricted-imports': [
'error',
{
name: packageName,
message: 'Forbid importing from owning @deephaven package.',
},
{
name: '@adobe/react-spectrum',
message:
'Import from @deephaven/components instead of @adobe/react-spectrum.',
},
],
},
overrides: [
{
files: [
'packages/components/src/spectrum/**/*.@(ts|tsx)',
'packages/components/src/theme/**/*.@(ts|tsx)',
],
rules: {
'no-restricted-imports': [
'error',
{
name: packageName,
message: 'Forbid importing from owning @deephaven package.',
},
],
},
},
],
})),
],
};
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.
@mattrunyon On my end, when I test with the npm test:lint with my code and with the code you suggested, they both behave the same.
However, I will be pushing the change you made if you see it as more valid, I see it as more of a semantic change (the new code is a little clearer for someone to understand)
The previous version didn't prevent importing from the owning deephaven package when in the spectrum and theme directories. It was actually preventing |
Closes #1908