|
| 1 | +const OFF = 0; |
| 2 | +const WARN = 1; |
| 3 | +const ERROR = 2; |
| 4 | + |
| 5 | +module.exports = { |
| 6 | + extends: ['@react-native-community', 'prettier'], |
| 7 | + plugins: ['prettier'], |
| 8 | + root: true, |
| 9 | + ignorePatterns: ['.eslintrc.js'], |
| 10 | + rules: { |
| 11 | + 'prettier/prettier': [ |
| 12 | + 'error', |
| 13 | + {}, |
| 14 | + { |
| 15 | + usePrettierrc: true, |
| 16 | + }, |
| 17 | + ], |
| 18 | + 'prefer-const': 'warn', |
| 19 | + 'no-console': ['error', { allow: ['warn', 'error'] }], |
| 20 | + // General |
| 21 | + indent: [ |
| 22 | + OFF, |
| 23 | + 2, |
| 24 | + { |
| 25 | + SwitchCase: 1, |
| 26 | + VariableDeclarator: 1, |
| 27 | + outerIIFEBody: 1, |
| 28 | + FunctionDeclaration: { |
| 29 | + parameters: 1, |
| 30 | + body: 1, |
| 31 | + }, |
| 32 | + FunctionExpression: { |
| 33 | + parameters: 1, |
| 34 | + body: 1, |
| 35 | + }, |
| 36 | + flatTernaryExpressions: true, |
| 37 | + offsetTernaryExpressions: true, |
| 38 | + }, |
| 39 | + ], |
| 40 | + 'global-require': OFF, |
| 41 | + 'no-plusplus': OFF, |
| 42 | + 'no-cond-assign': OFF, |
| 43 | + 'max-classes-per-file': [ERROR, 10], |
| 44 | + 'no-shadow': OFF, |
| 45 | + 'no-undef': OFF, |
| 46 | + 'no-bitwise': OFF, |
| 47 | + 'no-param-reassign': OFF, |
| 48 | + 'no-use-before-define': OFF, |
| 49 | + 'linebreak-style': [ERROR, 'unix'], |
| 50 | + semi: [ERROR, 'always'], |
| 51 | + 'object-curly-spacing': [ERROR, 'always'], |
| 52 | + 'eol-last': [ERROR, 'always'], |
| 53 | + 'no-console': OFF, |
| 54 | + 'no-restricted-syntax': [ |
| 55 | + WARN, |
| 56 | + { |
| 57 | + selector: |
| 58 | + "CallExpression[callee.object.name='console'][callee.property.name!=/^(warn|error|info|trace|disableYellowBox|tron)$/]", |
| 59 | + message: 'Unexpected property on console object was called', |
| 60 | + }, |
| 61 | + ], |
| 62 | + eqeqeq: [WARN, 'always'], |
| 63 | + quotes: [ |
| 64 | + ERROR, |
| 65 | + 'single', |
| 66 | + { avoidEscape: true, allowTemplateLiterals: false }, |
| 67 | + ], |
| 68 | + // typescript |
| 69 | + '@typescript-eslint/no-shadow': [ERROR], |
| 70 | + '@typescript-eslint/no-use-before-define': [ERROR], |
| 71 | + '@typescript-eslint/no-unused-vars': ERROR, |
| 72 | + '@typescript-eslint/consistent-type-definitions': [ERROR, 'interface'], |
| 73 | + '@typescript-eslint/indent': [ |
| 74 | + OFF, |
| 75 | + 2, |
| 76 | + { |
| 77 | + SwitchCase: 1, |
| 78 | + VariableDeclarator: 1, |
| 79 | + outerIIFEBody: 1, |
| 80 | + FunctionDeclaration: { |
| 81 | + parameters: 1, |
| 82 | + body: 1, |
| 83 | + }, |
| 84 | + FunctionExpression: { |
| 85 | + parameters: 1, |
| 86 | + body: 1, |
| 87 | + }, |
| 88 | + flatTernaryExpressions: true, |
| 89 | + offsetTernaryExpressions: true, |
| 90 | + }, |
| 91 | + ], |
| 92 | + // react |
| 93 | + 'react/jsx-props-no-spreading': OFF, |
| 94 | + 'react/jsx-filename-extension': [ |
| 95 | + ERROR, |
| 96 | + { extensions: ['.js', '.jsx', '.ts', '.tsx'] }, |
| 97 | + ], |
| 98 | + 'react/no-unescaped-entities': [ERROR, { forbid: ['>', '"', '}'] }], |
| 99 | + 'react/prop-types': [ |
| 100 | + ERROR, |
| 101 | + { ignore: ['action', 'dispatch', 'nav', 'navigation'] }, |
| 102 | + ], |
| 103 | + 'react/display-name': OFF, |
| 104 | + 'react/jsx-boolean-value': ERROR, |
| 105 | + 'react/jsx-no-undef': ERROR, |
| 106 | + 'react/jsx-uses-react': ERROR, |
| 107 | + 'react/jsx-sort-props': [ |
| 108 | + ERROR, |
| 109 | + { |
| 110 | + callbacksLast: true, |
| 111 | + shorthandFirst: true, |
| 112 | + ignoreCase: true, |
| 113 | + noSortAlphabetically: true, |
| 114 | + }, |
| 115 | + ], |
| 116 | + 'react/jsx-pascal-case': ERROR, |
| 117 | + 'react/no-children-prop': OFF, |
| 118 | + // react-native specific rules |
| 119 | + 'react-native/no-unused-styles': ERROR, |
| 120 | + 'react-native/no-inline-styles': ERROR, |
| 121 | + 'react-native/no-color-literals': ERROR, |
| 122 | + 'react-native/no-raw-text': ERROR, |
| 123 | + }, |
| 124 | + globals: { |
| 125 | + JSX: 'readonly', |
| 126 | + }, |
| 127 | + env: { |
| 128 | + jest: true, |
| 129 | + }, |
| 130 | +}; |
0 commit comments