Skip to content

Commit 3c38586

Browse files
author
Austin Green
authored
feat(dropdowns): migrate react-dropdowns to Typescript (#371)
1 parent 8209fe2 commit 3c38586

File tree

110 files changed

+4567
-3719
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+4567
-3719
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
packages/notifications/index.d.ts

.eslintrc.json

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
{
2+
"parser": "@typescript-eslint/parser",
23
"extends": [
34
"@zendeskgarden",
45
"@zendeskgarden/eslint-config/plugins/notice.js",
56
"plugin:react/recommended",
67
"plugin:jest/recommended",
78
"plugin:jsx-a11y/recommended",
8-
"prettier"
9+
"plugin:@typescript-eslint/recommended",
10+
"prettier/@typescript-eslint",
11+
"plugin:prettier/recommended"
912
],
1013
"settings": {
1114
"react": {
@@ -18,7 +21,7 @@
1821
"PACKAGE_VERSION": true,
1922
"COMPONENT_IDS": true
2023
},
21-
"plugins": ["prettier", "react", "jest", "jsx-a11y", "react-hooks"],
24+
"plugins": ["prettier", "react", "jest", "jsx-a11y", "react-hooks", "@typescript-eslint"],
2225
"env": {
2326
"es6": true,
2427
"browser": true,
@@ -30,13 +33,35 @@
3033
"valid-jsdoc": "off",
3134
"no-invalid-this": "off",
3235
"no-unused-expressions": ["error", { "allowShortCircuit": true }],
36+
"no-irregular-whitespace": ["error", { "skipTemplates": true }],
37+
"prefer-named-capture-group": "off",
3338
"react/jsx-key": "off",
3439
"react/display-name": "off",
3540
"react/no-unsafe": ["error", { "checkAliases": true }],
41+
"react/prop-types": ["error", { "ignore": ["children"] }],
3642
"jsx-a11y/label-has-for": "off",
3743
"jest/no-disabled-tests": "off",
3844
"react-hooks/rules-of-hooks": "error",
39-
"react-hooks/exhaustive-deps": "warn"
45+
"react-hooks/exhaustive-deps": "warn",
46+
"@typescript-eslint/explicit-function-return-type": "off",
47+
"@typescript-eslint/no-var-requires": "off",
48+
"@typescript-eslint/no-explicit-any": "off",
49+
"@typescript-eslint/camelcase": "off",
50+
"@typescript-eslint/interface-name-prefix": ["error", "always"],
51+
"@typescript-eslint/no-non-null-assertion": "off"
4052
},
41-
"overrides": [{ "files": ["*.spec.js"], "rules": { "react/prop-types": "off" } }]
53+
"overrides": [
54+
{
55+
"files": ["*.{ts,tsx}", "*.spec.{js,ts,tsx}"],
56+
"rules": {
57+
"react/prop-types": "off"
58+
}
59+
},
60+
{
61+
"files": ["*.js"],
62+
"rules": {
63+
"@typescript-eslint/no-unused-vars": "off"
64+
}
65+
}
66+
]
4267
}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
node_modules
33
*.log
44
.changelog
5+
.vscode
56

67
# Package specific
78
packages/**/dist

.lintstagedrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@
77
"prettier --write",
88
"git add"
99
],
10+
"*.{ts,tsx}": [
11+
"stylelint",
12+
"eslint",
13+
"jest --config=utils/test/jest.config.js --findRelatedTests",
14+
"prettier --write",
15+
"git add"
16+
],
1017
"*.md": [
1118
"markdownlint",
1219
"prettier --write",

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ before_install:
1616
install: yarn --frozen-lockfile --ignore-scripts
1717

1818
script:
19+
- yarn lerna bootstrap --ignore-scripts
1920
- yarn lint
21+
- yarn tsc
2022
- yarn format
21-
- yarn lerna bootstrap --ignore-scripts
2223
- yarn test:all --coverage --runInBand
2324

2425
after_success: yarn coveralls < demo/coverage/lcov.info

.yarnclean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@types/react-native

babel.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ module.exports = {
1818
plugins: [
1919
'@babel/plugin-transform-object-assign',
2020
'@babel/plugin-proposal-class-properties',
21+
'@babel/proposal-object-rest-spread',
2122
'babel-plugin-styled-components'
2223
]
2324
};

lerna.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
{
22
"version": "6.0.3",
33
"npmClient": "yarn",
4-
"npmClientArgs": [
5-
"--no-lockfile"
6-
],
4+
"npmClientArgs": ["--no-lockfile"],
75
"changelog": {
86
"repo": "zendeskgarden/react-components",
97
"cacheDir": ".changelog",
@@ -18,6 +16,8 @@
1816
"ignoreChanges": [
1917
"*.md",
2018
"*.spec.js",
19+
"*.spec.ts",
20+
"*.spec.tsx",
2121
"**/__snapshots__/**",
2222
"styleguide.config.js"
2323
],

package.json

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@
77
"build:analyze": "ANALYZE_BUNDLE=true yarn build:single",
88
"build:demo": "yarn build && lerna run build:demo --stream",
99
"build:single": "utils/scripts/scoped-npm-command.js --script build",
10-
"format": "yarn format:package_json && yarn format:js && yarn format:markdown",
10+
"format": "yarn format:package_json && yarn format:js && yarn format:ts && yarn format:markdown",
1111
"format:js": "prettier --loglevel warn --write 'packages/**/!(dist|umd)/*.js' && prettier --loglevel warn --write utils/**/*.js",
1212
"format:markdown": "prettier --loglevel warn --write 'packages/**/!(dist)/!(CHANGELOG)*.md'",
1313
"format:package_json": "prettier-package-json --write && lerna exec -- prettier-package-json --write",
14+
"format:ts": "prettier --loglevel warn --write 'packages/**/!(dist|umd)/*.{ts,tsx}' && prettier --loglevel warn --write utils/**/*.{ts,tsx}",
1415
"postinstall": "lerna bootstrap",
1516
"lint": "yarn lint:css && yarn lint:js && yarn lint:markdown",
1617
"lint:css": "stylelint \"packages/*/src/**/*.js\" && stylelint \"utils/**/*.js\"",
17-
"lint:js": "eslint packages/*/src/ utils/ --max-warnings 0",
18+
"lint:js": "eslint packages/*/src/ utils/ --ext js,ts,tsx --max-warnings 0",
1819
"lint:markdown": "markdownlint API.md DEVELOPMENT.md README.md VERSIONING.md packages/*/src/**/*.md packages/*/src/*.md packages/*/README.md",
1920
"new": "utils/scripts/create-package.js",
2021
"prepare": "yarn build",
@@ -28,13 +29,23 @@
2829
"@babel/cli": "7.4.4",
2930
"@babel/core": "7.4.5",
3031
"@babel/plugin-proposal-class-properties": "7.4.4",
32+
"@babel/plugin-proposal-object-rest-spread": "7.4.4",
3133
"@babel/plugin-transform-object-assign": "7.2.0",
3234
"@babel/polyfill": "7.4.4",
3335
"@babel/preset-env": "7.4.5",
3436
"@babel/preset-react": "7.0.0",
3537
"@svgr/webpack": "4.3.0",
3638
"@testing-library/react": "8.0.1",
39+
"@types/classnames": "2.2.8",
40+
"@types/jest": "24.0.13",
41+
"@types/prop-types": "15.7.1",
3742
"@types/react": "16.8.19",
43+
"@types/react-dom": "16.8.4",
44+
"@types/styled-components": "4.1.16",
45+
"@types/webpack": "4.4.32",
46+
"@typescript-eslint/eslint-plugin": "1.10.2",
47+
"@typescript-eslint/parser": "1.10.2",
48+
"@zendeskgarden/css-bedrock": "7.0.26",
3849
"@zendeskgarden/css-variables": "6.3.4",
3950
"@zendeskgarden/eslint-config": "7.2.1",
4051
"@zendeskgarden/stylelint-config": "10.0.0",
@@ -54,6 +65,7 @@
5465
"enzyme-to-json": "3.3.5",
5566
"eslint": "5.16.0",
5667
"eslint-config-prettier": "4.3.0",
68+
"eslint-loader": "2.1.2",
5769
"eslint-plugin-jest": "22.6.4",
5870
"eslint-plugin-jsx-a11y": "6.2.1",
5971
"eslint-plugin-notice": "0.7.8",
@@ -89,6 +101,7 @@
89101
"prettier": "1.18.2",
90102
"prettier-package-json": "2.1.0",
91103
"react": "16.8.6",
104+
"react-docgen-typescript": "1.12.5",
92105
"react-dom": "16.8.6",
93106
"react-styleguidist": "8.0.6",
94107
"regenerator-runtime": "0.13.2",
@@ -100,6 +113,9 @@
100113
"stylelint-config-styled-components": "0.1.1",
101114
"stylelint-order": "3.0.0",
102115
"stylelint-processor-styled-components": "1.8.0",
116+
"ts-jest": "24.0.2",
117+
"ts-loader": "6.0.2",
118+
"typescript": "3.5.1",
103119
"uglifyjs-webpack-plugin": "2.1.3",
104120
"webpack": "4.33.0",
105121
"webpack-bundle-analyzer": "3.3.2",

packages/dropdowns/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"build:demo": "../../utils/scripts/build-demo.sh",
1919
"start": "../../utils/scripts/start.sh"
2020
},
21+
"types": "./dist/typings/index.d.ts",
2122
"dependencies": {
2223
"@zendeskgarden/container-selection": "^0.2.3",
2324
"classnames": "^2.2.5",
@@ -32,6 +33,7 @@
3233
"styled-components": "^4.2.0"
3334
},
3435
"devDependencies": {
36+
"@types/lodash.debounce": "^4.0.6",
3537
"@zendeskgarden/css-arrows": "3.1.1",
3638
"@zendeskgarden/css-forms": "7.0.10",
3739
"@zendeskgarden/css-menus": "9.0.10",
@@ -49,5 +51,5 @@
4951
"access": "public"
5052
},
5153
"zendeskgarden:library": "GardenDropdowns",
52-
"zendeskgarden:src": "src/index.js"
54+
"zendeskgarden:src": "src/index.ts"
5355
}

0 commit comments

Comments
 (0)