Skip to content

Commit 9009a15

Browse files
authored
Merge pull request #4489 from Methuselah96/ts-try-hooks-again
Convert to TypeScript
2 parents b0411ff + 64086d0 commit 9009a15

File tree

253 files changed

+7316
-5487
lines changed

Some content is hidden

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

253 files changed

+7316
-5487
lines changed

.changeset/getChangelogEntry.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,25 @@ const { getInfo } = require('@changesets/get-github-info');
44
const getReleaseLine = async (changeset, type) => {
55
const [firstLine, ...futureLines] = changeset.summary
66
.split('\n')
7-
.map(l => l.trimRight());
7+
.map((l) => l.trimRight());
88
let { links } = await getInfo({
99
repo: 'JedWatson/react-select',
1010
commit: changeset.commit,
1111
});
1212
return `- ${links.commit}${links.pull === null ? '' : ` ${links.pull}`}${
1313
links.user === null ? '' : ` Thanks ${links.user}!`
14-
} - ${firstLine}\n${futureLines.map(l => ` ${l}`).join('\n')}`;
14+
} - ${firstLine}\n${futureLines.map((l) => ` ${l}`).join('\n')}`;
1515
};
1616

1717
const getDependencyReleaseLine = async (changesets, dependenciesUpdated) => {
1818
if (dependenciesUpdated.length === 0) return '';
1919

2020
const changesetLinks = changesets.map(
21-
changeset => `- Updated dependencies [${changeset.commit}]:`
21+
(changeset) => `- Updated dependencies [${changeset.commit}]:`
2222
);
2323

2424
const updatedDepenenciesList = dependenciesUpdated.map(
25-
dependency => ` - ${dependency.name}@${dependency.version}`
25+
(dependency) => ` - ${dependency.name}@${dependency.version}`
2626
);
2727

2828
return [...changesetLinks, ...updatedDepenenciesList].join('\n');

.circleci/config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ jobs:
5959
command: |
6060
yarn prettier:check
6161
yarn lint
62-
yarn flow check --flowconfig-name=.flowconfig-ci
62+
yarn type-check
6363
yarn test:jest
6464
yarn coveralls
6565
end_to_end:

.codesandbox/ci.json

-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
2-
31
{
42
"buildCommand": "build",
53
"packages": ["packages/*"],
64
"sandboxes": ["nfmxw"]
75
}
8-

.coveralls.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
service-name: travis-ci
2-
repo_token: itdMRdBNgDK8Gb5nIA63zVMEryaxTQxkR
2+
repo_token: itdMRdBNgDK8Gb5nIA63zVMEryaxTQxkR

.eslintignore

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ coverage/*
22
cypress/plugins/*
33
cypress/support/*
44
**/dist/*
5-
flow-typed/*
65
lib/*
76
node_modules/*
87
**/node_modules/*

.eslintrc.js

+12-7
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
module.exports = {
2-
extends: ['plugin:react-hooks/recommended'],
3-
parser: 'babel-eslint',
2+
extends: ['plugin:react-hooks/recommended', 'plugin:@typescript-eslint/base'],
3+
parser: '@typescript-eslint/parser',
44
env: {
55
browser: true,
66
es6: true,
77
node: true,
88
},
9-
plugins: ['react'],
9+
plugins: ['react', '@typescript-eslint'],
1010
rules: {
11-
'no-unused-vars': [
11+
'@typescript-eslint/no-unused-vars': [
1212
'error',
1313
{
1414
args: 'after-used',
@@ -23,9 +23,9 @@ module.exports = {
2323
'no-shadow': 1,
2424
'no-trailing-spaces': 1,
2525
'no-underscore-dangle': 1,
26-
'no-unused-expressions': 1,
26+
'@typescript-eslint/no-unused-expressions': 1,
2727
'object-curly-spacing': [1, 'always'],
28-
quotes: [2, 'single', 'avoid-escape'],
28+
'@typescript-eslint/quotes': [2, 'single', 'avoid-escape'],
2929
'react/jsx-boolean-value': 1,
3030
'react/jsx-no-undef': 1,
3131
'react/jsx-uses-react': 1,
@@ -37,7 +37,12 @@ module.exports = {
3737
'react/react-in-jsx-scope': 1,
3838
'react/self-closing-comp': 1,
3939
'react/sort-prop-types': 1,
40-
semi: 2,
40+
'@typescript-eslint/semi': 2,
4141
strict: 0,
4242
},
43+
settings: {
44+
react: {
45+
version: 'detect',
46+
},
47+
},
4348
};

.flowconfig

-23
This file was deleted.

.flowconfig-ci

-25
This file was deleted.

.github/CONTRIBUTING.md

+22-22
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,26 @@ welcome, from issue reports to PRs and documentation / write-ups.
55

66
Before you open a PR:
77

8-
* In development, run `yarn start` to build (+watch) the project source, and run
9-
the [development server](http://localhost:8000).
10-
* Please ensure all the examples work correctly after your change. If you're
11-
adding a major new use-case, add a new example demonstrating its use.
12-
* Be careful to follow the code style of the project. Run `yarn lint` after
13-
your changes and ensure you do not introduce any new errors or warnings.
14-
* This repository uses `flow`, please run `yarn flow` after your changes to ensure
15-
that you do not introduce any new type errors.
8+
- In development, run `yarn start` to build (+watch) the project source, and run
9+
the [development server](http://localhost:8000).
10+
- Please ensure all the examples work correctly after your change. If you're
11+
adding a major new use-case, add a new example demonstrating its use.
12+
- Be careful to follow the code style of the project. Run `yarn lint` after
13+
your changes and ensure you do not introduce any new errors or warnings.
14+
- This repository uses TypeScript, please run `yarn type-check` after your changes to ensure
15+
that you do not introduce any new type errors.
1616

17-
* Ensure that your effort is aligned with the project's roadmap by talking to
18-
the maintainers, especially if you are going to spend a lot of time on it.
19-
* Make sure there's an issue open for any work you take on and intend to submit
20-
as a pull request - it helps core members review your concept and direction
21-
early and is a good way to discuss what you're planning to do.
22-
* If you open an issue and are interested in working on a fix, please let us
23-
know. We'll help you get started, rather than adding it to the queue.
24-
* Make sure you do not add regressions by running `yarn test`.
25-
* Where possible, include tests with your changes, either that demonstrates the
26-
bug, or tests the new functionality. If you're not sure how to test your
27-
changes, feel free to ping @gwyneplaine or @JedWatson
28-
* Run `yarn coveralls` to check that the coverage hasn't dropped, and look at the
29-
report (under the generated `coverage` directory) to check that your changes are
30-
covered
17+
- Ensure that your effort is aligned with the project's roadmap by talking to
18+
the maintainers, especially if you are going to spend a lot of time on it.
19+
- Make sure there's an issue open for any work you take on and intend to submit
20+
as a pull request - it helps core members review your concept and direction
21+
early and is a good way to discuss what you're planning to do.
22+
- If you open an issue and are interested in working on a fix, please let us
23+
know. We'll help you get started, rather than adding it to the queue.
24+
- Make sure you do not add regressions by running `yarn test`.
25+
- Where possible, include tests with your changes, either that demonstrates the
26+
bug, or tests the new functionality. If you're not sure how to test your
27+
changes, feel free to ping @gwyneplaine or @JedWatson
28+
- Run `yarn coveralls` to check that the coverage hasn't dropped, and look at the
29+
report (under the generated `coverage` directory) to check that your changes are
30+
covered

.github/ISSUE_TEMPLATE.md

+6-5
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
Before creating an issue...
44

55
# Are you asking a question?
6-
Please don't file GitHub issues to ask questions. Use Stack Overflow with a [#react-select](http://stackoverflow.com/questions/tagged/react-select) tag.
76

7+
Please don't file GitHub issues to ask questions. Use Stack Overflow with a [#react-select](http://stackoverflow.com/questions/tagged/react-select) tag.
88

99
# Are you reporting a bug or runtime error?
10+
1011
Please include a test case that demonstrates the issue you're reporting!
1112

1213
This is very helpful to maintainers in order to help us see the issue you're seeing.
@@ -26,10 +27,10 @@ https://codesandbox.io/s/n34mq0743j
2627

2728
You may also find the [online Babel tool](https://babeljs.io/repl/) quite helpful if you wish to use ES6/ES7 syntax not yet supported by the browser you are using.
2829

29-
3030
# Are you making a feature request?
31+
3132
Provide as much information as possible about your requested feature. Here are a few questions you may consider answering:
3233

33-
* What's your use case? (Tell us about your application and what problem you're trying to solve.)
34-
* What interface do you have in mind? (What new properties or methods do you think might be helpful?)
35-
* Can you point to similar functionality with any existing libraries or components? (Working demos can be helpful.)
34+
- What's your use case? (Tell us about your application and what problem you're trying to solve.)
35+
- What interface do you have in mind? (What new properties or methods do you think might be helpful?)
36+
- Can you point to similar functionality with any existing libraries or components? (Working demos can be helpful.)

.github/workflows/release.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
- name: Checkout Repo
1414
uses: actions/checkout@master
1515
with:
16-
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
16+
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
1717
fetch-depth: 0
1818

1919
- name: Setup Node.js 10.x

.prettierignore

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ coverage/*
22
cypress/plugins/*
33
cypress/support/*
44
**/dist/*
5-
flow-typed/*
65
lib/*
76
node_modules/*
87
**/node_modules/*

CONTRIBUTING.md

+18-18
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,21 @@ welcome, from issue reports to PRs and documentation / write-ups.
55

66
Before you open a PR:
77

8-
* In development, run `yarn start` to build (and watch) the project source, and run
9-
the [development server](http://localhost:8000).
10-
* Please ensure all the examples work correctly after your change. If you're
11-
adding a major new use-case, add a new example `/docs/examples` and subsequent documentation demonstrating its use `/docs/pages`.
12-
* Ensure that your effort is aligned with the project's roadmap by talking to
13-
the maintainers, especially if you are going to spend a lot of time on it.
14-
* Make sure there's an issue open for any work you take on and intend to submit
15-
as a pull request - it helps core members review your concept and direction
16-
early and is a good way to discuss what you're planning to do.
17-
* If you open an issue and are interested in working on a fix, please let us
18-
know. We'll help you get started, rather than inadvertently doubling up on your hard work.
19-
* Make sure you do not add regressions by running `yarn test`.
20-
* Where possible, include tests with your changes, either that demonstrates the
21-
bug, or tests the new functionality. If you're not sure how to test your
22-
changes, feel free to ping @gwyneplaine
23-
* Please [follow our established coding conventions](https://github.com/keystonejs/keystone/wiki/Coding-Standards)
24-
(with regards to formatting, etc)
25-
* All new features and changes need documentation.
8+
- In development, run `yarn start` to build (and watch) the project source, and run
9+
the [development server](http://localhost:8000).
10+
- Please ensure all the examples work correctly after your change. If you're
11+
adding a major new use-case, add a new example `/docs/examples` and subsequent documentation demonstrating its use `/docs/pages`.
12+
- Ensure that your effort is aligned with the project's roadmap by talking to
13+
the maintainers, especially if you are going to spend a lot of time on it.
14+
- Make sure there's an issue open for any work you take on and intend to submit
15+
as a pull request - it helps core members review your concept and direction
16+
early and is a good way to discuss what you're planning to do.
17+
- If you open an issue and are interested in working on a fix, please let us
18+
know. We'll help you get started, rather than inadvertently doubling up on your hard work.
19+
- Make sure you do not add regressions by running `yarn test`.
20+
- Where possible, include tests with your changes, either that demonstrates the
21+
bug, or tests the new functionality. If you're not sure how to test your
22+
changes, feel free to ping @gwyneplaine
23+
- Please [follow our established coding conventions](https://github.com/keystonejs/keystone/wiki/Coding-Standards)
24+
(with regards to formatting, etc)
25+
- All new features and changes need documentation.

README.md

+9-7
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ yarn add react-select
3636
```
3737

