Skip to content

Commit

Permalink
chore: remove prop-types (#3442)
Browse files Browse the repository at this point in the history
* chore: remove prop-types

* test: update pin-external-deps danger check to display package with issue

* fix: lint

* fix: tests

* fix: website lint

* fix: more lint

* fix: more lint fixed that keep popping up

* chore: update changeset

* chore: rebase fixes

* chore: make these changes minor and remove upgrade guide notice

* fix: whoopsie

* chore: missing package.json files

---------

Co-authored-by: Si Taggart <[email protected]>
  • Loading branch information
TheSisb and SiTaggart authored Sep 20, 2023
1 parent d45a601 commit b8d7920
Show file tree
Hide file tree
Showing 380 changed files with 242 additions and 2,669 deletions.
88 changes: 88 additions & 0 deletions .changeset/sixty-baboons-brush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
---
'@twilio-paste/codemods': patch
'@twilio-paste/account-switcher': minor
'@twilio-paste/alert': minor
'@twilio-paste/alert-dialog': minor
'@twilio-paste/anchor': minor
'@twilio-paste/avatar': minor
'@twilio-paste/badge': minor
'@twilio-paste/base-radio-checkbox': minor
'@twilio-paste/breadcrumb': minor
'@twilio-paste/button': minor
'@twilio-paste/button-group': minor
'@twilio-paste/callout': minor
'@twilio-paste/card': minor
'@twilio-paste/chat-composer': minor
'@twilio-paste/chat-log': minor
'@twilio-paste/checkbox': minor
'@twilio-paste/code-block': minor
'@twilio-paste/combobox': minor
'@twilio-paste/data-grid': minor
'@twilio-paste/date-picker': minor
'@twilio-paste/description-list': minor
'@twilio-paste/detail-text': minor
'@twilio-paste/disclosure': minor
'@twilio-paste/display-heading': minor
'@twilio-paste/editable-code-block': minor
'@twilio-paste/file-picker': minor
'@twilio-paste/file-uploader': minor
'@twilio-paste/form': minor
'@twilio-paste/heading': minor
'@twilio-paste/help-text': minor
'@twilio-paste/in-page-navigation': minor
'@twilio-paste/inline-code': minor
'@twilio-paste/input': minor
'@twilio-paste/input-box': minor
'@twilio-paste/label': minor
'@twilio-paste/list': minor
'@twilio-paste/menu': minor
'@twilio-paste/minimizable-dialog': minor
'@twilio-paste/modal': minor
'@twilio-paste/pagination': minor
'@twilio-paste/paragraph': minor
'@twilio-paste/popover': minor
'@twilio-paste/product-switcher': minor
'@twilio-paste/progress-steps': minor
'@twilio-paste/radio-button-group': minor
'@twilio-paste/radio-group': minor
'@twilio-paste/screen-reader-only': minor
'@twilio-paste/select': minor
'@twilio-paste/separator': minor
'@twilio-paste/side-modal': minor
'@twilio-paste/sidebar': minor
'@twilio-paste/skeleton-loader': minor
'@twilio-paste/spinner': minor
'@twilio-paste/status': minor
'@twilio-paste/switch': minor
'@twilio-paste/table': minor
'@twilio-paste/tabs': minor
'@twilio-paste/textarea': minor
'@twilio-paste/time-picker': minor
'@twilio-paste/toast': minor
'@twilio-paste/tooltip': minor
'@twilio-paste/topbar': minor
'@twilio-paste/truncate': minor
'@twilio-paste/user-dialog': minor
'@twilio-paste/core': minor
'@twilio-paste/aspect-ratio': minor
'@twilio-paste/flex': minor
'@twilio-paste/grid': minor
'@twilio-paste/media-object': minor
'@twilio-paste/stack': minor
'@twilio-paste/box': minor
'@twilio-paste/combobox-primitive': minor
'@twilio-paste/disclosure-primitive': minor
'@twilio-paste/sibling-box': minor
'@twilio-paste/text': minor
'@twilio-paste/customization': minor
'@twilio-paste/design-tokens': minor
'@twilio-paste/lexical-library': minor
'@twilio-paste/react-spectrum-library': minor
'@twilio-paste/nextjs-template': minor
'@twilio-paste/style-props': minor
'@twilio-paste/token-contrast-checker': minor
---

Removed all run-time [prop-type checking](https://www.npmjs.com/package/prop-types)from Paste components. Paste now ships with only TypeScript types.

**ACTION NEEDED**: None. This should be 100% backwards compatible.
6 changes: 2 additions & 4 deletions .danger/__fixtures__/mock_package_2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@
"peerDependencies": {
"@twilio-paste/design-tokens": "^8.0.0",
"@twilio-paste/styling-library": "^1.0.0",
"@twilio-paste/theme": "^8.0.0",
"prop-types": "^15.7.2"
"@twilio-paste/theme": "^8.0.0"
},
"devDependencies": {
"@twilio-paste/design-tokens": "^8.0.0",
"@twilio-paste/styling-library": "^1.0.2",
"@twilio-paste/theme": "^8.0.0",
"prop-types": "^15.7.2"
"@twilio-paste/theme": "^8.0.0"
}
}
6 changes: 2 additions & 4 deletions .danger/__fixtures__/mock_package_3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@
"peerDependencies": {
"@twilio-paste/design-tokens": "^8.0.0",
"@twilio-paste/styling-library": "^1.0.0",
"@twilio-paste/theme": "^8.0.0",
"prop-types": "^15.7.2"
"@twilio-paste/theme": "^8.0.0"
},
"devDependencies": {
"@twilio-paste/design-tokens": "^8.0.0",
"@twilio-paste/styling-library": "^1.0.2",
"@twilio-paste/theme": "^8.0.0",
"prop-types": "^15.7.2"
"@twilio-paste/theme": "^8.0.0"
}
}
51 changes: 51 additions & 0 deletions .danger/__tests__/__snapshots__/pin-external-deps.spec.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`pin external dependencies check getUnPinnedExternalDepsFromPackageJSONFiles() should return an array of all the unpinned external deps across every provided package.json file 1`] = `
Array [
Object {
"dep": "lodash",
"name": "mock-package",
},
]
`;

