Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/create config for eslint, commitlint, prettier and husky (#181) #197

Merged
merged 6 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist
node_modules
10 changes: 7 additions & 3 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
"eslint:recommended",
"plugin:react/recommended",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended"
"plugin:react-hooks/recommended",
"plugin:import/recommended",
"plugin:jsx-a11y/recommended",
"prettier"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
Expand All @@ -18,14 +21,15 @@
"ecmaVersion": "latest",
"sourceType": "module"
},
"plugins": ["react", "@typescript-eslint"],
"plugins": ["react", "@typescript-eslint", "react-hooks", "import", "jsx-a11y", "prettier"],
"settings": {
"react": {
"version": "detect"
}
},
"rules": {
"react/react-in-jsx-scope": "off"
"react/react-in-jsx-scope": "off",
"import/no-unresolved": "off"
},
"globals": {
"chrome": "readonly"
Expand Down
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npm run commitlint ${1}
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx lint-staged
12 changes: 12 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
dist
node_modules
.gitignore
.github
.eslintignore
.husky
.nvmrc
.prettierignore
LICENSE
*.md
package-lock.json
yarn.lock
10 changes: 7 additions & 3 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{
"singleQuote": false,
"trailingComma": "es5",
"arrowParens": "always"
"trailingComma": "all",
"semi": true,
"singleQuote": true,
"arrowParens": "avoid",
"printWidth": 120,
"bracketSameLine": true,
"htmlWhitespaceSensitivity": "strict"
}
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,11 @@ This boilerplate is made for creating chrome extensions using React and Typescri
- [Vite](https://vitejs.dev/)
- [SASS](https://sass-lang.com/)
- [Twind](https://twind.dev/)
- [ESLint](https://eslint.org/)
- [Prettier](https://prettier.io/)
- [ESLint](https://eslint.org/)
- [Husky](https://typicode.github.io/husky/getting-started.html#automatic-recommended)
- [Commitlint](https://commitlint.js.org/#/guides-local-setup?id=install-commitlint)
- [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/#summary)
- [Chrome Extension Manifest Version 3](https://developer.chrome.com/docs/extensions/mv3/intro/)
- HRR(Hot Rebuild & Refresh/Reload)

Expand Down
1 change: 1 addition & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default { extends: ['@commitlint/config-conventional'] };
24 changes: 12 additions & 12 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ export default {
// collectCoverageFrom: undefined,

// The directory where Jest should output its coverage files
coverageDirectory: "coverage",
coverageDirectory: 'coverage',

// An array of regexp pattern strings used to skip coverage collection
// coveragePathIgnorePatterns: [
// "/node_modules/"
// ],

// Indicates which provider should be used to instrument code for coverage
coverageProvider: "v8",
coverageProvider: 'v8',

// A list of reporter names that Jest uses when writing coverage reports
// coverageReporters: [
Expand Down Expand Up @@ -82,9 +82,9 @@ export default {

// A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
moduleNameMapper: {
"^@src(.*)$": "<rootDir>/src$1",
"^@assets(.*)$": "<rootDir>/src/assets$1",
"^@pages(.*)$": "<rootDir>/src/pages$1",
'^@src(.*)$': '<rootDir>/src$1',
'^@assets(.*)$': '<rootDir>/src/assets$1',
'^@pages(.*)$': '<rootDir>/src/pages$1',
},

// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
Expand All @@ -97,7 +97,7 @@ export default {
// notifyMode: "failure-change",

// A preset that is used as a base for Jest's configuration
preset: "ts-jest",
preset: 'ts-jest',

// Run tests from one or more projects
// projects: undefined,
Expand Down Expand Up @@ -129,7 +129,7 @@ export default {
// runner: "jest-runner",

// The paths to modules that run some code to configure or set up the testing environment before each test
setupFiles: ["./test-utils/jest.setup.js"],
setupFiles: ['./test-utils/jest.setup.js'],

// A list of paths to modules that run some code to configure or set up the testing framework before each test
// setupFilesAfterEnv: [],
Expand All @@ -141,7 +141,7 @@ export default {
// snapshotSerializers: [],

// The test environment that will be used for testing
testEnvironment: "jsdom",
testEnvironment: 'jsdom',

// Options that will be passed to the testEnvironment
// testEnvironmentOptions: {},
Expand All @@ -157,10 +157,10 @@ export default {

// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
testPathIgnorePatterns: [
"<rootDir>/node_modules/",
"<rootDir>/test-utils/",
"<rootDir>/vite.config.ts",
"<rootDir>/jest.config.js",
'<rootDir>/node_modules/',
'<rootDir>/test-utils/',
'<rootDir>/vite.config.ts',
'<rootDir>/jest.config.js',
],

// The regexp pattern or array of patterns that Jest uses to detect test files
Expand Down
35 changes: 15 additions & 20 deletions manifest.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import packageJson from "./package.json";
import packageJson from './package.json';

/**
* After changing, please reload the extension at `chrome://extensions`
Expand All @@ -8,40 +8,35 @@ const manifest: chrome.runtime.ManifestV3 = {
name: packageJson.name,
version: packageJson.version,
description: packageJson.description,
permissions: ["storage"],
options_page: "src/pages/options/index.html",
permissions: ['storage'],
options_page: 'src/pages/options/index.html',
background: {
service_worker: "src/pages/background/index.js",
type: "module",
service_worker: 'src/pages/background/index.js',
type: 'module',
},
action: {
default_popup: "src/pages/popup/index.html",
default_icon: "icon-34.png",
default_popup: 'src/pages/popup/index.html',
default_icon: 'icon-34.png',
},
chrome_url_overrides: {
newtab: "src/pages/newtab/index.html",
newtab: 'src/pages/newtab/index.html',
},
icons: {
"128": "icon-128.png",
'128': 'icon-128.png',
},
content_scripts: [
{
matches: ["http://*/*", "https://*/*", "<all_urls>"],
js: ["src/pages/content/index.js"],
matches: ['http://*/*', 'https://*/*', '<all_urls>'],
js: ['src/pages/content/index.js'],
// KEY for cache invalidation
css: ["assets/css/contentStyle<KEY>.chunk.css"],
css: ['assets/css/contentStyle<KEY>.chunk.css'],
},
],
devtools_page: "src/pages/devtools/index.html",
devtools_page: 'src/pages/devtools/index.html',
web_accessible_resources: [
{
resources: [
"assets/js/*.js",
"assets/css/*.css",
"icon-128.png",
"icon-34.png",
],
matches: ["*://*/*"],
resources: ['assets/js/*.js', 'assets/css/*.css', 'icon-128.png', 'icon-34.png'],
matches: ['*://*/*'],
},
],
};
Expand Down
Loading