Skip to content

Commit

Permalink
feat: added elint, prettier and husky
Browse files Browse the repository at this point in the history
  • Loading branch information
burhanyilmaz committed Jan 7, 2024
1 parent 00b8807 commit 71f2c6c
Show file tree
Hide file tree
Showing 11 changed files with 125 additions and 9 deletions.
1 change: 1 addition & 0 deletions .eslintcache
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"/Users/burhanyilmaz/girisim/womob/src/screens/Test/index.tsx":"1"},{"size":149,"mtime":1704617600996,"results":"2","hashOfConfig":"3"},{"filePath":"4","messages":"5","suppressedMessages":"6","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"10og7mo","/Users/burhanyilmaz/girisim/womob/src/screens/Test/index.tsx",[],[]]
24 changes: 24 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
module.exports = {
root: true,
extends: ['universe/native'],
rules: {
'@typescript-eslint/no-shadow': ['error'],
'no-shadow': 'off',
'no-undef': 'off',
indent: ['error', 2],
quotes: ['error', 'single'],
semi: ['error', 'always'],
'no-console': ['error'],
'@typescript-eslint/no-unused-vars': ['error'],
'no-use-before-define': 'off',
'newline-before-return': ['error'],
'react-hooks/exhaustive-deps': 0,
'react/function-component-definition': 0,
'arrow-body-style': [1, 'as-needed'],
'object-curly-spacing': ['error', 'always'],
'eslint-disable-next-line': 'off',
'prettier/prettier': 'error',
'import/newline-after-import': ['error'],
'padding-line-between-statements': ['error', { blankLine: 'always', prev: '*', next: 'export' }],
},
};
1 change: 1 addition & 0 deletions .husky/_/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*
36 changes: 36 additions & 0 deletions .husky/_/husky.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env sh
if [ -z "$husky_skip_init" ]; then
debug () {
if [ "$HUSKY_DEBUG" = "1" ]; then
echo "husky (debug) - $1"
fi
}

readonly hook_name="$(basename -- "$0")"
debug "starting $hook_name..."

if [ "$HUSKY" = "0" ]; then
debug "HUSKY env variable is set to 0, skipping hook"
exit 0
fi

if [ -f ~/.huskyrc ]; then
debug "sourcing ~/.huskyrc"
. ~/.huskyrc
fi

readonly husky_skip_init=1
export husky_skip_init
sh -e "$0" "$@"
exitCode="$?"

if [ $exitCode != 0 ]; then
echo "husky - $hook_name hook exited with code $exitCode (error)"
fi

if [ $exitCode = 127 ]; then
echo "husky - command not found in PATH=$PATH"
fi

exit $exitCode
fi
19 changes: 19 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

if yarn run format; then
echo "✅ Code is formatted."
else
echo "❌ Code is not formatted. And maybe you need this command ⚠️ ⚠️ ⚠️ git add . ⚠️ ⚠️ ⚠️"
exit 1
fi


if yarn validate ; then
echo "✅ Code is valid."
else
yarn validate --fix
echo "❌ Code is invalid. And maybe you need this command ⚠️ ⚠️ ⚠️ git add . ⚠️ ⚠️ ⚠️"
exit 1
fi

9 changes: 9 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = {
arrowParens: 'avoid',
bracketSameLine: true,
tabWidth: 2,
semi: true,
singleQuote: true,
bracketSpacing: true,
printWidth: 1200,
}
8 changes: 3 additions & 5 deletions App.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { StatusBar } from "expo-status-bar";
import { Text, View } from "react-native";
import { StatusBar } from 'expo-status-bar';
import { Text, View } from 'react-native';

export default function App() {
return (
<View className="flex-1 items-center justify-center bg-white">
<Text>
Open up App.tsx to start working on your app!
</Text>
<Text>Open up App.tsx to start working on your app!</Text>
<StatusBar style="auto" />
</View>
);
Expand Down
5 changes: 3 additions & 2 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
module.exports = function(api) {
module.exports = function (api) {
api.cache(true);

return {
presets: ['babel-preset-expo'],
plugins: ["nativewind/babel"]
plugins: ['nativewind/babel'],
};
};
Binary file modified bun.lockb
Binary file not shown.
22 changes: 20 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web"
"web": "expo start --web",
"lint": "eslint --cache \"./src/**/*.{ts,tsx,jsx,js}\" --max-warnings=0",
"lint:fix": "yarn lint --fix ",
"validate": "yarn prettier --check \"./src/**/*.{ts,tsx,js,jsx}\" && yarn lint ",
"format": "prettier --write \"./src/**/*.{ts,tsx,js,jsx}\"",
"format:test": "prettier --write \"./src/**/*.spec.{ts,tsx,js,jsx}\"",
"husky:install": "husky install",
"build:android:local": "eas build --platform android --local --profile preview"
},
"dependencies": {
"expo": "~49.0.15",
Expand All @@ -18,8 +25,19 @@
"devDependencies": {
"@babel/core": "^7.20.0",
"@types/react": "~18.2.14",
"@typescript-eslint/eslint-plugin": "^6.4.0",
"eslint": "^8.56.0",
"eslint-config-standard-with-typescript": "^43.0.0",
"eslint-config-universe": "^12.0.0",
"eslint-plugin-import": "^2.25.2",
"eslint-plugin-n": "^15.0.0 || ^16.0.0 ",
"eslint-plugin-prettier": "^5.1.2",
"eslint-plugin-promise": "^6.0.0",
"eslint-plugin-react": "^7.33.2",
"husky": "^8.0.3",
"prettier": "^3.1.1",
"tailwindcss": "3.3.2",
"typescript": "^5.1.3"
"typescript": "*"
},
"private": true
}
9 changes: 9 additions & 0 deletions src/screens/Test/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Text, View } from 'react-native';

const TestScreen = () => (
<View>
<Text>TestScreen</Text>
</View>
);

export default TestScreen;

0 comments on commit 71f2c6c

Please sign in to comment.