UNPKG

2.6 kBJavaScriptView Raw
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/**
14 * @fileoverview Defines a schema for configs.
15 * @author Sylvan Mably
16 */
17
18"use strict";
19
20const baseConfigProperties = {
21 $schema: { type: "string" },
22 env: { type: "object" },
23 extends: { $ref: "#/definitions/stringOrStrings" },
24 globals: { type: "object" },
25 overrides: {
26 type: "array",
27 items: { $ref: "#/definitions/overrideConfig" },
28 additionalItems: false
29 },
30 parser: { type: ["string", "null"] },
31 parserOptions: { type: "object" },
32 plugins: { type: "array" },
33 processor: { type: "string" },
34 rules: { type: "object" },
35 settings: { type: "object" },
36 noInlineConfig: { type: "boolean" },
37 reportUnusedDisableDirectives: { type: "boolean" },
38
39 ecmaFeatures: { type: "object" } // deprecated; logs a warning when used
40};
41
42const configSchema = {
43 definitions: {
44 stringOrStrings: {
45 oneOf: [
46 { type: "string" },
47 {
48 type: "array",
49 items: { type: "string" },
50 additionalItems: false
51 }
52 ]
53 },
54 stringOrStringsRequired: {
55 oneOf: [
56 { type: "string" },
57 {
58 type: "array",
59 items: { type: "string" },
60 additionalItems: false,
61 minItems: 1
62 }
63 ]
64 },
65
66 // Config at top-level.
67 objectConfig: {
68 type: "object",
69 properties: {
70 root: { type: "boolean" },
71 ignorePatterns: { $ref: "#/definitions/stringOrStrings" },
72 ...baseConfigProperties
73 },
74 additionalProperties: false
75 },
76
77 // Config in `overrides`.
78 overrideConfig: {
79 type: "object",
80 properties: {
81 excludedFiles: { $ref: "#/definitions/stringOrStrings" },
82 files: { $ref: "#/definitions/stringOrStringsRequired" },
83 ...baseConfigProperties
84 },
85 required: ["files"],
86 additionalProperties: false
87 }
88 },
89
90 $ref: "#/definitions/objectConfig"
91};
92
93module.exports = configSchema;