A frontend-boilerplate to make easy to start new Sphinx projects. Configured with TypesScript, React, Webpack, Babel, SASS, Axios, React Router DOM, ES Lint, Stylelint, Jest, Testing Library, Cypress, Git and, Husky.
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
Already a pro? Just edit this README.md and make it your own. Want to make it easy? Use the template at the bottom!
- Create or upload files
- Add files using the command line or push an existing Git repository with the following command:
- Invite team members and collaborators
- Create a new merge request
- Automatically close issues from merge requests
- Automatically merge when pipeline succeeds
Use the built-in continuous integration in GitLab.
- Get started with GitLab CI/CD
- Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)
- Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy
- Use pull-based deployments for improved Kubernetes management
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to makeareadme.com for this template.
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
Choose a self-explaining name for your project.
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
If you have ideas for releases in the future, it is a good idea to list them in the README.
State if you are open to contributions and what your requirements are for accepting them.
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
Show your appreciation to those who have contributed to the project.
For open source projects, say how it is licensed.
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
-
Recommended IDE VS Code
- How to run this app
- Built with
- Folder structure
- Questions and answers
- Troubleshooting
- To do
- Recommended IDE extensions
- Recommended VS CODE settings.json
In order to install packages and run this application, you will need Node Package Manager v6.14.15 or higher
This application is running on Node version 14.18.0 LTS
- To change the Node version on IDE, open a new terminal and:
nvm use
- If you don't have the LTS version, install it with Node Version Manager:
nvm install --lts
- To set the LTS version as default on your terminal:
nvm alias default v14.18.0
- To check if the Node versions is the correct:
node --version
And you should see v14.18.0
To install all the node_modules packages:
npm install
To run on Development mode:
npm start
Build production mode:
npm run build
To run tests:
npm test
Tests coverage:
npm run test:coverage
To run tests on watch mode:
npm test --watchAll <fileName>
SCSS files:
npx stylelint **/*.scss
TypeScript files:
npm run eslint --ext .tsx,.ts src
All files:
npm run lint
Husky is already configured and commited. All you have to do is commit your changes.
Check the docs for more details Husky if you need to install it locally.
package.json
"husky": {
"hooks": {
"pre-commit": "npm lint", // already implemented or check how to install section
"pre-push": "npm test" // to be implemented or feel free to do it with npx husky add .husky/pre-push "npm test"
}
},
-
- How to install
-
-
How to install with Webpack
-
Useful sources:
-
-
-
How to install
-
How to init tesconfig
-
Useful sources:
- Typescript for new programmers
- Typescript for Javascript programmers
- Typescript handbook
- Typescript declaration files
- Typescript projects configurations
- Typescript from zero to hero - PT-BR 🇧🇷
-
@Types and Plugins:
-
-
-
How to install
-
Webpack getting started
-
Webpack asset management
-
Webpack output management
-
Webpack loaders
-
Webpack Typescript
-
Webpack concepts
-
Modules:
- webpack
- webpack-cli command line interface
- webpack-dev-server see also devServer
- webpack-merge
-
Plugins:
-
Officials:
- html-webpack-plugin basic for HTML files
- mini-css-extract-plugin extracts CSS into separate files
- compression-webpack-plugin compressed version of assets
- terser-webpack-plugin minify Javascript
-
Third Parties:
-
-
Loaders:
-
Transpiling:
-
Styling:
-
-
-
-
Required for Webpack:
-
/App.scss
@use 'pages/HomePage/HomePage';
@use 'pages/WorksPage/WorksPage';
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
height: 100vh;
width: 100vw;
}
/Routes.tsx
import React from 'react'
import { BrowserRouter as Router, Route, Switch } from 'react-router-dom'
import HomePage from 'pages/HomePage'
import WorksPage from 'pages/WorksPage'
const Routes: React.FC = () => {
return (
<Router>
<Switch>
<Route path="/" exact={true} component={HomePage} />
</Switch>
<Switch>
<Route path="/works" exact={true} component={WorksPage} />
</Switch>
</Router>
)
}
export default Routes
/src/services/api/getQuote.ts
import axios, { AxiosResponse } from 'axios'
export const getQuote = async (): Promise<AxiosResponse<never>> => {
const url = 'https://type.fit/api/quotes'
const result = await axios({
url,
method: 'GET',
headers: {
'Content-type': 'application/json',
},
})
return result
}
-
-
Required for Jest with TypeScript and Webpack:
-
Useful sources:
- Tutorial Jest for React
- Jest Webpack Guide
-
-
-
Required for Redux with TypeScript and React Router DOM:
-
Useful sources:
- React Router integration with Redux
- Redux Thunk typing actions, store, reducers, and thunk
- Redux DevTools Chrome Extension
-
├── atoms/
│
├── molecules/
│
├── organisms/
│
├── templates/
│
├── pages/
src/
├── components/
│ ├── atoms/
│ ├── molecules/
│ └── organisms/
│
├── layouts|templates/
│
├── pages/
For components, layouts, and pages
├── HeaderComponent/
│ ├── _HeaderComponent.scss
│ ├── HeaderComponent.tsx
│ └── index.ts
...
├── HomeLayout/
│ ├── _HomeLayout.scss
│ ├── HomeLayout.tsx
│ └── index.ts
...
├── HomePage/
│ ├── _HomePage.scss
│ ├── HomePage.tsx
│ └── index.ts
/
├── .husky/ <!-- generated afer run `npx husky install` -->
├── build/ <!-- generated afer run `npm start` -->
├── dist/ <!-- generated afer run `npm build` -->
├── node_modules/ <!-- generated afer run `npm install` -->
├── public/
├── src/
│ ├── __tests__/
│ ├── common/
│ ├── components/
│ ├── layouts/
│ ├── pages/
│ ├── services/
│ ├── App.scss
│ ├── App.tsx
│ ├── index.ejs
│ └── index.tsx
├── .editorconfig
├── .eslintignore
├── .eslintrc.json
├── .gitignore
├── .node-version
├── .nvmrc
├── .prettierignore
├── .prettierrc
├── .stylelintignore
├── .stylelintrc.json
├── babel.config.js
├── package-lock.json
├── package.json
├── README.md
├── tsconfig.json
├── webpack.config.js
├── webpack.development.js
└── webpack.production.js
For components, layouts, and pages
pages/
├── HomePage/
│ ├── _HomePage.scss
│ ├── HomePage.tsx
│ ├── HomePageMDC.js
│ └── index.ts
...
__tests__/
├── app/
├── coverage/ <!-- generated afer run `npm test` -->
├── helpers/
└── mocks/
__tests__/app/
├── components/
├── layouts/
└── pages/
__tests__/app/components/
├── atoms/
├── molecules/
└── organisms/
__tests__/app/components/atoms/InnerLink.(test|spec).tsx
__tests__/app/components/atoms/ListItem.(test|spec).tsx
__tests__/app/components/atoms/OuterLink.(test|spec).tsx
__tests__/app/components/molecules/TechList.(test|spec).tsx
__tests__/app/components/organisms/HomeNav.(test|spec).tsx
__tests__/app/layouts/organisms/HomeMain.(test|spec).tsx
__tests__/app/pages/organisms/HomePage.(test|spec).tsx
- Improves a lot the development experience. Has a lot of features that JavaScript does not have. Having a strong sinergy with Webpack, Babel, and ES Lint. Types makes the code basis easier to read and mantain. And it also boosts your knowledge about React and JavaScript. Since we have to care about every type of JSX Elements, DOM Events, functions, objects, and so on.
- Customize our projects configurations connecting plugins with Webpack, Babel, and ES Lint. Imports management, folder and file paths alias, and
others environments options. Are all available on
tsconfig.json
file.
- Webpack is a static module bundler for modern JavaScript applications. When webpack processes your application, it internally builds a dependency graph from one or more entry points and then combines every module your project needs into one or more bundles, which are static assets to serve your content from. Concepts
- Babel is a JavaScript compiler
- See also don-t-use-create-react-app-how-you-can-set-up-your-own-reactjs-boilerplate
- ESLint is a tool for identifying and reporting on patterns found in ECMAScript/JavaScript code, with the goal of making code more consistent and avoiding bugs.
- Ensures that every person that is working on this code basis is writing on the same pattern. Following the same linting rules and avoiding anti-patterns from being commited and pushed. Combined with Husky.
- See also eslint-plugin
- An opinionated code formatter. You press save and code is formatted.
- Need to install Prettier extension for yor IDE in order to automate foarmat on save and/or format on paste options.
- Same as ES Lint but for styles files like .scss, .css, .less, etc.
- To ensure all environments that are running this application are also running the same Node version.
- EditorConfig helps maintain consistent coding styles for multiple developers working on the same project across various editors and IDEs.
- CSS is hard to maintain. SASS is more porwerfull 💥. And there are plenty of UI libraries that supports SASS.
- UI libraries that supports SASS:
- Webpack relative or absolute path to the template. By default it will use src/index.ejs if it exists. Please see the docs for details.
- EJS is just a way to warite some JS on HTML. Since we need to capture values from HtmlWebpackPlugin.
- See html-webpack-plugin
- See also template-option
- The main idea here is to keep all files related to tests separated from others
src
folder files. By doing this, we prevent Webpack to load files with .test and .spec extensios. And other files that are only useful on test environment. Like mocks, Provider and jest-setup from utils. coverage
is a special folder that comes in when any test is runned. This is an automatic configuration placed onjest.config.js
on keycoverageDirectory
- Unit tests will be applied to components, layouts, and pages.
- End-to-End tests will be runned with Cypress further.
- Husky improves your commits and more 🐶 woof!
- To avoid having unlinted code in our repository, what we can do is add ESLint at one point of our process using Git Hooks. Like Husky!
-
On deploy, you must set build production folder to
dist/
instead of/
. -
Open an issue
⚠️
-
Configure Cypress for End-to-End tests
-
Implement Husky pre-push hook with tests
settings.json
{
"[css]": {
"editor.codeActionsOnSave": {
"source.fixAll.eslint": false,
"source.fixAll.stylelint": true
}
},
"[html]": {
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true,
"source.fixAll.stylelint": true
}
},
"auto-close-tag.activationOnLanguage": ["*"],
"code-runner.clearPreviousOutput": true,
"code-runner.runInTerminal": true,
"editor.autoClosingBrackets": "always",
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true,
"source.fixAll.stylelint": true
// "source.fixAll.prettier": false
},
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"editor.suggestSelection": "first",
"editor.tabCompletion": "on",
"editor.tabSize": 4,
"emmet.showSuggestionsAsSnippets": true,
"emmet.includeLanguages": {
"javascript": "javascriptreact",
"ejs": "html"
},
"files.associations": {
"*.md": "mdx"
},
"files.exclude": {
"**/.classpath": true,
"**/.project": true,
"**/.settings": true,
"**/.factorypath": true
},
"git.autoRepositoryDetection": "openEditors",
"gitlens.gitCommands.search.showResultsInSideBar": true,
"gitlens.hovers.annotations.over": "annotation",
"gitlens.hovers.annotations.changes": false,
"gitlens.hovers.annotations.details": false,
"gitlens.hovers.autolinks.enabled": false,
"gitlens.hovers.autolinks.enhanced": false,
"gitlens.hovers.avatars": false,
"gitlens.hovers.currentLine.changes": false,
"gitlens.hovers.currentLine.enabled": false,
"gitlens.hovers.currentLine.details": false,
"gitlens.hovers.pullRequests.enabled": false,
"importCost.smallPackageSize": 10,
"importCost.mediumPackageSize": 20,
"importCost.mediumPackageColor": "#CCBC00",
"javascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets": true,
"javascript.updateImportsOnFileMove.enabled": "always",
"liveServer.settings.donotVerifyTags": true,
"material-icon-theme.folders.associations": {
"widgets": "components",
"front-angular": "font",
"front-react": "React-Components",
"front-vue": "vue",
"store": "Redux-store",
"actions": "redux-actions",
"reducers": "redux-reducer",
"atoms": "React-components",
"molecules": "Node",
"organisms": "Other",
"favicons": "Admin"
},
"prettier.singleQuote": true,
"prettier.trailingComma": "none",
"prettier.bracketSpacing": true,
"typescript.updateImportsOnFileMove.enabled": "always",
"terminal.integrated.defaultProfile.linux": "/bin/zsh (migrated)",
"terminal.integrated.profiles.linux": {
"bash": {
"path": "bash",
"icon": "terminal-bash"
},
"zsh": {
"path": "zsh"
},
"fish": {
"path": "fish"
},
"tmux": {
"path": "tmux",
"icon": "terminal-tmux"
},
"pwsh": {
"path": "pwsh",
"icon": "terminal-powershell"
},
"bash (2)": {
"path": "/usr/bin/bash"
},
"/bin/zsh (migrated)": {
"path": "/bin/zsh",
"args": []
}
},
"window.zoomLevel": -1.0455173977264463,
"workbench.colorTheme": "Dracula",
"workbench.iconTheme": "material-icon-theme",
"workbench.tree.indent": 20
}