All files / src env-rule-severities.js

40% Statements 4/10
16.67% Branches 1/6
50% Functions 1/2
33.33% Lines 3/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67    1x                                                                                 1x   4x                                          
'use strict'
 
const severityOverrides = {
  // Allow dev tools in dev environment
  'no-console': 'off',
  'no-debugger': 'off',
 
  // These rules are non critical, stylistic rules, warn only in dev for them
  'arrow-body-style': 'warn',
  'class-methods-use-this': 'warn',
  'no-unused-vars': 'warn',
  'prefer-const': 'warn',
  'prefer-destructuring': 'warn',
  'sort-imports': 'warn',
 
  // Imports style preferences rules
  'import/first': 'warn',
  'import/order': 'warn',
 
  // Don't show any Prettier formatting errors during dev b/c they're SUPER
  // noisy and annoying and NOT helpful at that time
  'prettier/prettier': 'off',
 
  // React style preferences rules
  'react/default-props-match-prop-types': 'warn',
  'react/forbid-prop-types': 'warn',
  'react/jsx-boolean-value': 'warn',
  'react/jsx-sort-default-props': 'warn',
  'react/jsx-sort-props': 'warn',
  'react/sort-prop-types': 'warn',
  'react/no-multi-comp': 'warn',
  'react/no-unescaped-entities': 'warn',
  'react/no-unused-prop-types': 'warn',
  'react/no-unused-state': 'warn',
  'react/prefer-stateless-function': 'warn',
  'react/prop-types': 'warn',
  'react/require-default-props': 'warn',
  'react/self-closing-comp': 'warn',
 
  // Allow dev tools writing tests
  'testing-library/no-debug': 'off',
}
 
module.exports = (env, rules) => {
  // During tests linting, rule severity levels are not overridden
  Eif (env === 'test') return rules
 
  // Outside tests linting, downgrade severity levels for style and formatting
  // rules by setting the rule level. ESLint handles rule extends with a level
  // only by keeping the original rule settings and overriding the level only
  // which makes this a super convenient list of severity overrides that won't
  // affect the rule custom settings
  Object.keys(severityOverrides).forEach((rule) => {
    /* eslint-disable no-param-reassign */
    if (rules[rule]) {
      if (Array.isArray(rules[rule])) {
        rules[rule][0] = severityOverrides[rule]
      } else {
        rules[rule] = severityOverrides[rule]
      }
    }
    /* eslint-enable no-param-reassign */
  })
 
  return rules
}