Skip to content

Commit 6949539

Browse files
authored
feature: Eslint Added, code formated, made codebase consistent (#112)
1 parent af07ce6 commit 6949539

12 files changed

+139
-40
lines changed

.eslintrc

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"parserOptions": {
3+
"ecmaVersion": 2019,
4+
"sourceType": "module",
5+
// enable jsx support
6+
"ecmaFeatures": {
7+
"jsx": true
8+
}
9+
},
10+
"extends": [
11+
"eslint:recommended",
12+
"plugin:react/recommended",
13+
"plugin:jest/recommended",
14+
"plugin:react-hooks/recommended",
15+
"plugin:jsx-a11y/recommended",
16+
"plugin:json/recommended"
17+
],
18+
"rules": {
19+
"react/jsx-uses-react": "error",
20+
"react/jsx-uses-vars": "error",
21+
"react-hooks/rules-of-hooks": "error",
22+
"react-hooks/exhaustive-deps": "warn"
23+
},
24+
"env": {
25+
"browser": true,
26+
"node": true,
27+
"commonjs": true,
28+
"es6": true
29+
},
30+
"plugins": ["react", "jest", "react-hooks", "jsx-a11y"],
31+
"settings": {
32+
"react": {
33+
"version": "detect"
34+
}
35+
}
36+
}

.prettierignore

-3
This file was deleted.

.prettierrc

+4-3
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@
77
"jsxBracketSameLine": false,
88
"jsxSingleQuote": false,
99
"printWidth": 80,
10-
"proseWrap": "preserve",
10+
"proseWrap": "always",
1111
"quoteProps": "as-needed",
1212
"requirePragma": false,
1313
"semi": true,
1414
"singleQuote": false,
1515
"tabWidth": 2,
1616
"trailingComma": "es5",
1717
"useTabs": false,
18-
"vueIndentScriptAndStyle": false
19-
}
18+
"vueIndentScriptAndStyle": false,
19+
"endOfLine": "auto"
20+
}

.vscode/extensions.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"recommendations": [
33
"esbenp.prettier-vscode",
4-
"vscodeshift.material-ui-snippets"
4+
"vscodeshift.material-ui-snippets",
5+
"dbaeumer.vscode-eslint"
56
]
67
}

.vscode/settings.json

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/* recommmended settings for vscode */
2+
{
3+
"editor.defaultFormatter": "esbenp.prettier-vscode",
4+
"editor.formatOnSave": true,
5+
"editor.rulers": [80],
6+
"editor.snippetSuggestions": "top",
7+
"[javascript]": {
8+
"editor.defaultFormatter": "esbenp.prettier-vscode",
9+
"editor.suggestSelection": "recentlyUsed",
10+
"editor.suggest.showKeywords": false
11+
},
12+
"files.exclude": {
13+
"USE_GITIGNORE": true
14+
},
15+
"search.exclude": {
16+
"**/node_modules": true,
17+
"**/bower_components": true,
18+
"**/coverage": true,
19+
"**/dist": true,
20+
"**/build": true,
21+
"**/.build": true,
22+
"**/.gh-pages": true
23+
},
24+
"editor.codeActionsOnSave": {
25+
"source.fixAll.eslint": false
26+
},
27+
"eslint.validate": [
28+
"javascript",
29+
"javascriptreact",
30+
"typescript",
31+
"typescriptreact"
32+
],
33+
"eslint.options": {
34+
"env": {
35+
"browser": true,
36+
"jest/globals": true,
37+
"es6": true
38+
},
39+
"parserOptions": {
40+
"ecmaVersion": 2019,
41+
"sourceType": "module",
42+
"ecmaFeatures": {
43+
"jsx": true
44+
}
45+
},
46+
"rules": {
47+
"no-debugger": "off"
48+
}
49+
},
50+
"editor.formatOnPaste": false
51+
}

injectLatestProps.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@ exec(
2424
// the *entire* stdout and stderr (buffered)
2525
console.log(`stdout: ${stdout}`);
2626
console.log(`stderr: ${stderr}`);
27-
};
27+
}
28+
);

package.json

