|
| 1 | +const ruleTester = require("../../ruletester"); |
| 2 | +import * as rule from "./component-groups-invalidObjectProps-rename-to-missingPageProps"; |
| 3 | + |
| 4 | +ruleTester.run( |
| 5 | + "component-groups-invalidObjectProps-rename-to-missingPageProps", |
| 6 | + rule, |
| 7 | + { |
| 8 | + valid: [ |
| 9 | + // missing import |
| 10 | + { |
| 11 | + code: `const props: InvalidObjectProps;`, |
| 12 | + }, |
| 13 | + // import from wrong package |
| 14 | + { |
| 15 | + code: `import { InvalidObjectProps } from '@patternfly/react-core';`, |
| 16 | + }, |
| 17 | + ], |
| 18 | + invalid: [ |
| 19 | + { |
| 20 | + code: `import { InvalidObjectProps } from '@patternfly/react-component-groups'; |
| 21 | + const props: InvalidObjectProps; |
| 22 | + const otherProps = props as InvalidObjectProps;`, |
| 23 | + output: `import { MissingPageProps } from '@patternfly/react-component-groups'; |
| 24 | + const props: MissingPageProps; |
| 25 | + const otherProps = props as MissingPageProps;`, |
| 26 | + errors: [ |
| 27 | + { |
| 28 | + message: `InvalidObjectProps has been renamed to MissingPageProps.`, |
| 29 | + type: "ImportSpecifier", |
| 30 | + }, |
| 31 | + { |
| 32 | + message: `InvalidObjectProps has been renamed to MissingPageProps.`, |
| 33 | + type: "TSTypeReference", |
| 34 | + }, |
| 35 | + { |
| 36 | + message: `InvalidObjectProps has been renamed to MissingPageProps.`, |
| 37 | + type: "TSTypeReference", |
| 38 | + }, |
| 39 | + ], |
| 40 | + }, |
| 41 | + // named import with alias |
| 42 | + { |
| 43 | + code: `import { InvalidObjectProps as InvObjProps } from '@patternfly/react-component-groups';`, |
| 44 | + output: `import { MissingPageProps as InvObjProps } from '@patternfly/react-component-groups';`, |
| 45 | + errors: [ |
| 46 | + { |
| 47 | + message: `InvalidObjectProps has been renamed to MissingPageProps.`, |
| 48 | + type: "ImportSpecifier", |
| 49 | + }, |
| 50 | + ], |
| 51 | + }, |
| 52 | + // imports from dist |
| 53 | + { |
| 54 | + code: `import { InvalidObjectProps } from '@patternfly/react-component-groups/dist/cjs/InvalidObject';`, |
| 55 | + output: `import { MissingPageProps } from '@patternfly/react-component-groups/dist/cjs/InvalidObject';`, |
| 56 | + errors: [ |
| 57 | + { |
| 58 | + message: `InvalidObjectProps has been renamed to MissingPageProps.`, |
| 59 | + type: "ImportSpecifier", |
| 60 | + }, |
| 61 | + ], |
| 62 | + }, |
| 63 | + { |
| 64 | + code: `import { InvalidObjectProps } from '@patternfly/react-component-groups/dist/esm/InvalidObject';`, |
| 65 | + output: `import { MissingPageProps } from '@patternfly/react-component-groups/dist/esm/InvalidObject';`, |
| 66 | + errors: [ |
| 67 | + { |
| 68 | + message: `InvalidObjectProps has been renamed to MissingPageProps.`, |
| 69 | + type: "ImportSpecifier", |
| 70 | + }, |
| 71 | + ], |
| 72 | + }, |
| 73 | + { |
| 74 | + code: `import { InvalidObjectProps } from '@patternfly/react-component-groups/dist/dynamic/InvalidObject';`, |
| 75 | + output: `import { MissingPageProps } from '@patternfly/react-component-groups/dist/dynamic/InvalidObject';`, |
| 76 | + errors: [ |
| 77 | + { |
| 78 | + message: `InvalidObjectProps has been renamed to MissingPageProps.`, |
| 79 | + type: "ImportSpecifier", |
| 80 | + }, |
| 81 | + ], |
| 82 | + }, |
| 83 | + ], |
| 84 | + } |
| 85 | +); |
0 commit comments