Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- npm install --save-dev eslint prettier eslint-plugin-react eslint-plugin-react-native eslint-config-prettier eslint-plugin-prettier
- .eslintrc.js
- module.exports = {
- env: {
- browser: true,
- es2021: true,
- },
- extends: [
- 'eslint:recommended',
- 'plugin:react/recommended',
- 'plugin:react-native/all',
- 'prettier',
- ],
- parserOptions: {
- ecmaFeatures: {
- jsx: true,
- },
- ecmaVersion: 12,
- sourceType: 'module',
- },
- plugins: ['react', 'react-native', 'prettier'],
- rules: {
- 'prettier/prettier': 'error',
- 'react/react-in-jsx-scope': 'off', // Not needed with React 17+
- 'react/prop-types': 'off', // Optional if not using PropTypes
- 'react-native/no-inline-styles': 'warn', // Warning for inline styles
- },
- };
- .prettierrc
- {
- "singleQuote": true,
- "trailingComma": "es5",
- "tabWidth": 2,
- "semi": true,
- "jsxSingleQuote": false,
- "bracketSpacing": true
- }
- .prettierignore
- node_modules
- build
- package.json
- "scripts": {
- "lint": "eslint . --ext .js,.jsx,.ts,.tsx",
- "format": "prettier --write \"**/*.{js,jsx,ts,tsx,json,css,md}\""
- }
- npx husky-init && npm install
- npm install --save-dev lint-staged
- "husky": {
- "hooks": {
- "pre-commit": "lint-staged"
- }
- },
- "lint-staged": {
- "*.{js,jsx,ts,tsx}": "eslint --fix",
- "*.{js,jsx,ts,tsx,json,css,md}": "prettier --write"
- }
Advertisement
Add Comment
Please, Sign In to add comment