3838
Then use it in your app:
39+
3940
#### With React Component
41+
4042
```js
4143
import React from 'react';
4244
import Select from 'react-select';
@@ -51,10 +53,9 @@ class App extends React.Component {
5153
state = {
5254
selectedOption: null,
5355
};
54-
handleChange = selectedOption => {
55-
this.setState(
56-
{ selectedOption },
57-
() => console.log(`Option selected:`, this.state.selectedOption)
56+
handleChange = (selectedOption) => {
57+
this.setState({ selectedOption }, () =>
58+
console.log(`Option selected:`, this.state.selectedOption)
5859
);
5960
};
6061
render() {
@@ -72,9 +73,10 @@ class App extends React.Component {
7273
```
7374

7475
#### With React Hooks
76+
7577
```js
76-
import React, { useState } from "react";
77-
import Select from "react-select";
78+
import React, { useState } from 'react';
79+
import Select from 'react-select';
7880

7981
const options = [
8082
{ value: 'chocolate', label: 'Chocolate' },
@@ -84,7 +86,7 @@ const options = [
8486

8587
export default function App() {
8688
const [selectedOption, setSelectedOption] = useState(null);
87-
89+
8890
return (
8991
<div className="App">
9092
<Select

babel.config.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,9 @@ module.exports = {
44
['@babel/plugin-proposal-class-properties', { loose: true }],
55
'@babel/plugin-transform-runtime',
66
],
7-
presets: ['@babel/preset-env', '@babel/preset-react', '@babel/preset-flow'],
7+
presets: [
8+
'@babel/preset-env',
9+
'@babel/preset-react',
10+
'@babel/preset-typescript',
11+
],
812
};

cypress/integration/multi-select.spec.js renamed to cypress/integration/multi-select.spec.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const selector = require('../fixtures/selectors.json');
2-
const baseUrl = require('../../cypress.json').baseUrl;
1+
import selector from '../fixtures/selectors.json';
2+
import cypressJson from '../../cypress.json';
33

44
const setup = [
55
{ width: 1440, height: 900, viewport: 'macbook-15', device: 'Laptop' },
@@ -9,7 +9,7 @@ const setup = [
99

1010
describe('Multi Select', () => {
1111
before(() => {
12-
cy.visit(baseUrl);
12+
cy.visit(cypressJson.baseUrl);
1313
cy.title().should('equal', 'React-Select');
1414
cy.get('h1').should('contain', 'Test Page for Cypress');
1515
});
@@ -20,7 +20,7 @@ describe('Multi Select', () => {
2020
for (let config of setup) {
2121
const { viewport } = config;
2222
it(`Should display several default values that can be removed in view: ${viewport}`, () => {
23-
cy.get(selector.multiSelectDefaultValues).then(function($defaultValue) {
23+
cy.get(selector.multiSelectDefaultValues).then(function ($defaultValue) {
2424
expect($defaultValue).to.have.length(2);
2525
expect($defaultValue.eq(0)).to.contain('Purple');
2626
expect($defaultValue.eq(1)).to.contain('Red');
@@ -29,7 +29,7 @@ describe('Multi Select', () => {
2929
cy.get(selector.firstMultiValueRemove)
3030
.click()
3131
.get(selector.multiSelectDefaultValues)
32-
.then(function($defaultValue) {
32+
.then(function ($defaultValue) {
3333
expect($defaultValue).to.have.length(1);
3434
expect($defaultValue.eq(0)).to.contain('Red');
3535
})
@@ -42,7 +42,7 @@ describe('Multi Select', () => {
4242
.click()
4343
.type('{backspace}', { force: true })
4444
.get(selector.multiSelectDefaultValues)
45-
.then(function($defaultValue) {
45+
.then(function ($defaultValue) {
4646
expect($defaultValue).to.have.length(1);
4747
expect($defaultValue.eq(0)).to.contain('Purple');
4848
})
@@ -74,7 +74,7 @@ describe('Multi Select', () => {
7474
.type('Slate', { force: true })
7575
.type('{enter}', { force: true })
7676
.get(selector.multiSelectDefaultValues)
77-
.then(function($defaultValue) {
77+
.then(function ($defaultValue) {
7878
expect($defaultValue).to.have.length(5);
7979
expect($defaultValue.eq(0)).to.contain('Purple');
8080
expect($defaultValue.eq(1)).to.contain('Red');

0 commit comments

Comments
 (0)