Merge pull request 'Add prettier' (#9) from ivan/add-prettier into master
Reviewed-on: billnerds/rn-playground#9
This commit is contained in:
commit
521e9da4e3
4
.dir-locals.el
Normal file
4
.dir-locals.el
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
((nil
|
||||||
|
.
|
||||||
|
((lsp-pylsp-server-command . ("poetry" "run" "pylsp"))
|
||||||
|
(apheleia-inhibit . nil))))
|
106
.eslintrc.js
106
.eslintrc.js
@ -1,69 +1,53 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
"settings": {
|
settings: {
|
||||||
"react": {
|
react: {
|
||||||
"version": "detect",
|
version: "detect",
|
||||||
},
|
|
||||||
},
|
},
|
||||||
"env": {
|
},
|
||||||
"browser": true,
|
env: {
|
||||||
"es2021": true,
|
browser: true,
|
||||||
"node": true,
|
es2021: true,
|
||||||
|
node: true,
|
||||||
|
},
|
||||||
|
extends: ["plugin:react/recommended", "prettier"],
|
||||||
|
overrides: [
|
||||||
|
{
|
||||||
|
env: {
|
||||||
|
node: true,
|
||||||
|
},
|
||||||
|
files: [".eslintrc.{js,cjs}"],
|
||||||
|
parserOptions: {
|
||||||
|
sourceType: "script",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
"extends": "plugin:react/recommended",
|
],
|
||||||
"overrides": [
|
parser: "@typescript-eslint/parser",
|
||||||
{
|
parserOptions: {
|
||||||
"env": {
|
ecmaVersion: "latest",
|
||||||
"node": true,
|
sourceType: "module",
|
||||||
},
|
},
|
||||||
"files": [
|
plugins: ["@typescript-eslint", "react", "react-hooks", "react-native"],
|
||||||
".eslintrc.{js,cjs}",
|
rules: {
|
||||||
],
|
// Best Practices
|
||||||
"parserOptions": {
|
eqeqeq: ["error", "always"], // Enforce '===' instead of '=='
|
||||||
"sourceType": "script",
|
curly: "error", // Require curly braces for all control statements
|
||||||
},
|
"no-unused-vars": "warn", // Warn about variables that are declared but not used
|
||||||
},
|
|
||||||
],
|
|
||||||
"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
|
// React Specific
|
||||||
"eqeqeq": ["error", "always"], // Enforce '===' instead of '=='
|
"react/jsx-filename-extension": [1, { extensions: [".tsx"] }], // Allow jsx syntax in .tsx files
|
||||||
"curly": "error", // Require curly braces for all control statements
|
"react/react-in-jsx-scope": "off", // Not necessary with React 17+
|
||||||
"no-unused-vars": "warn", // Warn about variables that are declared but not used
|
"react/prop-types": "off", // Not needed with TypeScript
|
||||||
|
|
||||||
// Stylistic Issues
|
// React-Native Specific
|
||||||
"quotes": ["error", "double"], // Enforce double quotes
|
"react-native/no-unused-styles": "warn", // Warn about unused styles
|
||||||
"semi": ["error", "always"], // Enforce semicolons at the end of statements
|
"react-native/split-platform-components": "warn", // Encourage splitting of React Native components into platform-specific files
|
||||||
"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
|
// TypeScript Specific
|
||||||
"react/jsx-filename-extension": [1, { "extensions": [".tsx"] }], // Allow jsx syntax in .tsx files
|
"@typescript-eslint/explicit-function-return-type": "off",
|
||||||
"react/react-in-jsx-scope": "off", // Not necessary with React 17+
|
"@typescript-eslint/no-unused-vars": ["warn", { argsIgnorePattern: "^_" }], // Warn about variables that are declared but not used
|
||||||
"react/prop-types": "off", // Not needed with TypeScript
|
|
||||||
|
|
||||||
// React-Native Specific
|
// Hooks Specific
|
||||||
"react-native/no-unused-styles": "warn", // Warn about unused styles
|
"react-hooks/rules-of-hooks": "error", // Checks rules of Hooks
|
||||||
"react-native/split-platform-components": "warn", // Encourage splitting of React Native components into platform-specific files
|
"react-hooks/exhaustive-deps": "warn", // Checks effect dependencies
|
||||||
|
},
|
||||||
// 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
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
12
App.tsx
12
App.tsx
@ -1,14 +1,12 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { SafeAreaView, Text } from "react-native";
|
import { SafeAreaView, Text } from "react-native";
|
||||||
|
|
||||||
|
|
||||||
const App: React.FC = () => {
|
const App: React.FC = () => {
|
||||||
return (
|
return (
|
||||||
<SafeAreaView>
|
<SafeAreaView>
|
||||||
<Text>Hello, World!</Text>
|
<Text>Hello, World!</Text>
|
||||||
</SafeAreaView>
|
</SafeAreaView>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export default App;
|
export default App;
|
||||||
|
@ -53,7 +53,7 @@
|
|||||||
in with pkgs; {
|
in with pkgs; {
|
||||||
defaultPackage = appBuild;
|
defaultPackage = appBuild;
|
||||||
devShell = mkShell {
|
devShell = mkShell {
|
||||||
buildInputs = [ nodejs yarn watchman gradle_7 alejandra ];
|
buildInputs = [ nodejs yarn watchman gradle_7 alejandra nodePackages.prettier ];
|
||||||
ANDROID_SDK_BIN = android-sdk;
|
ANDROID_SDK_BIN = android-sdk;
|
||||||
shellHook = ''
|
shellHook = ''
|
||||||
export JAVA_HOME=${pkgs.jdk17.home}
|
export JAVA_HOME=${pkgs.jdk17.home}
|
||||||
|
@ -16,8 +16,9 @@
|
|||||||
"jest": {
|
"jest": {
|
||||||
"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
|
||||||
}
|
}
|
||||||
|
@ -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"
|
||||||
|
Loading…
Reference in New Issue
Block a user