generated from aboutmydreams/browser-extension-react-typescript-starter
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 72cdc02
Showing
57 changed files
with
8,550 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"extends": ["@commitlint/config-conventional"], | ||
"rules": { | ||
"footer-max-line-length": [1, "always"] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
{ | ||
"env": { | ||
"es2020": true | ||
}, | ||
"extends": [ | ||
"eslint:recommended", | ||
"plugin:react/recommended", | ||
"plugin:@typescript-eslint/recommended", | ||
"plugin:prettier/recommended", | ||
"react-app", | ||
"react-app/jest" | ||
], | ||
"parser": "@typescript-eslint/parser", | ||
"parserOptions": { | ||
"sourceType": "module", | ||
"ecmaVersion": 2020, | ||
"ecmaFeatures": { "jsx": true } | ||
}, | ||
"plugins": [ | ||
"import", | ||
"simple-import-sort", | ||
"react", | ||
"react-hooks", | ||
"@typescript-eslint", | ||
"prettier" | ||
], | ||
"rules": { | ||
"no-unused-expressions": "off", | ||
"@typescript-eslint/no-unused-expressions": 2, | ||
"@typescript-eslint/triple-slash-reference": "off", | ||
"simple-import-sort/imports": "error", | ||
"simple-import-sort/exports": "error" | ||
}, | ||
|
||
"overrides": [ | ||
{ | ||
"files": [".*rc.js", "*.config.js"], | ||
"env": { | ||
"node": true | ||
} | ||
}, | ||
{ | ||
"files": ["*.js", "*.jsx", "*.ts", "*.tsx"], | ||
"rules": { | ||
"simple-import-sort/imports": [ | ||
"warn", | ||
{ | ||
"groups": [ | ||
// Packages `react` related packages come first. | ||
["^react", "^@?\\w"], | ||
// Internal packages. | ||
["^(@|components)(/.*|$)"], | ||
// Side effect imports. | ||
["^\\u0000"], | ||
// Parent imports. Put `..` last. | ||
["^\\.\\.(?!/?$)", "^\\.\\./?$"], | ||
// Other relative imports. Put same-folder imports and `.` last. | ||
["^\\./(?=.*/)(?!/?$)", "^\\.(?!/?$)", "^\\./?$"], | ||
// Style imports. | ||
["^.+\\.?(css)$"] | ||
] | ||
} | ||
] | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16.x | ||
cache: 'yarn' | ||
|
||
- name: Install dependencies | ||
run: rm -rf node_modules && yarn install --frozen-lockfile | ||
|
||
- name: Build | ||
run: yarn build | ||
|
||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16.x | ||
cache: 'yarn' | ||
|
||
- name: Install dependencies | ||
run: rm -rf node_modules && yarn install --frozen-lockfile | ||
|
||
- name: Lint | ||
run: yarn ci:test:lint | ||
|
||
typecheck: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16.x | ||
cache: 'yarn' | ||
|
||
- name: Install dependencies | ||
run: rm -rf node_modules && yarn install --frozen-lockfile | ||
|
||
- name: Test types | ||
run: yarn ci:test:types | ||
|
||
unit: | ||
runs-on: ${{ matrix.os }} | ||
|
||
strategy: | ||
matrix: | ||
node-version: [14.x, 16.x] | ||
os: [ubuntu-latest] | ||
fail-fast: false | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
registry-url: https://registry.npmjs.org/ | ||
cache: yarn | ||
|
||
- name: Install dependencies | ||
run: rm -rf node_modules && yarn install --frozen-lockfile | ||
|
||
- name: Unit test | ||
run: yarn ci:test:unit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
pnpm-debug.log* | ||
lerna-debug.log* | ||
|
||
node_modules | ||
dist | ||
dist-ssr | ||
dist_firefox | ||
*.local | ||
|
||
# Editor directories and files | ||
.vscode/* | ||
!.vscode/extensions.json | ||
.idea | ||
.DS_Store | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
*.sln | ||
*.sw? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"**/*": "prettier --ignore-unknown --ignore-path .gitignore --write", | ||
"**/*.{js,ts,tsx}": "eslint --fix", | ||
"**/*.{css}": "stylelint --fix" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
save-exact=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"tabWidth": 2, | ||
"printWidth": 100, | ||
"singleQuote": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports = { | ||
'commit-msg': 'yarn commitlint --edit $1', | ||
'prepare-commit-msg': `grep -qE '^[^#]' .git/COMMIT_EDITMSG || (exec < /dev/tty && yarn cz --hook || true)`, | ||
'pre-commit': './node_modules/.bin/nano-staged', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"extends": ["stylelint-config-standard", "stylelint-config-prettier"], | ||
"rules": { | ||
"at-rule-no-unknown": [ | ||
true, | ||
{ | ||
"ignoreAtRules": ["tailwind", "apply", "variants", "responsive", "screen"] | ||
} | ||
], | ||
"declaration-block-trailing-semicolon": null, | ||
"no-descending-specificity": null | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2022 Sinan Bekar | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
<div align="center"> | ||
<br> | ||
<img src="https://raw.githubusercontent.com/sinanbekar/browser-extension-react-typescript-starter/main/public/images/extension_128.png" alt="Browser Extension React & TypeScript Starter" width="128"> | ||
<br> | ||
<h2> | ||
Browser Extension <br> | ||
React & TypeScript Starter | ||
<br> | ||
</h2> | ||
</div> | ||
|
||
<p align="center">A cross-platform (Chrome, Firefox, Edge, Opera, Brave) web browser extension (Manifest V3 and Manifest V2) starter kit with hot reload support, built with React, Typescript, Redux, Vite, ESLint, Prettier, TailwindCSS, Jest and more! </p> | ||
<hr /> | ||
|
||
<div align="center" > | ||
<a href="https://github.com/sinanbekar/browser-extension-react-typescript-starter/actions"> | ||
<img src="https://github.com/sinanbekar/browser-extension-react-typescript-starter/actions/workflows/ci.yml/badge.svg" alt="CI"> | ||
</a> | ||
| ||
<a> | ||
<img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg" alt="PRs welcome"> | ||
</a> | ||
| ||
<a href="https://github.com/sinanbekar/browser-extension-react-typescript-starter/blob/main/LICENSE"> | ||
<img src="https://img.shields.io/apm/l/atomic-design-ui.svg" alt="MIT License"> | ||
</a> | ||
|
||
</div> | ||
|
||
<p align="center"> | ||
<a href="#features">Features</a> · | ||
<a href="#quick-start">Quick Start</a> · | ||
<a href="#important-notes">Important Notes</a> · | ||
<a href="#license">License</a> | ||
</p> | ||
|
||
## Features | ||
|
||
- **Instant HMR** (hot reload)[^1] | ||
- Write once run on any browser | ||
- Global Redux support with persist option. Effortless communication between content, background, popup, options, and more pages. | ||
- Provides a basic content example and popup, options, and welcome pages with all React | ||
- Latest Manifest V3 support | ||
- Manifest V2 support (beta) | ||
- Dynamic manifest.json | ||
- Includes ESLint configured to work with TypeScript and Prettier | ||
- Includes stylelint and commitlint configured | ||
- Includes tests with Jest | ||
|
||
#### Built with | ||
|
||
- React | ||
- TypeScript | ||
- Redux (toolkit and redux-persist) | ||
- TailwindCSS | ||
- Vite | ||
- Jest | ||
- ESLint | ||
- Prettier | ||
- stylelint | ||
- commitlint | ||
- commitizen | ||
- simple-git-hooks (lightweight husky alternative) | ||
- nano-staged | ||
|
||
[^1]: While fully supported and stable in most cases, rarely hard reloading is recommended. | ||
|
||
## Browser Support | ||
|
||
| [![Chrome](https://raw.github.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png)](/) | [![Firefox](https://raw.github.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png)](/) | [![Edge](https://raw.github.com/alrra/browser-logos/master/src/edge/edge_48x48.png)](/) | [![Opera](https://raw.github.com/alrra/browser-logos/master/src/opera/opera_48x48.png)](/) | [![Brave](https://raw.github.com/alrra/browser-logos/master/src/brave/brave_48x48.png)](/) | | ||
| --------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | | ||
| ✔ | ✔ (Beta) | ✔ | ✔ | ✔ | | ||
|
||
## Quick Start | ||
|
||
> **Warning** **Please see [Important Notes](#important-notes) before start using.** | ||
Ensure you have | ||
|
||
- [Node.js](https://nodejs.org) 14 or later installed | ||
- [Yarn](https://yarnpkg.com) installed | ||
|
||
### Use the Template | ||
|
||
#### GitHub Template | ||
|
||
[Create a repo from this template on GitHub](https://github.com/sinanbekar/browser-extension-react-typescript-starter/generate). | ||
|
||
**_or_** | ||
|
||
#### Clone to local | ||
|
||
If you prefer to do it manually with the cleaner git history | ||
|
||
> **Note** If you don't have yarn installed, run: npm install -g yarn | ||
```bash | ||
npx degit sinanbekar/browser-extension-react-typescript-starter my-web-extension | ||
cd my-web-extension | ||
git init | ||
``` | ||
|
||
Then run the following: | ||
|
||
- `yarn install` to install dependencies. | ||
- `yarn dev` to start the development server. | ||
- `yarn build` to build an unpacked extension. | ||
|
||
- **Load extension in Chrome (Chromium)** | ||
|
||
- Go to the browser address bar and type `chrome://extensions` | ||
- Check the `Developer Mode` button to enable it. | ||
- Click on the `Load Unpacked Extension` button. | ||
- Select your `dist` folder in the project root. | ||
|
||
- **Load extension in Firefox** | ||
|
||
- Go to the browser address bar and type `about://debugger` | ||
- Click on the `Load Temporary Add-on` button. | ||
- Select your `dist_firefox` folder in the project root. | ||
|
||
### Available Commands | ||
|
||
- `yarn clean` to remove dist folder. `dev` and `build` commands call this command. | ||
- `yarn ci:test` to run lint & unit test & type checking in ci environment. `ci:test:lint`, `ci:test:style`, `ci:test:unit` commands also available. | ||
- `yarn format` to fix code with eslint, prettier and stylelint. | ||
- `yarn lint` to call ESLint, Prettier and stylelint. | ||
- `yarn test` for testing. | ||
|
||
## Important Notes | ||
|
||
This starter includes experimental packages and is currently in development. You can see changes in this repo often for now. | ||
|
||
Please use with caution. | ||
|
||
#### [@eduardoac-skimlinks/webext-redux](https://github.com/eduardoacskimlinks/webext-redux) | ||
|
||
> **Note** It is a fork of [webext-redux](https://github.com/tshaddix/webext-redux) with Manifest V3 support and is currently in release candidate (RC). | ||
> | ||
> Please see https://github.com/tshaddix/webext-redux/pull/282 | ||
> | ||
> **Warning** Do not update to react-redux version 8.x, it is not supported for now and is **break** your application. | ||
### Bundling | ||
|
||
#### [@crxjs/vite-plugin](https://github.com/crxjs/chrome-extension-tools) | ||
|
||
> **Note** This plugin powers the development side of this starter. | ||
> | ||
> docs: https://crxjs.dev/vite-plugin | ||
> | ||
> Special thanks to [@jacksteamdev](https://github.com/jacksteamdev) and contributors for this amazing plugin. | ||
## Contributing | ||
|
||
This repository is following the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) standard. | ||
|
||
## License | ||
|
||
MIT © [Sinan Bekar](https://sinan.engineer) |
Oops, something went wrong.