Skip to content

Commit

Permalink
Add Prettier and Husky (#57)
Browse files Browse the repository at this point in the history
- Imp: already ranned prettier over all the files in src directory via npm run format.
- added format script for future reference
- now complete codebase is consistent with styling via prettier.
- and bad commits protected via husky.
  • Loading branch information
jugshaurya authored Mar 26, 2021
1 parent 95b420c commit cf95af7
Show file tree
Hide file tree
Showing 20 changed files with 6,512 additions and 58 deletions.
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
/coverage
/build
19 changes: 19 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"arrowParens": "always",
"bracketSpacing": true,
"embeddedLanguageFormatting": "auto",
"htmlWhitespaceSensitivity": "css",
"insertPragma": false,
"jsxBracketSameLine": false,
"jsxSingleQuote": false,
"printWidth": 80,
"proseWrap": "preserve",
"quoteProps": "as-needed",
"requirePragma": false,
"semi": true,
"singleQuote": false,
"tabWidth": 2,
"trailingComma": "es5",
"useTabs": false,
"vueIndentScriptAndStyle": false
}
5 changes: 5 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"recommendations": [
"esbenp.prettier-vscode"
]
}
17 changes: 16 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
"predeploy": "npm run build",
"prepare": "node injectLatestProps.js",
"deploy": "gh-pages -d build",
"postinstall": "patch-package"
"postinstall": "patch-package",
"format": "prettier --write \"./src\""
},
"eslintConfig": {
"extends": "react-app"
Expand All @@ -53,8 +54,22 @@
"@babel/plugin-proposal-class-properties": "^7.10.4",
"customize-cra": "^1.0.0",
"gh-pages": "^3.1.0",
"husky": "^4.3.8",
"lint-staged": "^10.5.4",
"patch-package": "^6.2.2",
"postinstall-postinstall": "^2.1.0",
"prettier": "^2.2.1",
"react-app-rewired": "^2.1.6"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"*.{js,jsx,css,md,json}": [
"prettier --write --ignore-unknown",
"git add"
]
}
}
5 changes: 4 additions & 1 deletion src/App.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import React from "react";
import { SafeAreaInsetsContext, SafeAreaProvider } from 'react-native-safe-area-context';
import {
SafeAreaInsetsContext,
SafeAreaProvider,
} from "react-native-safe-area-context";

import Root from "./containers";
import "./App.css";
Expand Down
10 changes: 5 additions & 5 deletions src/App.test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
import React from "react";
import ReactDOM from "react-dom";
import App from "./App";

