Skip to content

Commit 4f93dfe

Browse files
committed
feat(typescript): typescript
1 parent fa67036 commit 4f93dfe

38 files changed

+2492
-1365
lines changed

.babelrc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
11
{
2+
"env": {
3+
"test": {
4+
"presets": [
5+
"@babel/preset-env",
6+
"@babel/preset-typescript",
7+
["@babel/preset-react", { "runtime": "automatic" }]
8+
],
9+
"plugins": []
10+
}
11+
},
212
"plugins": [
313
["@babel/plugin-proposal-decorators", { "legacy": true }],
414
"@babel/plugin-syntax-dynamic-import",

.eslintrc

Lines changed: 57 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,57 @@
1-
{
2-
"parser": "@babel/eslint-parser",
3-
"settings": {
4-
"react": {
5-
"version": "detect"
6-
}
7-
},
8-
"extends": ["standard", "prettier", "eslint:recommended", "plugin:react/recommended"],
9-
"env": {
10-
"es6": true,
11-
"jest": true
12-
},
13-
"plugins": ["react", "prettier"],
14-
"parserOptions": {
15-
"sourceType": "module",
16-
"ecmaVersion": 2018,
17-
"requireConfigFile": false,
18-
"ecmaFeatures": {
19-
"impliedStrict": true,
20-
"jsx": true,
21-
"arrowFunctions": true,
22-
"blockBindings": true,
23-
"defaultParams": true,
24-
"destructuring": true,
25-
"forOf": true,
26-
"generators": true,
27-
"objectLiteralComputedProperties": true,
28-
"objectLiteralShorthandMethods": true,
29-
"objectLiteralShorthandProperties": true,
30-
"experimentalObjectRestSpread": true,
31-
"restParams": true,
32-
"spread": true,
33-
"templateStrings": true,
34-
"modules": true,
35-
"classes": true
36-
}
37-
},
38-
"rules": {
39-
"react/jsx-no-bind": "off",
40-
"space-before-function-paren": 0,
41-
"react/jsx-boolean-value": 0,
42-
"max-len": [2, { "code": 120, "ignoreComments": true }],
43-
"newline-per-chained-call": 0,
44-
"no-trailing-spaces": ["error"],
45-
"quotes": ["error", "single", { "avoidEscape": true }],
46-
"comma-dangle": ["error", "never"],
47-
"no-template-curly-in-string": "off",
48-
"semi": ["error", "always"],
49-
"object-curly-spacing": ["error", "always"],
50-
"quote-props": ["error", "consistent"],
51-
"no-var": ["error"]
52-
}
53-
}
1+
{
2+
"parser": "@typescript-eslint/parser",
3+
"settings": {
4+
"react": {
5+
"version": "detect"
6+
}
7+
},
8+
"extends": [
9+
// "standard",
10+
"eslint:recommended",
11+
"plugin:@typescript-eslint/recommended",
12+
"plugin:react/recommended"
13+
],
14+
"env": {
15+
//error with "es2021": true
16+
"es6": true,
17+
"jest": true,
18+
"node": true,
19+
"browser": true
20+
},
21+
"plugins": ["@typescript-eslint", "react", "react-hooks"],
22+
"parserOptions": {
23+
"ecmaVersion": 12,
24+
"sourceType": "module",
25+
"requireConfigFile": false,
26+
"ecmaFeatures": {
27+
"jsx": true
28+
}
29+
},
30+
"rules": {
31+
"react/jsx-uses-react": "off",
32+
"react/react-in-jsx-scope": "off",
33+
"react/prop-types": "off",
34+
"react-hooks/rules-of-hooks": "error",
35+
"react-hooks/exhaustive-deps": "warn",
36+
"@typescript-eslint/explicit-module-boundary-types": "off",
37+
"react/jsx-no-bind": [
38+
"warn",
39+
{
40+
"ignoreRefs": true
41+
}
42+
],
43+
"space-before-function-paren": 0,
44+
"react/jsx-boolean-value": 0,
45+
"max-len": [2, { "code": 120, "ignoreComments": true }],
46+
"newline-per-chained-call": 0,
47+
"no-trailing-spaces": ["error"],
48+
"quotes": ["error", "single", { "avoidEscape": true }],
49+
"comma-dangle": ["error", "never"],
50+
"no-template-curly-in-string": "off",
51+
"semi": ["error", "always"],
52+
"object-curly-spacing": ["error", "always"],
53+
"quote-props": ["error", "consistent"],
54+
"no-var": ["error"],
55+
"indent": "off"
56+
}
57+
}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@
1212
node_modules/
1313
dist/
1414
build/
15+
/out-tsc/**

.prettierrc.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
// prettier.config.js or .prettierrc.js
22
module.exports = {
33
singleQuote: true,
4-
trailingComma: "none",
4+
trailingComma: 'none',
55
tabWidth: 2,
66
printWidth: 80,
77
semi: true,
88
bracketSpacing: true,
9-
jsxBracketSameLine: false,
10-
endOfLine: "lf"
9+
endOfLine: 'lf'
1110
};

example/index.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<link rel="icon" type="image/svg+xml" href="src/favicon.svg" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>Vite React TypeScript Tailwind Starter</title>
8+
</head>
9+
<body>
10+
<div id="root"></div>
11+
<script type="module" src="/src/index.tsx"></script>
12+
</body>
13+
</html>

example/package.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,22 @@
44
"version": "1.0.0",
55
"license": "MIT",
66
"dependencies": {
7+
"@types/react": "^17.0.43",
8+
"@types/react-dom": "^17.0.14",
9+
"@vitejs/plugin-react": "^1.3.0",
710
"gh-pages": "^2.1.1",
811
"react": "^18.0.0",
912
"react-dom": "^18.0.0",
1013
"react-scripts": "^5.0.0",
11-
"react-tooltip": "link:.."
14+
"react-tooltip": "link:..",
15+
"typescript": "^4.6.3",
16+
"vite": "^2.9.1",
17+
"vite-tsconfig-paths": "^3.4.1"
1218
},
1319
"scripts": {
20+
"dev": "vite",
21+
"build:vite": "tsc && vite build",
22+
"serve": "vite preview",
1423
"start": "react-scripts start",
1524
"build": "react-scripts build",
1625
"test": "react-scripts test --env=jsdom",

example/src/App.jsx renamed to example/src/App.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import React, { Component } from 'react';
2-
32
import ReactTooltip from 'react-tooltip';
43

5-
export default class App extends Component {
4+
export default class App extends Component<any, any> {
65
constructor(props) {
76
super(props);
87
this.state = {
File renamed without changes.

example/src/vite.config.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { defineConfig } from 'vite';
2+
import react from '@vitejs/plugin-react';
3+
import tsconfigPaths from 'vite-tsconfig-paths';
4+
5+
// https://vitejs.dev/config/
6+
export default defineConfig({
7+
plugins: [react(), tsconfigPaths()]
8+
});

0 commit comments

Comments
 (0)