forked from alan2207/bulletproof-react
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
40 changed files
with
2,849 additions
and
132 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,3 @@ | ||
REACT_APP_API_URL=http://api.bulletproofapp.com | ||
TSC_COMPILE_ON_ERROR=true | ||
ESLINT_NO_DEV_ERRORS=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,73 @@ | ||
module.exports = { | ||
root: true, | ||
env: { | ||
node: true, | ||
es6: true, | ||
}, | ||
parserOptions: { ecmaVersion: 8, sourceType: 'module' }, | ||
ignorePatterns: ['node_modules/*'], | ||
extends: ['eslint:recommended'], | ||
overrides: [ | ||
{ | ||
files: ['**/*.ts', '**/*.tsx'], | ||
parser: '@typescript-eslint/parser', | ||
settings: { | ||
react: { version: 'detect' }, | ||
'import/resolver': { | ||
typescript: {}, | ||
}, | ||
}, | ||
env: { | ||
browser: true, | ||
node: true, | ||
es6: true, | ||
}, | ||
extends: [ | ||
'eslint:recommended', | ||
'plugin:import/errors', | ||
'plugin:import/warnings', | ||
'plugin:import/typescript', | ||
'plugin:@typescript-eslint/recommended', | ||
'plugin:react/recommended', | ||
'plugin:react-hooks/recommended', | ||
'plugin:jsx-a11y/recommended', | ||
'plugin:prettier/recommended', | ||
], | ||
rules: { | ||
'no-restricted-imports': [ | ||
'error', | ||
{ | ||
patterns: ['@/features/*/*'], | ||
}, | ||
], | ||
'linebreak-style': ['error', 'unix'], | ||
'react/prop-types': 'off', | ||
|
||
'import/order': [ | ||
'error', | ||
{ | ||
groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index', 'object'], | ||
'newlines-between': 'always', | ||
alphabetize: { order: 'asc', caseInsensitive: true }, | ||
}, | ||
], | ||
'import/default': 'off', | ||
'import/no-named-as-default-member': 'off', | ||
'import/no-named-as-default': 'off', | ||
|
||
'react/react-in-jsx-scope': 'off', | ||
|
||
'jsx-a11y/anchor-is-valid': 'off', | ||
|
||
'@typescript-eslint/no-unused-vars': ['error'], | ||
|
||
'@typescript-eslint/explicit-function-return-type': ['off'], | ||
'@typescript-eslint/explicit-module-boundary-types': ['off'], | ||
'@typescript-eslint/no-empty-function': ['off'], | ||
'@typescript-eslint/no-explicit-any': ['off'], | ||
|
||
'prettier/prettier': ['error', {}, { usePrettierrc: 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,7 @@ | ||
{ | ||
"singleQuote": true, | ||
"trailingComma": "es5", | ||
"printWidth": 100, | ||
"tabWidth": 2, | ||
"useTabs": false | ||
} |
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,9 @@ | ||
{ | ||
"recommendations": [ | ||
"dbaeumer.vscode-eslint", | ||
"esbenp.prettier-vscode", | ||
"dsznajder.es7-react-js-snippets", | ||
"mariusalchimavicius.json-to-ts", | ||
"bradlc.vscode-tailwindcss" | ||
] | ||
} |
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 @@ | ||
{ | ||
"editor.formatOnSave": true, | ||
"editor.codeActionsOnSave": { | ||
"source.fixAll.eslint": 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,13 @@ | ||
const path = require("path"); | ||
module.exports = { | ||
webpack: { | ||
alias: { | ||
"@": path.resolve(__dirname, "src"), | ||
}, | ||
}, | ||
style: { | ||
postcss: { | ||
plugins: [require("tailwindcss"), require("autoprefixer")], | ||
}, | ||
}, | ||
}; |
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 @@ | ||
import React from "react"; | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
export interface {{ properCase name }}Props {} | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
export const {{ properCase name }} = (props: {{ properCase name }}Props) => { | ||
return ( | ||
<div> | ||
{{ properCase name }} | ||
</div> | ||
); | ||
}; |
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,32 @@ | ||
module.exports = { | ||
description: 'Component Generator', | ||
prompts: [ | ||
{ | ||
type: 'input', | ||
name: 'name', | ||
message: 'component name', | ||
}, | ||
{ | ||
type: 'input', | ||
name: 'folder', | ||
message: 'folder in components', | ||
}, | ||
], | ||
actions: [ | ||
{ | ||
type: 'add', | ||
path: 'src/components/{{folder}}/{{properCase name}}/index.ts', | ||
templateFile: 'generators/component/index.ts.hbs', | ||
}, | ||
{ | ||
type: 'add', | ||
path: 'src/components/{{folder}}/{{properCase name}}/{{properCase name}}.tsx', | ||
templateFile: 'generators/component/Component.tsx.hbs', | ||
}, | ||
{ | ||
type: 'add', | ||
path: 'src/components/{{folder}}/{{properCase name}}/{{properCase name}}.stories.tsx', | ||
templateFile: 'generators/component/Component.stories.tsx.hbs', | ||
}, | ||
], | ||
}; |
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 @@ | ||
export * from './{{ properCase name }}'; |
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
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 @@ | ||
const componentGenerator = require('./generators/component/index'); | ||
|
||
module.exports = function (plop) { | ||
plop.setGenerator('component', componentGenerator); | ||
}; |
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
This file was deleted.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -1,26 +1,10 @@ | ||
import React from 'react'; | ||
import logo from './logo.svg'; | ||
import './App.css'; | ||
import AppProvider from './context/AppProvider'; | ||
import { makeServer } from './server'; | ||
|
||
makeServer({ environment: 'development' }); | ||
|
||
function App() { | ||
return ( | ||
<div className="App"> | ||
<header className="App-header"> | ||
<img src={logo} className="App-logo" alt="logo" /> | ||
<p> | ||
Edit <code>src/App.tsx</code> and save to reload. | ||
</p> | ||
<a | ||
className="App-link" | ||
href="https://reactjs.org" | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
> | ||
Learn React | ||
</a> | ||
</header> | ||
</div> | ||
); | ||
return <AppProvider>123</AppProvider>; | ||
} | ||
|
||
export default App; |
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,24 @@ | ||
import clsx from 'clsx'; | ||
import { ReactNode } from 'react'; | ||
import { useForm, UseFormReturn, SubmitHandler, UseFormProps } from 'react-hook-form'; | ||
|
||
type FormProps<TFormValues> = { | ||
className?: string; | ||
onSubmit: SubmitHandler<TFormValues>; | ||
children: (methods: UseFormReturn<TFormValues>) => ReactNode; | ||
options?: UseFormProps<TFormValues>; | ||
}; | ||
|
||
export const Form = <TFormValues extends Record<string, any> = Record<string, any>>({ | ||
onSubmit, | ||
children, | ||
className, | ||
options, | ||
}: FormProps<TFormValues>) => { | ||
const methods = useForm<TFormValues>(options); | ||
return ( | ||
<form className={clsx('space-y-6', className)} onSubmit={methods.handleSubmit(onSubmit)}> | ||
{children(methods)} | ||
</form> | ||
); | ||
}; |
Oops, something went wrong.