it('renders without crashing', () => {
const div = document.createElement('div');
it("renders without crashing", () => {
const div = document.createElement("div");
ReactDOM.render(<App />, div);
ReactDOM.unmountComponentAtNode(div);
});
17 changes: 14 additions & 3 deletions src/components/Footer/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ function Footer() {
<Grid container spacing={5} justify="center">
<Grid item xs={12} md={6} lg={4}>
<Typography variant="h4" style={{ marginBottom: 10 }}>
Playground <span role="img" aria-label="playground">🚀</span>
Playground{" "}
<span role="img" aria-label="playground">
🚀
</span>
</Typography>

<Divider />
Expand All @@ -30,12 +33,20 @@ function Footer() {
<Typography>GitHub Repositoy</Typography>
</a>

<a href="https://reactnativeelements.com/" target="_blank" rel="noopener noreferrer">
<a
href="https://reactnativeelements.com/"
target="_blank"
rel="noopener noreferrer"
>
<Typography>Official Docs</Typography>
</a>
<br />

<a href="https://www.netlify.com" target="_blank" rel="noopener noreferrer">
<a
href="https://www.netlify.com"
target="_blank"
rel="noopener noreferrer"
>
<img
src="https://www.netlify.com/img/global/badges/netlify-color-accent.svg"
alt="Deploys by Netlify"
Expand Down
2 changes: 1 addition & 1 deletion src/components/playground/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default ({ params }) => {
<div
style={{
border: "1px dashed #ccc",
position:'relative'
position: "relative",
}}
>
<Compiler
Expand Down
15 changes: 12 additions & 3 deletions src/containers/Drawer/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ function ResponsiveDrawer(props) {
const [selectedIndex, setSelectedIndex] = React.useState(-1);

const handleDrawerToggle = (value) => {
if(value === false){
if (value === false) {
setMobileOpen(false);
} else {
setMobileOpen(true);
Expand All @@ -92,7 +92,12 @@ function ResponsiveDrawer(props) {
<div>
<div style={{ padding: "0.5rem" }}>
<Link to="/" onClick={() => handleDrawerToggle(false)}>
<Typography variant="h5">Playground <span role="img" aria-label="playground" >🚀</span></Typography>
<Typography variant="h5">
Playground{" "}
<span role="img" aria-label="playground">
🚀
</span>
</Typography>
</Link>
</div>
<List>
Expand Down Expand Up @@ -140,7 +145,11 @@ function ResponsiveDrawer(props) {
</Typography>
</Link>
<div style={{ marginLeft: "auto" }}>
<a href="https://reactnativeelements.com/" target="_blank" rel="noopener noreferrer">
<a
href="https://reactnativeelements.com/"
target="_blank"
rel="noopener noreferrer"
>
<Button color="inherit">Docs</Button>
</a>
<IconButton
Expand Down
8 changes: 7 additions & 1 deletion src/containers/Navigation/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,13 @@ export default function App() {
})}
<Route exact path="/explore">
<Helmet>
<title>Explore | Playground <span role="img" aria-label="playground">🚀</span> - React Native Elements</title>
<title>
Explore | Playground{" "}
<span role="img" aria-label="playground">
🚀
</span>{" "}
- React Native Elements
</title>
</Helmet>
<ExplorePage />
</Route>
Expand Down
2 changes: 1 addition & 1 deletion src/content/BottomSheet/bottomsheet.playground.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const BottomSheetPlayground = () => {
containerStyle: {
value: `{}`,
type: PropTypes.Object,
}
},
},
scope: {
BottomSheet,
Expand Down
2 changes: 1 addition & 1 deletion src/content/Rating/searchbar.playground.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const RatingPlayground = () => {
},
tintColor: {
type: PropTypes.String,
value: '',
value: "",
},
ratingColor: {
type: PropTypes.String,
Expand Down
1 change: 0 additions & 1 deletion src/content/Slider/slider.playground.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
import Playground from "../../components/playground";
import { useView, PropTypes } from "react-view";


const SliderPlayground = () => {
const params = useView({
componentName: "Slider",
Expand Down
14 changes: 7 additions & 7 deletions src/content/Text/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ const Content = lazy(() => importMDX("../Props/text.md"));
export default function TextPlayground() {
return (
<div>
<Playground />
<Suspense fallback={<div>Loading...</div>}>
<PropDrawer>
<Content />
</PropDrawer>
</Suspense>
</div>
<Playground />
<Suspense fallback={<div>Loading...</div>}>
<PropDrawer>
<Content />
</PropDrawer>
</Suspense>
</div>
);
}
2 changes: 1 addition & 1 deletion src/content/ToolTip/tooltip.playground.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const ToolTipPlayground = () => {
type: PropTypes.Number,
},
highlightColor: {
value: 'transparent',
value: "transparent",
type: PropTypes.String,
},
ModalComponent: {
Expand Down
8 changes: 5 additions & 3 deletions src/content/utils/createReactViewBaseConfig.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
export default function createReactViewBaseConfig(componentName, RNComponent) {
if (!componentName || !RNComponent) {
throw new Error('createBaseComponent needs a componentName name and RNComponent');
throw new Error(
"createBaseComponent needs a componentName name and RNComponent"
);
}

return ({
return {
componentName,
scope: {
RNComponent,
Expand All @@ -13,5 +15,5 @@ export default function createReactViewBaseConfig(componentName, RNComponent) {
named: [componentName],
},
},
});
};
}
14 changes: 7 additions & 7 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import * as serviceWorker from './serviceWorker';
import 'react-native-safe-area-context';
import React from "react";
import ReactDOM from "react-dom";
import "./index.css";
import App from "./App";
import * as serviceWorker from "./serviceWorker";
import "react-native-safe-area-context";

ReactDOM.render(<App />, document.getElementById('root'));
ReactDOM.render(<App />, document.getElementById("root"));

// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
Expand Down
6,379 changes: 6,378 additions & 1 deletion src/pages/home/animation.json

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion src/pages/home/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ function HomePage() {
<div style={{ width: "100%", textAlign: "center", marginBottom: "2rem" }}>
<Link to="/explore">
<Button variant="outlined" color="secondary">
<Typography variant="h6">Explore Now <span role="img" aria-label="explore">🌇</span></Typography>
<Typography variant="h6">
Explore Now{" "}
<span role="img" aria-label="explore">
🌇
</span>
</Typography>
</Button>
</Link>
</div>
Expand Down
Loading

0 comments on commit cf95af7

Please sign in to comment.