const ruleTester = require("../../ruletester"); import * as rule from "./button-support-favorite-variant"; ruleTester.run("button-support-favorite-variant", rule, { valid: [ { code: ``, }, { code: `import { Button } from '@patternfly/react-core'; import { SomeIcon } from '@patternfly/react-icons'; `, }, { code: `import { Button } from '@patternfly/react-core'; `, }, // Button not from PF, StarIcon from PF - should not trigger { code: `import { Button } from '@some-other-package'; import { StarIcon } from '@patternfly/react-icons'; `, }, // Both Button and StarIcon not from PF - should not trigger { code: `import { Button } from '@some-other-package'; import { StarIcon } from '@another-package'; `, }, // Button from PF, StarIcon not from PF (in icon prop) - should not trigger { code: `import { Button } from '@patternfly/react-core'; import { StarIcon } from '@some-other-package'; `, errors: [ { message: "It looks like you are trying to create a custom favorites button. Use `isFavorite` and `isFavorited` button properties instead to apply the correct styling.", type: "JSXElement", }, ], }, // StarIcon in icon prop { code: `import { Button } from '@patternfly/react-core'; import { StarIcon } from '@patternfly/react-icons'; `, errors: [ { message: "It looks like you are trying to create a custom favorites button. Use `isFavorite` and `isFavorited` button properties instead to apply the correct styling.", type: "JSXElement", }, ], }, // Button with aliased import { code: `import { Button as PFButton } from '@patternfly/react-core'; import { StarIcon } from '@patternfly/react-icons'; `, errors: [ { message: "It looks like you are trying to create a custom favorites button. Use `isFavorite` and `isFavorited` button properties instead to apply the correct styling.", type: "JSXElement", }, ], }, // StarIcon with text { code: `import { Button } from '@patternfly/react-core'; import { StarIcon } from '@patternfly/react-icons'; `, errors: [ { message: "It looks like you are trying to create a custom favorites button. Use `isFavorite` and `isFavorited` button properties instead to apply the correct styling.", type: "JSXElement", }, ], }, // StarIcon with other icon { code: `import { Button } from '@patternfly/react-core'; import { StarIcon, SomeIcon } from '@patternfly/react-icons'; `, errors: [ { message: "It looks like you are trying to create a custom favorites button. Use `isFavorite` and `isFavorited` button properties instead to apply the correct styling.", type: "JSXElement", }, ], }, // StarIcon in fragment with text { code: `import { Button } from '@patternfly/react-core'; import { StarIcon } from '@patternfly/react-icons'; `, errors: [ { message: "It looks like you are trying to create a custom favorites button. Use `isFavorite` and `isFavorited` button properties instead to apply the correct styling.", type: "JSXElement", }, ], }, // StarIcon with existing props { code: `import { Button } from '@patternfly/react-core'; import { StarIcon } from '@patternfly/react-icons'; `, errors: [ { message: "It looks like you are trying to create a custom favorites button. Use `isFavorite` and `isFavorited` button properties instead to apply the correct styling.", type: "JSXElement", }, ], }, ], });