Created
November 2, 2018 08:40
-
-
Save putuyoga/63d32f68aec7f489f79eb90ea3a25f33 to your computer and use it in GitHub Desktop.
My Favorite React Native ESLint Rule
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 = { | |
parser: 'babel-eslint', | |
env: { browser: true }, | |
extends: 'airbnb', | |
plugins: ['react', 'react-native', 'jsx-a11y', 'import', 'jest'], | |
rules: { | |
// Import Rules | |
'import/no-extraneous-dependencies': ['error', { devDependencies: true }], | |
'import/no-named-as-default': 1, | |
'import/prefer-default-export': 2, | |
// React Rules | |
'react/destructuring-assignment': 2, | |
'react/display-name': 2, | |
'react/forbid-prop-types': 2, | |
'react/jsx-boolean-value': 2, | |
'react/jsx-closing-tag-location': 2, | |
'react/jsx-curly-brace-presence': 1, | |
'react/jsx-filename-extension': 0, | |
'react/jsx-handler-names': ['warn', { | |
eventHandlerPrefix: '(_handle)', | |
eventHandlerPropPrefix: '(on)', | |
}], | |
'react/jsx-indent': 2, | |
'react/jsx-key': 2, | |
'react/jsx-max-props-per-line': ['error', { maximum: 1, when: 'multiline' }], | |
'react/jsx-no-bind': ['error', { ignoreRefs: true, allowArrowFunctions: false, allowBind: false }], | |
'react/jsx-no-comment-textnodes': 2, | |
'react/jsx-no-duplicate-props': 2, | |
'react/jsx-no-literals': 2, | |
'react/jsx-no-undef': 2, | |
'react/jsx-one-expression-per-line': 2, | |
'react/jsx-pascal-case': 2, | |
'react/jsx-sort-props': 2, | |
'react/jsx-tag-spacing': ['error', { beforeSelfClosing: 'always' }], | |
'react/jsx-wrap-multilines': 0, | |
'react/no-did-mount-set-state': 2, | |
'react/no-did-update-set-state': 2, | |
'react/no-direct-mutation-state': 2, | |
'react/no-string-refs': 2, | |
'react/no-typos': 2, | |
'react/no-unused-prop-types': 2, | |
'react/no-unused-state': 2, | |
'react/require-default-props': 2, | |
'react/sort-comp': 2, | |
// React Native Rules | |
'react-native/no-color-literals': 2, | |
'react-native/no-inline-styles': 2, | |
'react-native/no-unused-styles': 2, | |
'react-native/split-platform-components': 2, | |
// Base Rules | |
'arrow-body-style': [2, 'as-needed'], | |
'camelcase': 1, | |
'comma-dangle': ['error', 'never'], | |
'indent': 'off', | |
'indent-legacy': ['error', 2, { SwitchCase: 1 } ], | |
'jsx-a11y/mouse-events-have-key-events': 1, | |
'key-spacing': ['error', { mode: 'minimum' }], | |
'max-len': ['error', { code: 110, ignoreComments: true }], | |
'no-console': ['error'], | |
'no-else-return': 0, | |
'no-multi-spaces': ['error', { ignoreEOLComments: true }], | |
'no-trailing-spaces': 2, | |
'no-underscore-dangle': 0, | |
'no-unused-vars': ['error', { args: 'none' }], | |
'padded-blocks': 0, | |
'prefer-destructuring': 1, | |
'prefer-promise-reject-errors': 2, | |
'semi-style': 2, | |
'switch-colon-spacing': 2, | |
'template-tag-spacing': 2, | |
// General Code Quality | |
'complexity': ['warn', 4], | |
'max-params': ['warn', 4], | |
'max-lines-per-function': ['warn', { | |
max: 20, | |
skipComments: true, | |
skipBlankLines: true | |
}], | |
// Import | |
'import/no-cycle': ['warn', { maxDepth: Infinity }], | |
'import/prefer-default-export': 'warn', | |
'import/named': 'warn', | |
'import/no-named-as-default': 'warn', | |
}, | |
overrides: [ | |
{ | |
files: ['app/**/*.story.js', 'app/**/*.test.js'], | |
rules: { | |
'react/jsx-no-bind': 0 | |
} | |
} | |
], | |
settings: { | |
'import/resolver': { | |
node: { | |
extensions: [ | |
'.js', | |
'.android.js', | |
'.ios.js' | |
] | |
} | |
} | |
}, | |
globals: { | |
// Set each global variable name equal to true to allow the variable to be overwritten | |
// or false to disallow overwriting. | |
describe: true, | |
expect: true, | |
test: true, | |
beforeEach: true, | |
afterEach: true, | |
it: false, | |
jest: false, | |
__DEV__: false, | |
Exception: true, | |
ENV_FILE: false | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment