Skip to content

Commit

Permalink
fix(EmptyState): resolved rule being flagged for every specifier (#659)
Browse files Browse the repository at this point in the history
  • Loading branch information
thatblindgeye authored Jun 11, 2024
1 parent 7a5a9f4 commit 1603e39
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,5 +145,44 @@ ruleTester.run("emptyState-nonExported-components", rule, {
},
],
},
// We want to ensure the rule only gets thrown for the applicable components
{
code: `import { EmptyStateHeader, SomeOtherThing } from '@patternfly/react-core';`,
output: `import { EmptyStateHeader, SomeOtherThing } from '@patternfly/react-core';`,
errors: [
{
message: `EmptyStateHeader is no longer exported by PatternFly. This rule will not fix any imports, as our cleanup rule handles removal of unused imports.`,
type: "ImportSpecifier",
},
],
},
{
code: `import { EmptyStateHeader } from '@patternfly/react-core';export default EmptyStateHeader;`,
output: `import { EmptyStateHeader } from '@patternfly/react-core';`,
errors: [
{
message: `EmptyStateHeader is no longer exported by PatternFly. This rule will not fix any imports, as our cleanup rule handles removal of unused imports.`,
type: "ImportSpecifier",
},
{
message: `EmptyStateHeader is no longer exported by PatternFly.`,
type: "ExportDefaultDeclaration",
},
],
},
{
code: `import { EmptyStateHeader, SomeOtherThing } from '@patternfly/react-core';export { EmptyStateHeader, SomeOtherThing };`,
output: `import { EmptyStateHeader, SomeOtherThing } from '@patternfly/react-core';export { SomeOtherThing };`,
errors: [
{
message: `EmptyStateHeader is no longer exported by PatternFly. This rule will not fix any imports, as our cleanup rule handles removal of unused imports.`,
type: "ImportSpecifier",
},
{
message: `EmptyStateHeader is no longer exported by PatternFly.`,
type: "ExportNamedDeclaration",
},
],
},
],
});
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ module.exports = {

return {
ImportSpecifier(node: ImportSpecifier) {
if (!emptyStateImports.length) {
if (
!emptyStateImports.length ||
!emptyStateImports
?.map((imp) => imp.imported.name)
.includes(node.imported.name)
) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ module.exports = {

const variantValue = getAttributeValue(context, variant.value);

console.log(variantValue);
if (
(variant.value.type === "Literal" &&
variantValue === "chip-group") ||
Expand Down

0 comments on commit 1603e39

Please sign in to comment.