Merge pull request 'Install eslint' (#3) from linter into master

Reviewed-on: billnerds/rn-playground#3
Reviewed-by: Ivan Malison <ivanmalison@gmail.com>
This commit is contained in:
Kat Huang 2024-01-05 19:06:40 -07:00
commit b1467838da
3 changed files with 1240 additions and 31 deletions

64
.eslintrc.js Normal file
View File

@ -0,0 +1,64 @@
module.exports = {
"env": {
"browser": true,
"es2021": true,
"node": true
},
"extends": "plugin:react/recommended",
"overrides": [
{
"env": {
"node": true
},
"files": [
".eslintrc.{js,cjs}"
],
"parserOptions": {
"sourceType": "script"
}
}
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"plugins": [
"@typescript-eslint",
"react",
"react-hooks",
"react-native"
],
"rules": {
// Enforce tab width of 4 spaces
"indent": ["error", 4, { "SwitchCase": 1 }],
// Best Practices
"eqeqeq": ["error", "always"], // Enforce '===' instead of '=='
"curly": "error", // Require curly braces for all control statements
"no-unused-vars": "warn", // Warn about variables that are declared but not used
// Stylistic Issues
"quotes": ["error", "single"], // Enforce single quotes
"semi": ["error", "always"], // Enforce semicolons at the end of statements
"no-multi-spaces": "error", // Disallow multiple spaces that are not used for indentation
"comma-dangle": ["error", "always-multiline"], // Require trailing commas for multiline
// React Specific
"react/jsx-filename-extension": [1, { "extensions": [".tsx"] }], // Allow jsx syntax in .tsx files
"react/react-in-jsx-scope": "off", // Not necessary with React 17+
"react/prop-types": "off", // Not needed with TypeScript
// React-Native Specific
"react-native/no-unused-styles": "warn", // Warn about unused styles
"react-native/split-platform-components": "warn", // Encourage splitting of React Native components into platform-specific files
// TypeScript Specific
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-unused-vars": ["warn", { "argsIgnorePattern": "^_" }], // Warn about variables that are declared but not used
// Hooks Specific
"react-hooks/rules-of-hooks": "error", // Checks rules of Hooks
"react-hooks/exhaustive-deps": "warn", // Checks effect dependencies
},
};

View File

@ -6,13 +6,22 @@
"start": "expo start", "start": "expo start",
"android": "expo start --android", "android": "expo start --android",
"ios": "expo start --ios", "ios": "expo start --ios",
"web": "expo start --web" "web": "expo start --web",
"lint": "eslint . --ext .js,.ts,.tsx",
"lint:fix": "eslint . --ext .ts,.tsx --fix"
}, },
"dependencies": { "dependencies": {
"@typescript-eslint/eslint-plugin": "^6.17.0",
"@typescript-eslint/parser": "^6.17.0",
"eslint": "^8.56.0",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-native": "^4.1.0",
"expo": "~49.0.15", "expo": "~49.0.15",
"expo-status-bar": "~1.6.0", "expo-status-bar": "~1.6.0",
"react": "18.2.0", "react": "18.2.0",
"react-native": "0.72.6" "react-native": "0.72.6",
"typescript": "^5.3.3"
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.20.0" "@babel/core": "^7.20.0"

1194
yarn.lock

File diff suppressed because it is too large Load Diff