UNPKG

1.6 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 globals: { type: "object" },
11 parser: { type: ["string", "null"] },
12 parserOptions: { type: "object" },
13 plugins: { type: "array" },
14 rules: { type: "object" },
15 settings: { type: "object" },
16
17 ecmaFeatures: { type: "object" } // deprecated; logs a warning when used
18};
19
20const overrideProperties = Object.assign(
21 {},
22 baseConfigProperties,
23 {
24 files: {
25 oneOf: [
26 { type: "string" },
27 {
28 type: "array",
29 items: { type: "string" },
30 minItems: 1
31 }
32 ]
33 },
34 excludedFiles: {
35 oneOf: [
36 { type: "string" },
37 {
38 type: "array",
39 items: { type: "string" }
40 }
41 ]
42 }
43 }
44);
45
46const topLevelConfigProperties = Object.assign(
47 {},
48 baseConfigProperties,
49 {
50 extends: { type: ["string", "array"] },
51 root: { type: "boolean" },
52 overrides: {
53 type: "array",
54 items: {
55 type: "object",
56 properties: overrideProperties,
57 required: ["files"],
58 additionalProperties: false
59 }
60 }
61 }
62);
63
64const configSchema = {
65 type: "object",
66 properties: topLevelConfigProperties,
67 additionalProperties: false
68};
69
70module.exports = configSchema;