UNPKG

2.08 kBJavaScriptView Raw
1/**
2 * @fileoverview Defines a schema for configs.
3 * @author Sylvan Mably
4 */
5
6"use strict";
7
8const baseConfigProperties = {
9 env: { type: "object" },
10 extends: { $ref: "#/definitions/stringOrStrings" },
11 globals: { type: "object" },
12 overrides: {
13 type: "array",
14 items: { $ref: "#/definitions/overrideConfig" },
15 additionalItems: false
16 },
17 parser: { type: ["string", "null"] },
18 parserOptions: { type: "object" },
19 plugins: { type: "array" },
20 processor: { type: "string" },
21 rules: { type: "object" },
22 settings: { type: "object" },
23 noInlineConfig: { type: "boolean" },
24
25 ecmaFeatures: { type: "object" } // deprecated; logs a warning when used
26};
27
28const 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 ...baseConfigProperties
58 },
59 additionalProperties: false
60 },
61
62 // Config in `overrides`.
63 overrideConfig: {
64 type: "object",
65 properties: {
66 excludedFiles: { $ref: "#/definitions/stringOrStrings" },
67 files: { $ref: "#/definitions/stringOrStringsRequired" },
68 ...baseConfigProperties
69 },
70 required: ["files"],
71 additionalProperties: false
72 }
73 },
74
75 $ref: "#/definitions/objectConfig"
76};
77
78module.exports = configSchema;