123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307 |
- 'use strict';
- module.exports = {
- plugins: [
- 'react',
- ],
- parserOptions: {
- ecmaFeatures: {
- jsx: true,
- },
- },
- // View link below for react rules documentation
- // https://github.com/yannickcr/eslint-plugin-react#list-of-supported-rules
- rules: {
- // Specify whether double or single quotes should be used in JSX attributes
- // http://eslint.org/docs/rules/jsx-quotes
- 'jsx-quotes': [ 'error', 'prefer-double' ],
- 'class-methods-use-this': [ 'error', {
- exceptMethods: [
- 'render',
- 'getInitialState',
- 'getDefaultProps',
- 'getChildContext',
- 'componentWillMount',
- 'componentDidMount',
- 'componentWillReceiveProps',
- 'shouldComponentUpdate',
- 'componentWillUpdate',
- 'componentDidUpdate',
- 'componentWillUnmount',
- ],
- }],
- // Prevent missing displayName in a React component definition
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/display-name.md
- 'react/display-name': [ 'off', { ignoreTranspilerName: false }],
- // Forbid certain propTypes (any, array, object)
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/forbid-prop-types.md
- 'react/forbid-prop-types': [ 'off' ],
- // Enforce boolean attributes notation in JSX
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-boolean-value.md
- 'react/jsx-boolean-value': [ 'error', 'never' ],
- // Validate closing bracket location in JSX
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-closing-bracket-location.md
- 'react/jsx-closing-bracket-location': [ 'error', 'line-aligned' ],
- // Enforce or disallow spaces inside of curly braces in JSX attributes
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-curly-spacing.md
- 'react/jsx-curly-spacing': [ 'error', 'never', { allowMultiline: true }],
- // Enforce event handler naming conventions in JSX
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-handler-names.md
- 'react/jsx-handler-names': [ 'off', {
- eventHandlerPrefix: 'handle',
- eventHandlerPropPrefix: 'on',
- }],
- // Validate props indentation in JSX
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-indent-props.md
- 'react/jsx-indent-props': [ 'error', 2 ],
- // Validate JSX has key prop when in array or iterator
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-key.md
- 'react/jsx-key': 'off',
- // Limit maximum of props on a single line in JSX
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-max-props-per-line.md
- 'react/jsx-max-props-per-line': [ 'off', { maximum: 1 }],
- // Prevent usage of .bind() in JSX props
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-bind.md
- 'react/jsx-no-bind': [ 'error', {
- ignoreRefs: true,
- allowArrowFunctions: true,
- allowBind: false,
- }],
- // Prevent duplicate props in JSX
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-duplicate-props.md
- 'react/jsx-no-duplicate-props': [ 'error', { ignoreCase: true }],
- // Prevent usage of unwrapped JSX strings
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-literals.md
- 'react/jsx-no-literals': 'off',
- // Disallow undeclared variables in JSX
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-undef.md
- 'react/jsx-no-undef': 'error',
- // Enforce PascalCase for user-defined JSX components
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-pascal-case.md
- 'react/jsx-pascal-case': [ 'error', {
- allowAllCaps: true,
- ignore: [],
- }],
- // Enforce propTypes declarations alphabetical sorting
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/sort-prop-types.md
- 'react/sort-prop-types': [ 'off', {
- ignoreCase: true,
- callbacksLast: false,
- requiredFirst: false,
- }],
- // Deprecated in favor of react/jsx-sort-props
- 'react/jsx-sort-prop-types': 'off',
- // Enforce props alphabetical sorting
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-sort-props.md
- 'react/jsx-sort-props': [ 'off', {
- ignoreCase: true,
- callbacksLast: false,
- shorthandFirst: false,
- shorthandLast: false,
- }],
- // Prevent React to be incorrectly marked as unused
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-uses-react.md
- 'react/jsx-uses-react': [ 'error' ],
- // Prevent variables used in JSX to be incorrectly marked as unused
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-uses-vars.md
- 'react/jsx-uses-vars': 'error',
- // Prevent usage of dangerous JSX properties
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-danger.md
- 'react/no-danger': 'warn',
- // Prevent usage of deprecated methods
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-deprecated.md
- 'react/no-deprecated': [ 'error' ],
- // Prevent usage of setState in componentDidMount
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-did-mount-set-state.md
- 'react/no-did-mount-set-state': [ 'error' ],
- // Prevent usage of setState in componentDidUpdate
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-did-update-set-state.md
- 'react/no-did-update-set-state': [ 'error' ],
- // Prevent direct mutation of this.state
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-direct-mutation-state.md
- 'react/no-direct-mutation-state': 'off',
- // Prevent usage of isMounted
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-is-mounted.md
- 'react/no-is-mounted': 'error',
- // Prevent multiple component definition per file
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-multi-comp.md
- 'react/no-multi-comp': [ 'error', { ignoreStateless: true }],
- // Prevent usage of setState
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-set-state.md
- 'react/no-set-state': 'off',
- // Prevent using string references
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-string-refs.md
- 'react/no-string-refs': 'error',
- // Prevent usage of unknown DOM property
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-unknown-property.md
- 'react/no-unknown-property': 'error',
- // Require ES6 class declarations over React.createClass
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prefer-es6-class.md
- 'react/prefer-es6-class': [ 'error', 'always' ],
- // Require stateless functions when not using lifecycle methods, setState or ref
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prefer-stateless-function.md
- 'react/prefer-stateless-function': 'off',
- // Prevent missing props validation in a React component definition
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prop-types.md
- 'react/prop-types': [ 'error', { ignore: [], customValidators: [] }],
- // Prevent missing React when using JSX
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/react-in-jsx-scope.md
- 'react/react-in-jsx-scope': 'error',
- // Require render() methods to return something
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/require-render-return.md
- 'react/require-render-return': 'error',
- // Prevent extra closing tags for components without children
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/self-closing-comp.md
- 'react/self-closing-comp': 'error',
- // Enforce component methods order
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/sort-comp.md
- 'react/sort-comp': [ 'error', {
- order: [
- 'static-methods',
- 'lifecycle',
- '/^on.+$/',
- '/^(get|set)(?!(InitialState$|DefaultProps$|ChildContext$)).+$/',
- 'everything-else',
- '/^render.+$/',
- 'render',
- ],
- }],
- // Prevent missing parentheses around multilines JSX
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-wrap-multilines.md
- 'react/jsx-wrap-multilines': [ 'error', {
- declaration: true,
- assignment: true,
- return: true,
- }],
- // Require that the first prop in a JSX element be on a new line when the element is multiline
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-first-prop-new-line.md
- 'react/jsx-first-prop-new-line': [ 'error', 'multiline' ],
- // Enforce spacing around jsx equals signs
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-equals-spacing.md
- 'react/jsx-equals-spacing': [ 'error', 'never' ],
- // Enforce JSX indentation
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-indent.md
- 'react/jsx-indent': [ 'error', 2 ],
- // Disallow target="_blank" on links
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-target-blank.md
- 'react/jsx-no-target-blank': 'error',
- // only .jsx files may have JSX
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-filename-extension.md
- 'react/jsx-filename-extension': [ 'error', { extensions: [ '.jsx' ] }],
- // prevent accidental JS comments from being injected into JSX as text
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-comment-textnodes.md
- 'react/jsx-no-comment-textnodes': 'error',
- // disallow using React.render/ReactDOM.render's return value
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-render-return-value.md
- 'react/no-render-return-value': 'error',
- // require a shouldComponentUpdate method, or PureRenderMixin
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/require-optimization.md
- 'react/require-optimization': [ 'off', { allowDecorators: [] }],
- // warn against using findDOMNode()
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-find-dom-node.md
- 'react/no-find-dom-node': 'error',
- // Forbid certain props on Components
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/forbid-component-props.md
- 'react/forbid-component-props': [ 'off', { forbid: [] }],
- // Prevent problem with children and props.dangerouslySetInnerHTML
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-danger-with-children.md
- 'react/no-danger-with-children': 'error',
- // Prevent unused propType definitions
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-unused-prop-types.md
- 'react/no-unused-prop-types': [ 'error', {
- customValidators: [
- ],
- skipShapeProps: true,
- }],
- // Require style prop value be an object or var
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/style-prop-object.md
- 'react/style-prop-object': 'error',
- // Prevent invalid characters from appearing in markup
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-unescaped-entities.md
- 'react/no-unescaped-entities': 'error',
- // Prevent passing of children as props
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-children-prop.md
- 'react/no-children-prop': 'error',
- // Validate whitespace in and around the JSX opening and closing brackets
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-tag-spacing.md
- 'react/jsx-tag-spacing': [ 'error', {
- closingSlash: 'never',
- beforeSelfClosing: 'always',
- afterOpening: 'never',
- }],
- // Prevent usage of Array index in keys
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-array-index-key.md
- 'react/no-array-index-key': 'error',
- // Enforce a defaultProps definition for every prop that is not a required prop
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/require-default-props.md
- 'react/require-default-props': 'off',
- },
- settings: {
- 'import/resolver': {
- node: {
- extensions: [ '.js', '.jsx', '.json' ],
- },
- },
- react: {
- pragma: 'React',
- version: '0.14',
- },
- },
- };
|