index.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. module.exports = {
  2. env: {
  3. es6: true,
  4. node: true,
  5. browser: true,
  6. commonjs: true,
  7. },
  8. parserOptions: {
  9. ecmaVersion: 2017,
  10. sourceType: 'module',
  11. ecmaFeatures: {impliedStrict: true},
  12. },
  13. extends: 'eslint:recommended',
  14. rules: {
  15. // Allow use of console.log
  16. 'no-console': 0,
  17. // Warn when a variable is unused
  18. 'no-unused-vars': 1,
  19. // Prefer destructuring assignments
  20. 'prefer-destructuring': 1,
  21. // Disallow `return await p` (use `return p`!)
  22. 'no-return-await': 2,
  23. // Disallow unused expressions w/o side effects
  24. 'no-unused-expressions': 2,
  25. // No semicolons, thanks
  26. 'semi': [2, 'never'],
  27. // Use curly brackets when the block is on a different line to the keyword
  28. 'curly': [2, 'multi-line'],
  29. // Use separate var statements for each variable
  30. 'one-var': [2, 'never'],
  31. // Prefer const over let over var
  32. 'no-var': 1,
  33. 'prefer-const': 1,
  34. // If you do use var, hoist it to the top of the function manually
  35. 'vars-on-top': 2,
  36. // Disallow backward comparisons eg. `5 > age`
  37. 'yoda': [2, 'never'],
  38. // Enforce consistent newlines in arrays and objects
  39. 'array-bracket-newline': [2, 'consistent'],
  40. 'object-curly-newline': [2, {consistent: true}],
  41. // Require a trailing comma on multiline literals, where possible
  42. 'comma-dangle': [2, 'always-multiline'],
  43. // ESLint doesn't let us enforce different spacing rules for destructured
  44. // parameters, so the following are disabled. Hopefully a plugin/fix comes
  45. // for this in the future :)
  46. 'object-curly-spacing': [0, 'never'],
  47. 'array-bracket-spacing': [0, 'never'],
  48. // Object literal naming
  49. 'quote-props': [1, 'consistent-as-needed'],
  50. 'object-shorthand': [1, 'always', {
  51. avoidQuotes: true,
  52. avoidExplicitReturnArrows: true,
  53. }],
  54. // String style
  55. 'quotes': [2, 'single', {avoidEscape: true, allowTemplateLiterals: true}],
  56. 'prefer-template': 2,
  57. 'template-curly-spacing': [2, 'never'],
  58. 'no-useless-concat': 2,
  59. // Use camelCase
  60. 'camelcase': 2,
  61. // Symbols
  62. 'symbol-description': 1,
  63. 'no-new-symbol': 2,
  64. // Braces on same line as keyword
  65. 'brace-style': [2, '1tbs'],
  66. // Always use spacing inside one-liner blocks
  67. 'block-spacing': [2, 'always'],
  68. // Don't use spaces in computed property names
  69. 'computed-property-spacing': [2, 'never'],
  70. // Enforce 2-space indentation
  71. 'indent': [2, 2, {SwitchCase: 1}],
  72. // Enforce spacing around blocks and keywords
  73. 'keyword-spacing': 2,
  74. 'switch-colon-spacing': 2,
  75. 'space-before-blocks': 2,
  76. // Warn where `else if` would be better suited
  77. 'no-lonely-if': 1,
  78. // Operator style
  79. 'operator-linebreak': [2, 'before'],
  80. 'space-infix-ops': 2,
  81. // Function style
  82. 'function-paren-newline': [2, 'multiline'],
  83. 'func-style': [2, 'declaration', {allowArrowFunctions: true}],
  84. 'func-call-spacing': [2, 'never'],
  85. 'prefer-rest-params': 2,
  86. 'prefer-spread': 2,
  87. 'space-in-parens': [2, 'never'],
  88. // Require parens when using `new`
  89. 'new-parens': 2,
  90. // Arrow function style
  91. 'arrow-body-style': [2, 'as-needed'],
  92. 'arrow-parens': [2, 'as-needed'],
  93. 'arrow-spacing': 2,
  94. 'prefer-arrow-callback': 1,
  95. // Max line-length of 80, except strings and stuff
  96. 'max-len': [1, {
  97. code: 80,
  98. ignoreStrings: true,
  99. ignoreTemplateLiterals: true,
  100. ignoreRegExpLiterals: true,
  101. }],
  102. // Enforce files end in \n and use unix newlines (\n)
  103. 'eol-last': 2,
  104. 'linebreak-style': 2,
  105. },
  106. }