+14-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,13 @@
3333
"prepare": "node injectLatestProps.js",
3434
"deploy": "gh-pages -d build",
3535
"postinstall": "patch-package",
36-
"format": "prettier --write \"./src\""
36+
"prettier": "prettier --ignore-path .gitignore \"**/*.+(js|jsx|json)\" --ignore-unknown",
37+
"format": "npm run prettier -- --write",
38+
"check-format": "npm run prettier -- --check",
39+
"lint": "eslint --ignore-path .gitignore . --fix",
40+
"check-lint": "eslint --ignore-path .gitignore .",
41+
"make-consistent": "npm run format && npm run lint",
42+
"validate": "npm run check-format && npm run check-lint"
3743
},
3844
"eslintConfig": {
3945
"extends": "react-app"
@@ -54,8 +60,13 @@
5460
"@babel/plugin-proposal-class-properties": "^7.10.4",
5561
"@babel/preset-env": "^7.13.12",
5662
"customize-cra": "^1.0.0",
63+
"eslint-plugin-jest": "^24.3.5",
64+
"eslint-plugin-json": "^2.1.2",
65+
"eslint-plugin-jsx-a11y": "^6.4.1",
66+
"eslint-plugin-react": "^7.23.2",
67+
"eslint-plugin-react-hooks": "^4.2.0",
5768
"gh-pages": "^3.1.0",
58-
"husky": "^4.3.8",
69+
"husky": "^6.0.0",
5970
"lint-staged": "^10.5.4",
6071
"patch-package": "^6.2.2",
6172
"postinstall-postinstall": "^2.1.0",
@@ -69,7 +80,7 @@
6980
},
7081
"lint-staged": {
7182
"*.{js,jsx,css,md,json}": [
72-
"prettier --write --ignore-unknown",
83+
"npm run validate",
7384
"git add"
7485
]
7586
}

public/manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"src": "logo512.png",
1717
"type": "image/png",
1818
"sizes": "512x512"
19-
}
19+
}
2020
],
2121
"start_url": ".",
2222
"display": "standalone",

src/App.test.js

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from "react";
22
import ReactDOM from "react-dom";
33
import App from "./App";
44

