-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(mod): add user-feedback css update warning (#747)
* feat(mod): add user-feedback css update warning * account for alias, default * account for default import * remove unused imports
- Loading branch information
Showing
5 changed files
with
80 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
...-pf-codemods/src/rules/v6/userFeedbackWarnChanges/user-feedback-warn-changes.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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`. |
45 changes: 45 additions & 0 deletions
45
...lugin-pf-codemods/src/rules/v6/userFeedbackWarnChanges/user-feedback-warn-changes.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
}, | ||
], | ||
}, | ||
], | ||
}); |
30 changes: 30 additions & 0 deletions
30
...int-plugin-pf-codemods/src/rules/v6/userFeedbackWarnChanges/user-feedback-warn-changes.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.`, | ||
}); | ||
} | ||
}, | ||
}; | ||
}, | ||
}; |