es6.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. module.exports = {
  2. env: {
  3. es6: true
  4. },
  5. parserOptions: {
  6. ecmaVersion: 6,
  7. sourceType: 'module',
  8. ecmaFeatures: {
  9. generators: false,
  10. objectLiteralDuplicateProperties: false
  11. }
  12. },
  13. rules: {
  14. // enforces no braces where they can be omitted
  15. // https://eslint.org/docs/rules/arrow-body-style
  16. // TODO: enable requireReturnForObjectLiteral?
  17. 'arrow-body-style': ['error', 'as-needed', {
  18. requireReturnForObjectLiteral: false,
  19. }],
  20. // require parens in arrow function arguments
  21. // https://eslint.org/docs/rules/arrow-parens
  22. 'arrow-parens': ['error', 'always'],
  23. // require space before/after arrow function's arrow
  24. // https://eslint.org/docs/rules/arrow-spacing
  25. 'arrow-spacing': ['error', { before: true, after: true }],
  26. // verify super() callings in constructors
  27. 'constructor-super': 'error',
  28. // enforce the spacing around the * in generator functions
  29. // https://eslint.org/docs/rules/generator-star-spacing
  30. 'generator-star-spacing': ['error', { before: false, after: true }],
  31. // disallow modifying variables of class declarations
  32. // https://eslint.org/docs/rules/no-class-assign
  33. 'no-class-assign': 'error',
  34. // disallow arrow functions where they could be confused with comparisons
  35. // https://eslint.org/docs/rules/no-confusing-arrow
  36. 'no-confusing-arrow': ['error', {
  37. allowParens: true,
  38. }],
  39. // disallow modifying variables that are declared using const
  40. 'no-const-assign': 'error',
  41. // disallow duplicate class members
  42. // https://eslint.org/docs/rules/no-dupe-class-members
  43. 'no-dupe-class-members': 'error',
  44. // disallow importing from the same path more than once
  45. // https://eslint.org/docs/rules/no-duplicate-imports
  46. // replaced by https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-duplicates.md
  47. 'no-duplicate-imports': 'off',
  48. // disallow symbol constructor
  49. // https://eslint.org/docs/rules/no-new-symbol
  50. 'no-new-symbol': 'error',
  51. // Disallow specified names in exports
  52. // https://eslint.org/docs/rules/no-restricted-exports
  53. 'no-restricted-exports': ['error', {
  54. restrictedNamedExports: [
  55. 'default', // use `export default` to provide a default export
  56. 'then', // this will cause tons of confusion when your module is dynamically `import()`ed, and will break in most node ESM versions
  57. ],
  58. }],
  59. // disallow specific imports
  60. // https://eslint.org/docs/rules/no-restricted-imports
  61. 'no-restricted-imports': ['off', {
  62. paths: [],
  63. patterns: []
  64. }],
  65. // disallow to use this/super before super() calling in constructors.
  66. // https://eslint.org/docs/rules/no-this-before-super
  67. 'no-this-before-super': 'error',
  68. // disallow useless computed property keys
  69. // https://eslint.org/docs/rules/no-useless-computed-key
  70. 'no-useless-computed-key': 'error',
  71. // disallow unnecessary constructor
  72. // https://eslint.org/docs/rules/no-useless-constructor
  73. 'no-useless-constructor': 'error',
  74. // disallow renaming import, export, and destructured assignments to the same name
  75. // https://eslint.org/docs/rules/no-useless-rename
  76. 'no-useless-rename': ['error', {
  77. ignoreDestructuring: false,
  78. ignoreImport: false,
  79. ignoreExport: false,
  80. }],
  81. // require let or const instead of var
  82. 'no-var': 'error',
  83. // require method and property shorthand syntax for object literals
  84. // https://eslint.org/docs/rules/object-shorthand
  85. 'object-shorthand': ['error', 'always', {
  86. ignoreConstructors: false,
  87. avoidQuotes: true,
  88. }],
  89. // suggest using arrow functions as callbacks
  90. 'prefer-arrow-callback': ['error', {
  91. allowNamedFunctions: false,
  92. allowUnboundThis: true,
  93. }],
  94. // suggest using of const declaration for variables that are never modified after declared
  95. 'prefer-const': ['error', {
  96. destructuring: 'any',
  97. ignoreReadBeforeAssign: true,
  98. }],
  99. // Prefer destructuring from arrays and objects
  100. // https://eslint.org/docs/rules/prefer-destructuring
  101. 'prefer-destructuring': ['error', {
  102. VariableDeclarator: {
  103. array: false,
  104. object: true,
  105. },
  106. AssignmentExpression: {
  107. array: true,
  108. object: false,
  109. },
  110. }, {
  111. enforceForRenamedProperties: false,
  112. }],
  113. // disallow parseInt() in favor of binary, octal, and hexadecimal literals
  114. // https://eslint.org/docs/rules/prefer-numeric-literals
  115. 'prefer-numeric-literals': 'error',
  116. // suggest using Reflect methods where applicable
  117. // https://eslint.org/docs/rules/prefer-reflect
  118. 'prefer-reflect': 'off',
  119. // use rest parameters instead of arguments
  120. // https://eslint.org/docs/rules/prefer-rest-params
  121. 'prefer-rest-params': 'error',
  122. // suggest using the spread syntax instead of .apply()
  123. // https://eslint.org/docs/rules/prefer-spread
  124. 'prefer-spread': 'error',
  125. // suggest using template literals instead of string concatenation
  126. // https://eslint.org/docs/rules/prefer-template
  127. 'prefer-template': 'error',
  128. // disallow generator functions that do not have yield
  129. // https://eslint.org/docs/rules/require-yield
  130. 'require-yield': 'error',
  131. // enforce spacing between object rest-spread
  132. // https://eslint.org/docs/rules/rest-spread-spacing
  133. 'rest-spread-spacing': ['error', 'never'],
  134. // import sorting
  135. // https://eslint.org/docs/rules/sort-imports
  136. 'sort-imports': ['off', {
  137. ignoreCase: false,
  138. ignoreDeclarationSort: false,
  139. ignoreMemberSort: false,
  140. memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
  141. }],
  142. // require a Symbol description
  143. // https://eslint.org/docs/rules/symbol-description
  144. 'symbol-description': 'error',
  145. // enforce usage of spacing in template strings
  146. // https://eslint.org/docs/rules/template-curly-spacing
  147. 'template-curly-spacing': 'error',
  148. // enforce spacing around the * in yield* expressions
  149. // https://eslint.org/docs/rules/yield-star-spacing
  150. 'yield-star-spacing': ['error', 'after']
  151. }
  152. };