├── .eslintrc.js └── README.md /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | parser: 'babel-eslint', 4 | extends: ['airbnb', 'prettier', 'plugin:flowtype/recommended'], 5 | plugins: ['react', 'react-native', 'jsx-a11y', 'import', 'react-hooks'], 6 | parserOptions: { 7 | ecmaFeatures: { 8 | jsx: true 9 | } 10 | }, 11 | env: { 12 | 'react-native/react-native': true 13 | }, 14 | rules: { 15 | 'react-hooks/rules-of-hooks': 'error', 16 | 'react-hooks/exhaustive-deps': 'warn', 17 | 'react/jsx-filename-extension': ['off'], 18 | 'react/jsx-one-expression-per-line': 0, 19 | 'linebreak-style': ['off'], 20 | 'implicit-arrow-linebreak': 0, 21 | 'no-undef': ['error'], 22 | 'react/sort-comp': ['off'], 23 | 'react/prefer-stateless-function': ['off'], 24 | 'react/destructuring-assignment': 1, 25 | 'function-paren-newline': 0, 26 | semi: ['error', 'never'], 27 | 'spaced-comment': 0, 28 | 'comma-dangle': ['error', 'never'], 29 | 'react/prop-types': 0, 30 | 'no-extra-boolean-cast': 0, 31 | 'quote-props': 0, 32 | 'object-curly-spacing': ['error', 'always'], 33 | camelcase: 0, 34 | 'no-nested-ternary': 0, 35 | 'react/jsx-wrap-multilines': 0, 36 | 'object-curly-newline': 0, 37 | 'operator-linebreak': 0, 38 | 'no-unused-expressions': 0, 39 | 'global-require': 0, 40 | 'max-len': 0, 41 | 'import/no-cycle': 0, 42 | 'no-underscore-dangle': 0, 43 | 'no-return-assign': 0, 44 | 'import/prefer-default-export': 0, 45 | 'jsx-quotes': ['error', 'prefer-double'], 46 | 'no-console': 'error', 47 | 'arrow-parens': 0, 48 | 'eol-last': 0, 49 | 'react/destructuring-assignment': 0, 50 | 'react-native/no-unused-styles': 0, 51 | 'react-native/split-platform-components': 0, 52 | 'react-native/no-inline-styles': 0, 53 | 'react-native/no-color-literals': 0, 54 | 'react-native/no-raw-text': 0, 55 | 'consistent-return': 0 56 | }, 57 | settings: { 58 | 'import/resolver': { 59 | node: { 60 | extensions: ['.js', '.ios.js', '.android.js'] 61 | } 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # eslint + prettierrc 2 | 3 | ### step 1 4 | ``` 5 | yarn add eslint eslint-config-airbnb babel-preset-airbnb eslint-plugin-import eslint-plugin-jsx-a11y eslint-plugin-react eslint-watch babel-core babel-eslint babel-preset-react-native pre-commit prettier prettier-eslint eslint-plugin-prettier eslint-config-prettier eslint-plugin-react eslint-plugin-react-native eslint-plugin-flowtype eslint-plugin-react-hooks --dev 6 | ``` 7 | 8 | ### step 2 9 | edit .eslintrc.js 10 | 11 | ```js 12 | module.exports = { 13 | root: true, 14 | parser: 'babel-eslint', 15 | extends: ['airbnb', 'prettier', 'plugin:flowtype/recommended'], 16 | plugins: ['react', 'react-native', 'jsx-a11y', 'import', 'react-hooks'], 17 | parserOptions: { 18 | ecmaFeatures: { 19 | jsx: true 20 | } 21 | }, 22 | env: { 23 | 'react-native/react-native': true 24 | }, 25 | rules: { 26 | 'react-hooks/rules-of-hooks': 'error', 27 | 'react-hooks/exhaustive-deps': 'warn', 28 | 'react/jsx-filename-extension': ['off'], 29 | 'react/jsx-one-expression-per-line': 0, 30 | 'linebreak-style': ['off'], 31 | 'implicit-arrow-linebreak': 0, 32 | 'no-undef': ['error'], 33 | 'react/sort-comp': ['off'], 34 | 'react/prefer-stateless-function': ['off'], 35 | 'react/destructuring-assignment': 1, 36 | 'function-paren-newline': 0, 37 | semi: ['error', 'never'], 38 | 'spaced-comment': 0, 39 | 'comma-dangle': ['error', 'never'], 40 | 'react/prop-types': 0, 41 | 'no-extra-boolean-cast': 0, 42 | 'quote-props': 0, 43 | 'object-curly-spacing': ['error', 'always'], 44 | camelcase: 0, 45 | 'no-nested-ternary': 0, 46 | 'react/jsx-wrap-multilines': 0, 47 | 'object-curly-newline': 0, 48 | 'operator-linebreak': 0, 49 | 'no-unused-expressions': 0, 50 | 'global-require': 0, 51 | 'max-len': 0, 52 | 'import/no-cycle': 0, 53 | 'no-underscore-dangle': 0, 54 | 'no-return-assign': 0, 55 | 'import/prefer-default-export': 0, 56 | 'jsx-quotes': ['error', 'prefer-double'], 57 | 'no-console': 'error', 58 | 'arrow-parens': 0, 59 | 'eol-last': 0, 60 | 'react/destructuring-assignment': 0, 61 | 'react-native/no-unused-styles': 0, 62 | 'react-native/split-platform-components': 0, 63 | 'react-native/no-inline-styles': 0, 64 | 'react-native/no-color-literals': 0, 65 | 'react-native/no-raw-text': 0, 66 | 'consistent-return': 0 67 | }, 68 | settings: { 69 | 'import/resolver': { 70 | node: { 71 | extensions: ['.js', '.ios.js', '.android.js'] 72 | } 73 | } 74 | } 75 | } 76 | ``` 77 | 78 | ### step 3 79 | edit .prettierrc.js 80 | ``` 81 | module.exports = { 82 | singleQuote: true, 83 | printWidth: 120, 84 | tabWidth: 2, 85 | trailingComma: 'none', 86 | bracketSpacing: true, 87 | semi: false, 88 | useTabs: false, 89 | jsxBracketSameLine: false 90 | } 91 | ``` 92 | 93 | 94 | 95 | ### step 4 96 | Open up your package.json and make the following updates. 97 | ``` 98 | "scripts": { 99 | "ios": "react-native run-ios --simulator='iPhone SE'", 100 | "android": "react-native run-android", 101 | "lint": "esw src/**", 102 | "lint-watch": "esw -w --changed src/**", 103 | "postinstall":"cd ./ios && pod install && cd .." 104 | }, 105 | "precommit": "lint", 106 | ``` 107 | 108 | ### step 5 109 | create folder `src` and to transfer flie `src/index.js` 110 | 111 | ### step 6 112 | restart project 113 | `yarn start-ios` 114 | or 115 | `yarn start-android` 116 | 117 | ### done 118 | --------------------------------------------------------------------------------