diff --git a/.husky/commit-msg b/.husky/commit-msg new file mode 100755 index 0000000..a4dc436 --- /dev/null +++ b/.husky/commit-msg @@ -0,0 +1 @@ +npx commitlint --edit diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100755 index 0000000..2312dc5 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1 @@ +npx lint-staged diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..93463ee --- /dev/null +++ b/.prettierrc @@ -0,0 +1,10 @@ +{ + "printWidth": 120, + "tabWidth": 2, + "useTabs": false, + "semi": true, + "singleQuote": true, + "trailingComma": "all", + "bracketSpacing": true, + "jsxBracketSameLine": true + } \ No newline at end of file diff --git a/commitlint.config.js b/commitlint.config.js new file mode 100644 index 0000000..9dd3ffe --- /dev/null +++ b/commitlint.config.js @@ -0,0 +1,2 @@ +// commitlint.config.js +module.exports = { extends: ['@commitlint/config-conventional'] }; diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 0000000..32a72e3 --- /dev/null +++ b/eslint.config.js @@ -0,0 +1,45 @@ +const prettier = require('eslint-plugin-prettier'); + +module.exports = [ + { + files: ['**/*.ts', '**/*.tsx'], + ignores: ['node_modules/**', 'build/**', 'dist/**'], + languageOptions: { + parserOptions: { + parser: '@typescript-eslint/parser', + ecmaVersion: 'latest', + sourceType: 'module', + ecmaFeatures: { + jsx: true, // Enable JSX support + }, + }, + globals: { + React: 'readonly', + }, + }, + plugins: { + '@typescript-eslint': require('@typescript-eslint/eslint-plugin'), + react: require('eslint-plugin-react'), + 'react-native': require('eslint-plugin-react-native'), + prettier: prettier, + }, + rules: { + semi: ['warn', 'always'], + 'prefer-const': 'error', + 'react-native/no-unused-styles': 'warn', + 'react-native/split-platform-components': 'warn', + 'react-native/no-inline-styles': 'error', + 'react/jsx-filename-extension': ['error', { extensions: ['.tsx'] }], + '@typescript-eslint/explicit-function-return-type': 'off', + '@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_' }], + '@typescript-eslint/colon-trailing-spacing': ['off'], + 'prettier/prettier': [ + 'warn', + { + endOfLine: 'auto', + usePrettierrc: true, // Use .prettierrc file for configuration + }, + ], + }, + }, +]; diff --git a/package.json b/package.json index d534d4c..57b8e1c 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,8 @@ "web": "expo start --web", "test": "jest --watchAll", "lint": "expo lint", - "prebuild": "EXPO_TV=1 expo prebuild --clean" + "prebuild": "EXPO_TV=1 expo prebuild --clean", + "prepare": "husky install" }, "jest": { "preset": "jest-expo" @@ -19,16 +20,20 @@ "@expo/vector-icons": "^14.0.0", "@react-navigation/drawer": "^6.6.15", "@react-navigation/native": "^6.0.2", + "@typescript-eslint/eslint-plugin": "^8.12.2", + "@typescript-eslint/parser": "^8.12.2", "expo": "~51.0.13", "expo-build-properties": "~0.12.3", "expo-constants": "~16.0.2", "expo-font": "~12.0.7", + "expo-linear-gradient": "~13.0.2", "expo-linking": "~6.3.1", "expo-router": "~3.5.16", "expo-splash-screen": "~0.27.5", "expo-status-bar": "~1.12.1", "expo-system-ui": "~3.0.6", "expo-web-browser": "~13.0.3", + "lint-staged": "^15.2.10", "react": "18.2.0", "react-dom": "18.2.0", "react-native": "npm:react-native-tvos@~0.74.2-0", @@ -38,22 +43,38 @@ "react-native-safe-area-context": "4.10.1", "react-native-screens": "3.31.1", "react-native-web": "~0.19.10", - "react-tv-space-navigation": "^3.6.1", - "expo-linear-gradient": "~13.0.2" + "react-tv-space-navigation": "^3.6.1" }, "devDependencies": { "@babel/core": "^7.20.0", - "babel-plugin-module-resolver": "^4.1.0", + "@commitlint/cli": "^19.5.0", + "@commitlint/config-conventional": "^19.5.0", "@react-native-tvos/config-tv": "^0.0.10", "@types/jest": "^29.5.12", "@types/react": "~18.2.45", "@types/react-test-renderer": "^18.0.7", + "babel-plugin-module-resolver": "^4.1.0", + "eslint": "^9.13.0", + "eslint-plugin-prettier": "^5.2.1", + "eslint-plugin-react": "^7.37.1", + "eslint-plugin-react-native": "^4.1.0", + "husky": "^9.1.6", "jest": "^29.2.1", "jest-expo": "~51.0.1", + "prettier": "^3.3.3", "react-native-pixel-perfect": "^1.0.2", "react-test-renderer": "18.2.0", "typescript": "~5.3.3" }, + "lint-staged": { + "*.js": [ + "eslint --fix", + "prettier --write" + ], + "*.tsx": [ + "prettier --write" + ] + }, "expo": { "install": { "exclude": [