You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.1 KiB

4 years ago
  1. 'use strict';
  2. const kebabCase = require('kebab-case');
  3. const rules = require('./lib/rules/rules.json')
  4. module.exports.rules = require('./lib/rules/all');
  5. const all = Object.keys(rules);
  6. const compatible = Object.keys(rules).filter(rule => rules[rule].compatible);
  7. const incompatible = Object.keys(rules).filter(rule => !rules[rule].compatible);
  8. const WARN = 1;
  9. const ERROR = 2;
  10. const configure = (list, level) => (
  11. list.reduce((ret, rule) => (Object.assign({}, ret,
  12. { ['you-dont-need-lodash-underscore/' + (rules[rule].ruleName || kebabCase(rule))]: level })), {})
  13. )
  14. module.exports.configs = {
  15. 'all-warn': {
  16. plugins: [
  17. 'you-dont-need-lodash-underscore'
  18. ],
  19. rules: configure(all, WARN)
  20. },
  21. 'all': {
  22. plugins: [
  23. 'you-dont-need-lodash-underscore'
  24. ],
  25. rules: configure(all, ERROR)
  26. },
  27. 'compatible-warn': {
  28. plugins: [
  29. 'you-dont-need-lodash-underscore'
  30. ],
  31. rules: configure(compatible, WARN)
  32. },
  33. 'compatible': {
  34. plugins: [
  35. 'you-dont-need-lodash-underscore'
  36. ],
  37. rules: Object.assign(
  38. configure(compatible, ERROR),
  39. configure(incompatible, WARN)
  40. )
  41. }
  42. }