exports[`pin external dependencies check getUnPinnedExternalDepsFromPackageJSONFiles() should return an array of all the unpinned external deps across every provided package.json file 2`] = `
Array [
Object {
"dep": "csstype",
"name": "mock-package-2",
},
Object {
"dep": "lodash",
"name": "mock-package-2",
},
]
`;

exports[`pin external dependencies check getUnPinnedExternalDepsFromPackageJSONFiles() should return an array of all the unpinned external deps across every provided package.json file 3`] = `Array []`;

exports[`pin external dependencies check getUnPinnedExternalDepsFromPackageJSONFiles() should return an array of all the unpinned external deps across every provided package.json file 4`] = `
Array [
Object {
"dep": "lodash",
"name": "mock-package",
},
]
`;

exports[`pin external dependencies check getUnPinnedExternalDepsFromPackageJSONFiles() should return an array of all the unpinned external deps across every provided package.json file 5`] = `
Array [
Object {
"dep": "lodash",
"name": "mock-package",
},
Object {
"dep": "csstype",
"name": "mock-package-2",
},
Object {
"dep": "lodash",
"name": "mock-package-2",
},
]
`;
14 changes: 7 additions & 7 deletions .danger/__tests__/pin-external-deps.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,32 @@ describe('pin external dependencies check', () => {
});
describe('getUnPinnedExternalDepsFromPackageJSONFiles()', () => {
it('should return an array of all the unpinned external deps across every provided package.json file', () => {
expect(getUnPinnedExternalDepsFromPackageJSONFiles(['./.danger/__fixtures__/mock_package/package.json'])).toEqual(
['lodash']
);
expect(
getUnPinnedExternalDepsFromPackageJSONFiles(['./.danger/__fixtures__/mock_package/package.json'])
).toMatchSnapshot();

expect(
getUnPinnedExternalDepsFromPackageJSONFiles(['./.danger/__fixtures__/mock_package_2/package.json'])
).toEqual(['csstype', 'lodash']);
).toMatchSnapshot();

expect(
getUnPinnedExternalDepsFromPackageJSONFiles(['./.danger/__fixtures__/mock_package_3/package.json'])
).toEqual([]);
).toMatchSnapshot();

expect(
getUnPinnedExternalDepsFromPackageJSONFiles([
'./.danger/__fixtures__/mock_package/package.json',
'./.danger/__fixtures__/mock_package_3/package.json',
])
).toEqual(['lodash']);
).toMatchSnapshot();

expect(
getUnPinnedExternalDepsFromPackageJSONFiles([
'./.danger/__fixtures__/mock_package/package.json',
'./.danger/__fixtures__/mock_package_2/package.json',
'./.danger/__fixtures__/mock_package_3/package.json',
])
).toEqual(['lodash', 'csstype', 'lodash']);
).toMatchSnapshot();
});
});

