constants.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. const definitions = [
  2. {
  3. name: 'NA',
  4. value: 'inapplicable',
  5. priority: 0,
  6. group: 'inapplicable'
  7. },
  8. {
  9. name: 'PASS',
  10. value: 'passed',
  11. priority: 1,
  12. group: 'passes'
  13. },
  14. {
  15. name: 'CANTTELL',
  16. value: 'cantTell',
  17. priority: 2,
  18. group: 'incomplete'
  19. },
  20. {
  21. name: 'FAIL',
  22. value: 'failed',
  23. priority: 3,
  24. group: 'violations'
  25. }
  26. ];
  27. const constants = {
  28. helpUrlBase: 'https://dequeuniversity.com/rules/',
  29. results: [],
  30. resultGroups: [],
  31. resultGroupMap: {},
  32. impact: Object.freeze(['minor', 'moderate', 'serious', 'critical']),
  33. preload: Object.freeze({
  34. /**
  35. * array of supported & preload(able) asset types.
  36. */
  37. assets: ['cssom', 'media'],
  38. /**
  39. * timeout value when resolving preload(able) assets
  40. */
  41. timeout: 10000
  42. }),
  43. allOrigins: '<unsafe_all_origins>',
  44. sameOrigin: '<same_origin>'
  45. };
  46. definitions.forEach(definition => {
  47. const name = definition.name;
  48. const value = definition.value;
  49. const priority = definition.priority;
  50. const group = definition.group;
  51. constants[name] = value;
  52. constants[name + '_PRIO'] = priority;
  53. constants[name + '_GROUP'] = group;
  54. constants.results[priority] = value;
  55. constants.resultGroups[priority] = group;
  56. constants.resultGroupMap[value] = group;
  57. });
  58. // Freeze everything
  59. Object.freeze(constants.results);
  60. Object.freeze(constants.resultGroups);
  61. Object.freeze(constants.resultGroupMap);
  62. Object.freeze(constants);
  63. export default constants;