[d565449] | 1 | /**
|
---|
| 2 | * @fileoverview Defines a schema for configs.
|
---|
| 3 | * @author Sylvan Mably
|
---|
| 4 | */
|
---|
| 5 |
|
---|
| 6 | const baseConfigProperties = {
|
---|
| 7 | $schema: { type: "string" },
|
---|
| 8 | env: { type: "object" },
|
---|
| 9 | extends: { $ref: "#/definitions/stringOrStrings" },
|
---|
| 10 | globals: { type: "object" },
|
---|
| 11 | overrides: {
|
---|
| 12 | type: "array",
|
---|
| 13 | items: { $ref: "#/definitions/overrideConfig" },
|
---|
| 14 | additionalItems: false
|
---|
| 15 | },
|
---|
| 16 | parser: { type: ["string", "null"] },
|
---|
| 17 | parserOptions: { type: "object" },
|
---|
| 18 | plugins: { type: "array" },
|
---|
| 19 | processor: { type: "string" },
|
---|
| 20 | rules: { type: "object" },
|
---|
| 21 | settings: { type: "object" },
|
---|
| 22 | noInlineConfig: { type: "boolean" },
|
---|
| 23 | reportUnusedDisableDirectives: { type: "boolean" },
|
---|
| 24 |
|
---|
| 25 | ecmaFeatures: { type: "object" } // deprecated; logs a warning when used
|
---|
| 26 | };
|
---|
| 27 |
|
---|
| 28 | const configSchema = {
|
---|
| 29 | definitions: {
|
---|
| 30 | stringOrStrings: {
|
---|
| 31 | oneOf: [
|
---|
| 32 | { type: "string" },
|
---|
| 33 | {
|
---|
| 34 | type: "array",
|
---|
| 35 | items: { type: "string" },
|
---|
| 36 | additionalItems: false
|
---|
| 37 | }
|
---|
| 38 | ]
|
---|
| 39 | },
|
---|
| 40 | stringOrStringsRequired: {
|
---|
| 41 | oneOf: [
|
---|
| 42 | { type: "string" },
|
---|
| 43 | {
|
---|
| 44 | type: "array",
|
---|
| 45 | items: { type: "string" },
|
---|
| 46 | additionalItems: false,
|
---|
| 47 | minItems: 1
|
---|
| 48 | }
|
---|
| 49 | ]
|
---|
| 50 | },
|
---|
| 51 |
|
---|
| 52 | // Config at top-level.
|
---|
| 53 | objectConfig: {
|
---|
| 54 | type: "object",
|
---|
| 55 | properties: {
|
---|
| 56 | root: { type: "boolean" },
|
---|
| 57 | ignorePatterns: { $ref: "#/definitions/stringOrStrings" },
|
---|
| 58 | ...baseConfigProperties
|
---|
| 59 | },
|
---|
| 60 | additionalProperties: false
|
---|
| 61 | },
|
---|
| 62 |
|
---|
| 63 | // Config in `overrides`.
|
---|
| 64 | overrideConfig: {
|
---|
| 65 | type: "object",
|
---|
| 66 | properties: {
|
---|
| 67 | excludedFiles: { $ref: "#/definitions/stringOrStrings" },
|
---|
| 68 | files: { $ref: "#/definitions/stringOrStringsRequired" },
|
---|
| 69 | ...baseConfigProperties
|
---|
| 70 | },
|
---|
| 71 | required: ["files"],
|
---|
| 72 | additionalProperties: false
|
---|
| 73 | }
|
---|
| 74 | },
|
---|
| 75 |
|
---|
| 76 | $ref: "#/definitions/objectConfig"
|
---|
| 77 | };
|
---|
| 78 |
|
---|
| 79 | export default configSchema;
|
---|