Expand Down
18 changes: 11 additions & 7 deletions .danger/pin-external-deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,14 @@ export const getUnpinnedExternalDeps = (deps: Record<string, string>): string[]
* @param {string[]} pkgJSONFiles
* @return {*} {string[]}
*/
export const getUnPinnedExternalDepsFromPackageJSONFiles = (pkgJSONFiles: string[]): string[] => {
const unPinnedExternalDeps: string[] = [];
export const getUnPinnedExternalDepsFromPackageJSONFiles = (
pkgJSONFiles: string[]
): Array<{dep: string; name: string}> => {
const unPinnedExternalDeps: Array<{dep: string; name: string}> = [];
pkgJSONFiles.forEach((pkgJSON) => {
const fileContent = fs.readFileSync(pkgJSON).toString();
const {dependencies} = JSON.parse(fileContent);
getUnpinnedExternalDeps(dependencies).forEach((dep) => unPinnedExternalDeps.push(dep));
const {name, dependencies} = JSON.parse(fileContent);
getUnpinnedExternalDeps(dependencies).forEach((dep) => unPinnedExternalDeps.push({dep, name}));
});
return unPinnedExternalDeps;
};
Expand All @@ -57,10 +59,12 @@ export default () => {
const unpinnedExternalDeps = getUnPinnedExternalDepsFromPackageJSONFiles(packageJSONsChanged);

if (unpinnedExternalDeps.length > 0) {
let locationString = ``;
unpinnedExternalDeps.forEach(({dep, name}) => {
locationString += `* ${name} - ${dep}\n`;
});
fail(
`There are some package.json files in this PR that contain unpinned external package libraries. Please pin your external package libraries by removing the ^ from the beginning of the version number. See: ${JSON.stringify(
unpinnedExternalDeps
)}`
`There are some package.json files in this PR that contain unpinned external package libraries. Please pin your external package libraries by removing the ^ from the beginning of the version number. See:\n\n${locationString}`
);
}
}
Expand Down
21 changes: 1 addition & 20 deletions .vscode/component.code-snippets
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,7 @@
},
"Paste React component with props file outline": {
"prefix": "prindexp",
"body": [
"import * as React from 'react';",
"import PropTypes from 'prop-types';",
"import {Box} from '@twilio-paste/box';",
"",
"${1:prfcp}",
""
],
"body": ["import * as React from 'react';", "import {Box} from '@twilio-paste/box';", "", "${1:prfcp}", ""],
"description": "Create an component with props file starter"
},
"Paste React Function Component With Props": {
Expand All @@ -47,10 +40,6 @@
"",
"${1:ComponentName}.displayName = '${1:ComponentName}';",
"",
"${1:ComponentName}.propTypes = {",
" children: PropTypes.node.isRequired,",
"};",
"",
"export {${1:ComponentName}};"
],
"description": "Create a React component"
Expand All @@ -70,10 +59,6 @@
"",
"${1:ComponentName}.displayName = '${1:ComponentName}';",
"",
"${1:ComponentName}.propTypes = {",
" children: PropTypes.node.isRequired,",
"};",
"",
"export {${1:ComponentName}};"
],
"description": "Create a React component"
Expand Down Expand Up @@ -113,10 +98,6 @@
"",
"Styled${1:ComponentName}.displayName = 'Styled${1:ComponentName}';",
"",
"Styled${1:ComponentName}.propTypes = {",
" children: PropTypes.node.isRequired,",
"};",
"",
"export {Styled${1:ComponentName}};"
],
"description": "Create a Styled component"
Expand Down
1 change: 0 additions & 1 deletion apps/vs-code-intellisense/src/test/runTest.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as path from 'path';

import {runTests} from '@vscode/test-electron';

