From 23edffce12895c32eb67a65ebb060b9d977beedc Mon Sep 17 00:00:00 2001 From: Cole Bemis Date: Fri, 22 Jan 2021 15:54:36 -0800 Subject: [PATCH 01/13] =?UTF-8?q?Text.js=20=E2=86=92=20Text.tsx?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/{Text.js => Text.tsx} | 10 ++++++---- src/__tests__/{Text.js => Text.tsx} | 0 .../__snapshots__/{Text.js.snap => Text.tsx.snap} | 0 3 files changed, 6 insertions(+), 4 deletions(-) rename src/{Text.js => Text.tsx} (52%) rename src/__tests__/{Text.js => Text.tsx} (100%) rename src/__tests__/__snapshots__/{Text.js.snap => Text.tsx.snap} (100%) diff --git a/src/Text.js b/src/Text.tsx similarity index 52% rename from src/Text.js rename to src/Text.tsx index 60e121612d8..d90bc3934f5 100644 --- a/src/Text.js +++ b/src/Text.tsx @@ -1,10 +1,11 @@ -import styled from 'styled-components' import PropTypes from 'prop-types' +import React from 'react' +import styled from 'styled-components' +import {COMMON, SystemCommonProps, SystemTypographyProps, TYPOGRAPHY} from './constants' +import sx, {SxProp} from './sx' import theme from './theme' -import {TYPOGRAPHY, COMMON} from './constants' -import sx from './sx' -const Text = styled.span` +const Text = styled.span` ${TYPOGRAPHY}; ${COMMON}; ${sx}; @@ -21,4 +22,5 @@ Text.propTypes = { theme: PropTypes.object } +export type TextProps = React.ComponentProps export default Text diff --git a/src/__tests__/Text.js b/src/__tests__/Text.tsx similarity index 100% rename from src/__tests__/Text.js rename to src/__tests__/Text.tsx diff --git a/src/__tests__/__snapshots__/Text.js.snap b/src/__tests__/__snapshots__/Text.tsx.snap similarity index 100% rename from src/__tests__/__snapshots__/Text.js.snap rename to src/__tests__/__snapshots__/Text.tsx.snap From 73d7e76d3b94b00bbbc1969faae87b2cca4324cf Mon Sep 17 00:00:00 2001 From: Cole Bemis Date: Fri, 22 Jan 2021 15:57:49 -0800 Subject: [PATCH 02/13] Remove React import --- src/Text.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Text.tsx b/src/Text.tsx index d90bc3934f5..fad64d7ca81 100644 --- a/src/Text.tsx +++ b/src/Text.tsx @@ -1,5 +1,4 @@ import PropTypes from 'prop-types' -import React from 'react' import styled from 'styled-components' import {COMMON, SystemCommonProps, SystemTypographyProps, TYPOGRAPHY} from './constants' import sx, {SxProp} from './sx' From 7128403c488a2cfefda3743d7f92be8142071bc8 Mon Sep 17 00:00:00 2001 From: Cole Bemis Date: Fri, 22 Jan 2021 15:58:06 -0800 Subject: [PATCH 03/13] Create cool-snakes-bathe.md --- .changeset/cool-snakes-bathe.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/cool-snakes-bathe.md diff --git a/.changeset/cool-snakes-bathe.md b/.changeset/cool-snakes-bathe.md new file mode 100644 index 00000000000..83896219e26 --- /dev/null +++ b/.changeset/cool-snakes-bathe.md @@ -0,0 +1,5 @@ +--- +"@primer/components": patch +--- + +Migrate `Text` to TypeScript From 43299b90a466c79f4f37e229ce494bc5935391e8 Mon Sep 17 00:00:00 2001 From: Clay Miller Date: Tue, 26 Jan 2021 17:19:00 -0500 Subject: [PATCH 04/13] chore: Use '@typescript-eslint/parser' for ESLint --- .eslintrc.json | 39 ++++++++++++++------------- package.json | 2 ++ yarn.lock | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 92 insertions(+), 20 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 429f3cb1979..4298e8e89a1 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,12 +1,6 @@ { - "parser": "@babel/eslint-parser", - "extends": [ - "plugin:github/recommended", - "plugin:github/browser", - "plugin:react/recommended", - "plugin:jsx-a11y/recommended", - "plugin:react-hooks/recommended" - ], + "parser": "@typescript-eslint/parser", + "extends": ["plugin:react/recommended", "plugin:jsx-a11y/recommended", "plugin:react-hooks/recommended"], "globals": { "__DEV__": "readonly" }, @@ -17,24 +11,29 @@ "jest": true, "node": true }, + // rules which apply to JS, TS, etc. "rules": { "react/prop-types": 0, "react/display-name": 0, "import/no-namespace": 0, "no-shadow": 0, - "no-unused-vars": [ - "error", - { - "ignoreRestSiblings": true - } - ], "eslint-comments/no-use": 0, "react-hooks/exhaustive-deps": "error", - "jsx-a11y/label-has-for": [ - 2, - { - "components": [] + "jsx-a11y/label-has-for": [2, {"components": []}] + }, + "overrides": [ + // rules which apply only to JS + { + "files": ["**/*.js", "**/*.jsx"], + "extends": ["plugin:github/recommended", "plugin:github/browser"], + "rules": { + "no-unused-vars": ["error", {"ignoreRestSiblings": true}] } - ] - } + }, + // rules which apply only to TS + { + "files": ["**/*.ts", "**/*.tsx"], + "extends": ["plugin:@typescript-eslint/recommended"] + } + ] } diff --git a/package.json b/package.json index 7312f88f7a3..925048cb1a7 100644 --- a/package.json +++ b/package.json @@ -73,6 +73,8 @@ "@testing-library/user-event": "12.6.0", "@types/jest": "26.0.20", "@types/jest-axe": "3.5.1", + "@typescript-eslint/eslint-plugin": "4.14.1", + "@typescript-eslint/parser": "4.14.1", "@wojtekmaj/enzyme-adapter-react-17": "0.3.2", "babel-core": "7.0.0-bridge.0", "babel-plugin-add-react-displayname": "0.0.5", diff --git a/yarn.lock b/yarn.lock index 0b64c8805af..0bb13d80bca 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2067,6 +2067,20 @@ dependencies: "@types/yargs-parser" "*" +"@typescript-eslint/eslint-plugin@4.14.1": + version "4.14.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.14.1.tgz#22dd301ce228aaab3416b14ead10b1db3e7d3180" + integrity sha512-5JriGbYhtqMS1kRcZTQxndz1lKMwwEXKbwZbkUZNnp6MJX0+OVXnG0kOlBZP4LUAxEyzu3cs+EXd/97MJXsGfw== + dependencies: + "@typescript-eslint/experimental-utils" "4.14.1" + "@typescript-eslint/scope-manager" "4.14.1" + debug "^4.1.1" + functional-red-black-tree "^1.0.1" + lodash "^4.17.15" + regexpp "^3.0.0" + semver "^7.3.2" + tsutils "^3.17.1" + "@typescript-eslint/eslint-plugin@>=2.25.0": version "4.14.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.14.0.tgz#92db8e7c357ed7d69632d6843ca70b71be3a721d" @@ -2093,6 +2107,18 @@ eslint-scope "^5.0.0" eslint-utils "^2.0.0" +"@typescript-eslint/experimental-utils@4.14.1": + version "4.14.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-4.14.1.tgz#a5c945cb24dabb96747180e1cfc8487f8066f471" + integrity sha512-2CuHWOJwvpw0LofbyG5gvYjEyoJeSvVH2PnfUQSn0KQr4v8Dql2pr43ohmx4fdPQ/eVoTSFjTi/bsGEXl/zUUQ== + dependencies: + "@types/json-schema" "^7.0.3" + "@typescript-eslint/scope-manager" "4.14.1" + "@typescript-eslint/types" "4.14.1" + "@typescript-eslint/typescript-estree" "4.14.1" + eslint-scope "^5.0.0" + eslint-utils "^2.0.0" + "@typescript-eslint/experimental-utils@^1.13.0": version "1.13.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-1.13.0.tgz#b08c60d780c0067de2fb44b04b432f540138301e" @@ -2102,6 +2128,16 @@ "@typescript-eslint/typescript-estree" "1.13.0" eslint-scope "^4.0.0" +"@typescript-eslint/parser@4.14.1": + version "4.14.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-4.14.1.tgz#3bd6c24710cd557d8446625284bcc9c6d52817c6" + integrity sha512-mL3+gU18g9JPsHZuKMZ8Z0Ss9YP1S5xYZ7n68Z98GnPq02pYNQuRXL85b9GYhl6jpdvUc45Km7hAl71vybjUmw== + dependencies: + "@typescript-eslint/scope-manager" "4.14.1" + "@typescript-eslint/types" "4.14.1" + "@typescript-eslint/typescript-estree" "4.14.1" + debug "^4.1.1" + "@typescript-eslint/parser@>=2.25.0": version "4.14.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-4.14.0.tgz#62d4cd2079d5c06683e9bfb200c758f292c4dee7" @@ -2120,11 +2156,24 @@ "@typescript-eslint/types" "4.14.0" "@typescript-eslint/visitor-keys" "4.14.0" +"@typescript-eslint/scope-manager@4.14.1": + version "4.14.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-4.14.1.tgz#8444534254c6f370e9aa974f035ced7fe713ce02" + integrity sha512-F4bjJcSqXqHnC9JGUlnqSa3fC2YH5zTtmACS1Hk+WX/nFB0guuynVK5ev35D4XZbdKjulXBAQMyRr216kmxghw== + dependencies: + "@typescript-eslint/types" "4.14.1" + "@typescript-eslint/visitor-keys" "4.14.1" + "@typescript-eslint/types@4.14.0": version "4.14.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.14.0.tgz#d8a8202d9b58831d6fd9cee2ba12f8a5a5dd44b6" integrity sha512-VsQE4VvpldHrTFuVPY1ZnHn/Txw6cZGjL48e+iBxTi2ksa9DmebKjAeFmTVAYoSkTk7gjA7UqJ7pIsyifTsI4A== +"@typescript-eslint/types@4.14.1": + version "4.14.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.14.1.tgz#b3d2eb91dafd0fd8b3fce7c61512ac66bd0364aa" + integrity sha512-SkhzHdI/AllAgQSxXM89XwS1Tkic7csPdndUuTKabEwRcEfR8uQ/iPA3Dgio1rqsV3jtqZhY0QQni8rLswJM2w== + "@typescript-eslint/typescript-estree@1.13.0": version "1.13.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-1.13.0.tgz#8140f17d0f60c03619798f1d628b8434913dc32e" @@ -2147,6 +2196,20 @@ semver "^7.3.2" tsutils "^3.17.1" +"@typescript-eslint/typescript-estree@4.14.1": + version "4.14.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.14.1.tgz#20d3b8c8e3cdc8f764bdd5e5b0606dd83da6075b" + integrity sha512-M8+7MbzKC1PvJIA8kR2sSBnex8bsR5auatLCnVlNTJczmJgqRn8M+sAlQfkEq7M4IY3WmaNJ+LJjPVRrREVSHQ== + dependencies: + "@typescript-eslint/types" "4.14.1" + "@typescript-eslint/visitor-keys" "4.14.1" + debug "^4.1.1" + globby "^11.0.1" + is-glob "^4.0.1" + lodash "^4.17.15" + semver "^7.3.2" + tsutils "^3.17.1" + "@typescript-eslint/visitor-keys@4.14.0": version "4.14.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.14.0.tgz#b1090d9d2955b044b2ea2904a22496849acbdf54" @@ -2155,6 +2218,14 @@ "@typescript-eslint/types" "4.14.0" eslint-visitor-keys "^2.0.0" +"@typescript-eslint/visitor-keys@4.14.1": + version "4.14.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.14.1.tgz#e93c2ff27f47ee477a929b970ca89d60a117da91" + integrity sha512-TAblbDXOI7bd0C/9PE1G+AFo7R5uc+ty1ArDoxmrC1ah61Hn6shURKy7gLdRb1qKJmjHkqu5Oq+e4Kt0jwf1IA== + dependencies: + "@typescript-eslint/types" "4.14.1" + eslint-visitor-keys "^2.0.0" + "@webassemblyjs/ast@1.9.0": version "1.9.0" resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.9.0.tgz#bd850604b4042459a5a41cd7d338cbed695ed964" From feeb9691f4939c675c99faaf9cea993317f2ecd1 Mon Sep 17 00:00:00 2001 From: Cole Bemis Date: Tue, 26 Jan 2021 15:36:37 -0800 Subject: [PATCH 05/13] =?UTF-8?q?Flex.js=20=E2=86=92=20Flex.tsx?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/{Flex.js => Flex.tsx} | 4 +++- src/__tests__/{Flex.js => Flex.tsx} | 0 src/__tests__/__snapshots__/{Flex.js.snap => Flex.tsx.snap} | 0 3 files changed, 3 insertions(+), 1 deletion(-) rename src/{Flex.js => Flex.tsx} (70%) rename src/__tests__/{Flex.js => Flex.tsx} (100%) rename src/__tests__/__snapshots__/{Flex.js.snap => Flex.tsx.snap} (100%) diff --git a/src/Flex.js b/src/Flex.tsx similarity index 70% rename from src/Flex.js rename to src/Flex.tsx index 5f0a95f7c09..ce69f2e303b 100644 --- a/src/Flex.js +++ b/src/Flex.tsx @@ -1,6 +1,7 @@ import styled from 'styled-components' -import theme from './theme' import Box from './Box' +import theme from './theme' +import {ComponentProps} from './utils/types' const Flex = styled(Box)`` @@ -13,4 +14,5 @@ Flex.propTypes = { ...Box.propTypes } +export type FlexProps = ComponentProps export default Flex diff --git a/src/__tests__/Flex.js b/src/__tests__/Flex.tsx similarity index 100% rename from src/__tests__/Flex.js rename to src/__tests__/Flex.tsx diff --git a/src/__tests__/__snapshots__/Flex.js.snap b/src/__tests__/__snapshots__/Flex.tsx.snap similarity index 100% rename from src/__tests__/__snapshots__/Flex.js.snap rename to src/__tests__/__snapshots__/Flex.tsx.snap From 4076bf4e173d997c46ba1130c5f0f86f04952790 Mon Sep 17 00:00:00 2001 From: Cole Bemis Date: Tue, 26 Jan 2021 15:37:54 -0800 Subject: [PATCH 06/13] Add changeset --- .changeset/happy-taxis-compare.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/happy-taxis-compare.md diff --git a/.changeset/happy-taxis-compare.md b/.changeset/happy-taxis-compare.md new file mode 100644 index 00000000000..f7c15c5e33a --- /dev/null +++ b/.changeset/happy-taxis-compare.md @@ -0,0 +1,5 @@ +--- +"@primer/components": patch +--- + +Migrate `Flex` to TypeScript From f9a7e78a0e512be90cc349483ed6fab2010e1765 Mon Sep 17 00:00:00 2001 From: Cole Bemis Date: Tue, 26 Jan 2021 16:05:31 -0800 Subject: [PATCH 07/13] Add changeset --- .changeset/friendly-carrots-accept.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/friendly-carrots-accept.md diff --git a/.changeset/friendly-carrots-accept.md b/.changeset/friendly-carrots-accept.md new file mode 100644 index 00000000000..0748d3cbdee --- /dev/null +++ b/.changeset/friendly-carrots-accept.md @@ -0,0 +1,5 @@ +--- +"@primer/components": patch +--- + +Migrate `ProgressBar` to TypeScript From 41e55677eb8266e2cc7a3a05b2e97c0a70def807 Mon Sep 17 00:00:00 2001 From: Cole Bemis Date: Tue, 26 Jan 2021 16:12:15 -0800 Subject: [PATCH 08/13] Fix prop passing in BaseStyles --- src/BaseStyles.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/BaseStyles.tsx b/src/BaseStyles.tsx index 2a4213846b3..9e0fb178a1c 100644 --- a/src/BaseStyles.tsx +++ b/src/BaseStyles.tsx @@ -35,12 +35,12 @@ const Base = styled.div` export type BaseStylesProps = ComponentProps function BaseStyles(props: BaseStylesProps) { - const {color, lineHeight, fontFamily, theme, ...rest} = props + const {children, ...rest} = props useMouseIntent() return ( - {props.children} + {children} ) } From 1519738c9dcd6e7bc23649751766e18683323f76 Mon Sep 17 00:00:00 2001 From: Cole Bemis Date: Tue, 26 Jan 2021 16:25:17 -0800 Subject: [PATCH 09/13] =?UTF-8?q?Grid.js=20=E2=86=92=20Grid.tsx?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/{Grid.js => Grid.tsx} | 8 +++++--- src/__tests__/{Grid.js => Grid.tsx} | 0 .../__snapshots__/{Grid.js.snap => Grid.tsx.snap} | 0 3 files changed, 5 insertions(+), 3 deletions(-) rename src/{Grid.js => Grid.tsx} (55%) rename src/__tests__/{Grid.js => Grid.tsx} (100%) rename src/__tests__/__snapshots__/{Grid.js.snap => Grid.tsx.snap} (100%) diff --git a/src/Grid.js b/src/Grid.tsx similarity index 55% rename from src/Grid.js rename to src/Grid.tsx index c023334ab0e..349c3a57711 100644 --- a/src/Grid.js +++ b/src/Grid.tsx @@ -1,9 +1,10 @@ import styled from 'styled-components' -import {GRID} from './constants' -import theme from './theme' import Box from './Box' +import {GRID, SystemGridProps} from './constants' +import theme from './theme' +import {ComponentProps} from './utils/types' -const Grid = styled(Box)` +const Grid = styled(Box)` ${GRID}; ` @@ -17,4 +18,5 @@ Grid.propTypes = { ...GRID.propTypes } +export type GridProps = ComponentProps export default Grid diff --git a/src/__tests__/Grid.js b/src/__tests__/Grid.tsx similarity index 100% rename from src/__tests__/Grid.js rename to src/__tests__/Grid.tsx diff --git a/src/__tests__/__snapshots__/Grid.js.snap b/src/__tests__/__snapshots__/Grid.tsx.snap similarity index 100% rename from src/__tests__/__snapshots__/Grid.js.snap rename to src/__tests__/__snapshots__/Grid.tsx.snap From 4847e29763b418fbd2893de9307901375bcf5735 Mon Sep 17 00:00:00 2001 From: Cole Bemis Date: Tue, 26 Jan 2021 17:04:38 -0800 Subject: [PATCH 10/13] Delete Modal.js --- src/Modal.js | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 src/Modal.js diff --git a/src/Modal.js b/src/Modal.js deleted file mode 100644 index e69de29bb2d..00000000000 From 2214db8b028abcbc1fb89e7dc73de1371cc930ed Mon Sep 17 00:00:00 2001 From: Clay Miller Date: Wed, 27 Jan 2021 11:09:57 -0500 Subject: [PATCH 11/13] fix: Move overrides into the block with extended rulesets --- .eslintrc.json | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 4298e8e89a1..65235903158 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -11,13 +11,15 @@ "jest": true, "node": true }, + "settings": { + "react": { + "version": "detect" + } + }, // rules which apply to JS, TS, etc. "rules": { "react/prop-types": 0, "react/display-name": 0, - "import/no-namespace": 0, - "no-shadow": 0, - "eslint-comments/no-use": 0, "react-hooks/exhaustive-deps": "error", "jsx-a11y/label-has-for": [2, {"components": []}] }, @@ -27,6 +29,9 @@ "files": ["**/*.js", "**/*.jsx"], "extends": ["plugin:github/recommended", "plugin:github/browser"], "rules": { + "eslint-comments/no-use": 0, + "import/no-namespace": 0, + "no-shadow": 0, "no-unused-vars": ["error", {"ignoreRestSiblings": true}] } }, From 34ff4885311686699fbb6d2e3fab0337bad3d016 Mon Sep 17 00:00:00 2001 From: Cole Bemis Date: Wed, 27 Jan 2021 10:50:50 -0800 Subject: [PATCH 12/13] Add changeset --- .changeset/tricky-gifts-bake.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/tricky-gifts-bake.md diff --git a/.changeset/tricky-gifts-bake.md b/.changeset/tricky-gifts-bake.md new file mode 100644 index 00000000000..c6e4fc812da --- /dev/null +++ b/.changeset/tricky-gifts-bake.md @@ -0,0 +1,5 @@ +--- +"@primer/components": patch +--- + +Migrate `Grid` to TypeScript From 781800dde065ca7c506a95d535914e72a0d184ac Mon Sep 17 00:00:00 2001 From: Cole Bemis Date: Wed, 27 Jan 2021 11:06:39 -0800 Subject: [PATCH 13/13] Update release PR title --- .github/workflows/release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2f573517f8d..784ffbd044e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -26,6 +26,7 @@ jobs: id: changesets uses: changesets/action@master with: + title: Release Tracking # This expects you to have a script called release which does a build for your packages and calls changeset publish publish: yarn release env: