style.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513
  1. 'use strict';
  2. const os = require('os');
  3. module.exports = {
  4. rules: {
  5. /**
  6. * enforce spaces inside of brackets
  7. * @see http://eslint.org/docs/rules/array-bracket-spacing
  8. * @since 3.0.0
  9. */
  10. 'array-bracket-spacing': [ 'error', 'always', {
  11. objectsInArrays: false,
  12. arraysInArrays: false,
  13. }],
  14. /**
  15. * enforce spaces inside of single line blocks
  16. * @see http://eslint.org/docs/rules/block-spacing
  17. */
  18. 'block-spacing': [ 'error', 'always' ],
  19. /**
  20. * @see http://eslint.org/docs/rules/brace-style
  21. * @since 3.0.0
  22. * @example
  23. *
  24. * ```js
  25. * // correct
  26. * if (foo) {
  27. * bar();
  28. * }
  29. *
  30. * foo: { type: Array, default() { return []; } }
  31. *
  32. * if (foo) bar();
  33. *
  34. * if (foo) { bar(); }
  35. *
  36. * // incorrect
  37. *
  38. * if (foo) {
  39. * bar();
  40. * }
  41. * else {
  42. * baz();
  43. * }
  44. * ```
  45. */
  46. 'brace-style': [ 'error', '1tbs', { allowSingleLine: true }],
  47. /**
  48. * not require camel case names
  49. * @see http://eslint.org/docs/rules/camelcase
  50. */
  51. camelcase: 'off',
  52. /**
  53. * enforce spacing before and after comma
  54. * @see http://eslint.org/docs/rules/comma-spacing
  55. */
  56. 'comma-spacing': [ 'error', { before: false, after: true }],
  57. /**
  58. * enforce one true comma style
  59. * @see http://eslint.org/docs/rules/comma-style
  60. * @since 3.0.0
  61. * @example
  62. *
  63. * ```js
  64. * // incorrect
  65. * var foo = 1
  66. * ,
  67. * bar = 2;
  68. *
  69. * var foo = 1
  70. * , bar = 2;
  71. *
  72. * var foo = ["apples"
  73. * , "oranges"];
  74. *
  75. * function bar() {
  76. * return {
  77. * "a": 1
  78. * ,"b:": 'error
  79. * };
  80. * }
  81. * ```
  82. */
  83. 'comma-style': [ 'error', 'last' ],
  84. /**
  85. * allow padding inside computed properties
  86. * @see http://eslint.org/docs/rules/computed-property-spacing
  87. */
  88. 'computed-property-spacing': 'off',
  89. /**
  90. * not enforces consistent naming when capturing the current execution context
  91. * @see http://eslint.org/docs/rules/consistent-this
  92. */
  93. 'consistent-this': 'off',
  94. /**
  95. * enforce newline at the end of file, with no multiple empty lines
  96. * @see http://eslint.org/docs/rules/eol-last
  97. */
  98. 'eol-last': 'error',
  99. /**
  100. * not require function expressions to have a name
  101. * @see http://eslint.org/docs/rules/func-names
  102. */
  103. 'func-names': 'off',
  104. /**
  105. * not enforces use of function declarations or expressions
  106. * @see http://eslint.org/docs/rules/func-style
  107. */
  108. 'func-style': 'off',
  109. /**
  110. * Blacklist certain identifiers to prevent them being used
  111. * @see http://eslint.org/docs/rules/id-blacklist
  112. */
  113. 'id-blacklist': 'off',
  114. /**
  115. * not enforces minimum and maximum identifier lengths
  116. * (variable names, property names etc.)
  117. * @see http://eslint.org/docs/rules/id-length
  118. */
  119. 'id-length': 'off',
  120. /**
  121. * not require identifiers to match the provided regular expression
  122. * @see http://eslint.org/docs/rules/id-match
  123. */
  124. 'id-match': 'off',
  125. /**
  126. * this option sets a specific tab width for your code
  127. * @see http://eslint.org/docs/rules/indent
  128. */
  129. indent: [ 'error', 2, { SwitchCase: 1, VariableDeclarator: 1 }],
  130. /**
  131. * enforces spacing between keys and values in object literal properties
  132. * @see http://eslint.org/docs/rules/key-spacing
  133. */
  134. 'key-spacing': [ 'error', { beforeColon: false, afterColon: true }],
  135. /**
  136. * require a space before & after certain keywords
  137. * @see http://eslint.org/docs/rules/keyword-spacing
  138. */
  139. 'keyword-spacing': [ 'error', {
  140. before: true,
  141. after: true,
  142. overrides: {
  143. return: { after: true },
  144. throw: { after: true },
  145. case: { after: true },
  146. },
  147. }],
  148. /**
  149. * enforces the usage of Unix line endings: \n for LF
  150. * @see http://eslint.org/docs/rules/linebreak-style
  151. */
  152. 'linebreak-style': [ (os.platform() === 'win32' ? 'off' : 'error'), 'unix' ],
  153. /**
  154. * not enforces empty lines around comments
  155. * @see http://eslint.org/docs/rules/lines-around-comment
  156. */
  157. 'lines-around-comment': 'off',
  158. /**
  159. * specify the maximum depth that blocks can be nested
  160. * @see http://eslint.org/docs/rules/max-depth
  161. */
  162. 'max-depth': 'off',
  163. /**
  164. * not specify the maximum length of a line in your program
  165. * @see http://eslint.org/docs/rules/max-len
  166. * @since 3.0.0
  167. */
  168. 'max-len': 'off',
  169. /**
  170. * not specify the maximum depth callbacks can be nested
  171. * @see http://eslint.org/docs/rules/max-nested-callbacks
  172. */
  173. 'max-nested-callbacks': 'off',
  174. /**
  175. * limits the number of parameters that can be used in the function declaration.
  176. * @see http://eslint.org/docs/rules/max-params
  177. */
  178. 'max-params': 'off',
  179. /**
  180. * specify the maximum number of statement allowed in a function
  181. * @see http://eslint.org/docs/rules/max-statements
  182. */
  183. 'max-statements': 'off',
  184. /**
  185. * restrict the number of statements per line
  186. * @see http://eslint.org/docs/rules/max-statements-per-line
  187. * @since 3.0.0
  188. */
  189. 'max-statements-per-line': 'off',
  190. /**
  191. * not require a capital letter for constructors
  192. * @see http://eslint.org/docs/rules/new-cap
  193. */
  194. 'new-cap': 'off',
  195. /**
  196. * disallow the omission of parentheses when invoking a constructor with no arguments
  197. * @see http://eslint.org/docs/rules/new-parens
  198. */
  199. 'new-parens': 'error',
  200. /**
  201. * allow an empty newline after var statement
  202. * @see http://eslint.org/docs/rules/newline-after-var
  203. */
  204. 'newline-after-var': 'off',
  205. /**
  206. * @see http://eslint.org/docs/rules/newline-before-return
  207. */
  208. 'newline-before-return': 'off',
  209. /**
  210. * enforces new line after each method call in the chain to make it
  211. * more readable and easy to maintain
  212. */
  213. 'newline-per-chained-call': [ 'error', { ignoreChainWithDepth: 3 }],
  214. /**
  215. * disallow use of the Array constructor
  216. * @see http://eslint.org/docs/rules/no-array-constructor
  217. */
  218. 'no-array-constructor': 'error',
  219. /**
  220. * disallow use of bitwise operators
  221. * @see http://eslint.org/docs/rules/no-bitwise
  222. */
  223. 'no-bitwise': 'error',
  224. /**
  225. * allow use of the continue statement
  226. * @see http://eslint.org/docs/rules/no-continue
  227. */
  228. 'no-continue': 'off',
  229. /**
  230. * allow comments inline after code
  231. * @see http://eslint.org/docs/rules/no-inline-comments
  232. */
  233. 'no-inline-comments': 'off',
  234. /**
  235. * allow if as the only statement in an else block
  236. * @see http://eslint.org/docs/rules/no-lonely-if
  237. */
  238. 'no-lonely-if': 'off',
  239. /**
  240. * disallow mixed spaces and tabs for indentation
  241. * @see http://eslint.org/docs/rules/no-mixed-spaces-and-tabs
  242. */
  243. 'no-mixed-spaces-and-tabs': [ 'error', false ],
  244. /**
  245. * disallow multiple empty lines and only one newline at the end
  246. * @see http://eslint.org/docs/rules/no-multiple-empty-lines
  247. * @since 3.0.0
  248. */
  249. 'no-multiple-empty-lines': [ 'error', { max: 2, maxEOF: 1 }],
  250. /**
  251. * allow negated conditions
  252. * @see http://eslint.org/docs/rules/no-negated-condition
  253. */
  254. 'no-negated-condition': 'off',
  255. /**
  256. * disallow negating the left operand in `in` expressions
  257. * @see http://eslint.org/docs/rules/no-negated-in-lhs
  258. */
  259. 'no-negated-in-lhs': 'error',
  260. /**
  261. * allow nested ternary expressions
  262. * @see http://eslint.org/docs/rules/no-nested-ternary
  263. */
  264. 'no-nested-ternary': 'off',
  265. /**
  266. * disallow use of the Object constructor
  267. * @see http://eslint.org/docs/rules/no-new-object
  268. */
  269. 'no-new-object': 'error',
  270. /**
  271. * allow use of unary operators, ++ and --
  272. * @see http://eslint.org/docs/rules/no-plusplus
  273. */
  274. 'no-plusplus': 'off',
  275. /**
  276. * disallow certain syntax forms
  277. * @see http://eslint.org/docs/rules/no-restricted-syntax
  278. */
  279. 'no-restricted-syntax': [
  280. 2,
  281. 'WithStatement',
  282. ],
  283. /**
  284. * disallow space between function identifier and application
  285. * @see http://eslint.org/docs/rules/no-spaced-func
  286. */
  287. 'no-spaced-func': 'error',
  288. /**
  289. * allow the use of ternary operators
  290. * @see http://eslint.org/docs/rules/no-ternary
  291. */
  292. 'no-ternary': 'off',
  293. /**
  294. * disallow trailing whitespace at the end of lines
  295. * @see http://eslint.org/docs/rules/no-trailing-spaces
  296. */
  297. 'no-trailing-spaces': 'error',
  298. /**
  299. * allow dangling underscores in identifiers
  300. * @see http://eslint.org/docs/rules/no-underscore-dangle
  301. */
  302. 'no-underscore-dangle': 'off',
  303. /**
  304. * allow the use of Boolean literals in conditional expressions
  305. * also, prefer `a || b` over `a ? a : b`
  306. * @see http://eslint.org/docs/rules/no-unneeded-ternary
  307. */
  308. 'no-unneeded-ternary': 'error',
  309. /**
  310. * disallow whitespace before properties
  311. * @see http://eslint.org/docs/rules/no-whitespace-before-property
  312. */
  313. 'no-whitespace-before-property': 'error',
  314. /**
  315. * require padding inside curly braces
  316. * @see http://eslint.org/docs/rules/object-curly-spacing
  317. * @since 3.0.0
  318. * @example
  319. *
  320. * ```js
  321. * // incorrect
  322. * var obj = {'foo': 'bar'};
  323. * var obj = {'foo': 'bar' };
  324. * var obj = { baz: {'foo': 'qux'}, bar};
  325. * var obj = {baz: { 'foo': 'qux' }, bar};
  326. * var obj = {'foo': 'bar'
  327. * };
  328. * ```
  329. */
  330. 'object-curly-spacing': [ 'error', 'always' ],
  331. /**
  332. * not enforce "same line" or "multiple line" on object properties.
  333. * @see http://eslint.org/docs/rules/object-property-newline
  334. */
  335. 'object-property-newline': 'off',
  336. /**
  337. * allow just one var statement per function
  338. * @see http://eslint.org/docs/rules/one-var
  339. */
  340. 'one-var': 'off',
  341. /**
  342. * require a newline around variable declaration
  343. * @see http://eslint.org/docs/rules/one-var-declaration-per-line
  344. * @since 3.0.0
  345. */
  346. 'one-var-declaration-per-line': [ 'error', 'always' ],
  347. /**
  348. * not require assignment operator shorthand where possible or prohibit it entirely
  349. * @see http://eslint.org/docs/rules/operator-assignment
  350. */
  351. 'operator-assignment': 'off',
  352. /**
  353. * not enforce operators to be placed before or after line breaks
  354. * @see http://eslint.org/docs/rules/operator-linebreak
  355. */
  356. 'operator-linebreak': 'off',
  357. /**
  358. * allow padding within blocks
  359. * @see http://eslint.org/docs/rules/padded-blocks
  360. */
  361. 'padded-blocks': 'off',
  362. /**
  363. * not require quotes around object literal property names
  364. * @see http://eslint.org/docs/rules/quote-props
  365. */
  366. 'quote-props': [ 'error', 'as-needed', { keywords: false }],
  367. /**
  368. * specify whether double or single quotes should be used
  369. * @see http://eslint.org/docs/rules/quotes
  370. */
  371. quotes: [ 'error', 'single', { avoidEscape: true }],
  372. /**
  373. * do not require jsdoc
  374. * @see http://eslint.org/docs/rules/require-jsdoc
  375. */
  376. 'require-jsdoc': 'off',
  377. /**
  378. * disallow use of semicolons instead of ASI
  379. * @see http://eslint.org/docs/rules/semi
  380. */
  381. semi: [ 'error', 'always' ],
  382. /**
  383. * enforce spacing before and after semicolons
  384. * @see http://eslint.org/docs/rules/semi-spacing
  385. */
  386. 'semi-spacing': [ 'error', { before: false, after: true }],
  387. /**
  388. * not sort variables within the same declaration block
  389. * @see http://eslint.org/docs/rules/sort-vars
  390. */
  391. 'sort-vars': 'off',
  392. /**
  393. * disallow space before blocks
  394. * @see http://eslint.org/docs/rules/space-before-blocks
  395. */
  396. 'space-before-blocks': 'error',
  397. /**
  398. * require or disallow space before function opening parenthesis
  399. * @see http://eslint.org/docs/rules/space-before-function-paren
  400. */
  401. 'space-before-function-paren': [ 'error', {
  402. anonymous: 'never',
  403. named: 'never',
  404. }],
  405. /**
  406. * require or disallow spaces inside parentheses
  407. * @see http://eslint.org/docs/rules/space-in-parens
  408. */
  409. 'space-in-parens': [ 'error', 'never' ],
  410. /**
  411. * require spaces around operators
  412. * @see http://eslint.org/docs/rules/space-infix-ops
  413. */
  414. 'space-infix-ops': 'error',
  415. /**
  416. * Require spaces before/after unary operators
  417. * @see http://eslint.org/docs/rules/space-unary-ops
  418. */
  419. 'space-unary-ops': [ 'error', {
  420. words: true,
  421. nonwords: false,
  422. }],
  423. /**
  424. * require or disallow a space immediately following the // or /* in a comment
  425. * @see http://eslint.org/docs/rules/spaced-comment
  426. */
  427. 'spaced-comment': [ 'error', 'always', {
  428. exceptions: [ '-', '+' ],
  429. markers: [ '*!' ],
  430. }],
  431. /**
  432. * not require regex literals to be wrapped in parentheses
  433. * @see http://eslint.org/docs/rules/wrap-regex
  434. */
  435. 'wrap-regex': 'off',
  436. /**
  437. * unnecessary escape usage
  438. * @see http://eslint.org/docs/rules/no-useless-escape
  439. */
  440. 'no-useless-escape': 'off',
  441. },
  442. };