async function main() {
Expand Down
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@
"@types/color": "^3.0.0",
"@types/jest": "^24.0.18",
"@types/node": "^18.11.13",
"@types/prop-types": "^15.7.5",
"@types/react": "^18.0.27",
"@types/react-color": "^3.0.6",
"@types/react-github-button": "^0.1.1",
Expand Down Expand Up @@ -192,7 +191,6 @@
"plop": "^2.7.4",
"precise-commits": "^1.0.2",
"prettier": "^2.8.1",
"prop-types": "^15.7.2",
"puppeteer-core": "^19.6.1",
"react": "^18.0.0",
"react-dom": "^18.0.0",
Expand Down
18 changes: 0 additions & 18 deletions packages/paste-codemods/tools/.cache/mappings.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"Avatar": "@twilio-paste/core/avatar",
"AvatarGroup": "@twilio-paste/core/avatar",
"Badge": "@twilio-paste/core/badge",
"BadgePropTypes": "@twilio-paste/core/badge",
"BadgeVariants": "@twilio-paste/core/badge",
"badgeAnchorStyles": "@twilio-paste/core/badge",
"badgeBaseStyles": "@twilio-paste/core/badge",
Expand All @@ -33,10 +32,8 @@
"Breadcrumb": "@twilio-paste/core/breadcrumb",
"BreadcrumbItem": "@twilio-paste/core/breadcrumb",
"Button": "@twilio-paste/core/button",
"ButtonPropTypes": "@twilio-paste/core/button",
"ButtonToggleStyles": "@twilio-paste/core/button",
"DestructiveSecondaryButtonToggleStyles": "@twilio-paste/core/button",
"DirectButtonPropTypes": "@twilio-paste/core/button",
"ButtonGroup": "@twilio-paste/core/button-group",
"Callout": "@twilio-paste/core/callout",
"CalloutHeading": "@twilio-paste/core/callout",
Expand Down Expand Up @@ -128,7 +125,6 @@
"FormPillGroup": "@twilio-paste/core/form-pill-group",
"useFormPillState": "@twilio-paste/core/form-pill-group",
"Heading": "@twilio-paste/core/heading",
"HeadingPropTypes": "@twilio-paste/core/heading",
"HelpText": "@twilio-paste/core/help-text",
"HelpTextVariants": "@twilio-paste/core/help-text",
"InPageNavigation": "@twilio-paste/core/in-page-navigation",
Expand All @@ -151,19 +147,12 @@
"Menu": "@twilio-paste/core/menu",
"MenuBadge": "@twilio-paste/core/menu",
"MenuBadgeContent": "@twilio-paste/core/menu",
"MenuBadgePropTypes": "@twilio-paste/core/menu",
"MenuButton": "@twilio-paste/core/menu",
"MenuButtonPropTypes": "@twilio-paste/core/menu",
"MenuGroup": "@twilio-paste/core/menu",
"MenuGroupContext": "@twilio-paste/core/menu",
"MenuGroupPropTypes": "@twilio-paste/core/menu",
"MenuItem": "@twilio-paste/core/menu",
"MenuItemCheckbox": "@twilio-paste/core/menu",
"MenuItemCheckboxPropTypes": "@twilio-paste/core/menu",
"MenuItemPropTypes": "@twilio-paste/core/menu",
"MenuItemRadio": "@twilio-paste/core/menu",
"MenuItemRadioPropTypes": "@twilio-paste/core/menu",
"MenuPropTypes": "@twilio-paste/core/menu",
"MenuSeparator": "@twilio-paste/core/menu",
"StyledMenuItem": "@twilio-paste/core/menu",
"SubMenuButton": "@twilio-paste/core/menu",
Expand Down Expand Up @@ -270,19 +259,12 @@
"Switch": "@twilio-paste/core/switch",
"SwitchGroup": "@twilio-paste/core/switch",
"TBody": "@twilio-paste/core/table",
"TBodyPropTypes": "@twilio-paste/core/table",
"TFoot": "@twilio-paste/core/table",
"TFootPropTypes": "@twilio-paste/core/table",
"THead": "@twilio-paste/core/table",
"THeadPropTypes": "@twilio-paste/core/table",
"Table": "@twilio-paste/core/table",
"TablePropTypes": "@twilio-paste/core/table",
"Td": "@twilio-paste/core/table",
"TdPropTypes": "@twilio-paste/core/table",
"Th": "@twilio-paste/core/table",
"ThPropTypes": "@twilio-paste/core/table",
"Tr": "@twilio-paste/core/table",
"TrPropTypes": "@twilio-paste/core/table",
"Tab": "@twilio-paste/core/tabs",
"TabList": "@twilio-paste/core/tabs",
"TabPanel": "@twilio-paste/core/tabs",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Button, Label, MediaObject, TBodyPropTypes} from '@twilio-paste/core';
import {Button, Label, MediaObject} from '@twilio-paste/core';
import {Table} from '@twilio-paste/core';
import {Button as Stuffin} from '@twilio-paste/core';
import {Button as Stuff} from '@sendgrid/ui-components';
import {Input} from '@twilio-paste/core';
import {Card} from '@twilio-paste/core/dist/card';
import {Card} from '@twilio-paste/core/dist/card';
Loading

0 comments on commit b8d7920

Please sign in to comment.