Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
@skava/eslint-config / src / rules / react.js
Size: Mime:
module.exports = {
  plugins: [
    'react',
  ],
  settings: {
    'react': {
      pragma: 'React',
      version: '16.6.0',
    },
  },
  rules: {
    'react/jsx-handler-names': [
      2,
      {
        eventHandlerPrefix: 'handle',
        eventHandlerPropPrefix: 'on',
      },
    ],

    // @NOTE should be using schema types
    // enabled: for enabling the rule. 0=off, 1=warn, 2=error. Defaults to 0.
    // ignore: optional array of props name to ignore during validation.
    // customValidators: optional array of validators used for propTypes validation.
    // skipUndeclared: only error on components that have a propTypes block declared
    'react/jsx-no-undef': 2,
    // 'react/jsx-uses-react': 1,
    // 'react/jsx-uses-vars': 1,
    'react/no-multi-comp': 0,

    // autofix on this sucvks
    // 'react/self-closing-comp': 1,

    'react/jsx-wrap-multilines': [
      'error',
      { declaration: true, assignment: true, return: true, arrow: false },
    ],

    // @see https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-bind.md#protips
    // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-bind.md#allowarrowfunctions
    // enforce not using nested arrow fns
    'react/jsx-no-bind': [
      2,
      {
        ignoreRefs: false,
        allowArrowFunctions: false,
        allowBind: false,
      },
    ],

    // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-string-refs.md
    'react/no-string-refs': 2,
    'react/no-direct-mutation-state': 2,
    'react/no-danger-with-children': 2,
    // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-children-prop.md
    'react/jsx-pascal-case': [
      2,
      {
        allowAllCaps: true,
        // ignore: <ignore>
      },
    ],

    // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-key.md
    'react/jsx-key': 2,
    // https://www.fullstackreact.com/p/appendix-a-proptypes/
    'react/prop-types': [
      'error',
      {
        ignore: ['children'],
        skipUndeclared: true,
        // @TODO
        // customValidators: [],
      },
    ],
    'react/boolean-prop-naming': [
      'error',
      {
        rule: '^(is|has|should)[A-Z]([A-Za-z0-9]?)+',
      },
    ],
    'react/jsx-curly-spacing': [
      2,
      {
        when: 'never',
        spacing: {
          objectLiterals: 'always',
        },
      },
    ],
    // PRETTIER WILL NOT CONFORM
    // 'react/jsx-closing-bracket-location': [
    //   2,
    //   {
    //     nonEmpty: 'props-aligned',
    //     selfClosing: 'line-aligned',
    //   },
    // ],
    // 'react/jsx-closing-tag-location': 2,
    // react/jsx-no-comment-textnodes

    // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/default-props-match-prop-types.md
    // 'react/default-props-match-prop-types': [2, {
    //   'allowRequiredDefaults': true,
    // }],
    'react/require-default-props': 1,

    // 'react/prefer-es6-class': 2,
    'react/jsx-equals-spacing': [2, 'never'],
    'react/jsx-no-target-blank': 2,
    // 'react/jsx-pascal-case': 2,
    // missing:
    'react/no-typos': 2,

    // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-unused-prop-types.md
    'react/no-unknown-property': [
      2,
      {
        ignore: [],
      },
    ],
    // 'react/jsx-curly-brace-presence': [2, 'always'],
    'react/no-array-index-key': 2,
    // 'react/no-direct-mutation-state': 2,
    'react/jsx-uses-vars': 1,
    'react/react-in-jsx-scope': 2,
    'react/no-danger': 2,
    'react/no-did-update-set-state': 2,
    'react/no-did-mount-set-state': 2,
    'react/no-is-mounted': 2,
    'react/no-find-dom-node': 2,
    'react/display-name': 2,
    'react/no-set-state': 1,

    // @TODO @JAMES @PERF: enable on perf stage
    // 'react/require-optimization': [
    //   2,
    //   {
    //     allowDecorators: [],
    //   },
    // ],
    'react/require-render-return': 2,

    // 'react/prefer-stateless-function': [0, { 'ignorePureComponents': true }]
    // 'react/jsx-max-props-per-line': 3,
    // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/sort-comp.md
    'react/sort-comp': [
      1,
      {
        order: ['static-methods', 'lifecycle', 'everything-else', 'render'],
        groups: {
          lifecycle: [
            'displayName',
            'propTypes',
            'defaultProps',
            'contextTypes',
            'childContextTypes',
            'mixins',
            'statics',
            'defaultProps',
            'constructor',
            'getDefaultProps',
            'getInitialState',
            'state',
            'getChildContext',
            'componentWillMount',
            'componentDidMount',
            'componentWillReceiveProps',
            'shouldComponentUpdate',
            'componentWillUpdate',
            'componentDidUpdate',
            'componentWillUnmount',
          ],
        },
      },
    ],
  }
}