Skip to content

Commit

Permalink
feat(mod): add user-feedback css update warning (#747)
Browse files Browse the repository at this point in the history
* feat(mod): add user-feedback css update warning

* account for alias, default

* account for default import

* remove unused imports
  • Loading branch information
kmcfaul authored Sep 26, 2024
1 parent 7425fe7 commit 2ca012f
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export const warningRules = [
"toolbarLabelGroupContent-updated-markup",
"tooltip-warn-triggerRef-may-be-required",
"treeView-warn-selectable-styling-modifier-removed",
"user-feedback-warn-changes",
"wizard-warn-button-order",
"wizardFooter-warn-update-markup",
"wizardNavItem-warn-update-markup",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function pfPackageMatches(
parts[1] +
"(/dist/(esm|js|dynamic))?" +
(parts[2] ? "/" + parts[2] : "") +
(["react-component-groups", "react-tokens"].includes(parts[1])
(["react-component-groups", "react-tokens", "react-user-feedback"].includes(parts[1])
? `(/.*)?$`
: `(/(components|helpers${
parts[1] === "react-icons" ? "|icons" : ""
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### user-feedback-warn-changes [(#76)](https://github.com/patternfly/react-user-feedback/pull/76)

The internal scss stylesheet that `FeedbackModal` and its internal components were referencing has been refactored into a css stylesheet. The new `Feedback.css` file will have to be imported to maintain styling on `FeedbackModal`, and may be located in the dist (`@patternfly/react-user-feedback/dist/esm/Feedback/Feedback.css`) or in the `src`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
const ruleTester = require("../../ruletester");
import * as rule from "./user-feedback-warn-changes";

ruleTester.run("user-feedback-warn-changes", rule, {
valid: [
{
code: `<FeedbackModal />`,
},
{
code: `import { FeedbackModal } from '@patternfly/some-other-package';`,
}
],
invalid: [
{
code: `import { FeedbackModal } from '@patternfly/react-user-feedback';`,
output: `import { FeedbackModal } from '@patternfly/react-user-feedback';`,
errors: [
{
message: `FeedbackModal no longer internally references a scss stylesheet. You may have to import "Feedback.css" located in the dist "@patternfly/react-user-feedback/dist/esm/Feedback/Feedback.css" to maintain styling on FeedbackModal.`,
type: "ImportDeclaration",
},
],
},
{
code: `import { FeedbackModal as MyModal } from '@patternfly/react-user-feedback';`,
output: `import { FeedbackModal as MyModal } from '@patternfly/react-user-feedback';`,
errors: [
{
message: `FeedbackModal no longer internally references a scss stylesheet. You may have to import "Feedback.css" located in the dist "@patternfly/react-user-feedback/dist/esm/Feedback/Feedback.css" to maintain styling on FeedbackModal.`,
type: "ImportDeclaration",
},
],
},
{
code: `import myDefaultModal from '@patternfly/react-user-feedback/dist/esm/Feedback/FeedbackModal';`,
output: `import myDefaultModal from '@patternfly/react-user-feedback/dist/esm/Feedback/FeedbackModal';`,
errors: [
{
message: `FeedbackModal no longer internally references a scss stylesheet. You may have to import "Feedback.css" located in the dist "@patternfly/react-user-feedback/dist/esm/Feedback/Feedback.css" to maintain styling on FeedbackModal.`,
type: "ImportDeclaration",
},
],
},
],
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { getAllImportsFromPackage, getComponentImportName } from "../../helpers";
import { Rule } from "eslint";
import { ImportDeclaration } from "estree-jsx";

// https://github.com/patternfly/react-user-feedback/pull/76
module.exports = {
meta: {},
create: function (context: Rule.RuleContext) {
const imports = getAllImportsFromPackage(context, "@patternfly/react-user-feedback", ["FeedbackModal"]);

return !imports.length
? {}
: {
ImportDeclaration(node: ImportDeclaration) {
if (
node.specifiers.find(
(specifier) =>
(specifier.type === "ImportSpecifier" || specifier.type === "ImportDefaultSpecifier")
&& getComponentImportName(specifier, ["FeedbackModal"]) === "FeedbackModal"
)
) {
context.report({
node,
message: `FeedbackModal no longer internally references a scss stylesheet. You may have to import "Feedback.css" located in the dist "@patternfly/react-user-feedback/dist/esm/Feedback/Feedback.css" to maintain styling on FeedbackModal.`,
});
}
},
};
},
};

0 comments on commit 2ca012f

Please sign in to comment.