Skip to content

Commit 1e64985

Browse files
committed
lint-staged, eslint, husky, prettier added
1 parent 68bfa2f commit 1e64985

29 files changed

+2728
-469
lines changed

.babelrc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
{
2-
"presets": [
3-
"@babel/preset-env"
4-
],
2+
"presets": ["@babel/preset-env"],
53
"plugins": ["@babel/plugin-transform-react-jsx"]
6-
}
4+
}

.eslintrc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"extends": ["airbnb", "prettier"],
3+
"plugins": ["prettier"],
4+
"rules": {
5+
"prettier/prettier": ["error"],
6+
"react/prop-types": "warn",
7+
"react/jsx-filename-extension": 0,
8+
"react/jsx-one-expression-per-line": 0,
9+
"react/jsx-props-no-spreading": 0,
10+
"react/require-default-props": 0,
11+
"react/forbid-prop-types": 0,
12+
"jsx-a11y/alt-text": 0,
13+
"import/prefer-default-export": 0,
14+
"import/no-extraneous-dependencies": 0
15+
}
16+
}

.prettierrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"printWidth": 100,
3+
"singleQuote": true
4+
}

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ It works with express.js framework to run Node.js server. Custom renderer we hav
1818
### Code Example
1919

2020
```js
21-
import React from "react";
22-
import { ReactXpress, App, Static, Router, Get, Post } from "../lib";
21+
import React from 'react';
22+
import { ReactXpress, App, Static, Router, Get, Post } from '../lib';
2323

2424
const HomePage = () => <h1>Welcome to home page</h1>;
2525
const AboutPage = () => <h1>About Company</h1>;
@@ -35,7 +35,7 @@ const ExpressApp = () => (
3535
<Get path="/about" content={<AboutPage />} />
3636
</Router>
3737
<Router path="/api">
38-
<Post path="/status" content={{ msg: "It is okay, bro" }} />
38+
<Post path="/status" content={{ msg: 'It is okay, bro' }} />
3939
</Router>
4040
</App>
4141
);

examples/advanced/components.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import React from "react";
1+
import React from 'react';
22

33
export const PostItem = ({ userId, id, title, body }) => (
4-
<div style={{ width: 500, margin: "0 auto" }}>
4+
<div style={{ width: 500, margin: '0 auto' }}>
55
<p>
66
UserID: {userId} / PostID: {id}
77
</p>

examples/advanced/handlers.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
1-
import React from "react";
2-
import axios from "axios";
1+
import React from 'react';
2+
import axios from 'axios';
33

4-
import { PostItem } from "./components";
4+
import { PostItem } from './components';
55

66
export const postHandler = async (req, res, _, renderPage) => {
77
const { id } = req.params;
88
try {
9-
const { data } = await axios(
10-
`https://jsonplaceholder.typicode.com/posts/${id}`
11-
);
9+
const { data } = await axios(`https://jsonplaceholder.typicode.com/posts/${id}`);
1210
renderPage(() => <PostItem {...data} />);
1311
} catch (error) {
14-
res.status(500).end("Error");
12+
res.status(500).end('Error');
1513
}
1614
};
1715

1816
export const postsHandler = async (req, res, _, renderPage) => {
1917
try {
20-
const { data } = await axios("https://jsonplaceholder.typicode.com/posts");
18+
const { data } = await axios('https://jsonplaceholder.typicode.com/posts');
2119
renderPage(() => data.map((post) => <PostItem key={post.id} {...post} />));
2220
} catch (error) {
23-
res.status(500).end("Error");
21+
res.status(500).end('Error');
2422
}
2523
};

examples/advanced/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import React from "react";
2-
import { ReactXpress, App, Static, Router, Get } from "../../lib";
3-
import { postHandler, postsHandler } from "./handlers";
1+
import React from 'react';
2+
import { ReactXpress, App, Static, Router, Get } from '../../lib';
3+
import { postHandler, postsHandler } from './handlers';
44

55
const ExpressApp = () => (
66
<App port={8080}>

examples/basic/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import React from "react";
2-
import { ReactXpress, App, Static, Router, Get } from "../../lib";
1+
import React from 'react';
2+
import { ReactXpress, App, Static, Router, Get } from '../../lib';
33

44
const ExpressApp = () => (
55
<App port={8080}>

lib/components/App.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import React from "react";
2-
import PropTypes from "prop-types";
1+
import React from 'react';
2+
import PropTypes from 'prop-types';
33

44
export const App = ({ children, port }) => <app port={port}>{children}</app>;
55

lib/components/Res.js

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
import React from "react";
2-
import PropTypes from "prop-types";
1+
import React from 'react';
2+
import PropTypes from 'prop-types';
33

4-
const Render = ({ component }) => {
5-
return <param type="render" content={component} />;
6-
};
4+
const Render = ({ component }) => <param type="render" content={component} />;
75

86
Render.propTypes = {
97
component: PropTypes.func,
@@ -13,13 +11,9 @@ const Content = ({ json, contentType, text }) => {
1311
const ComponentsArray = [];
1412

1513
if (contentType)
16-
ComponentsArray.push(
17-
<param key="contentType" type="content-type" content={contentType} />
18-
);
19-
if (json)
20-
ComponentsArray.push(<param key="json" type="json" content={json} />);
21-
if (text)
22-
ComponentsArray.push(<param key="text" type="text" content={text} />);
14+
ComponentsArray.push(<param key="contentType" type="content-type" content={contentType} />);
15+
if (json) ComponentsArray.push(<param key="json" type="json" content={json} />);
16+
if (text) ComponentsArray.push(<param key="text" type="text" content={text} />);
2317

2418
return ComponentsArray;
2519
};
@@ -30,26 +24,22 @@ Content.propTypes = {
3024
text: PropTypes.string,
3125
};
3226

33-
const Status = ({ statusCode }) => {
34-
return <param type="status" content={statusCode} />;
35-
};
27+
const Status = ({ statusCode }) => <param type="status" content={statusCode} />;
3628

3729
Status.propTypes = {
3830
statusCode: PropTypes.number,
3931
};
4032

41-
const Redirect = ({ path, statusCode }) => {
42-
return <param type="redirect" content={{ path, statusCode }} />;
43-
};
33+
const Redirect = ({ path, statusCode }) => <param type="redirect" content={{ path, statusCode }} />;
4434

4535
Redirect.propTypes = {
4636
path: PropTypes.string.isRequired,
4737
statusCode: PropTypes.number,
4838
};
4939

50-
const SendFile = ({ path, options, onError = () => {} }) => {
51-
return <param type="send-file" content={{ path, options, onError }} />;
52-
};
40+
const SendFile = ({ path, options, onError = () => {} }) => (
41+
<param type="send-file" content={{ path, options, onError }} />
42+
);
5343

5444
SendFile.propTypes = {
5545
path: PropTypes.string.isRequired,

0 commit comments

Comments
 (0)