Make eslint compatible with prettier

This commit is contained in:
Ivan Malison 2024-01-06 19:32:00 -07:00
parent 160590658b
commit ed8371e08a
3 changed files with 55 additions and 64 deletions

View File

@ -1,56 +1,40 @@
module.exports = { module.exports = {
"settings": { settings: {
"react": { react: {
"version": "detect", version: "detect",
}, },
}, },
"env": { env: {
"browser": true, browser: true,
"es2021": true, es2021: true,
"node": true, node: true,
}, },
"extends": "plugin:react/recommended", extends: ["plugin:react/recommended", "prettier"],
"overrides": [ overrides: [
{ {
"env": { env: {
"node": true, node: true,
}, },
"files": [ files: [".eslintrc.{js,cjs}"],
".eslintrc.{js,cjs}", parserOptions: {
], sourceType: "script",
"parserOptions": {
"sourceType": "script",
}, },
}, },
], ],
"parser": "@typescript-eslint/parser", parser: "@typescript-eslint/parser",
"parserOptions": { parserOptions: {
"ecmaVersion": "latest", ecmaVersion: "latest",
"sourceType": "module", sourceType: "module",
}, },
"plugins": [ plugins: ["@typescript-eslint", "react", "react-hooks", "react-native"],
"@typescript-eslint", rules: {
"react",
"react-hooks",
"react-native",
],
"rules": {
// Enforce tab width of 4 spaces
"indent": ["error", 4, { "SwitchCase": 1 }],
// Best Practices // Best Practices
"eqeqeq": ["error", "always"], // Enforce '===' instead of '==' eqeqeq: ["error", "always"], // Enforce '===' instead of '=='
"curly": "error", // Require curly braces for all control statements curly: "error", // Require curly braces for all control statements
"no-unused-vars": "warn", // Warn about variables that are declared but not used "no-unused-vars": "warn", // Warn about variables that are declared but not used
// Stylistic Issues
"quotes": ["error", "double"], // Enforce double 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 Specific
"react/jsx-filename-extension": [1, { "extensions": [".tsx"] }], // Allow jsx syntax in .tsx files "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/react-in-jsx-scope": "off", // Not necessary with React 17+
"react/prop-types": "off", // Not needed with TypeScript "react/prop-types": "off", // Not needed with TypeScript
@ -60,7 +44,7 @@ module.exports = {
// TypeScript Specific // TypeScript Specific
"@typescript-eslint/explicit-function-return-type": "off", "@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-unused-vars": ["warn", { "argsIgnorePattern": "^_" }], // Warn about variables that are declared but not used "@typescript-eslint/no-unused-vars": ["warn", { argsIgnorePattern: "^_" }], // Warn about variables that are declared but not used
// Hooks Specific // Hooks Specific
"react-hooks/rules-of-hooks": "error", // Checks rules of Hooks "react-hooks/rules-of-hooks": "error", // Checks rules of Hooks

View File

@ -17,7 +17,8 @@
"preset": "jest-expo", "preset": "jest-expo",
"transformIgnorePatterns": [ "transformIgnorePatterns": [
"node_modules/(?!((jest-)?react-native|@react-native(-community)?)|expo(nent)?|@expo(nent)?/.*|@expo-google-fonts/.*|react-navigation|@react-navigation/.*|@unimodules/.*|unimodules|sentry-expo|native-base|react-native-svg)" "node_modules/(?!((jest-)?react-native|@react-native(-community)?)|expo(nent)?|@expo(nent)?/.*|@expo-google-fonts/.*|react-navigation|@react-navigation/.*|@unimodules/.*|unimodules|sentry-expo|native-base|react-native-svg)"
]}, ]
},
"dependencies": { "dependencies": {
"@types/react": "~18.2.14", "@types/react": "~18.2.14",
"@typescript-eslint/eslint-plugin": "^6.17.0", "@typescript-eslint/eslint-plugin": "^6.17.0",
@ -37,7 +38,8 @@
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.20.0", "@babel/core": "^7.20.0",
"@types/jest": "^29.5.11" "@types/jest": "^29.5.11",
"eslint-config-prettier": "^9.1.0"
}, },
"private": true "private": true
} }

View File

@ -3966,6 +3966,11 @@ escodegen@^2.0.0:
optionalDependencies: optionalDependencies:
source-map "~0.6.1" source-map "~0.6.1"
eslint-config-prettier@^9.1.0:
version "9.1.0"
resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-9.1.0.tgz#31af3d94578645966c082fcb71a5846d3c94867f"
integrity sha512-NSWl5BFQWEPi1j4TjVNItzYV7dZXZ+wP6I6ZhrBGpChQhZRUaElihE9uRRkcbRnNb76UMKDF3r+WTmNcGPKsqw==
eslint-plugin-react-hooks@^4.6.0: eslint-plugin-react-hooks@^4.6.0:
version "4.6.0" version "4.6.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-4.6.0.tgz#4c3e697ad95b77e93f8646aaa1630c1ba607edd3" resolved "https://registry.yarnpkg.com/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-4.6.0.tgz#4c3e697ad95b77e93f8646aaa1630c1ba607edd3"