config-schema.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * STOP!!! DO NOT MODIFY.
  3. *
  4. * This file is part of the ongoing work to move the eslintrc-style config
  5. * system into the @eslint/eslintrc package. This file needs to remain
  6. * unchanged in order for this work to proceed.
  7. *
  8. * If you think you need to change this file, please contact @nzakas first.
  9. *
  10. * Thanks in advance for your cooperation.
  11. */
  12. /**
  13. * @fileoverview Defines a schema for configs.
  14. * @author Sylvan Mably
  15. */
  16. "use strict";
  17. const baseConfigProperties = {
  18. $schema: { type: "string" },
  19. env: { type: "object" },
  20. extends: { $ref: "#/definitions/stringOrStrings" },
  21. globals: { type: "object" },
  22. overrides: {
  23. type: "array",
  24. items: { $ref: "#/definitions/overrideConfig" },
  25. additionalItems: false
  26. },
  27. parser: { type: ["string", "null"] },
  28. parserOptions: { type: "object" },
  29. plugins: { type: "array" },
  30. processor: { type: "string" },
  31. rules: { type: "object" },
  32. settings: { type: "object" },
  33. noInlineConfig: { type: "boolean" },
  34. reportUnusedDisableDirectives: { type: "boolean" },
  35. ecmaFeatures: { type: "object" } // deprecated; logs a warning when used
  36. };
  37. const configSchema = {
  38. definitions: {
  39. stringOrStrings: {
  40. oneOf: [
  41. { type: "string" },
  42. {
  43. type: "array",
  44. items: { type: "string" },
  45. additionalItems: false
  46. }
  47. ]
  48. },
  49. stringOrStringsRequired: {
  50. oneOf: [
  51. { type: "string" },
  52. {
  53. type: "array",
  54. items: { type: "string" },
  55. additionalItems: false,
  56. minItems: 1
  57. }
  58. ]
  59. },
  60. // Config at top-level.
  61. objectConfig: {
  62. type: "object",
  63. properties: {
  64. root: { type: "boolean" },
  65. ignorePatterns: { $ref: "#/definitions/stringOrStrings" },
  66. ...baseConfigProperties
  67. },
  68. additionalProperties: false
  69. },
  70. // Config in `overrides`.
  71. overrideConfig: {
  72. type: "object",
  73. properties: {
  74. excludedFiles: { $ref: "#/definitions/stringOrStrings" },
  75. files: { $ref: "#/definitions/stringOrStringsRequired" },
  76. ...baseConfigProperties
  77. },
  78. required: ["files"],
  79. additionalProperties: false
  80. }
  81. },
  82. $ref: "#/definitions/objectConfig"
  83. };
  84. module.exports = configSchema;