5+
// eslint-disable-next-line jest/expect-expect
56
it("renders without crashing", () => {
67
const div = document.createElement("div");
78
ReactDOM.render(<App />, div);

src/content/ButtonGroup/buttongroup.playground.jsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from "react";
2-
import { ButtonGroup} from "react-native-elements";
2+
import { ButtonGroup } from "react-native-elements";
33

44
import Playground from "../../components/playground";
55
import { useView, PropTypes } from "react-view";
@@ -57,7 +57,7 @@ const ButtonGroupPlayground = () => {
5757
propHook: {
5858
what: `selectedIdx`,
5959
into: `selectedIndex`,
60-
}
60+
},
6161
},
6262
selectMultiple: {
6363
type: PropTypes.Boolean,
@@ -70,12 +70,12 @@ const ButtonGroupPlayground = () => {
7070
selectedIndex: {
7171
type: PropTypes.Number,
7272
value: `1`,
73-
stateful: true
73+
stateful: true,
7474
},
7575
selectedIndexes: {
7676
type: PropTypes.Array,
7777
value: `[]`,
78-
stateful: true
78+
stateful: true,
7979
},
8080
selectedTextStyle: {
8181
type: PropTypes.Object,

src/content/CheckBox/checkbox.playground.jsx

+19-19
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,23 @@ const HeaderPlayground = () => {
1111
center: {
1212
type: PropTypes.Boolean,
1313
value: false,
14-
description: "Aligns checkbox to center (optional)"
14+
description: "Aligns checkbox to center (optional)",
1515
},
1616
right: {
1717
type: PropTypes.Boolean,
1818
value: false,
19-
description: "Aligns checkbox to right (optional)"
19+
description: "Aligns checkbox to right (optional)",
2020
},
2121
checked: {
2222
type: PropTypes.Boolean,
2323
value: false,
2424
stateful: true,
25-
description: "Flag for checking the icon (required)"
25+
description: "Flag for checking the icon (required)",
2626
},
2727
checkedColor: {
2828
type: PropTypes.String,
2929
value: "#0F0",
30-
description: "Default checked color (optional)"
30+
description: "Default checked color (optional)",
3131
},
3232
checkedIcon: {
3333
type: PropTypes.Object,
@@ -37,7 +37,7 @@ const HeaderPlayground = () => {
3737
checkedTitle: {
3838
type: PropTypes.String,
3939
value: `Great!`,
40-
description: "Specify a custom checked message (optional)"
40+
description: "Specify a custom checked message (optional)",
4141
},
4242
Component: {
4343
type: PropTypes.ReactNode,
@@ -47,71 +47,71 @@ const HeaderPlayground = () => {
4747
containerStyle: {
4848
type: PropTypes.Object,
4949
value: `{width: "75%"}`,
50-
description: "Style of main container (optional)"
50+
description: "Style of main container (optional)",
5151
},
5252
fontFamily: {
5353
type: PropTypes.String,
5454
value: null,
55-
description: "Specify different font family"
55+
description: "Specify different font family",
5656
},
5757
iconRight: {
5858
type: PropTypes.Boolean,
5959
value: false,
60-
description: "Moves icon to right of text (optional)"
60+
description: "Moves icon to right of text (optional)",
6161
},
6262
iconType: {
6363
type: PropTypes.String,
6464
value: null,
65-
description: "type of icon set"
65+
description: "type of icon set",
6666
},
6767
onIconPress: {
6868
type: PropTypes.Function,
6969
value: `() => setChecked(!checked)`,
7070
propHook: {
7171
what: "!checked",
72-
into: "checked"
72+
into: "checked",
7373
},
74-
description: "onPress function for checkbox (required)"
74+
description: "onPress function for checkbox (required)",
7575
},
7676
onLongIconPress: {
7777
type: PropTypes.Function,
7878
value: `() => console.log("onLongIconPress()")`,
79-
description: "onLongPress function for checkbox (optional)"
79+
description: "onLongPress function for checkbox (optional)",
8080
},
8181
onLongPress: {
8282
type: PropTypes.Function,
8383
value: `() => console.log("onLongPress()")`,
84-
description: "onLongPress function for checkbox (optional)"
84+
description: "onLongPress function for checkbox (optional)",
8585
},
8686
onPress: {
8787
type: PropTypes.Function,
8888
value: `() => console.log("onPress()")`,
89-
description: "onPress function for container (optional)"
89+
description: "onPress function for container (optional)",
9090
},
9191
size: {
9292
type: PropTypes.Number,
9393
value: 30,
94-
description: "Size of the checkbox"
94+
description: "Size of the checkbox",
9595
},
9696
textStyle: {
9797
type: PropTypes.Object,
9898
value: `{}`,
99-
description: "Style of text (optional)"
99+
description: "Style of text (optional)",
100100
},
101101
title: {
102102
type: PropTypes.Object,
103103
value: `"Check for Awesomeness"`,
104-
description: "Title of checkbox"
104+
description: "Title of checkbox",
105105
},
106106
titleProps: {
107107
type: PropTypes.Object,
108108
value: `{}`,
109-
description: "Additional props for the title Text component (optional)"
109+
description: "Additional props for the title Text component (optional)",
110110
},
111111
uncheckedColor: {
112112
type: PropTypes.String,
113113
value: `#F00`,
114-
description: "Default unchecked color (optional)"
114+
description: "Default unchecked color (optional)",
115115
},
116116
uncheckedIcon: {
117117
type: PropTypes.Object,

src/content/Overlay/overlay.playground.jsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ const OverlayPlayground = () => {
1717
children: {
1818
type: PropTypes.ReactNode,
1919
value: `<Text>Some content</Text><TouchableOpacity onPress={()=>setIsVisible(!isVisible)}><Text>Click to close</Text></TouchableOpacity>`,
20-
propHook: ({getInstrumentOnChange, fnBodyAppend}) => ({
20+
propHook: ({ getInstrumentOnChange, fnBodyAppend }) => ({
2121
JSXAttribute(path) {
22-
if (path.get('name').node.name === 'onPress') {
22+
if (path.get("name").node.name === "onPress") {
2323
fnBodyAppend(
24-
path.get('value'),
25-
getInstrumentOnChange('false', 'isVisible')
24+
path.get("value"),
25+
getInstrumentOnChange("false", "isVisible")
2626
);
2727
}
2828
},
@@ -49,7 +49,7 @@ const OverlayPlayground = () => {
4949
propHook: {
5050
what: `false`,
5151
into: `isVisible`,
52-
}
52+
},
5353
},
5454
overlayStyle: {
5555
type: PropTypes.Object,

0 commit comments

Comments
 (0)