diff --git a/packages/eslint-plugin/lib/rules/prefer-web-component-library.js b/packages/eslint-plugin/lib/rules/prefer-web-component-library.js index b38db21dae..5cd15dc0b4 100644 --- a/packages/eslint-plugin/lib/rules/prefer-web-component-library.js +++ b/packages/eslint-plugin/lib/rules/prefer-web-component-library.js @@ -4,50 +4,6 @@ const MESSAGE = const getPropNode = (node, propName) => node.openingElement.attributes.find(n => n.name.name === propName); -const telephoneTransformer = (context, node) => { - const componentName = node.openingElement.name; - const patternNode = getPropNode(node, 'pattern'); - const notClickableNode = getPropNode(node, 'notClickable'); - const contactNode = getPropNode(node, 'contact'); - const contactValue = contactNode?.value.expression || contactNode?.value; - - const stripHyphens = contactValue?.type === 'Literal'; - const international = - patternNode?.value.expression?.property?.name === 'OUTSIDE_US'; - - context.report({ - node, - message: MESSAGE, - data: { - reactComponent: componentName.name, - webComponent: 'va-telephone', - }, - suggest: [ - { - desc: 'Migrate component', - fix: fixer => { - // Replace the node name - // and remove the `pattern` prop if it's there - return [ - fixer.replaceText(componentName, 'va-telephone'), - stripHyphens && - fixer.replaceTextRange( - // Leave the quotes alone - [contactValue.range[0] + 1, contactValue.range[1] - 1], - contactValue.value.replace(/[^\d]/g, ''), - ), - international && - fixer.insertTextBefore(patternNode, 'international'), - patternNode && fixer.remove(patternNode), - notClickableNode && - fixer.replaceText(notClickableNode, 'not-clickable'), - ].filter(i => !!i); - }, - }, - ], - }); -}; - const textInputTransformer = (context, node) => { const componentName = node.openingElement.name; const error = getPropNode(node, 'errorMessage'); @@ -374,9 +330,6 @@ module.exports = { case 'Pagination': paginationTransformer(context, node); break; - case 'Telephone': - telephoneTransformer(context, node); - break; case 'TextInput': textInputTransformer(context, node); break; diff --git a/packages/eslint-plugin/package.json b/packages/eslint-plugin/package.json index ca65d88168..2314594510 100644 --- a/packages/eslint-plugin/package.json +++ b/packages/eslint-plugin/package.json @@ -1,6 +1,6 @@ { "name": "@department-of-veterans-affairs/eslint-plugin", - "version": "1.10.0", + "version": "1.11.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": { diff --git a/packages/eslint-plugin/tests/lib/rules/prefer-web-component-library.js b/packages/eslint-plugin/tests/lib/rules/prefer-web-component-library.js index e0a4910b13..7031b5c019 100644 --- a/packages/eslint-plugin/tests/lib/rules/prefer-web-component-library.js +++ b/packages/eslint-plugin/tests/lib/rules/prefer-web-component-library.js @@ -36,12 +36,6 @@ 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 Telephone from '../components/Telephone'; - // const phone = () => () - // `, - // }, { code: ` import Breadcrumbs from '../../components/Breadcrumbs'; @@ -50,141 +44,6 @@ ruleTester.run('prefer-web-component-library', rule, { }, ], invalid: [ - { - code: mockFile( - 'Telephone', - 'const phone = () => ()', - ), - errors: [ - { - suggestions: [ - { - desc: 'Migrate component', - output: mockFile( - 'Telephone', - 'const phone = () => ()', - ), - }, - ], - }, - ], - }, - { - code: mockFile( - 'Telephone', - 'const phone = () => ()', - ), - errors: [ - { - suggestions: [ - { - desc: 'Migrate component', - // There is an extra space which would get removed on an autosave format - output: mockFile( - 'Telephone', - 'const phone = () => ()', - ), - }, - ], - }, - ], - }, - { - code: mockFile( - 'Telephone', - 'const phone = () => ()', - ), - errors: [ - { - suggestions: [ - { - desc: 'Migrate component', - output: mockFile( - 'Telephone', - 'const phone = () => ()', - ), - }, - ], - }, - ], - }, - { - code: mockFile( - 'Telephone', - 'const phone = () => ()', - ), - errors: [ - { - suggestions: [ - { - desc: 'Migrate component', - output: mockFile( - 'Telephone', - 'const phone = () => ()', - ), - }, - ], - }, - ], - }, - - { - code: mockFile( - 'Telephone', - 'const phone = () => ()', - ), - errors: [ - { - suggestions: [ - { - desc: 'Migrate component', - output: mockFile( - 'Telephone', - 'const phone = () => ()', - ), - }, - ], - }, - ], - }, - { - code: mockFile( - 'Telephone', - 'const phone = () => ()', - ), - errors: [ - { - suggestions: [ - { - desc: 'Migrate component', - output: mockFile( - 'Telephone', - 'const phone = () => ()', - ), - }, - ], - }, - ], - }, - { - code: mockFile( - 'Telephone', - 'const phone = () => ()', - ), - errors: [ - { - suggestions: [ - { - desc: 'Migrate component', - output: mockFile( - 'Telephone', - 'const phone = () => ()', - ), - }, - ], - }, - ], - }, { code: mockFile( 'Breadcrumbs',