Set up development environment

This commit is contained in:
Dmitriy Shishkov 2020-12-12 01:45:35 +05:00
parent a813c1057a
commit 43c18eb46e
No known key found for this signature in database
GPG Key ID: D76D70029F55183E
14 changed files with 5850 additions and 3 deletions

7
.babelrc Normal file
View File

@ -0,0 +1,7 @@
{
"presets": [
["@babel/preset-env", { "modules": false }],
"@babel/preset-react"
],
"plugins": ["react-hot-loader/babel"]
}

25
.eslintrc Normal file
View File

@ -0,0 +1,25 @@
{
"parser": "@typescript-eslint/parser",
"plugins": ["prettier"],
"extends": [
"plugin:react/recommended",
"plugin:@typescript-eslint/recommended",
"prettier"
],
"parserOptions": {
"ecmaVersion": 2020,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
}
},
"rules": {
"no-console": 0,
"prettier/prettier": 2
},
"settings": {
"react": {
"version": "detect"
}
}
}

View File

@ -31,6 +31,11 @@ jobs:
uses: borales/actions-yarn@v2.0.0
with:
cmd: format
- name: Run linter
uses: borales/actions-yarn@v2.0.0
with:
cmd: lint
- name: Commit actions
uses: stefanzweifel/git-auto-commit-action@v4

1
.gitignore vendored
View File

@ -1,6 +1,7 @@
/node_modules
/build
.cache/
npm-debug.log*
yarn-debug.log*

View File

@ -2,5 +2,7 @@
"trailingComma": "es5",
"tabWidth": 2,
"semi": true,
"singleQuote": false
"singleQuote": false,
"arrowParens": "avoid",
"printWidth": 80
}

View File

@ -2,8 +2,42 @@
"name": "timetable-generator",
"version": "1.0.0",
"description": "Application for sheduling classes in UPML",
"main": "index.js",
"main": "src/index.js",
"author": "dm1sh <me@dmitriy.icu>",
"license": "MIT",
"private": true
"private": true,
"scripts": {
"build": "webpack",
"dev": "webpack serve",
"lint": "eslint --config .eslintrc",
"format": "prettier --write \"src/**/*.+(js|ts|jsx|tsx|json|css|md)\""
},
"devDependencies": {
"@babel/core": "^7.12.10",
"@babel/preset-env": "^7.12.10",
"@babel/preset-react": "^7.12.10",
"@types/node": "^14.14.12",
"@types/react": "^15.0.0 || ^16.0.0 || ^17.0.0 ",
"@types/react-dom": "^17.0.0",
"@typescript-eslint/eslint-plugin": "^4.9.1",
"@typescript-eslint/parser": "^4.9.1",
"css-loader": "^5.0.1",
"eslint": "^7.15.0",
"eslint-config-prettier": "^7.0.0",
"eslint-plugin-prettier": "^3.2.0",
"eslint-plugin-react": "^7.21.5",
"eslint-webpack-plugin": "^2.4.1",
"html-webpack-plugin": "^4.5.0",
"prettier": "^2.2.1",
"style-loader": "^2.0.0",
"ts-loader": "^8.0.12",
"typescript": "^4.1.2",
"webpack": "^5.10.0",
"webpack-cli": "^4.2.0",
"webpack-dev-server": "^3.11.0"
},
"dependencies": {
"react": "^15.0.0 || ^16.0.0 || ^17.0.0 ",
"react-dom": "^15.0.0 || ^16.0.0 || ^17.0.0 "
}
}

11
public/index.html Normal file
View File

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Application</title>
</head>
<body>
<div id="root"></div>
</body>
</html>

13
src/App.tsx Normal file
View File

@ -0,0 +1,13 @@
import React from "react";
import styles from "./styles/App.module.css";
const App: React.FC = () => {
console.log("test");
return (
<div>
<h1 className={styles.title}>Hello, world</h1>
</div>
);
};
export default App;

9
src/custom.d.ts vendored Normal file
View File

@ -0,0 +1,9 @@
declare module "*.svg" {
const content: string;
export default content;
}
declare module "*.module.css" {
const classes: { [key: string]: string };
export default classes;
}

5
src/index.tsx Normal file
View File

@ -0,0 +1,5 @@
import React from "react";
import ReactDOM from "react-dom";
import App from "./App";
ReactDOM.render(<App />, document.getElementById("root"));

View File

@ -0,0 +1,3 @@
.title {
color: red;
}

16
tsconfig.json Normal file
View File

@ -0,0 +1,16 @@
{
"compilerOptions": {
"outDir": "./build/",
"sourceMap": true,
"strict": true,
"noImplicitReturns": true,
"noImplicitAny": true,
"module": "es6",
"moduleResolution": "node",
"target": "es5",
"allowJs": true,
"jsx": "react",
"allowSyntheticDefaultImports": true
},
"include": ["./src/**/*"]
}

66
webpack.config.js Normal file
View File

@ -0,0 +1,66 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const webpack = require("webpack");
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const ESLintPlugin = require("eslint-webpack-plugin");
module.exports = {
entry: "./src/index.tsx",
target: "web",
devtool: "inline-source-map",
mode: "development",
module: {
rules: [
{
test: /\.tsx?$/,
use: "ts-loader",
include: path.resolve(__dirname, "src"),
},
{
test: /\.css$/,
use: [
"style-loader",
{
loader: "css-loader",
options: {
modules: true,
},
},
],
include: path.resolve(__dirname, "./src/styles"),
},
{
test: /\.(?:ico|gif|png|jpg|jpeg)$/i,
type: "asset/resource",
exclude: /node_modules/,
},
{
test: /\.(woff(2)?|eot|ttf|otf|svg|)$/,
type: "asset/inline",
exclude: /node_modules/,
},
],
},
resolve: {
extensions: [".tsx", ".ts", ".js"],
},
output: {
filename: "bundle.js",
path: path.resolve(__dirname, "build"),
},
devServer: {
contentBase: path.join(__dirname, "build"),
compress: true,
port: 3000,
},
plugins: [
new ESLintPlugin(),
new webpack.ProgressPlugin(),
new HtmlWebpackPlugin({
template: path.join(__dirname, "public", "index.html"),
}),
],
stats: {
reasons: true,
},
};

5650
yarn.lock Normal file

File diff suppressed because it is too large Load Diff