diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..0abbe11 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,22 @@ + +root = true + +[*] +indent_style = space +indent_size = 2 +end_of_line = lf +charset = utf-8 +max_line_length = 80 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.md] +max_line_length = 0 +trim_trailing_whitespace = false + +[*.{js,jsx,ts,tsx}] +charset = utf-8 + +[{package.json}] +indent_style = space +indent_size = 2 \ No newline at end of file diff --git a/.eslintrc.cjs b/.eslintrc.cjs new file mode 100644 index 0000000..e728fcc --- /dev/null +++ b/.eslintrc.cjs @@ -0,0 +1,27 @@ +module.exports = { + env: { + browser: true, + es2021: true, + }, + extends: [ + 'airbnb', + 'airbnb-typescript', + 'airbnb/hooks', + 'plugin:react/recommended', + 'plugin:@typescript-eslint/recommended', + 'plugin:prettier/recommended', + ], + ignorePatterns: ['node_modules/'], + overrides: [], + parser: '@typescript-eslint/parser', + parserOptions: { + ecmaVersion: 'latest', + sourceType: 'module', + project: './tsconfig.json', + }, + plugins: ['react', '@typescript-eslint', 'prettier'], + rules: { + 'react/react-in-jsx-scope': 0, + 'react-hooks/exhaustive-deps': 'warn', + }, +}; diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6181974 --- /dev/null +++ b/.gitignore @@ -0,0 +1,26 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +node_modules +dist +dist-ssr +*.local + +# Editor directories and files +.idea +.DS_Store +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? + +# Linter cache files +.eslintcache +.stylelintcache diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100755 index 0000000..7e15468 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,4 @@ +#!/usr/bin/env sh +. "$(dirname -- "$0")/_/husky.sh" + +npm run lint-staged diff --git a/.postcssrc.json b/.postcssrc.json new file mode 100644 index 0000000..ab3bed5 --- /dev/null +++ b/.postcssrc.json @@ -0,0 +1,6 @@ +{ + "syntax": "postcss-scss", + "plugins": { + "autoprefixer": {} + } +} diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..df2df8a --- /dev/null +++ b/.prettierignore @@ -0,0 +1,6 @@ +.vscode/ +node_modules/ +package-lock.json +package.json +README.md +.eslintignore diff --git a/.prettierrc.cjs b/.prettierrc.cjs new file mode 100644 index 0000000..c0b4d65 --- /dev/null +++ b/.prettierrc.cjs @@ -0,0 +1,10 @@ +module.exports = { + printWidth: 60, + tabWidth: 2, + useTabs: false, + semi: true, + singleQuote: true, + trailingComma: 'all', + bracketSpacing: true, + arrowParens: 'avoid', +}; diff --git a/.stylelintrc.json b/.stylelintrc.json new file mode 100644 index 0000000..4cb79e7 --- /dev/null +++ b/.stylelintrc.json @@ -0,0 +1,23 @@ +{ + "plugins": ["stylelint-scss"], + "extends": [ + "stylelint-config-standard-scss", + "stylelint-config-prettier-scss" + ], + "rules": { + "font-family-name-quotes": null, + "scss/at-rule-no-unknown": [ + true, + { + "ignoreAtRules": ["layer"] + } + ], + "selector-class-pattern": null + }, + "overrides": [ + { + "customSyntax": "postcss-scss", + "files": ["**/*.scss"] + } + ] +} diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..0e25de0 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,8 @@ +{ + "recommendations": [ + "esbenp.prettier-vscode", + "dbaeumer.vscode-eslint", + "Syler.sass-indented", + "ZixuanChen.vitest-explorer" + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..bfc4f26 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,36 @@ +{ + "editor.quickSuggestions": { + "strings": true + }, + "[javascript]": { + "editor.defaultFormatter": "esbenp.prettier-vscode", + "editor.formatOnSave": true, + "editor.formatOnPaste": true + }, + "[json]": { + "editor.defaultFormatter": "esbenp.prettier-vscode", + "editor.formatOnSave": true, + "editor.formatOnPaste": true + }, + "[jsonc]": { + "editor.defaultFormatter": "esbenp.prettier-vscode", + "editor.formatOnSave": true, + "editor.formatOnPaste": true + }, + "[typescript]": { + "editor.defaultFormatter": "esbenp.prettier-vscode", + "editor.formatOnSave": true, + "editor.formatOnPaste": true + }, + "[typescriptreact]": { + "editor.defaultFormatter": "esbenp.prettier-vscode", + "editor.formatOnSave": true, + "editor.formatOnPaste": true + }, + "[markdown]": { + "editor.wordWrap": "on", + "editor.formatOnSave": true, + "editor.renderWhitespace": "all", + "editor.acceptSuggestionOnEnter": "off" + } +} diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..eb630ac --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2022 Gabriel Pereira Woitechen + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..5d260a6 --- /dev/null +++ b/README.md @@ -0,0 +1,65 @@ +# ⚡ [Reactivite](https://github.com/armanatz/Reactivite) ⚡ + +A minimal starter for React with TypeScript support with out of the box formatting and linting. Utilizes the blazing fast Vite build tool. + +## Features + +- [React](https://reactjs.org) with [TypeScript](https://www.typescriptlang.org) using the [Vite](https://vitejs.dev) build tool. +- Supports [Sass](https://sass-lang.com/) with [automatic type declaration file creation](https://github.com/activeguild/vite-plugin-sass-dts) when using SCSS Modules. +- Utilizes [PostCSS](https://postcss.org/) with the [Autoprefixer](https://github.com/postcss/autoprefixer) plugin to optimize CSS and SCSS code. +- Supports TypeScript [absolute imports](https://github.com/aleclarson/vite-tsconfig-paths). +- Uses [ESLint](https://eslint.org) (with ESLint AirBnB Config), [stylelint](https://stylelint.io) and [Prettier](https://prettier.io) for code linting and formatting. +- Runs pre-commit command using [Husky](https://github.com/typicode/husky) to run [lint-staged](https://github.com/okonet/lint-staged). +- Unit and integration testing using [Vitest](https://vitest.dev/) and [Testing Library](https://testing-library.com/). +- Comes with a light VSCode setting file to enable formatting on save for JSON, JavaScript, TypeScript, TypeScript React, and Markdown files. +- Recommends useful extensions to install when using VSCode as your editor. + +## Getting Started + +Either use this repo as a [GitHub template](https://github.com/armanatz/Reactivite) or use [degit](https://github.com/Rich-Harris/degit) to make a clean copy of this repo: + +``` +npx degit armanatz/Reactivite#master my-app +``` + +After that, navigate to your project folder and install dependencies: + +``` +// If using NPM as your package manager +npm i + +// If using Yarn as your package manager +yarn +``` + +Then you can run the local development server using: + +``` +// If using NPM as your package manager +npm run dev + +// If using Yarn as your package manager +yarn dev +``` + +To build your application, run: + +``` +// If using NPM as your package manager +npm build + +// If using Yarn as your package manager +yarn build +``` + +Build files will be located in the `dist` folder once generated. + +## Available Scripts + +- `format`: Formats all files with Prettier. +- `lint`: Type-checks all files with TypeScript, and then lints all files using ESLint and StyleLint. +- `preview`: Allows for a local preview of the production build of the application. +- `test`: Runs unit and integration tests based on file changes tracked in git using Vitest. +- `test:ci`: Runs all unit and integration tests in CI mode using Vitest. +- `test:watch`: Runs Vitest test runner in watch mode. +- `validate`: Runs all linting commands defined in `lint`, and then runs `test:ci` for testing. diff --git a/index.html b/index.html new file mode 100644 index 0000000..0401886 --- /dev/null +++ b/index.html @@ -0,0 +1,29 @@ + + +
+ + + + + +Hello Vite + React!
++ +
+
+ Edit App.tsx
and save to test HMR
+ updates.
+
+ + Learn React + + {' | '} + + Vite Docs + +
+