Last active
December 19, 2024 13:28
-
-
Save Henriquetf/fdee0bc7ed5af922e27985c2a0da69f4 to your computer and use it in GitHub Desktop.
React Native Typescript ESLint config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"env": { | |
"es6": true | |
}, | |
"extends": [ | |
"plugin:react/recommended", | |
"plugin:@typescript-eslint/recommended", | |
"airbnb", | |
"plugin:import/errors", | |
"plugin:import/warnings", | |
"plugin:import/typescript", | |
"prettier", | |
"prettier/react", | |
"prettier/@typescript-eslint" | |
], | |
"globals": { | |
"Atomics": "readonly", | |
"SharedArrayBuffer": "readonly", | |
"__DEV__": "readonly" | |
}, | |
"parser": "@typescript-eslint/parser", | |
"parserOptions": { | |
"ecmaFeatures": { | |
"jsx": true | |
}, | |
"ecmaVersion": 2018, | |
"sourceType": "module" | |
}, | |
"plugins": ["react", "react-hooks", "@typescript-eslint", "prettier"], | |
"rules": { | |
"prettier/prettier": "error", | |
"no-console": ["warn", { "allow": ["tron"] }], | |
"spaced-comment": ["error", "always", { "markers": ["/"] }], | |
"import/prefer-default-export": "off", | |
"class-methods-use-this": "off", | |
"no-unused-expressions": "off", | |
"no-unused-vars": "off", | |
// TypeScript | |
"@typescript-eslint/no-non-null-assertion": "off", | |
"@typescript-eslint/explicit-function-return-type": "off", | |
"@typescript-eslint/no-unused-expressions": "error", | |
// React | |
"react/jsx-props-no-spreading": "off", | |
"react/jsx-filename-extension": [ | |
"warn", | |
{ | |
"extensions": [".js", ".jsx", ".ts", ".tsx"] | |
} | |
], | |
"react/prop-types": "off", | |
// React Hooks | |
"react-hooks/rules-of-hooks": "error", | |
"react-hooks/exhaustive-deps": "warn", | |
"import/extensions": [ | |
"error", | |
"ignorePackages", | |
{ | |
"js": "never", | |
"jsx": "never", | |
"ts": "never", | |
"tsx": "never" | |
} | |
] | |
}, | |
"settings": { | |
"import/resolver": { | |
"node": { | |
"paths": ["./src"] | |
}, | |
"babel-module": {} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"singleQuote": true, | |
"trailingComma": "all" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function getBabelConfig(api) { | |
api.cache(true); | |
const plugins = [ | |
[ | |
require.resolve('babel-plugin-module-resolver'), | |
{ | |
alias: { | |
'~': './src', | |
}, | |
extensions: ['.js', '.ts', '.tsx'], | |
}, | |
], | |
]; | |
return { | |
presets: ['module:metro-react-native-babel-preset'], | |
plugins, | |
}; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"scripts": { | |
"lint": "yarn lint:ts && yarn lint:style", | |
"lint:ts": "tsc --noEmit", | |
"lint:style": "eslint \"**/*.{js,ts,jsx,tsx}\"", | |
"lint:fix": "eslint \"**/*.{js,ts,jsx,tsx}\" --quiet --fix" | |
}, | |
"devDependencies": { | |
"@types/react": "^16.9.20", | |
"@types/react-native": "^0.61.16", | |
"@typescript-eslint/eslint-plugin": "^2.20.0", | |
"@typescript-eslint/parser": "^2.20.0", | |
"babel-plugin-module-resolver": "^4.0.0", | |
"eslint": "^6.8.0", | |
"eslint-config-airbnb": "^18.0.1", | |
"eslint-config-prettier": "^6.10.0", | |
"eslint-import-resolver-babel-module": "^5.1.2", | |
"eslint-plugin-import": "^2.20.1", | |
"eslint-plugin-jsx-a11y": "^6.2.3", | |
"eslint-plugin-prettier": "^3.1.2", | |
"eslint-plugin-react": "^7.18.3", | |
"eslint-plugin-react-hooks": "^2.4.0", | |
"prettier": "^1.19.1", | |
"typescript": "^3.7.5" | |
}, | |
"jest": { | |
"preset": "react-native" | |
}, | |
"private": true | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"compilerOptions": { | |
"target": "esnext", | |
"module": "commonjs", | |
"lib": ["es6"], | |
"allowJs": true, | |
"jsx": "react-native", | |
"noEmit": true, | |
"incremental": true, | |
"isolatedModules": true, | |
"strict": true, | |
"moduleResolution": "node", | |
"baseUrl": "./src", | |
"resolveJsonModule": true, | |
"paths": { | |
"~/*": ["*"] | |
}, | |
"allowSyntheticDefaultImports": true, | |
"esModuleInterop": true, | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment