Open Andrei-Stepanov opened 1 year ago
Hi, Update from a discussion on Slack with Dallas Nicol, it turned out that the place of error was:
import ReactTable from '@patternfly/react-table';
This commit fixed it:
https://github.com/fedora-ci/ciboard/commit/7c869d249eee4ff1147200b52fe3d8099c55c1dc
As far as fixing this on the codemod side. If we added a specifier?.name
it would work for Andrei's case as the Table
etc were imported by name.
However, it could be possible that we are wanting to target an import that could come through the default and used in that way (ReactTable.Table
). In these cases if we just fixed with an undefined check, the codemod wouldn't be able to target them and do it's job (it would be ignored).
To really fix this, we'd have to make exceptions for this type of import... which would affect nearly all codemods and likely be a pretty significant effort.
As this is pretty uncommon and not a super trivial fix, I wonder if it would be good enough to ignore specifiers without import names (these default imports) by using the specifier.imported?.name
(will have to check for all such instances in codemods) and then adding another codemod that just checks for such import specifiers and gives a warning like:
/src/path/file.tsx 10:1 warning This import specifier does not have an import name. The codemods will be unable to check against it. We recommend using named imports instead of default imports.
We had the same error with this import:
import * as Patternfly from "@patternfly/react-core";
Using specifier.imported?.name
in the rule fixes it.
The error:
TypeError: Error while loading rule '@patternfly/pf-codemods/aboutModalBoxHero-remove-subcomponent': Cannot read properties of undefined (reading 'name')
Hello,
Could you please help me? I am following: https://www.patternfly.org/get-started/upgrade/release-notes/ I get an error: