Skip to content

Commit 004e2cd

Browse files
authored
Merge pull request #36 from braposo/convert-to-typescript
Convert to typescript
2 parents 60dd7c2 + a04acfd commit 004e2cd

17 files changed

+4462
-1494
lines changed

.babelrc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
"modules": false
88
}
99
],
10-
"@babel/react"
10+
"@babel/react",
11+
"@babel/typescript"
1112
],
1213
"plugins": [
13-
"@babel/plugin-proposal-object-rest-spread",
1414
"@babel/plugin-proposal-class-properties"
1515
],
1616
"env": {
@@ -20,4 +20,4 @@
2020
]
2121
}
2222
}
23-
}
23+
}

.eslintrc

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,34 @@
11
{
2-
"extends": "edited",
2+
"extends": [
3+
"airbnb-base",
4+
"eslint:recommended",
5+
"plugin:react/recommended",
6+
"plugin:@typescript-eslint/eslint-recommended",
7+
"plugin:@typescript-eslint/recommended",
8+
"plugin:@typescript-eslint/recommended-requiring-type-checking",
9+
"plugin:prettier/recommended",
10+
"prettier/react",
11+
"prettier/@typescript-eslint"
12+
],
13+
"parser": "@typescript-eslint/parser",
314
"parserOptions": {
4-
"ecmaVersion": 6,
5-
"sourceType": "module",
6-
"ecmaFeatures": {
7-
"jsx": true
8-
}
15+
"project": "./tsconfig.json"
16+
},
17+
"plugins": ["@typescript-eslint", "react", "prettier"],
18+
"rules": {
19+
"class-methods-use-this": "off",
20+
"dot-notation": "off",
21+
"func-names": ["error", "as-needed"],
22+
"no-nested-ternary": "off"
923
},
1024
"settings": {
25+
"react": {
26+
"version": "detect"
27+
},
1128
"import/resolver": {
1229
"node": {
13-
"extensions": [".js", ".jsx"]
30+
"extensions": [".js", ".tsx", ".ts"]
1431
}
1532
}
16-
},
17-
"rules": {
18-
"react/prefer-es6-class": [2, "always"],
19-
"arrow-parens": [2, "as-needed"]
2033
}
2134
}

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,6 @@ node_modules
2323

2424
dist/
2525
es/
26-
lib/
26+
lib/
27+
examples/cache/
28+
examples/dist/

CODE_OF_CONDUCT.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
6+
7+
## Our Standards
8+
9+
Examples of behavior that contributes to creating a positive environment include:
10+
11+
- Using welcoming and inclusive language
12+
- Being respectful of differing viewpoints and experiences
13+
- Gracefully accepting constructive criticism
14+
- Focusing on what is best for the community
15+
- Showing empathy towards other community members
16+
17+
Examples of unacceptable behavior by participants include:
18+
19+
- The use of sexualized language or imagery and unwelcome sexual attention or advances
20+
- Trolling, insulting/derogatory comments, and personal or political attacks
21+
- Public or private harassment
22+
- Publishing others' private information, such as a physical or electronic address, without explicit permission
23+
- Other conduct which could reasonably be considered inappropriate in a professional setting
24+
25+
## Our Responsibilities
26+
27+
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
28+
29+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
30+
31+
## Scope
32+
33+
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
34+
35+
## Enforcement
36+
37+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at [email protected]. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
38+
39+
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
40+
41+
## Attribution
42+
43+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
44+
45+
[homepage]: http://contributor-covenant.org
46+
[version]: http://contributor-covenant.org/version/1/4/

CONTRIBUTING.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,27 @@ Fork, then clone the repo:
1515
git clone https://github.com/your-username/react-text-loop.git
1616
```
1717

18-
Build package for dev mode. It will automatically watch any changes in `src/` forlder:
18+
Run the examples, which will automatically watch any changes in `src/` folder:
19+
1920
```
20-
yarn run dev
21+
yarn start
2122
```
2223

23-
We follow [eslint-config-edited](https://www.npmjs.com/package/eslint-config-edited) for code style.
24-
2524
### Building and testing
2625

2726
Build package:
2827
```
29-
yarn run build
28+
yarn build
3029
```
3130

3231
To run the tests:
3332
```
34-
npm run test
33+
yarn test
3534
```
3635

3736
To perform linting with `eslint`, run the following:
3837
```
39-
npm run lint
38+
yarn lint
4039
```
4140

4241
### New Features

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,14 @@ animations and spring params.
2222

2323
[![Edit react-text-loop][codesandbox-badge]][codesandbox]
2424

25-
### Code
25+
You can also run the examples by cloning the repo and running `yarn start`.
26+
27+
### Usage
2628

2729
```jsx
2830
import TextLoop from "react-text-loop";
31+
import Link from "react-router";
32+
import { BodyText } from "./ui";
2933

3034
class App extends Component {
3135
render() {
@@ -121,4 +125,4 @@ Please follow our
121125
[modules-badge]: https://img.shields.io/badge/module%20formats-umd%2C%20cjs%2C%20esm-green.svg?style=flat-square
122126
[prs-badge]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square
123127
[codesandbox-badge]: https://codesandbox.io/static/img/play-codesandbox.svg
124-
[codesandbox]: https://codesandbox.io/s/github/braposo/react-text-loop/
128+
[codesandbox]: https://codesandbox.io/s/react-text-loop-playground-br4q1

examples/App.jsx renamed to examples/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const StyledTextLoop = cxs(TextLoop)({
2424
display: "block",
2525
});
2626

27-
class App extends React.PureComponent {
27+
class App extends React.PureComponent<{}, { options: string[]; interval: number }> {
2828
constructor(props) {
2929
super(props);
3030
this.state = {

examples/index.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<html>
2+
<body>
3+
<div id="root"></div>
4+
<script src="./index.tsx"></script>
5+
</body>
6+
</html>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from "react";
22
import { render } from "react-dom";
3-
import App from "./examples/App";
3+
import App from "./App";
44

55
render(<App />, document.getElementById("root"));

package.json

Lines changed: 43 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,20 @@
55
"main": "./lib/index.js",
66
"module": "es/index.js",
77
"scripts": {
8-
"build": "yarn run build:commonjs && yarn run build:es && npm run build:umd && npm run build:umd:min",
9-
"build:es": "babel src -d es",
10-
"build:commonjs": "cross-env BABEL_ENV=commonjs babel src -d lib",
11-
"build:umd": "cross-env BABEL_ENV=commonjs NODE_ENV=development webpack src/index.js -o dist/react-text-loop.js",
12-
"build:umd:min": "cross-env BABEL_ENV=commonjs NODE_ENV=production webpack src/index.js -o dist/react-text-loop.min.js",
8+
"build": "run-p build:commonjs build:es build:umd build:umd:min build:ts build:ts-es",
9+
"build:es": "babel src -d es --extensions .ts,.tsx",
10+
"build:commonjs": "cross-env BABEL_ENV=commonjs babel src -d lib --extensions .ts,.tsx",
11+
"build:umd": "cross-env BABEL_ENV=commonjs NODE_ENV=development webpack src/index.ts -o dist/react-text-loop.js",
12+
"build:umd:min": "cross-env BABEL_ENV=commonjs NODE_ENV=production webpack src/index.ts -o dist/react-text-loop.min.js",
13+
"build:ts": "tsc",
14+
"build:ts-es": "tsc -m es6 --outDir es",
1315
"clean": "rimraf lib dist es",
1416
"dev": "yarn run clean && cross-env BABEL_ENV=commonjs babel src -d lib --watch",
15-
"dev:server": "webpack-dev-server ",
16-
"lint": "eslint src/ --ext .js,.jsx",
17+
"start": "parcel examples/index.html -d examples/dist --cache-dir examples/cache --open",
18+
"lint": "eslint src/ --ext .js,.tsx,.ts",
1719
"prepublishOnly": "yarn run clean && yarn run build",
18-
"test": "echo \"No tests available\" && exit 0"
20+
"test": "echo \"No tests available\" && exit 0",
21+
"ts:check": "tsc -p tsconfig.json --allowJs false --noEmit --emitDeclarationOnly false"
1922
},
2023
"repository": {
2124
"type": "git",
@@ -48,33 +51,46 @@
4851
},
4952
"homepage": "https://github.com/braposo/react-text-loop#readme",
5053
"devDependencies": {
51-
"@babel/cli": "^7.2.3",
52-
"@babel/core": "^7.2.2",
53-
"@babel/plugin-proposal-class-properties": "^7.2.3",
54-
"@babel/plugin-proposal-object-rest-spread": "^7.2.0",
55-
"@babel/plugin-transform-modules-commonjs": "^7.2.0",
56-
"@babel/preset-env": "^7.2.3",
54+
"@babel/cli": "^7.6.0",
55+
"@babel/core": "^7.6.0",
56+
"@babel/plugin-proposal-class-properties": "^7.5.5",
57+
"@babel/plugin-proposal-object-rest-spread": "^7.5.5",
58+
"@babel/plugin-transform-modules-commonjs": "^7.6.0",
59+
"@babel/preset-env": "^7.6.0",
5760
"@babel/preset-react": "^7.0.0",
58-
"babel-eslint": "^10.0.1",
59-
"babel-loader": "^8.0.4",
60-
"cross-env": "^5.2.0",
61-
"eslint": "^5.11.0",
62-
"eslint-config-edited": "^1.0.1",
63-
"eslint-plugin-import": "^2.14.0",
64-
"eslint-plugin-react": "^7.11.1",
65-
"react": "^16.7.0",
66-
"react-dom": "^16.7.0",
67-
"rimraf": "^2.6.2",
68-
"webpack": "^4.28.2",
69-
"webpack-cli": "^3.1.2"
61+
"@babel/preset-typescript": "^7.6.0",
62+
"@types/node": "^12.7.5",
63+
"@types/react": "^16.9.2",
64+
"@types/react-dom": "^16.9.0",
65+
"@types/react-motion": "^0.0.29",
66+
"@typescript-eslint/eslint-plugin": "^2.2.0",
67+
"@typescript-eslint/parser": "^2.2.0",
68+
"babel-eslint": "^10.0.3",
69+
"babel-loader": "^8.0.6",
70+
"cross-env": "^5.2.1",
71+
"eslint": "^6.4.0",
72+
"eslint-config-airbnb-base": "^14.0.0",
73+
"eslint-config-prettier": "^6.3.0",
74+
"eslint-plugin-import": "^2.18.2",
75+
"eslint-plugin-prettier": "^3.1.0",
76+
"eslint-plugin-react": "^7.14.3",
77+
"npm-run-all": "^4.1.5",
78+
"parcel-bundler": "^1.12.3",
79+
"prettier": "^1.18.2",
80+
"react": "^16.9.0",
81+
"react-dom": "^16.9.0",
82+
"rimraf": "^3.0.0",
83+
"source-map-loader": "^0.2.4",
84+
"typescript": "^3.6.3",
85+
"webpack": "^4.40.2",
86+
"webpack-cli": "^3.3.8"
7087
},
7188
"peerDependencies": {
7289
"react": "^15.0.1 || ^16.0.1",
7390
"react-dom": "^15.0.1 || ^16.0.1"
7491
},
7592
"dependencies": {
7693
"cxs": "^6.2.0",
77-
"prop-types": "^15.6.2",
7894
"react-fast-compare": "2.0.4",
7995
"react-motion": "^0.5.2"
8096
}

0 commit comments

Comments
 (0)