Skip to content

Commit

Permalink
remove breadcrumb eslint transformer
Browse files Browse the repository at this point in the history
  • Loading branch information
harshil1793 committed Nov 7, 2023
1 parent 410fa5f commit 407daf0
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 80 deletions.
32 changes: 0 additions & 32 deletions packages/eslint-plugin/lib/rules/prefer-web-component-library.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,35 +42,6 @@ const textInputTransformer = (context, node) => {
});
};

const breadcrumbsTransformer = (context, node) => {
const componentName = node.openingElement.name;
const closingTag = node.closingElement.name;
const selectedFacilityNode = getPropNode(node, 'selectedFacility');

context.report({
node,
message: MESSAGE,
data: {
reactComponent: componentName.name,
webComponent: 'va-breadcrumbs',
},
suggest: [
{
desc: 'Migrate component',
fix: fixer => {
// Replace opening and close tags
// and remove `selectedFacilityNode` prop if present
return [
fixer.replaceText(componentName, 'va-breadcrumbs'),
fixer.replaceText(closingTag, 'va-breadcrumbs'),
selectedFacilityNode && fixer.remove(selectedFacilityNode),
].filter(i => !!i);
},
},
],
});
};

const modalTransformer = (context, node) => {
const openingTagNode = node.openingElement.name;
const closingTagNode = node.closingElement?.name;
Expand Down Expand Up @@ -282,9 +253,6 @@ module.exports = {
if (!isLibraryImport(context, componentName)) return;

switch (componentName) {
case 'Breadcrumbs':
breadcrumbsTransformer(context, node);
break;
case 'Modal':
modalTransformer(context, node);
break;
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@department-of-veterans-affairs/eslint-plugin",
"version": "1.13.0",
"version": "1.14.0",
"description": "ESLint plugin for va.gov projects",
"homepage": "https://github.com/department-of-veterans-affairs/veteran-facing-services-tools/tree/master/packages/eslint-plugin#readme",
"bugs": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,54 +35,7 @@ const mockFileComponentLibraryNamedImport = (name, snippet) => {
ruleTester.run('prefer-web-component-library', rule, {
// This rule should not trigger on application components, only React components
// from the `component-library`
valid: [
{
code: `
import Breadcrumbs from '../../components/Breadcrumbs';
const breadcrumbs = () => (<Breadcrumbs><a href="#home">Home</a></Breadcrumbs>)
`,
},
],
invalid: [
{
code: mockFile(
'Breadcrumbs',
'const breadcrumb = () => (<Breadcrumbs><a href="/">Home</a></Breadcrumbs>)',
),
errors: [
{
suggestions: [
{
desc: 'Migrate component',
output: mockFile(
'Breadcrumbs',
'const breadcrumb = () => (<va-breadcrumbs><a href="/">Home</a></va-breadcrumbs>)',
),
},
],
},
],
},
{
code: mockFile(
'Breadcrumbs',
'const breadcrumb = () => (<Breadcrumbs selectedFacility={selectedResult}><a href="/">Home</a></Breadcrumbs>)',
),
errors: [
{
suggestions: [
{
desc: 'Migrate component',
// There is an extra space which would get removed on an autosave format
output: mockFile(
'Breadcrumbs',
'const breadcrumb = () => (<va-breadcrumbs ><a href="/">Home</a></va-breadcrumbs>)',
),
},
],
},
],
},
{
code: mockFile(
'Modal',
Expand Down

0 comments on commit 407daf0

Please sign in to comment.