Skip to content

Commit eecdaad

Browse files
committed
Added lint and prettier along with husky
Updated beta version
1 parent f7fecd2 commit eecdaad

File tree

6 files changed

+321
-15
lines changed

6 files changed

+321
-15
lines changed

.eslintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
**/node_modules
22
example/
33
lib/
4+
src/__mocks__
5+
src/__tests__

.eslintrc.js

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,24 @@
11
module.exports = {
2-
extends: ['@react-native-community', 'plugin:prettier/recommended'],
3-
plugins: ['simple-import-sort'],
4-
root: true,
2+
extends: [
3+
'@react-native-community',
4+
'plugin:prettier/recommended',
5+
'plugin:@typescript-eslint/eslint-recommended',
6+
'plugin:@typescript-eslint/recommended',
7+
'plugin:react-hooks/recommended',
8+
],
9+
parser: '@typescript-eslint/parser',
10+
plugins: ['@typescript-eslint', 'simple-import-sort', 'react-hooks'],
511
rules: {
12+
'prettier/prettier': 0,
13+
'react-native/no-unused-styles': ['warn'],
14+
'@typescript-eslint/prefer-namespace-keyword': 'off',
15+
'@typescript-eslint/no-namespace': 'off',
16+
'@typescript-eslint/explicit-module-boundary-types': 'off',
17+
'react-hooks/rules-of-hooks': 'error',
18+
'react-hooks/exhaustive-deps': 'warn',
19+
'no-shadow': 'off',
20+
'@typescript-eslint/no-shadow': ['error'],
21+
'@typescript-eslint/no-var-requires': 0,
622
'import/order': 'off',
723
'simple-import-sort/exports': 'error',
824
'simple-import-sort/imports': 'error',

.husky/pre-commit

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
npx lint-staged
5+
yarn test-coverage

package.json

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@mutualmobile/react-native-barricade",
3-
"version": "1.0.0-beta.1",
3+
"version": "1.0.0-beta.2",
44
"description": "A local server configurable at runtime to develop, test, and prototype your React Native app. Using just mock responses, Barricade can build the whole app without getting blocked by the unavailability of APIs.",
55
"homepage": "https://github.com/mutualmobile/react-native-barricade#readme",
66
"main": "lib/index.js",
@@ -39,9 +39,18 @@
3939
],
4040
"scripts": {
4141
"compile": "rm -rf lib && tsc -p .",
42-
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
43-
"prepare": "yarn compile",
44-
"test": "jest"
42+
"lint": "eslint .",
43+
"prettier-check": "prettier src --check",
44+
"prettier-format": "prettier src --write",
45+
"prepare": "yarn compile && husky install",
46+
"test": "jest",
47+
"test-coverage": "jest --coverage"
48+
},
49+
"lint-staged": {
50+
"*.{js,jsx,ts,tsx}": [
51+
"eslint --cache --fix",
52+
"prettier --write"
53+
]
4554
},
4655
"devDependencies": {
4756
"@babel/core": "^7.20.0",
@@ -53,12 +62,19 @@
5362
"@types/react-native": "^0.71.1",
5463
"@types/react-test-renderer": "^18.0.0",
5564
"@types/url-parse": "^1.4.8",
65+
"@typescript-eslint/eslint-plugin": "^5.50.0",
66+
"@typescript-eslint/parser": "^5.50.0",
5667
"babel-jest": "^29.2.1",
5768
"eslint": "^8.19.0",
69+
"eslint-plugin-ft-flow": "^2.0.3",
70+
"eslint-plugin-react-hooks": "^4.6.0",
5871
"eslint-plugin-simple-import-sort": "^10.0.0",
72+
"husky": "^8.0.3",
5973
"jest": "^29.2.1",
6074
"jest-environment-jsdom": "^29.4.1",
75+
"lint-staged": "^13.1.0",
6176
"metro-react-native-babel-preset": "0.73.7",
77+
"prettier": "^2.8.3",
6278
"react": "18.2.0",
6379
"react-native": "0.71.1",
6480
"react-test-renderer": "18.2.0",

src/network/barricade.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ export class Barricade {
9797
}
9898
}
9999
const result = request as RequestConfigForLib;
100-
result.selectedResponseLabel = selectedItem!.label;
100+
result.selectedResponseLabel = selectedItem?.label;
101101

102102
return result;
103103
}
@@ -243,7 +243,7 @@ export class Barricade {
243243
xhr.responseType = request.responseType;
244244
xhr.timeout = request.timeout ?? 0;
245245
xhr.withCredentials = request.withCredentials;
246-
for (let h in request._headers) {
246+
for (const h in request._headers) {
247247
xhr.setRequestHeader(h, request._headers[h]);
248248
}
249249

0 commit comments

Comments
 (0)