├── src ├── all_types │ ├── playground.ts │ ├── basics │ │ ├── index.ts │ │ ├── metadata.ts │ │ ├── base.ts │ │ ├── enum.ts │ │ ├── null.ts │ │ ├── __tests__ │ │ │ ├── string.ts │ │ │ └── enum.ts │ │ ├── boolean.ts │ │ ├── string.ts │ │ └── number.ts │ ├── utils │ │ └── IsType.ts │ ├── general │ │ ├── index.ts │ │ ├── const.ts │ │ ├── oneOf.ts │ │ ├── __tests__ │ │ │ ├── ref.ts │ │ │ ├── utils.ts │ │ │ ├── anyOf.ts │ │ │ └── allOf.ts │ │ ├── utils.ts │ │ ├── ref.ts │ │ ├── allOf.ts │ │ ├── anyOf.ts │ │ └── pick.ts │ ├── json_schema │ │ ├── __tests__ │ │ │ ├── def_ref.ts │ │ │ ├── type.ts │ │ │ └── json_schema.ts │ │ ├── type.ts │ │ └── json_schema.ts │ ├── array │ │ ├── array.ts │ │ └── __tests__ │ │ │ └── basic.ts │ └── object │ │ ├── __tests__ │ │ └── basic.ts │ │ └── object.ts └── index.ts ├── .gitignore ├── .npmignore ├── examples ├── babelpreset.ts ├── user.schema.ts ├── babelrc.ts ├── bitbucket_pipelines.ts └── eslintrc.ts ├── package.json ├── README.md ├── tsconfig.json ├── LICENSE └── yarn.lock /src/all_types/playground.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .vscode 2 | node_modules 3 | dist 4 | 5 | .DS_Store -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | examples 2 | .vscode 3 | src 4 | tsconfig.json 5 | -------------------------------------------------------------------------------- /src/all_types/basics/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./boolean"; 2 | export * from "./null"; 3 | export * from "./number"; 4 | export * from "./string"; 5 | -------------------------------------------------------------------------------- /src/all_types/utils/IsType.ts: -------------------------------------------------------------------------------- 1 | import {Boolean} from "ts-toolbelt"; 2 | 3 | export type IsType = T extends K ? Boolean.True : Boolean.False; 4 | -------------------------------------------------------------------------------- /src/all_types/basics/metadata.ts: -------------------------------------------------------------------------------- 1 | export type Metadata = { 2 | $schema: string; 3 | title: string; 4 | description: string; 5 | default: any; 6 | }; 7 | -------------------------------------------------------------------------------- /src/all_types/general/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./anyOf"; 2 | export * from "./allOf"; 3 | export * from "./oneOf"; 4 | export * from "./ref"; 5 | export * from "./const"; 6 | -------------------------------------------------------------------------------- /src/all_types/basics/base.ts: -------------------------------------------------------------------------------- 1 | import {EnumType} from "./enum"; 2 | import {Metadata} from "./metadata"; 3 | 4 | export type BaseType = Partial & Partial; 5 | -------------------------------------------------------------------------------- /src/all_types/general/const.ts: -------------------------------------------------------------------------------- 1 | export type ConstType = { 2 | const: T; 3 | }; 4 | 5 | export type ResolvedConstType = T extends ConstType ? U : never; 6 | -------------------------------------------------------------------------------- /src/all_types/basics/enum.ts: -------------------------------------------------------------------------------- 1 | export type EnumType = { 2 | enum: readonly T[]; 3 | }; 4 | 5 | export type ResolvedEnumType = T extends EnumType ? U : never; 6 | -------------------------------------------------------------------------------- /src/all_types/basics/null.ts: -------------------------------------------------------------------------------- 1 | import {BaseType} from "./base"; 2 | 3 | export type NullType = BaseType & { 4 | type: "null"; 5 | }; 6 | 7 | export type ResolvedNullType = T extends NullType ? null : never; 8 | -------------------------------------------------------------------------------- /src/all_types/basics/__tests__/string.ts: -------------------------------------------------------------------------------- 1 | import {ResolvedStringType} from "../string"; 2 | 3 | const basic = { 4 | type: "string", 5 | }; 6 | 7 | // should be string 8 | type ResolvedBasic = ResolvedStringType; 9 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./all_types/json_schema/json_schema"; 2 | export * from "./all_types/array/array"; 3 | export * from "./all_types/basics"; 4 | export * from "./all_types/object/object"; 5 | export * from "./all_types/general"; 6 | -------------------------------------------------------------------------------- /src/all_types/basics/boolean.ts: -------------------------------------------------------------------------------- 1 | import {BaseType} from "./base"; 2 | 3 | export type BooleanType = BaseType & { 4 | type: "boolean"; 5 | default?: boolean; 6 | }; 7 | 8 | export type ResolvedBooleanType = T extends BooleanType ? boolean : never; 9 | -------------------------------------------------------------------------------- /src/all_types/basics/string.ts: -------------------------------------------------------------------------------- 1 | import {BaseType} from "./base"; 2 | 3 | export type StringType = BaseType & { 4 | type: "string"; 5 | minLen?: number; 6 | maxLen?: number; 7 | pattern?: string; // this should be a regexp 8 | }; 9 | 10 | export type ResolvedStringType = T extends StringType ? string : never; 11 | -------------------------------------------------------------------------------- /src/all_types/basics/__tests__/enum.ts: -------------------------------------------------------------------------------- 1 | import {ResolvedEnumType} from "../enum"; 2 | 3 | const basic = { 4 | enum: ["foo", "bar", undefined], 5 | }; 6 | 7 | type ResolvedBasic = ResolvedEnumType; 8 | 9 | const enumWithString = { 10 | type: "string", 11 | enum: ["foo", "bar", undefined], 12 | }; 13 | 14 | type ResolvedEnumWithString = ResolvedEnumType; 15 | -------------------------------------------------------------------------------- /src/all_types/general/oneOf.ts: -------------------------------------------------------------------------------- 1 | import {List} from "ts-toolbelt"; 2 | 3 | import {BaseType} from "../basics/base"; 4 | import {JsonSchema, ResolvedJsonSchema} from "../.."; 5 | 6 | export type OneOf = BaseType & { 7 | oneOf: readonly JsonSchema[]; 8 | }; 9 | 10 | export type ResolvedOneOf = T extends OneOf 11 | ? ResolvedJsonSchema, Base> 12 | : never; 13 | -------------------------------------------------------------------------------- /src/all_types/general/__tests__/ref.ts: -------------------------------------------------------------------------------- 1 | import {ResolvedRef} from "../ref"; 2 | 3 | const test = { 4 | $ref: "#/definitions/obj2", 5 | }; 6 | 7 | type Base = { 8 | definitions: { 9 | obj1: {type: "string"}; 10 | obj2: { 11 | type: "object"; 12 | required: ["test1"]; 13 | properties: {test1: {type: "string"}}; 14 | }; 15 | }; 16 | }; 17 | 18 | type ResolvedTest = ResolvedRef; 19 | -------------------------------------------------------------------------------- /examples/babelpreset.ts: -------------------------------------------------------------------------------- 1 | import {ResolvedJsonSchema} from "../src"; 2 | 3 | const babelPreset = { 4 | type: "array", 5 | items: { 6 | type: ["string", "array"], 7 | items: { 8 | description: "the preset name in .[0] and the options object in .[1]", 9 | type: ["string", "object"], 10 | }, 11 | }, 12 | }; 13 | 14 | type BabelPreset = ResolvedJsonSchema; 15 | 16 | const preset: BabelPreset = [["test", {type: "test"}]]; 17 | -------------------------------------------------------------------------------- /src/all_types/json_schema/__tests__/def_ref.ts: -------------------------------------------------------------------------------- 1 | import {ResolvedJsonSchema} from "../json_schema"; 2 | 3 | export const defref = { 4 | type: "object", 5 | required: ["image"], 6 | definitions: { 7 | simple_image: { 8 | type: "string", 9 | }, 10 | 11 | image: { 12 | $ref: "#/definitions/simple_image", 13 | }, 14 | }, 15 | properties: { 16 | image: { 17 | $ref: "#/definitions/image", 18 | }, 19 | }, 20 | }; 21 | 22 | type DefRef = ResolvedJsonSchema; 23 | -------------------------------------------------------------------------------- /src/all_types/basics/number.ts: -------------------------------------------------------------------------------- 1 | import {BaseType} from "./base"; 2 | 3 | type BaseNumber = { 4 | minimum?: number; 5 | exclusiveMinimum?: number; 6 | maximum?: number; 7 | exclusiveMaximum?: number; 8 | multipleOf?: number; 9 | }; 10 | 11 | export type NumberType = BaseType & 12 | BaseNumber & { 13 | readonly type: "number"; 14 | }; 15 | 16 | export type IntegerType = BaseType & 17 | BaseNumber & { 18 | readonly type: "integer"; 19 | }; 20 | 21 | export type ResolvedNumberType = T extends NumberType | IntegerType 22 | ? number 23 | : never; 24 | -------------------------------------------------------------------------------- /src/all_types/general/utils.ts: -------------------------------------------------------------------------------- 1 | import {List, Boolean} from "ts-toolbelt"; 2 | 3 | export type HasSlash = T extends `${infer U}/${infer F}` 4 | ? Boolean.True 5 | : Boolean.False; 6 | 7 | export type GetPath = List.Filter< 8 | List.Flatten< 9 | HasSlash extends Boolean.True 10 | ? T extends `${infer U}/${infer F}` 11 | ? HasSlash extends Boolean.True 12 | ? [U, GetPath] 13 | : [U, F] 14 | : [] 15 | : [] 16 | >, 17 | "" 18 | >; 19 | 20 | export type GetRefPath = T extends `#${infer U}` 21 | ? GetPath 22 | : never; 23 | -------------------------------------------------------------------------------- /src/all_types/json_schema/__tests__/type.ts: -------------------------------------------------------------------------------- 1 | import {ResolvedMultiType} from "../type"; 2 | 3 | const basic = { 4 | type: ["string", "number"], 5 | }; 6 | 7 | // should be string | number 8 | type BasicResolved = ResolvedMultiType; 9 | 10 | const single = { 11 | type: ["string"], 12 | }; 13 | 14 | // should be string 15 | type SingleResolved = ResolvedMultiType; 16 | 17 | const multiArray = { 18 | type: ["string", "array"], 19 | items: { 20 | type: "string", 21 | }, 22 | }; 23 | 24 | // should be string | string[] 25 | type MultiArrayResolved = ResolvedMultiType; 26 | -------------------------------------------------------------------------------- /src/all_types/general/ref.ts: -------------------------------------------------------------------------------- 1 | import {Object} from "ts-toolbelt"; 2 | import {BaseType} from "../basics/base"; 3 | import {GetRefPath} from "./utils"; 4 | import {Pick} from "./pick"; 5 | import {JsonSchema, ResolvedJsonSchema} from "../json_schema/json_schema"; 6 | 7 | export type Ref = BaseType & { 8 | readonly $ref: string; 9 | }; 10 | 11 | export type ResolvedRef< 12 | T, 13 | Base extends object = {}, 14 | Excluded = T extends Ref ? Object.Omit : never, 15 | R = T extends Ref ? Pick> : never 16 | > = T extends Ref 17 | ? R & Excluded extends JsonSchema 18 | ? ResolvedJsonSchema 19 | : never 20 | : never; 21 | -------------------------------------------------------------------------------- /src/all_types/general/__tests__/utils.ts: -------------------------------------------------------------------------------- 1 | import {GetPath, GetRefPath} from "../utils"; 2 | 3 | const leftSlash = "/test"; 4 | const midSlash = "test/test"; 5 | const rightSlash = "test/"; 6 | const noSlash = "test"; 7 | const threeSlash = "test/test/test"; 8 | 9 | type LeftSlashPath = GetPath; 10 | type MidSlashPath = GetPath; 11 | type RightSlashPath = GetPath; 12 | type NoSlash = GetPath; 13 | type ThreeSlashPath = GetPath; 14 | 15 | const simpleRef = "#/test"; 16 | type SimpleRefPath = GetRefPath; 17 | 18 | const multiRefPath = "#/definitions/user1"; 19 | type MultiRefPath = GetRefPath; 20 | -------------------------------------------------------------------------------- /src/all_types/general/allOf.ts: -------------------------------------------------------------------------------- 1 | import {List, Union, Object, Any} from "ts-toolbelt"; 2 | 3 | import {BaseType} from "../basics/base"; 4 | import {JsonSchema, ResolvedJsonSchema} from "../.."; 5 | 6 | export type AllOf = BaseType & { 7 | allOf: readonly any[]; 8 | }; 9 | 10 | export type ResolvedAllOf< 11 | T, 12 | Base extends object = {}, 13 | Items extends List.List = T extends AllOf ? T["allOf"] : never, 14 | Excluded = T extends AllOf ? Object.Omit : never, 15 | Total = T extends AllOf 16 | ? Union.IntersectOf< 17 | { 18 | [k in keyof Items]: Items[k] & Excluded; 19 | }[number] 20 | > 21 | : never 22 | > = Total extends JsonSchema ? ResolvedJsonSchema : never; 23 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "json-schema-type", 3 | "author": "Rishabh Jain ", 4 | "version": "0.0.18", 5 | "license": "Apache-2.0", 6 | "main": "src/index.js", 7 | "typings": "dist/index.d.ts", 8 | "typesVersions": { 9 | ">=4.1": { "*": ["ts4.1/*"] } 10 | }, 11 | "repository": { 12 | "url": "https://github.com/RishabhJain96/json-schema-type", 13 | "type": "git" 14 | }, 15 | "scripts": { 16 | "dev": "ts-node src/index.ts", 17 | "build": "tsc", 18 | "prepublish": "yarn build" 19 | }, 20 | "devDependencies": { 21 | "ts-node": "^9.0.0", 22 | "ts-node-dev": "^1.0.0", 23 | "typescript": "^4.1.2" 24 | }, 25 | "dependencies": { 26 | "ts-toolbelt": "^8.0.7" 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/all_types/array/array.ts: -------------------------------------------------------------------------------- 1 | import {BaseType} from "../basics/base"; 2 | import {JsonSchema, ResolvedJsonSchema} from "../json_schema/json_schema"; 3 | 4 | type ArrayRestrictions = { 5 | additionalItems?: boolean | JsonSchema; 6 | minItems?: number; 7 | maxItems?: number; 8 | uniqueItems?: boolean; 9 | }; 10 | 11 | type ArrayWithItem = { 12 | type: "array"; 13 | items: JsonSchema; 14 | }; 15 | 16 | type BasicArrayType = { 17 | type: "array"; 18 | }; 19 | 20 | export type ArrayType = (ArrayWithItem | BasicArrayType) & 21 | ArrayRestrictions & 22 | BaseType; 23 | 24 | export type ResolvedArrayType< 25 | T extends ArrayType, 26 | Base extends object = {} 27 | > = T extends ArrayWithItem 28 | ? ResolvedJsonSchema[] 29 | : T extends BasicArrayType 30 | ? any[] 31 | : never; 32 | -------------------------------------------------------------------------------- /src/all_types/general/anyOf.ts: -------------------------------------------------------------------------------- 1 | import {List, Any, Union, Object} from "ts-toolbelt"; 2 | import {JsonSchema, ResolvedJsonSchema} from "../.."; 3 | import {BaseType} from "../basics/base"; 4 | 5 | export type AnyOf = BaseType & { 6 | anyOf: readonly any[]; 7 | }; 8 | 9 | export type ResolvedAnyOf< 10 | T, 11 | Base extends object = {}, 12 | Excluded = T extends AnyOf ? Object.Omit : never, 13 | Items extends List.List = T extends AnyOf ? T["anyOf"] : [], 14 | K extends Any.Key = List.Keys, 15 | AL = List.AtLeast< 16 | Union.ListOf< 17 | { 18 | [k in K]-?: List.At; 19 | }[K] 20 | > 21 | > 22 | > = AL extends List.List 23 | ? AL[number] & Excluded extends JsonSchema 24 | ? ResolvedJsonSchema 25 | : never 26 | : never; 27 | -------------------------------------------------------------------------------- /examples/user.schema.ts: -------------------------------------------------------------------------------- 1 | import {ResolvedJsonSchema} from "../src"; 2 | 3 | const UserSchema = { 4 | type: "object", 5 | required: ["email", "password"], 6 | properties: { 7 | name: {type: "string"}, 8 | email: {type: "string"}, 9 | password: {type: "string"}, 10 | tags: { 11 | type: "array", 12 | items: { 13 | type: "string", 14 | }, 15 | }, 16 | profile: { 17 | type: "object", 18 | additionalProperties: {type: "string"}, 19 | properties: { 20 | avatar: {type: "string"}, 21 | createdYear: {type: "integer"}, 22 | isAdmin: {type: "boolean"}, 23 | }, 24 | }, 25 | }, 26 | }; 27 | 28 | type User = ResolvedJsonSchema; 29 | 30 | const SampleUser: User = { 31 | email: "test@test.com", 32 | password: "very_secure_password", 33 | profile: { 34 | sample: "test", 35 | }, 36 | }; 37 | -------------------------------------------------------------------------------- /src/all_types/general/__tests__/anyOf.ts: -------------------------------------------------------------------------------- 1 | import {ResolvedAnyOf} from ".."; 2 | 3 | const basic = { 4 | anyOf: [ 5 | {type: "string"}, 6 | {type: "integer"}, 7 | {type: "object", properties: {name: {type: "string"}}}, 8 | {type: "object", properties: {user: {type: "string"}}}, 9 | ], 10 | }; 11 | 12 | type ResolvedBasic = ResolvedAnyOf; 13 | 14 | const test: ResolvedBasic = { 15 | name: "test", 16 | user: "wow", 17 | }; 18 | 19 | const no = { 20 | anyOf: [], 21 | }; 22 | 23 | type ResolvedNo = ResolvedAnyOf; 24 | 25 | const allOfAnyOf = { 26 | type: "object", 27 | anyOf: [ 28 | { 29 | properties: { 30 | extractStyles: { 31 | $ref: "#/definitions/extractStyling/properties/extractStyles", 32 | }, 33 | }, 34 | }, 35 | ], 36 | }; 37 | 38 | type ResolvedAllOf = ResolvedAnyOf; 39 | -------------------------------------------------------------------------------- /src/all_types/json_schema/type.ts: -------------------------------------------------------------------------------- 1 | import {Any, List, Object} from "ts-toolbelt"; 2 | import {ArrayType} from "../array/array"; 3 | import { 4 | BooleanType, 5 | IntegerType, 6 | NullType, 7 | NumberType, 8 | StringType, 9 | } from "../basics"; 10 | import {ObjectType} from "../object/object"; 11 | import {JsonSchema, ResolvedJsonSchema} from "./json_schema"; 12 | 13 | type ExtractType = T["type"]; 14 | 15 | export type TypeName = 16 | | ExtractType 17 | | ExtractType 18 | | ExtractType 19 | | ExtractType 20 | | ExtractType 21 | | ExtractType 22 | | ExtractType; 23 | 24 | export type MultiType = { 25 | type: readonly TypeName[]; 26 | }; 27 | 28 | export type ResolvedMultiType< 29 | T, 30 | Base extends object = {}, 31 | Types extends List.List = T extends MultiType ? T["type"] : [], 32 | WithoutType = T extends MultiType ? Object.Omit : {} 33 | > = T extends MultiType 34 | ? { 35 | [k in keyof Types]: ResolvedJsonSchema< 36 | Any.Cast<{type: Types[k]} & WithoutType, JsonSchema>, 37 | Base 38 | >; 39 | }[number] 40 | : never; 41 | -------------------------------------------------------------------------------- /src/all_types/general/__tests__/allOf.ts: -------------------------------------------------------------------------------- 1 | import {List} from "ts-toolbelt"; 2 | import {AllOf, ResolvedAllOf} from ".."; 3 | import {IsType} from "../../utils/IsType"; 4 | 5 | const basic = { 6 | allOf: [{type: "string"}, {type: "string", pattern: ""}], 7 | }; 8 | 9 | type ResolvedBasic = ResolvedAllOf; 10 | 11 | const no = { 12 | allOf: [], 13 | }; 14 | 15 | type ResolvedNo = ResolvedAllOf; 16 | 17 | const simpleMergeTest = { 18 | type: "object", 19 | allOf: [ 20 | { 21 | properties: { 22 | name: {type: "string"}, 23 | random: {type: "boolean"}, 24 | }, 25 | }, 26 | {required: ["name"]}, 27 | ], 28 | }; 29 | 30 | type ResolvedSimpleMergeTest = ResolvedAllOf; 31 | 32 | type T = IsType; 33 | 34 | const matchingKeyMergeTest = { 35 | type: "object", 36 | allOf: [ 37 | { 38 | properties: { 39 | name: {type: "string"}, 40 | random: {type: "boolean"}, 41 | }, 42 | }, 43 | { 44 | properties: { 45 | second: {type: "string"}, 46 | }, 47 | }, 48 | {required: ["name"]}, 49 | ], 50 | }; 51 | type ResolvedMatchingKeyMergeTest = ResolvedAllOf; 52 | -------------------------------------------------------------------------------- /src/all_types/object/__tests__/basic.ts: -------------------------------------------------------------------------------- 1 | import {ResolvedObjectType} from "../object"; 2 | 3 | const basic = { 4 | type: "object", 5 | }; 6 | 7 | // should be any object type 8 | type Basic = ResolvedObjectType; 9 | 10 | const withOnlyProperties = { 11 | type: "object", 12 | properties: { 13 | simple: {type: "integer"}, 14 | }, 15 | }; 16 | 17 | type OnlyProperties = ResolvedObjectType; 18 | 19 | const withProperties = { 20 | type: "object", 21 | required: ["stringTest", "multiTest", "nullTest"], 22 | properties: { 23 | stringTest: {type: "string"}, 24 | integerTest: {type: "integer"}, 25 | booleanTest: {type: "boolean"}, 26 | arrayTest: {type: "array"}, 27 | arrayWithItemsTest: {type: "array", items: {type: "string"}}, 28 | nullTest: {type: "null"}, 29 | multiTest: {type: ["string", "null"]}, 30 | }, 31 | }; 32 | 33 | type Properties = ResolvedObjectType; 34 | 35 | const test: Properties = { 36 | stringTest: "test", 37 | integerTest: 0, 38 | booleanTest: false, 39 | arrayTest: [], 40 | arrayWithItemsTest: ["test"], 41 | nullTest: null, 42 | multiTest: null, 43 | }; 44 | 45 | const withAdditionalProperties = { 46 | type: "object", 47 | properties: { 48 | simple: {type: "integer"}, 49 | }, 50 | additionalProperties: {type: ["string", "number"]}, 51 | }; 52 | 53 | type WithAdditionalProperties = ResolvedObjectType< 54 | typeof withAdditionalProperties 55 | >; 56 | -------------------------------------------------------------------------------- /src/all_types/json_schema/__tests__/json_schema.ts: -------------------------------------------------------------------------------- 1 | import {Ref} from "../../general/ref"; 2 | import {ResolvedJsonSchema} from "../json_schema"; 3 | 4 | const basicString = { 5 | type: "string", 6 | }; 7 | 8 | type ResolvedBasicString = ResolvedJsonSchema; 9 | 10 | const basicStringWithEnum = { 11 | type: "string", 12 | enum: ["foo", "bar", 0, undefined], 13 | }; 14 | 15 | type ResolvedBasicStringWithEnum = ResolvedJsonSchema< 16 | typeof basicStringWithEnum 17 | >; 18 | 19 | const basicObject = { 20 | type: "object", 21 | required: ["test"], 22 | properties: { 23 | test: {type: "string"}, 24 | }, 25 | }; 26 | 27 | type ResolvedBasicObject = ResolvedJsonSchema; 28 | 29 | const withDefinition = { 30 | definitions: { 31 | person: { 32 | type: "object", 33 | required: ["first_name", "last_name", "age"], 34 | properties: { 35 | first_name: {type: "string"}, 36 | last_name: {type: "string"}, 37 | age: {type: "integer"}, 38 | }, 39 | }, 40 | football_team: { 41 | type: "object", 42 | required: ["name", "league"], 43 | properties: { 44 | name: {type: "string"}, 45 | league: {type: "string"}, 46 | year_founded: {type: "integer"}, 47 | }, 48 | }, 49 | }, 50 | anyOf: [ 51 | {$ref: "#/definitions/person"}, 52 | {$ref: "#/definitions/football_team"}, 53 | ], 54 | }; 55 | 56 | type ResolvedWithDefinitions = ResolvedJsonSchema; 57 | -------------------------------------------------------------------------------- /src/all_types/array/__tests__/basic.ts: -------------------------------------------------------------------------------- 1 | import {ResolvedArrayType} from "../array"; 2 | 3 | const basicSchema = { 4 | type: "array", 5 | }; 6 | 7 | // should be any[] 8 | type ResolvedBasic = ResolvedArrayType; 9 | 10 | const schemaWithStringItems = { 11 | type: "array", 12 | items: { 13 | type: "string", 14 | }, 15 | }; 16 | 17 | // should be string[] 18 | type ResolvedStringItems = ResolvedArrayType; 19 | 20 | const schemaWithNumberItems = { 21 | type: "array", 22 | items: { 23 | type: "integer", 24 | }, 25 | }; 26 | 27 | // should be number[] 28 | type ResolvedNumberItems = ResolvedArrayType; 29 | 30 | const fake = { 31 | type: "random", 32 | }; 33 | 34 | const schemaWithArrayItems = { 35 | type: "array", 36 | items: { 37 | type: "array", 38 | items: { 39 | type: "number", 40 | }, 41 | }, 42 | }; 43 | 44 | // should be number[][] 45 | type ResolvedArrayItems = ResolvedArrayType; 46 | 47 | const schemaWithMultipleItems = { 48 | type: "array", 49 | items: { 50 | type: ["string", "number"], 51 | }, 52 | }; 53 | 54 | // should be (string | number)[] 55 | type ResolvedMultiple = ResolvedArrayType; 56 | 57 | const nestedArrayWithMultipleItems = { 58 | type: "array", 59 | items: { 60 | type: "array", 61 | items: { 62 | type: ["string", "number", "null"], 63 | }, 64 | }, 65 | }; 66 | 67 | type ResolvedNestedMultiple = ResolvedArrayType< 68 | typeof nestedArrayWithMultipleItems 69 | >; 70 | -------------------------------------------------------------------------------- /src/all_types/json_schema/json_schema.ts: -------------------------------------------------------------------------------- 1 | import {ArrayType, ResolvedArrayType} from "../array/array"; 2 | import { 3 | BooleanType, 4 | IntegerType, 5 | NullType, 6 | NumberType, 7 | ResolvedBooleanType, 8 | ResolvedNullType, 9 | ResolvedNumberType, 10 | ResolvedStringType, 11 | StringType, 12 | } from "../basics"; 13 | import {EnumType, ResolvedEnumType} from "../basics/enum"; 14 | import { 15 | AllOf, 16 | AnyOf, 17 | ConstType, 18 | OneOf, 19 | ResolvedAllOf, 20 | ResolvedAnyOf, 21 | ResolvedConstType, 22 | ResolvedOneOf, 23 | } from "../general"; 24 | import {Ref, ResolvedRef} from "../general/ref"; 25 | import {ObjectType, ResolvedObjectType} from "../object/object"; 26 | import {MultiType, ResolvedMultiType} from "./type"; 27 | 28 | type DefinitionRecord = {[key: string]: JsonSchema | DefinitionRecord}; 29 | 30 | export type JsonSchema = {id?: string; definitions?: DefinitionRecord} & ( 31 | | StringType 32 | | NumberType 33 | | IntegerType 34 | | BooleanType 35 | | NullType 36 | | ArrayType 37 | | ObjectType 38 | | MultiType 39 | | EnumType 40 | | ConstType 41 | | AnyOf 42 | | AllOf 43 | | OneOf 44 | | Ref 45 | ); 46 | 47 | export type ResolvedJsonSchema< 48 | T extends JsonSchema, 49 | Root extends object = T 50 | > = T extends Ref 51 | ? ResolvedRef 52 | : T extends AllOf 53 | ? ResolvedAllOf 54 | : T extends AnyOf 55 | ? ResolvedAnyOf 56 | : T extends OneOf 57 | ? ResolvedOneOf 58 | : T extends EnumType 59 | ? ResolvedEnumType 60 | : T extends ConstType 61 | ? ResolvedConstType 62 | : T extends StringType 63 | ? ResolvedStringType 64 | : T extends NumberType | IntegerType 65 | ? ResolvedNumberType 66 | : T extends BooleanType 67 | ? ResolvedBooleanType 68 | : T extends NullType 69 | ? ResolvedNullType 70 | : T extends ArrayType 71 | ? ResolvedArrayType 72 | : T extends MultiType 73 | ? ResolvedMultiType 74 | : T extends ObjectType 75 | ? ResolvedObjectType 76 | : never; 77 | -------------------------------------------------------------------------------- /src/all_types/general/pick.ts: -------------------------------------------------------------------------------- 1 | import {IterationOf} from "Iteration/IterationOf"; 2 | import {Iteration} from "Iteration/Iteration"; 3 | import {Pos} from "Iteration/Pos"; 4 | import {Next} from "Iteration/Next"; 5 | import {Key} from "Any/Key"; 6 | import {_Pick as _OPick} from "Object/Pick"; 7 | import {LastIndex} from "List/LastIndex"; 8 | import {List} from "List/List"; 9 | import {Boolean} from "Boolean/Boolean"; 10 | import {_ListOf} from "Object/ListOf"; 11 | 12 | type Action< 13 | O extends object, 14 | Path extends List, 15 | I extends Iteration = IterationOf<"0"> 16 | > = O extends List ? _ListOf<_OPick]>> : _OPick]>; 17 | 18 | /** 19 | @hidden 20 | */ 21 | type PickObject< 22 | O, 23 | Path extends List, 24 | I extends Iteration = IterationOf<"0"> 25 | > = O extends object // If it's an object 26 | ? Action extends infer Picked // Pick the current index 27 | ? Pos extends LastIndex // If it's the last index 28 | ? Picked[keyof Picked] // Return the picked object 29 | : { 30 | // Otherwise, continue diving 31 | [K in keyof Picked]: PickObject>; 32 | }[keyof Picked] & {} 33 | : never 34 | : O; // Not an object - x 35 | 36 | /** 37 | @hidden 38 | */ 39 | type PickList< 40 | O, 41 | Path extends List, 42 | I extends Iteration = IterationOf<"0"> 43 | > = O extends object // Same as above, but 44 | ? O extends (infer A)[] // If O is an array 45 | ? PickList[] // Dive into the array 46 | : _OPick]> extends infer Picked 47 | ? Pos extends LastIndex 48 | ? Picked 49 | : { 50 | [K in keyof Picked]: PickList>; 51 | } & {} 52 | : never 53 | : O; 54 | 55 | /** 56 | Extract out of `O` the fields at `Path` 57 | @param O to extract from 58 | @param Path to be followed 59 | @param list (?=`0`) `1` to work within object lists 60 | @returns [[Object]] 61 | @example 62 | ```ts 63 | ``` 64 | */ 65 | export type Pick< 66 | O extends object, 67 | Path extends List, 68 | list extends Boolean = 0 69 | > = { 70 | 0: PickObject; 71 | 1: PickList; 72 | }[list]; 73 | -------------------------------------------------------------------------------- /src/all_types/object/object.ts: -------------------------------------------------------------------------------- 1 | import {Any, Boolean} from "ts-toolbelt"; 2 | import {BaseType} from "../basics/base"; 3 | import {JsonSchema, ResolvedJsonSchema} from "../json_schema/json_schema"; 4 | 5 | type BasicObjectType = { 6 | type: "object"; 7 | }; 8 | 9 | type PropertiesObjectType = { 10 | type: "object"; 11 | properties: Record; 12 | }; 13 | 14 | type AdditionalPropertiesObjectType = { 15 | type: "object"; 16 | additionalProperties: boolean | JsonSchema; 17 | }; 18 | 19 | type ArrDependency = Record; 20 | 21 | type SchemaDependency = Record; 22 | 23 | type ObjectDependency = ArrDependency | SchemaDependency; 24 | 25 | export type ObjectType = BaseType & { 26 | type: "object"; 27 | properties?: Record; 28 | required?: readonly string[]; 29 | additionalProperties?: boolean | JsonSchema; 30 | minProperties?: number; 31 | maxProperties?: number; 32 | dependencies?: ObjectDependency | ObjectDependency[]; 33 | patternProperties?: Record | Record[]; 34 | }; 35 | 36 | export type RequiredPropertyKeys = Req extends readonly string[] 37 | ? {[K in keyof Props]-?: K extends Req[number] ? K : never}[keyof Props] 38 | : never; 39 | 40 | // we add keyof Props here so that if no required is given then everything is optional 41 | export type OptionalPropertyKeys = Req extends readonly string[] 42 | ? {[K in keyof Props]-?: K extends Req[number] ? never : K}[keyof Props] 43 | : keyof Props; 44 | 45 | export type ResolvedObjectType< 46 | T extends ObjectType, 47 | Base extends object = {}, 48 | Props = T["properties"], 49 | Req = T["required"], 50 | AdditionalProps = T["additionalProperties"] 51 | > = T extends PropertiesObjectType 52 | ? { 53 | [K in RequiredPropertyKeys]: Props[K] extends JsonSchema 54 | ? ResolvedJsonSchema 55 | : never; 56 | } & 57 | { 58 | [K in OptionalPropertyKeys]?: Props[K] extends JsonSchema 59 | ? ResolvedJsonSchema 60 | : never; 61 | } & 62 | (T extends AdditionalPropertiesObjectType 63 | ? AdditionalProps extends boolean 64 | ? Boolean.BooleanOf extends Boolean.True 65 | ? {[key: string]: any} 66 | : {} 67 | : AdditionalProps extends JsonSchema 68 | ? {[key: string]: ResolvedJsonSchema} 69 | : {} 70 | : {}) 71 | : T extends BasicObjectType 72 | ? {[key: string]: any} 73 | : never; 74 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # json-schema-type 2 | 3 | Generate typescript model definitions with **just** the JSON schema (including reference resolution). 4 | 5 | :warning: Currently in **beta** 6 | 7 | ## Motivation 8 | 9 | Avoid typing the JSON schema and then also managing typescript types. A large differentiating factor between this library and other libraries is that we use the JSON schema as a source of truth. 10 | 11 | If you already have JSON schemas, you can get typescript types with _little/no_ modifications. This can be particularly helpful when you already have a schema to do validation. Especially consider servers that are expecting JSON schemas (fastify, objection.js, etc). 12 | 13 | Following the formal specification found here: https://cswr.github.io/JsonSchema/ 14 | 15 | ## Usage 16 | 17 | **Requires typescript 4.1+** 18 | 19 | In order to use this library, your JSON schema must be declared as a type literal in Typescript. This prevents type widening. You can do this with either the `` operator or using `as const` (`{} as const`). Then, you can use the `ResolvedJsonSchema` type along with the `typeof` typescript operator to create a type for your model. 20 | 21 | ```ts 22 | import {ResolvedJsonSchema} from "json-schema-type"; 23 | 24 | const UserSchema = { 25 | type: "object", 26 | required: ["email", "password"], 27 | properties: { 28 | name: {type: "string"}, 29 | email: {type: "string"}, 30 | password: {type: "string"}, 31 | tags: { 32 | type: "array", 33 | items: { 34 | type: "string", 35 | }, 36 | }, 37 | profile: { 38 | type: "object", 39 | properties: { 40 | avatar: {type: "string"}, 41 | createdYear: {type: "integer"}, 42 | isAdmin: {type: "boolean"}, 43 | }, 44 | }, 45 | }, 46 | }; 47 | 48 | type User = ResolvedJsonSchema; 49 | 50 | // User is typed according to the schema above 51 | const SampleUser: User = { 52 | email: "test@test.com", 53 | password: "very_secure_password", 54 | }; 55 | ``` 56 | 57 | ## Supported Operations 58 | 59 | Crossed out items are typed at the schema level but not enforced at the type level. 60 | 61 | - [x] String, Integer, Number, Boolean, Null types 62 | - [x] ~~String restrictions~~ 63 | - [x] Basic array type 64 | - [x] Array items 65 | - [x] Array additional items 66 | - [x] ~~Array min items~~ 67 | - [x] ~~Array max items~~ 68 | - [x] Basic object type 69 | - [x] Object properties 70 | - [x] Object required 71 | - [x] Object additional properties 72 | - [x] ~~Object min/max properties~~ 73 | - [x] Object dependencies 74 | - [x] ~~Object patternProperties~~ 75 | - [x] anyOf 76 | - [x] allOf 77 | - [x] oneOf 78 | - [ ] not 79 | - [x] Enum 80 | - [x] Metadata 81 | - [x] Multiple types 82 | - [x] Definitions 83 | - [x] References 84 | - [x] Const 85 | 86 | ## Alternatives: 87 | 88 | - `@sinclair/typebox`: Specifies a builder format and allows you to get the model types back. 89 | - `fluent-schema`: Driven by fastify. You do not get types from this and are expected to generate them yourself. 90 | - `@bluejay/schema`: Similar to typebox. Exposes a set of utility methods to generate typed json schema definitions. 91 | -------------------------------------------------------------------------------- /examples/babelrc.ts: -------------------------------------------------------------------------------- 1 | import {ResolvedJsonSchema} from "../src"; 2 | 3 | const schema = { 4 | title: "JSON schema for Babel 6+ configuration files", 5 | $schema: "http://json-schema.org/draft-04/schema#", 6 | type: "object", 7 | properties: { 8 | ast: { 9 | default: true, 10 | description: "Include the AST in the returned object", 11 | type: "boolean", 12 | }, 13 | auxiliaryCommentAfter: { 14 | description: "Attach a comment after all non-user injected code.", 15 | type: "string", 16 | }, 17 | auxiliaryCommentBefore: { 18 | description: "Attach a comment before all non-user injected code.", 19 | type: "string", 20 | }, 21 | code: { 22 | default: true, 23 | description: "Enable code generation", 24 | type: "boolean", 25 | }, 26 | comments: { 27 | default: true, 28 | description: "Output comments in generated output.", 29 | type: "boolean", 30 | }, 31 | compact: { 32 | default: "auto", 33 | description: 34 | 'Do not include superfluous whitespace characters and line terminators. When set to "auto" compact is set to true on input sizes of >500KB.', 35 | type: ["string", "boolean"], 36 | enum: ["auto", true, false], 37 | }, 38 | env: { 39 | default: {}, 40 | description: 41 | 'This is an object of keys that represent different environments. For example, you may have: `{ env: { production: { /* specific options */ } } }` which will use those options when the environment variable BABEL_ENV is set to "production". If BABEL_ENV isn\'t set then NODE_ENV will be used, if it\'s not set then it defaults to "development"', 42 | type: "object", 43 | }, 44 | extends: { 45 | description: "A path to a .babelrc file to extend", 46 | type: "string", 47 | }, 48 | filename: { 49 | default: "unknown", 50 | description: "Filename for use in errors etc.", 51 | type: "string", 52 | }, 53 | filenameRelative: { 54 | description: 'Filename relative to sourceRoot (defaults to "filename")', 55 | type: "string", 56 | }, 57 | highlightCode: { 58 | description: "ANSI highlight syntax error code frames", 59 | type: "boolean", 60 | }, 61 | ignore: { 62 | description: 'Opposite of the "only" option', 63 | type: ["array", "string"], 64 | items: { 65 | type: "string", 66 | }, 67 | }, 68 | inputSourceMap: { 69 | default: true, 70 | description: 71 | "If true, attempt to load an input sourcemap from the file itself. If an object is provided, it will be treated as the source map object itself.", 72 | type: ["boolean", "object"], 73 | }, 74 | keepModuleIdExtensions: { 75 | default: false, 76 | description: "Keep extensions in module ids", 77 | type: "boolean", 78 | }, 79 | moduleId: { 80 | description: "Specify a custom name for module ids.", 81 | type: "string", 82 | }, 83 | moduleIds: { 84 | default: false, 85 | description: 86 | "If truthy, insert an explicit id for modules. By default, all modules are anonymous. (Not available for common modules)", 87 | type: "string", 88 | }, 89 | moduleRoot: { 90 | description: 91 | 'Optional prefix for the AMD module formatter that will be prepend to the filename on module definitions. (defaults to "sourceRoot")', 92 | type: "string", 93 | }, 94 | only: { 95 | description: 96 | "A glob, regex, or mixed array of both, matching paths to only compile. Can also be an array of arrays containing paths to explicitly match. When attempting to compile a non-matching file it's returned verbatim.", 97 | type: ["array", "string"], 98 | items: { 99 | type: "string", 100 | }, 101 | }, 102 | plugins: { 103 | description: "List of plugins to load and use", 104 | type: "array", 105 | items: { 106 | type: ["string", "array"], 107 | items: { 108 | description: "the plugin name in .[0] and the options object in .[1]", 109 | type: ["string", "object"], 110 | }, 111 | }, 112 | }, 113 | presets: { 114 | description: "List of presets (a set of plugins) to load and use", 115 | type: "array", 116 | items: { 117 | type: ["string", "array"], 118 | items: { 119 | description: "the preset name in .[0] and the options object in .[1]", 120 | type: ["string", "object"], 121 | }, 122 | }, 123 | }, 124 | retainLines: { 125 | default: false, 126 | description: 127 | "Retain line numbers. This will lead to wacky code but is handy for scenarios where you can't use source maps. NOTE: This will obviously not retain the columns.", 128 | type: "boolean", 129 | }, 130 | sourceFileName: { 131 | description: 132 | 'Set sources[0] on returned source map. (defaults to "filenameRelative")', 133 | type: "string", 134 | }, 135 | sourceMaps: { 136 | default: false, 137 | description: 138 | 'If truthy, adds a map property to returned output. If set to "inline", a comment with a sourceMappingURL directive is added to the bottom of the returned code. If set to "both" then a map property is returned as well as a source map comment appended.', 139 | type: ["string", "boolean"], 140 | enum: ["both", "inline", true, false], 141 | }, 142 | sourceMapTarget: { 143 | description: 144 | 'Set file on returned source map. (defaults to "filenameRelative")', 145 | type: "string", 146 | }, 147 | sourceRoot: { 148 | description: 149 | 'The root from which all sources are relative. (defaults to "moduleRoot")', 150 | type: "string", 151 | }, 152 | }, 153 | }; 154 | 155 | type BabelConfig = ResolvedJsonSchema; 156 | 157 | const config: BabelConfig = { 158 | moduleIds: "test", 159 | ast: false, 160 | presets: ["test"], 161 | sourceMaps: true, 162 | only: ["true"], 163 | }; 164 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | /* Visit https://aka.ms/tsconfig.json to read more about this file */ 4 | 5 | /* Basic Options */ 6 | // "incremental": true, /* Enable incremental compilation */ 7 | "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */ 8 | "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */ 9 | // "lib": [], /* Specify library files to be included in the compilation. */ 10 | // "allowJs": true, /* Allow javascript files to be compiled. */ 11 | // "checkJs": true, /* Report errors in .js files. */ 12 | // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ 13 | // "declaration": true, /* Generates corresponding '.d.ts' file. */ 14 | "declaration": true, 15 | // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ 16 | // "sourceMap": true, /* Generates corresponding '.map' file. */ 17 | // "outFile": "./", /* Concatenate and emit output to single file. */ 18 | "outDir": "./dist", 19 | // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ 20 | // "composite": true, /* Enable project compilation */ 21 | // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */ 22 | // "removeComments": true, /* Do not emit comments to output. */ 23 | // "noEmit": true, /* Do not emit outputs. */ 24 | // "importHelpers": true, /* Import emit helpers from 'tslib'. */ 25 | // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ 26 | // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ 27 | 28 | /* Strict Type-Checking Options */ 29 | "strict": true, /* Enable all strict type-checking options. */ 30 | // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ 31 | // "strictNullChecks": true, /* Enable strict null checks. */ 32 | // "strictFunctionTypes": true, /* Enable strict checking of function types. */ 33 | // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */ 34 | // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */ 35 | // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ 36 | // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ 37 | 38 | /* Additional Checks */ 39 | // "noUnusedLocals": true, /* Report errors on unused locals. */ 40 | // "noUnusedParameters": true, /* Report errors on unused parameters. */ 41 | // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ 42 | // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ 43 | // "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */ 44 | 45 | /* Module Resolution Options */ 46 | // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ 47 | // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ 48 | // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ 49 | // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ 50 | // "typeRoots": [], /* List of folders to include type definitions from. */ 51 | // "types": [], /* Type declaration files to be included in compilation. */ 52 | // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ 53 | "esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ 54 | // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ 55 | // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ 56 | 57 | /* Source Map Options */ 58 | // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ 59 | // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ 60 | // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ 61 | // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ 62 | 63 | /* Experimental Options */ 64 | // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ 65 | // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ 66 | 67 | /* Advanced Options */ 68 | "skipLibCheck": true, /* Skip type checking of declaration files. */ 69 | "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */ 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. -------------------------------------------------------------------------------- /examples/bitbucket_pipelines.ts: -------------------------------------------------------------------------------- 1 | import {ResolvedJsonSchema} from "../src/all_types/json_schema/json_schema"; 2 | 3 | const schema = { 4 | $schema: "http://json-schema.org/draft-07/schema#", 5 | $id: "https://bitbucket.org/product/features/pipelines", 6 | title: "Bitbucket Pipelines Schema", 7 | type: "object", 8 | properties: { 9 | image: { 10 | $ref: "#/definitions/image", 11 | default: "atlassian/default-image:latest", 12 | }, 13 | clone: { 14 | $ref: "#/definitions/clone", 15 | }, 16 | options: { 17 | $ref: "#/definitions/options", 18 | }, 19 | definitions: { 20 | $ref: "#/definitions/definitions", 21 | }, 22 | pipelines: { 23 | $ref: "#/definitions/pipelines", 24 | }, 25 | }, 26 | additionalProperties: false, 27 | required: ["pipelines"], 28 | definitions: { 29 | pipelines: { 30 | type: "object", 31 | title: "Build pipelines", 32 | description: 33 | "The start of your pipelines definitions. Under this keyword you must define your build pipelines using at least one of the following:\n\n * default (for all branches that don't match any of the following)\n * branches (Git and Mercurial)\n * tags (Git)\n * bookmarks (Mercurial)", 34 | properties: { 35 | branches: { 36 | type: "object", 37 | title: "Branch-specific build pipelines", 38 | description: 39 | "Defines a section for all branch-specific build pipelines. The names or expressions in this section are matched against:\n\n * branches in your Git repository\n * named branches in your Mercurial repository\n\nYou can use glob patterns for handling the branch names.", 40 | additionalProperties: { 41 | $ref: "#/definitions/steps", 42 | }, 43 | minProperties: 1, 44 | }, 45 | bookmarks: { 46 | type: "object", 47 | title: 48 | "Bookmark-specific build pipelines (to be used in Mercurial repositories)", 49 | description: 50 | "Defines all bookmark-specific build pipelines. \n\nThe names or expressions in this section are matched against bookmarks in your Mercurial repository. \n\nYou can use glob patterns for handling the tag names.", 51 | additionalProperties: { 52 | $ref: "#/definitions/steps", 53 | }, 54 | minProperties: 1, 55 | }, 56 | custom: { 57 | type: "object", 58 | title: "Manually triggered build pipelines", 59 | description: 60 | "Defines pipelines that can only be triggered manually or scheduled from the Bitbucket Cloud interface.", 61 | additionalProperties: { 62 | $ref: "#/definitions/stepsWithVariables", 63 | }, 64 | minProperties: 1, 65 | }, 66 | tags: { 67 | type: "object", 68 | title: "Tag-specific build pipelines", 69 | description: 70 | "Defines all tag-specific build pipelines. \n\nThe names or expressions in this section are matched against tags and annotated tags in your Git repository. \n\nYou can use glob patterns for handling the tag names.", 71 | additionalProperties: { 72 | $ref: "#/definitions/steps", 73 | }, 74 | minProperties: 1, 75 | }, 76 | "pull-requests": { 77 | type: "object", 78 | title: "Pull-request-specific build pipelines", 79 | description: 80 | "A special pipeline which only runs on pull requests. Pull-requests has the same level of indentation as branches.\n\nThis type of pipeline runs a little differently to other pipelines. When it's triggered, we'll merge the destination branch into your working branch before it runs. If the merge fails we will stop the pipeline.", 81 | additionalProperties: { 82 | $ref: "#/definitions/steps", 83 | }, 84 | minProperties: 1, 85 | }, 86 | default: { 87 | title: "Default build pipeline for branches", 88 | description: 89 | "The default pipeline runs on every push to the repository, unless a branch-specific pipeline is defined. \nYou can define a branch pipeline in the branches section.\n\nNote: The default pipeline doesn't run on tags or bookmarks.", 90 | $ref: "#/definitions/steps", 91 | }, 92 | }, 93 | additionalProperties: false, 94 | }, 95 | stepsWithVariables: { 96 | type: "array", 97 | items: { 98 | anyOf: [ 99 | { 100 | type: "object", 101 | properties: { 102 | variables: { 103 | type: "array", 104 | description: "List of variables for the custom pipeline", 105 | items: { 106 | type: "object", 107 | properties: { 108 | name: { 109 | type: "string", 110 | description: "Name of a variable for the custom pipeline", 111 | minLength: 1, 112 | }, 113 | }, 114 | additionalProperties: false, 115 | }, 116 | minItems: 1, 117 | }, 118 | }, 119 | additionalProperties: false, 120 | }, 121 | { 122 | type: "object", 123 | properties: { 124 | step: { 125 | $ref: "#/definitions/step", 126 | }, 127 | }, 128 | additionalProperties: false, 129 | }, 130 | { 131 | type: "object", 132 | properties: { 133 | parallel: { 134 | $ref: "#/definitions/parallel", 135 | }, 136 | }, 137 | additionalProperties: false, 138 | }, 139 | ], 140 | }, 141 | minItems: 1, 142 | }, 143 | steps: { 144 | type: "array", 145 | items: { 146 | anyOf: [ 147 | { 148 | type: "object", 149 | properties: { 150 | step: { 151 | $ref: "#/definitions/step", 152 | }, 153 | }, 154 | additionalProperties: false, 155 | }, 156 | { 157 | type: "object", 158 | properties: { 159 | parallel: { 160 | $ref: "#/definitions/parallel", 161 | }, 162 | }, 163 | additionalProperties: false, 164 | }, 165 | ], 166 | }, 167 | minItems: 1, 168 | }, 169 | step: { 170 | type: "object", 171 | title: "Build execution unit", 172 | description: 173 | "Define s a build execution unit. \n\nSteps are executed in the order that they appear in the bitbucket-pipelines.yml file. \nYou can use up to 10 steps in a pipeline.", 174 | properties: { 175 | name: { 176 | type: "string", 177 | title: "Name of the step", 178 | description: 179 | "You can add a name to a step to make displays and reports easier to read and understand.", 180 | minLength: 1, 181 | }, 182 | image: { 183 | $ref: "#/definitions/image", 184 | }, 185 | "max-time": { 186 | $ref: "#/definitions/max-time", 187 | }, 188 | size: { 189 | $ref: "#/definitions/size", 190 | }, 191 | script: { 192 | $ref: "#/definitions/script", 193 | description: "Commands to execute in the step", 194 | }, 195 | "after-script": { 196 | $ref: "#/definitions/script", 197 | title: "Commands to execute after the step succeeds or fails", 198 | description: 199 | "Commands inside an after-script section will run when the step succeeds or fails. This could be useful for clean up commands, test coverage, notifications, or rollbacks you might want to run, especially if your after-script uses the value of BITBUCKET_EXIT_CODE.\n\nNote: If any commands in the after-script section fail:\n\n* we won't run any more commands in that section\n\n* it will not effect the reported status of the step.", 200 | }, 201 | artifacts: { 202 | type: "array", 203 | title: "Files produced by a step to share with a following step", 204 | description: 205 | "Defines files to be shared from one step to a later step in your pipeline. Artifacts can be defined using glob patterns.", 206 | items: { 207 | type: "string", 208 | description: "Glob pattern for the path to the artifacts", 209 | minLength: 1, 210 | }, 211 | minItems: 1, 212 | }, 213 | caches: { 214 | type: "array", 215 | description: "Caches enabled for the step", 216 | items: { 217 | type: "string", 218 | description: "Name of the cache", 219 | minLength: 1, 220 | }, 221 | minItems: 1, 222 | }, 223 | clone: { 224 | $ref: "#/definitions/clone", 225 | }, 226 | services: { 227 | type: "array", 228 | description: "Services enabled for the step", 229 | items: { 230 | type: "string", 231 | description: "Name of the service", 232 | minLength: 1, 233 | }, 234 | minItems: 1, 235 | maxItems: 5, 236 | }, 237 | trigger: { 238 | type: "string", 239 | title: "Step trigger type", 240 | description: 241 | "Specifies whether a step will run automatically or only after someone manually triggers it. You can define the trigger type as manual or automatic. If the trigger type is not defined, the step defaults to running automatically. The first step cannot be manual. If you want to have a whole pipeline only run from a manual trigger then use a custom pipeline.", 242 | enum: ["automatic", "manual"], 243 | default: "automatic", 244 | }, 245 | deployment: { 246 | type: "string", 247 | title: "Type of environment for the deployment step", 248 | description: 249 | "Sets the type of environment for your deployment step, used in the Deployments dashboard.", 250 | minLength: 1, 251 | }, 252 | }, 253 | required: ["script"], 254 | additionalProperties: false, 255 | }, 256 | parallel: { 257 | type: "array", 258 | title: "Set of steps to run concurrently", 259 | description: 260 | "Parallel steps enable you to build and test faster, by running a set of steps at the same time.\n\nThe total number of build minutes used by a pipeline will not change if you make the steps parallel, but you'll be able to see the results sooner.\n\nThere is a limit of 10 for the total number of steps you can run in a pipeline, regardless of whether they are running in parallel or serial.", 261 | items: { 262 | type: "object", 263 | properties: { 264 | step: { 265 | $ref: "#/definitions/step", 266 | }, 267 | }, 268 | additionalProperties: false, 269 | }, 270 | minItems: 2, 271 | }, 272 | script: { 273 | description: 274 | "Contains a list of commands that are executed in sequence. \n\nScripts are executed in the order in which they appear in a step. \n\nWe recommend that you move large scripts to a separate script file and call it from the bitbucket-pipelines.yml.", 275 | type: "array", 276 | items: { 277 | oneOf: [ 278 | { 279 | type: "string", 280 | description: "Command to execute", 281 | minLength: 1, 282 | }, 283 | { 284 | $ref: "#/definitions/pipe", 285 | }, 286 | ], 287 | }, 288 | minItems: 1, 289 | }, 290 | pipe: { 291 | type: "object", 292 | title: "Pipe to execute", 293 | description: 294 | "Pipes make complex tasks easier, by doing a lot of the work behind the scenes.\nThis means you can just select which pipe you want to use, and supply the necessary variables.\nYou can look at the repository for the pipe to see what commands it is running.\n\nLearn more about pipes: https://confluence.atlassian.com/bitbucket/pipes-958765631.html", 295 | properties: { 296 | pipe: { 297 | type: "string", 298 | title: "Pipe identifier", 299 | description: 300 | "Pipes make complex tasks easier, by doing a lot of the work behind the scenes.\nThis means you can just select which pipe you want to use, and supply the necessary variables.\nYou can look at the repository for the pipe to see what commands it is running.\n\nLearn more about pipes: https://confluence.atlassian.com/bitbucket/pipes-958765631.html", 301 | minLength: 1, 302 | }, 303 | variables: { 304 | type: "object", 305 | description: "Environment variables passed to the pipe", 306 | additionalProperties: { 307 | type: "string", 308 | description: "Environment variable value", 309 | minLength: 1, 310 | }, 311 | minProperties: 1, 312 | }, 313 | }, 314 | required: ["pipe"], 315 | additionalProperties: false, 316 | }, 317 | definitions: { 318 | type: "object", 319 | title: "Defines resources used elsewhere in the pipeline configuration", 320 | description: 321 | "Define resources used elsewhere in your pipeline configuration. \nResources can include:\n\n* services that run in separate Docker containers – see https://confluence.atlassian.com/x/gC8kN\n\n* caches – see https://confluence.atlassian.com/x/bA1hNQ#Cachingdependencies-custom-caches\n\n* YAML anchors - a way to define a chunk of your yaml for easy re-use - see https://confluence.atlassian.com/bitbucket/yaml-anchors-960154027.html", 322 | properties: { 323 | services: { 324 | $ref: "#/definitions/services", 325 | }, 326 | caches: { 327 | $ref: "#/definitions/caches", 328 | }, 329 | }, 330 | }, 331 | services: { 332 | type: "object", 333 | title: "Defines services that run in separate Docker containers", 334 | description: 335 | "Rather than trying to build all the resources you might need into one large image, we can spin up separate docker containers for services. This will tend to speed up the build, and makes it very easy to change a single service without having to redo your whole image.", 336 | additionalProperties: { 337 | type: "object", 338 | properties: { 339 | image: { 340 | $ref: "#/definitions/image", 341 | }, 342 | variables: { 343 | type: "object", 344 | description: 345 | "Environment variables passed to the service container", 346 | additionalProperties: { 347 | type: "string", 348 | description: "Environment variable value", 349 | minLength: 1, 350 | }, 351 | minProperties: 1, 352 | }, 353 | memory: { 354 | type: "integer", 355 | description: "Memory limit for the service container, in megabytes", 356 | minimum: 128, 357 | default: 1024, 358 | }, 359 | }, 360 | }, 361 | }, 362 | caches: { 363 | type: "object", 364 | title: "Defines custom caches to be used by pipelines", 365 | description: 366 | "Re-downloading dependencies from the internet for each step of a build can take a lot of time. Using a cache they are downloaded once to our servers and then locally loaded into the build each time.", 367 | patternProperties: { 368 | "^(?!-)[-a-z0-9]{0,49}[a-z0-9]$": { 369 | type: "string", 370 | title: "Path to the directory to be cached", 371 | description: 372 | "Path to the directory to be cached, can be absolute or relative to the clone directory", 373 | minLength: 1, 374 | }, 375 | }, 376 | not: { 377 | required: ["docker"], 378 | }, 379 | additionalProperties: false, 380 | }, 381 | options: { 382 | type: "object", 383 | title: "Global settings that apply to all pipelines", 384 | description: 385 | "Contains global settings that apply to all your pipelines. The main keyword you'd use here is max-time.", 386 | properties: { 387 | docker: { 388 | type: "boolean", 389 | description: 390 | "A flag to add Docker to all build steps in all pipelines", 391 | }, 392 | "max-time": { 393 | $ref: "#/definitions/max-time", 394 | }, 395 | size: { 396 | $ref: "#/definitions/size", 397 | }, 398 | }, 399 | additionalProperties: false, 400 | }, 401 | "max-time": { 402 | type: "integer", 403 | description: "Maximum amount of minutes a step can execute", 404 | minimum: 1, 405 | maximum: 120, 406 | default: 120, 407 | }, 408 | size: { 409 | type: "string", 410 | title: "Multiplier of the resources allocated to a pipeline step", 411 | description: 412 | "You can allocate additional resources to a step, or to the whole pipeline. \nBy specifying the size of 2x, you'll have double the resources available (eg. 4GB memory → 8GB memory).\n\nAt this time, valid sizes are 1x and 2x.", 413 | enum: ["1x", "2x"], 414 | default: "1x", 415 | }, 416 | clone: { 417 | type: "object", 418 | title: "Contains settings to clone the repository into a container", 419 | description: 420 | "Contains settings for when we clone your repository into a container. Settings here include:\n\n* lfs - Support for Git lfs\n\n* depth - the depth of the Git clone.", 421 | properties: { 422 | depth: { 423 | description: 424 | "Depth of Git clones for all pipelines (supported only for Git repositories)", 425 | oneOf: [ 426 | { 427 | type: "integer", 428 | minimum: 1, 429 | }, 430 | { 431 | const: "full", 432 | }, 433 | ], 434 | default: 50, 435 | }, 436 | enabled: { 437 | type: "boolean", 438 | description: "Enables cloning of the repository", 439 | default: true, 440 | }, 441 | lfs: { 442 | type: "boolean", 443 | description: 444 | "Enables the download of LFS files in the clone (supported only for Git repositories)", 445 | default: false, 446 | }, 447 | }, 448 | additionalProperties: false, 449 | }, 450 | runAsUser: { 451 | type: "integer", 452 | title: "The UID of a user in the docker image to run as", 453 | description: 454 | "Overrides image's default user, specified user UID must be an existing user in the image with a valid home directory", 455 | }, 456 | simpleImage: { 457 | type: "string", 458 | title: 459 | "Name of the Docker image which may or may not include registry URL, tag, and digest value", 460 | description: 461 | "The Docker container to run your builds.\n\nsee: https://confluence.atlassian.com/x/kYU5Lw for details", 462 | minLength: 1, 463 | }, 464 | imageWithCustomUser: { 465 | type: "object", 466 | properties: { 467 | name: { 468 | $ref: "#/definitions/simpleImage", 469 | }, 470 | "run-as-user": { 471 | $ref: "#/definitions/runAsUser", 472 | }, 473 | }, 474 | required: ["name"], 475 | additionalProperties: false, 476 | }, 477 | privateImage: { 478 | type: "object", 479 | description: "A docker image hosted in a private repository", 480 | properties: { 481 | name: { 482 | $ref: "#/definitions/simpleImage", 483 | }, 484 | username: { 485 | type: "string", 486 | description: "Username to use to fetch the Docker image", 487 | minLength: 1, 488 | }, 489 | password: { 490 | type: "string", 491 | description: "Password to use to fetch the Docker image", 492 | minLength: 1, 493 | }, 494 | email: { 495 | type: "string", 496 | description: "Email to use to fetch the Docker image", 497 | format: "email", 498 | minLength: 1, 499 | }, 500 | "run-as-user": { 501 | $ref: "#/definitions/runAsUser", 502 | }, 503 | }, 504 | required: ["name", "username", "password"], 505 | additionalProperties: false, 506 | }, 507 | awsImage: { 508 | type: "object", 509 | description: "A docker image hosted by AWS ECR", 510 | properties: { 511 | name: { 512 | $ref: "#/definitions/simpleImage", 513 | }, 514 | aws: { 515 | type: "object", 516 | description: "AWS credentials", 517 | properties: { 518 | "access-key": { 519 | type: "string", 520 | description: "AWS Access Key", 521 | minLength: 1, 522 | }, 523 | "secret-key": { 524 | type: "string", 525 | description: "AWS Secret Key", 526 | minLength: 1, 527 | }, 528 | }, 529 | required: ["access-key", "secret-key"], 530 | additionalProperties: false, 531 | }, 532 | "run-as-user": { 533 | $ref: "#/definitions/runAsUser", 534 | }, 535 | }, 536 | required: ["name", "aws"], 537 | additionalProperties: false, 538 | }, 539 | image: { 540 | oneOf: [ 541 | { 542 | $ref: "#/definitions/simpleImage", 543 | }, 544 | { 545 | $ref: "#/definitions/imageWithCustomUser", 546 | }, 547 | { 548 | $ref: "#/definitions/privateImage", 549 | }, 550 | { 551 | $ref: "#/definitions/awsImage", 552 | }, 553 | ], 554 | }, 555 | }, 556 | }; 557 | 558 | type BitbucketPipeline = ResolvedJsonSchema; 559 | 560 | const example: BitbucketPipeline = { 561 | image: "node:10.15.0", 562 | pipelines: { 563 | custom: { 564 | sonar: [ 565 | { 566 | step: { 567 | script: ['echo "Manual triggers for Sonar are awesome!"'], 568 | }, 569 | }, 570 | ], 571 | "deployment-to-prod": [ 572 | { 573 | step: { 574 | script: ['echo "Manual triggers for deployments are awesome!"'], 575 | }, 576 | }, 577 | ], 578 | }, 579 | branches: { 580 | staging: [ 581 | { 582 | step: { 583 | script: ['echo "Auto pipelines are cool too."'], 584 | }, 585 | }, 586 | ], 587 | }, 588 | }, 589 | }; 590 | -------------------------------------------------------------------------------- /yarn.lock: -------------------------------------------------------------------------------- 1 | # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. 2 | # yarn lockfile v1 3 | 4 | 5 | "@types/strip-bom@^3.0.0": 6 | version "3.0.0" 7 | resolved "https://registry.yarnpkg.com/@types/strip-bom/-/strip-bom-3.0.0.tgz#14a8ec3956c2e81edb7520790aecf21c290aebd2" 8 | integrity sha1-FKjsOVbC6B7bdSB5CuzyHCkK69I= 9 | 10 | "@types/strip-json-comments@0.0.30": 11 | version "0.0.30" 12 | resolved "https://registry.yarnpkg.com/@types/strip-json-comments/-/strip-json-comments-0.0.30.tgz#9aa30c04db212a9a0649d6ae6fd50accc40748a1" 13 | integrity sha512-7NQmHra/JILCd1QqpSzl8+mJRc8ZHz3uDm8YV1Ks9IhK0epEiTw8aIErbvH9PI+6XbqhyIQy3462nEsn7UVzjQ== 14 | 15 | anymatch@~3.1.1: 16 | version "3.1.1" 17 | resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-3.1.1.tgz#c55ecf02185e2469259399310c173ce31233b142" 18 | integrity sha512-mM8522psRCqzV+6LhomX5wgp25YVibjh8Wj23I5RPkPppSVSjyKD2A2mBJmWGa+KN7f2D6LNh9jkBCeyLktzjg== 19 | dependencies: 20 | normalize-path "^3.0.0" 21 | picomatch "^2.0.4" 22 | 23 | arg@^4.1.0: 24 | version "4.1.3" 25 | resolved "https://registry.yarnpkg.com/arg/-/arg-4.1.3.tgz#269fc7ad5b8e42cb63c896d5666017261c144089" 26 | integrity sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA== 27 | 28 | array-find-index@^1.0.1: 29 | version "1.0.2" 30 | resolved "https://registry.yarnpkg.com/array-find-index/-/array-find-index-1.0.2.tgz#df010aa1287e164bbda6f9723b0a96a1ec4187a1" 31 | integrity sha1-3wEKoSh+Fku9pvlyOwqWoexBh6E= 32 | 33 | balanced-match@^1.0.0: 34 | version "1.0.0" 35 | resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" 36 | integrity sha1-ibTRmasr7kneFk6gK4nORi1xt2c= 37 | 38 | binary-extensions@^2.0.0: 39 | version "2.1.0" 40 | resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.1.0.tgz#30fa40c9e7fe07dbc895678cd287024dea241dd9" 41 | integrity sha512-1Yj8h9Q+QDF5FzhMs/c9+6UntbD5MkRfRwac8DoEm9ZfUBZ7tZ55YcGVAzEe4bXsdQHEk+s9S5wsOKVdZrw0tQ== 42 | 43 | brace-expansion@^1.1.7: 44 | version "1.1.11" 45 | resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" 46 | integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA== 47 | dependencies: 48 | balanced-match "^1.0.0" 49 | concat-map "0.0.1" 50 | 51 | braces@~3.0.2: 52 | version "3.0.2" 53 | resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107" 54 | integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A== 55 | dependencies: 56 | fill-range "^7.0.1" 57 | 58 | buffer-from@^1.0.0: 59 | version "1.1.1" 60 | resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef" 61 | integrity sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A== 62 | 63 | camelcase-keys@^2.0.0: 64 | version "2.1.0" 65 | resolved "https://registry.yarnpkg.com/camelcase-keys/-/camelcase-keys-2.1.0.tgz#308beeaffdf28119051efa1d932213c91b8f92e7" 66 | integrity sha1-MIvur/3ygRkFHvodkyITyRuPkuc= 67 | dependencies: 68 | camelcase "^2.0.0" 69 | map-obj "^1.0.0" 70 | 71 | camelcase@^2.0.0: 72 | version "2.1.1" 73 | resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-2.1.1.tgz#7c1d16d679a1bbe59ca02cacecfb011e201f5a1f" 74 | integrity sha1-fB0W1nmhu+WcoCys7PsBHiAfWh8= 75 | 76 | chokidar@^3.4.0: 77 | version "3.4.3" 78 | resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.4.3.tgz#c1df38231448e45ca4ac588e6c79573ba6a57d5b" 79 | integrity sha512-DtM3g7juCXQxFVSNPNByEC2+NImtBuxQQvWlHunpJIS5Ocr0lG306cC7FCi7cEA0fzmybPUIl4txBIobk1gGOQ== 80 | dependencies: 81 | anymatch "~3.1.1" 82 | braces "~3.0.2" 83 | glob-parent "~5.1.0" 84 | is-binary-path "~2.1.0" 85 | is-glob "~4.0.1" 86 | normalize-path "~3.0.0" 87 | readdirp "~3.5.0" 88 | optionalDependencies: 89 | fsevents "~2.1.2" 90 | 91 | concat-map@0.0.1: 92 | version "0.0.1" 93 | resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" 94 | integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s= 95 | 96 | currently-unhandled@^0.4.1: 97 | version "0.4.1" 98 | resolved "https://registry.yarnpkg.com/currently-unhandled/-/currently-unhandled-0.4.1.tgz#988df33feab191ef799a61369dd76c17adf957ea" 99 | integrity sha1-mI3zP+qxke95mmE2nddsF635V+o= 100 | dependencies: 101 | array-find-index "^1.0.1" 102 | 103 | dateformat@~1.0.4-1.2.3: 104 | version "1.0.12" 105 | resolved "https://registry.yarnpkg.com/dateformat/-/dateformat-1.0.12.tgz#9f124b67594c937ff706932e4a642cca8dbbfee9" 106 | integrity sha1-nxJLZ1lMk3/3BpMuSmQsyo27/uk= 107 | dependencies: 108 | get-stdin "^4.0.1" 109 | meow "^3.3.0" 110 | 111 | decamelize@^1.1.2: 112 | version "1.2.0" 113 | resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" 114 | integrity sha1-9lNNFRSCabIDUue+4m9QH5oZEpA= 115 | 116 | diff@^4.0.1: 117 | version "4.0.2" 118 | resolved "https://registry.yarnpkg.com/diff/-/diff-4.0.2.tgz#60f3aecb89d5fae520c11aa19efc2bb982aade7d" 119 | integrity sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A== 120 | 121 | dynamic-dedupe@^0.3.0: 122 | version "0.3.0" 123 | resolved "https://registry.yarnpkg.com/dynamic-dedupe/-/dynamic-dedupe-0.3.0.tgz#06e44c223f5e4e94d78ef9db23a6515ce2f962a1" 124 | integrity sha1-BuRMIj9eTpTXjvnbI6ZRXOL5YqE= 125 | dependencies: 126 | xtend "^4.0.0" 127 | 128 | error-ex@^1.2.0: 129 | version "1.3.2" 130 | resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.2.tgz#b4ac40648107fdcdcfae242f428bea8a14d4f1bf" 131 | integrity sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g== 132 | dependencies: 133 | is-arrayish "^0.2.1" 134 | 135 | fill-range@^7.0.1: 136 | version "7.0.1" 137 | resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.0.1.tgz#1919a6a7c75fe38b2c7c77e5198535da9acdda40" 138 | integrity sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ== 139 | dependencies: 140 | to-regex-range "^5.0.1" 141 | 142 | find-up@^1.0.0: 143 | version "1.1.2" 144 | resolved "https://registry.yarnpkg.com/find-up/-/find-up-1.1.2.tgz#6b2e9822b1a2ce0a60ab64d610eccad53cb24d0f" 145 | integrity sha1-ay6YIrGizgpgq2TWEOzK1TyyTQ8= 146 | dependencies: 147 | path-exists "^2.0.0" 148 | pinkie-promise "^2.0.0" 149 | 150 | fs.realpath@^1.0.0: 151 | version "1.0.0" 152 | resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" 153 | integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8= 154 | 155 | fsevents@~2.1.2: 156 | version "2.1.3" 157 | resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.1.3.tgz#fb738703ae8d2f9fe900c33836ddebee8b97f23e" 158 | integrity sha512-Auw9a4AxqWpa9GUfj370BMPzzyncfBABW8Mab7BGWBYDj4Isgq+cDKtx0i6u9jcX9pQDnswsaaOTgTmA5pEjuQ== 159 | 160 | function-bind@^1.1.1: 161 | version "1.1.1" 162 | resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d" 163 | integrity sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A== 164 | 165 | get-stdin@^4.0.1: 166 | version "4.0.1" 167 | resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-4.0.1.tgz#b968c6b0a04384324902e8bf1a5df32579a450fe" 168 | integrity sha1-uWjGsKBDhDJJAui/Gl3zJXmkUP4= 169 | 170 | glob-parent@~5.1.0: 171 | version "5.1.1" 172 | resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.1.tgz#b6c1ef417c4e5663ea498f1c45afac6916bbc229" 173 | integrity sha512-FnI+VGOpnlGHWZxthPGR+QhR78fuiK0sNLkHQv+bL9fQi57lNNdquIbna/WrfROrolq8GK5Ek6BiMwqL/voRYQ== 174 | dependencies: 175 | is-glob "^4.0.1" 176 | 177 | glob@^7.1.3: 178 | version "7.1.6" 179 | resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.6.tgz#141f33b81a7c2492e125594307480c46679278a6" 180 | integrity sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA== 181 | dependencies: 182 | fs.realpath "^1.0.0" 183 | inflight "^1.0.4" 184 | inherits "2" 185 | minimatch "^3.0.4" 186 | once "^1.3.0" 187 | path-is-absolute "^1.0.0" 188 | 189 | graceful-fs@^4.1.2: 190 | version "4.2.4" 191 | resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.4.tgz#2256bde14d3632958c465ebc96dc467ca07a29fb" 192 | integrity sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw== 193 | 194 | has@^1.0.3: 195 | version "1.0.3" 196 | resolved "https://registry.yarnpkg.com/has/-/has-1.0.3.tgz#722d7cbfc1f6aa8241f16dd814e011e1f41e8796" 197 | integrity sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw== 198 | dependencies: 199 | function-bind "^1.1.1" 200 | 201 | hosted-git-info@^2.1.4: 202 | version "2.8.8" 203 | resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.8.tgz#7539bd4bc1e0e0a895815a2e0262420b12858488" 204 | integrity sha512-f/wzC2QaWBs7t9IYqB4T3sR1xviIViXJRJTWBlx2Gf3g0Xi5vI7Yy4koXQ1c9OYDGHN9sBy1DQ2AB8fqZBWhUg== 205 | 206 | indent-string@^2.1.0: 207 | version "2.1.0" 208 | resolved "https://registry.yarnpkg.com/indent-string/-/indent-string-2.1.0.tgz#8e2d48348742121b4a8218b7a137e9a52049dc80" 209 | integrity sha1-ji1INIdCEhtKghi3oTfppSBJ3IA= 210 | dependencies: 211 | repeating "^2.0.0" 212 | 213 | inflight@^1.0.4: 214 | version "1.0.6" 215 | resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" 216 | integrity sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk= 217 | dependencies: 218 | once "^1.3.0" 219 | wrappy "1" 220 | 221 | inherits@2: 222 | version "2.0.4" 223 | resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" 224 | integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== 225 | 226 | is-arrayish@^0.2.1: 227 | version "0.2.1" 228 | resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d" 229 | integrity sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0= 230 | 231 | is-binary-path@~2.1.0: 232 | version "2.1.0" 233 | resolved "https://registry.yarnpkg.com/is-binary-path/-/is-binary-path-2.1.0.tgz#ea1f7f3b80f064236e83470f86c09c254fb45b09" 234 | integrity sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw== 235 | dependencies: 236 | binary-extensions "^2.0.0" 237 | 238 | is-core-module@^2.1.0: 239 | version "2.1.0" 240 | resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.1.0.tgz#a4cc031d9b1aca63eecbd18a650e13cb4eeab946" 241 | integrity sha512-YcV7BgVMRFRua2FqQzKtTDMz8iCuLEyGKjr70q8Zm1yy2qKcurbFEd79PAdHV77oL3NrAaOVQIbMmiHQCHB7ZA== 242 | dependencies: 243 | has "^1.0.3" 244 | 245 | is-extglob@^2.1.1: 246 | version "2.1.1" 247 | resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2" 248 | integrity sha1-qIwCU1eR8C7TfHahueqXc8gz+MI= 249 | 250 | is-finite@^1.0.0: 251 | version "1.1.0" 252 | resolved "https://registry.yarnpkg.com/is-finite/-/is-finite-1.1.0.tgz#904135c77fb42c0641d6aa1bcdbc4daa8da082f3" 253 | integrity sha512-cdyMtqX/BOqqNBBiKlIVkytNHm49MtMlYyn1zxzvJKWmFMlGzm+ry5BBfYyeY9YmNKbRSo/o7OX9w9ale0wg3w== 254 | 255 | is-glob@^4.0.1, is-glob@~4.0.1: 256 | version "4.0.1" 257 | resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.1.tgz#7567dbe9f2f5e2467bc77ab83c4a29482407a5dc" 258 | integrity sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg== 259 | dependencies: 260 | is-extglob "^2.1.1" 261 | 262 | is-number@^7.0.0: 263 | version "7.0.0" 264 | resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b" 265 | integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng== 266 | 267 | is-utf8@^0.2.0: 268 | version "0.2.1" 269 | resolved "https://registry.yarnpkg.com/is-utf8/-/is-utf8-0.2.1.tgz#4b0da1442104d1b336340e80797e865cf39f7d72" 270 | integrity sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI= 271 | 272 | load-json-file@^1.0.0: 273 | version "1.1.0" 274 | resolved "https://registry.yarnpkg.com/load-json-file/-/load-json-file-1.1.0.tgz#956905708d58b4bab4c2261b04f59f31c99374c0" 275 | integrity sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA= 276 | dependencies: 277 | graceful-fs "^4.1.2" 278 | parse-json "^2.2.0" 279 | pify "^2.0.0" 280 | pinkie-promise "^2.0.0" 281 | strip-bom "^2.0.0" 282 | 283 | loud-rejection@^1.0.0: 284 | version "1.6.0" 285 | resolved "https://registry.yarnpkg.com/loud-rejection/-/loud-rejection-1.6.0.tgz#5b46f80147edee578870f086d04821cf998e551f" 286 | integrity sha1-W0b4AUft7leIcPCG0Eghz5mOVR8= 287 | dependencies: 288 | currently-unhandled "^0.4.1" 289 | signal-exit "^3.0.0" 290 | 291 | make-error@^1.1.1: 292 | version "1.3.6" 293 | resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.6.tgz#2eb2e37ea9b67c4891f684a1394799af484cf7a2" 294 | integrity sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw== 295 | 296 | map-obj@^1.0.0, map-obj@^1.0.1: 297 | version "1.0.1" 298 | resolved "https://registry.yarnpkg.com/map-obj/-/map-obj-1.0.1.tgz#d933ceb9205d82bdcf4886f6742bdc2b4dea146d" 299 | integrity sha1-2TPOuSBdgr3PSIb2dCvcK03qFG0= 300 | 301 | meow@^3.3.0: 302 | version "3.7.0" 303 | resolved "https://registry.yarnpkg.com/meow/-/meow-3.7.0.tgz#72cb668b425228290abbfa856892587308a801fb" 304 | integrity sha1-cstmi0JSKCkKu/qFaJJYcwioAfs= 305 | dependencies: 306 | camelcase-keys "^2.0.0" 307 | decamelize "^1.1.2" 308 | loud-rejection "^1.0.0" 309 | map-obj "^1.0.1" 310 | minimist "^1.1.3" 311 | normalize-package-data "^2.3.4" 312 | object-assign "^4.0.1" 313 | read-pkg-up "^1.0.1" 314 | redent "^1.0.0" 315 | trim-newlines "^1.0.0" 316 | 317 | minimatch@^3.0.4: 318 | version "3.0.4" 319 | resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" 320 | integrity sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA== 321 | dependencies: 322 | brace-expansion "^1.1.7" 323 | 324 | minimist@^1.1.3, minimist@^1.2.5: 325 | version "1.2.5" 326 | resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602" 327 | integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw== 328 | 329 | mkdirp@^1.0.4: 330 | version "1.0.4" 331 | resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e" 332 | integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw== 333 | 334 | normalize-package-data@^2.3.2, normalize-package-data@^2.3.4: 335 | version "2.5.0" 336 | resolved "https://registry.yarnpkg.com/normalize-package-data/-/normalize-package-data-2.5.0.tgz#e66db1838b200c1dfc233225d12cb36520e234a8" 337 | integrity sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA== 338 | dependencies: 339 | hosted-git-info "^2.1.4" 340 | resolve "^1.10.0" 341 | semver "2 || 3 || 4 || 5" 342 | validate-npm-package-license "^3.0.1" 343 | 344 | normalize-path@^3.0.0, normalize-path@~3.0.0: 345 | version "3.0.0" 346 | resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65" 347 | integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA== 348 | 349 | object-assign@^4.0.1: 350 | version "4.1.1" 351 | resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" 352 | integrity sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM= 353 | 354 | once@^1.3.0: 355 | version "1.4.0" 356 | resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" 357 | integrity sha1-WDsap3WWHUsROsF9nFC6753Xa9E= 358 | dependencies: 359 | wrappy "1" 360 | 361 | parse-json@^2.2.0: 362 | version "2.2.0" 363 | resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-2.2.0.tgz#f480f40434ef80741f8469099f8dea18f55a4dc9" 364 | integrity sha1-9ID0BDTvgHQfhGkJn43qGPVaTck= 365 | dependencies: 366 | error-ex "^1.2.0" 367 | 368 | path-exists@^2.0.0: 369 | version "2.1.0" 370 | resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-2.1.0.tgz#0feb6c64f0fc518d9a754dd5efb62c7022761f4b" 371 | integrity sha1-D+tsZPD8UY2adU3V77YscCJ2H0s= 372 | dependencies: 373 | pinkie-promise "^2.0.0" 374 | 375 | path-is-absolute@^1.0.0: 376 | version "1.0.1" 377 | resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" 378 | integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18= 379 | 380 | path-parse@^1.0.6: 381 | version "1.0.6" 382 | resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.6.tgz#d62dbb5679405d72c4737ec58600e9ddcf06d24c" 383 | integrity sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw== 384 | 385 | path-type@^1.0.0: 386 | version "1.1.0" 387 | resolved "https://registry.yarnpkg.com/path-type/-/path-type-1.1.0.tgz#59c44f7ee491da704da415da5a4070ba4f8fe441" 388 | integrity sha1-WcRPfuSR2nBNpBXaWkBwuk+P5EE= 389 | dependencies: 390 | graceful-fs "^4.1.2" 391 | pify "^2.0.0" 392 | pinkie-promise "^2.0.0" 393 | 394 | picomatch@^2.0.4, picomatch@^2.2.1: 395 | version "2.2.2" 396 | resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.2.2.tgz#21f333e9b6b8eaff02468f5146ea406d345f4dad" 397 | integrity sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg== 398 | 399 | pify@^2.0.0: 400 | version "2.3.0" 401 | resolved "https://registry.yarnpkg.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c" 402 | integrity sha1-7RQaasBDqEnqWISY59yosVMw6Qw= 403 | 404 | pinkie-promise@^2.0.0: 405 | version "2.0.1" 406 | resolved "https://registry.yarnpkg.com/pinkie-promise/-/pinkie-promise-2.0.1.tgz#2135d6dfa7a358c069ac9b178776288228450ffa" 407 | integrity sha1-ITXW36ejWMBprJsXh3YogihFD/o= 408 | dependencies: 409 | pinkie "^2.0.0" 410 | 411 | pinkie@^2.0.0: 412 | version "2.0.4" 413 | resolved "https://registry.yarnpkg.com/pinkie/-/pinkie-2.0.4.tgz#72556b80cfa0d48a974e80e77248e80ed4f7f870" 414 | integrity sha1-clVrgM+g1IqXToDnckjoDtT3+HA= 415 | 416 | read-pkg-up@^1.0.1: 417 | version "1.0.1" 418 | resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-1.0.1.tgz#9d63c13276c065918d57f002a57f40a1b643fb02" 419 | integrity sha1-nWPBMnbAZZGNV/ACpX9AobZD+wI= 420 | dependencies: 421 | find-up "^1.0.0" 422 | read-pkg "^1.0.0" 423 | 424 | read-pkg@^1.0.0: 425 | version "1.1.0" 426 | resolved "https://registry.yarnpkg.com/read-pkg/-/read-pkg-1.1.0.tgz#f5ffaa5ecd29cb31c0474bca7d756b6bb29e3f28" 427 | integrity sha1-9f+qXs0pyzHAR0vKfXVra7KePyg= 428 | dependencies: 429 | load-json-file "^1.0.0" 430 | normalize-package-data "^2.3.2" 431 | path-type "^1.0.0" 432 | 433 | readdirp@~3.5.0: 434 | version "3.5.0" 435 | resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.5.0.tgz#9ba74c019b15d365278d2e91bb8c48d7b4d42c9e" 436 | integrity sha512-cMhu7c/8rdhkHXWsY+osBhfSy0JikwpHK/5+imo+LpeasTF8ouErHrlYkwT0++njiyuDvc7OFY5T3ukvZ8qmFQ== 437 | dependencies: 438 | picomatch "^2.2.1" 439 | 440 | redent@^1.0.0: 441 | version "1.0.0" 442 | resolved "https://registry.yarnpkg.com/redent/-/redent-1.0.0.tgz#cf916ab1fd5f1f16dfb20822dd6ec7f730c2afde" 443 | integrity sha1-z5Fqsf1fHxbfsggi3W7H9zDCr94= 444 | dependencies: 445 | indent-string "^2.1.0" 446 | strip-indent "^1.0.1" 447 | 448 | repeating@^2.0.0: 449 | version "2.0.1" 450 | resolved "https://registry.yarnpkg.com/repeating/-/repeating-2.0.1.tgz#5214c53a926d3552707527fbab415dbc08d06dda" 451 | integrity sha1-UhTFOpJtNVJwdSf7q0FdvAjQbdo= 452 | dependencies: 453 | is-finite "^1.0.0" 454 | 455 | resolve@^1.0.0, resolve@^1.10.0: 456 | version "1.19.0" 457 | resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.19.0.tgz#1af5bf630409734a067cae29318aac7fa29a267c" 458 | integrity sha512-rArEXAgsBG4UgRGcynxWIWKFvh/XZCcS8UJdHhwy91zwAvCZIbcs+vAbflgBnNjYMs/i/i+/Ux6IZhML1yPvxg== 459 | dependencies: 460 | is-core-module "^2.1.0" 461 | path-parse "^1.0.6" 462 | 463 | rimraf@^2.6.1: 464 | version "2.7.1" 465 | resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.7.1.tgz#35797f13a7fdadc566142c29d4f07ccad483e3ec" 466 | integrity sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w== 467 | dependencies: 468 | glob "^7.1.3" 469 | 470 | "semver@2 || 3 || 4 || 5": 471 | version "5.7.1" 472 | resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" 473 | integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== 474 | 475 | signal-exit@^3.0.0: 476 | version "3.0.3" 477 | resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.3.tgz#a1410c2edd8f077b08b4e253c8eacfcaf057461c" 478 | integrity sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA== 479 | 480 | source-map-support@^0.5.12, source-map-support@^0.5.17: 481 | version "0.5.19" 482 | resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.19.tgz#a98b62f86dcaf4f67399648c085291ab9e8fed61" 483 | integrity sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw== 484 | dependencies: 485 | buffer-from "^1.0.0" 486 | source-map "^0.6.0" 487 | 488 | source-map@^0.6.0: 489 | version "0.6.1" 490 | resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" 491 | integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== 492 | 493 | spdx-correct@^3.0.0: 494 | version "3.1.1" 495 | resolved "https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-3.1.1.tgz#dece81ac9c1e6713e5f7d1b6f17d468fa53d89a9" 496 | integrity sha512-cOYcUWwhCuHCXi49RhFRCyJEK3iPj1Ziz9DpViV3tbZOwXD49QzIN3MpOLJNxh2qwq2lJJZaKMVw9qNi4jTC0w== 497 | dependencies: 498 | spdx-expression-parse "^3.0.0" 499 | spdx-license-ids "^3.0.0" 500 | 501 | spdx-exceptions@^2.1.0: 502 | version "2.3.0" 503 | resolved "https://registry.yarnpkg.com/spdx-exceptions/-/spdx-exceptions-2.3.0.tgz#3f28ce1a77a00372683eade4a433183527a2163d" 504 | integrity sha512-/tTrYOC7PPI1nUAgx34hUpqXuyJG+DTHJTnIULG4rDygi4xu/tfgmq1e1cIRwRzwZgo4NLySi+ricLkZkw4i5A== 505 | 506 | spdx-expression-parse@^3.0.0: 507 | version "3.0.1" 508 | resolved "https://registry.yarnpkg.com/spdx-expression-parse/-/spdx-expression-parse-3.0.1.tgz#cf70f50482eefdc98e3ce0a6833e4a53ceeba679" 509 | integrity sha512-cbqHunsQWnJNE6KhVSMsMeH5H/L9EpymbzqTQ3uLwNCLZ1Q481oWaofqH7nO6V07xlXwY6PhQdQ2IedWx/ZK4Q== 510 | dependencies: 511 | spdx-exceptions "^2.1.0" 512 | spdx-license-ids "^3.0.0" 513 | 514 | spdx-license-ids@^3.0.0: 515 | version "3.0.6" 516 | resolved "https://registry.yarnpkg.com/spdx-license-ids/-/spdx-license-ids-3.0.6.tgz#c80757383c28abf7296744998cbc106ae8b854ce" 517 | integrity sha512-+orQK83kyMva3WyPf59k1+Y525csj5JejicWut55zeTWANuN17qSiSLUXWtzHeNWORSvT7GLDJ/E/XiIWoXBTw== 518 | 519 | strip-bom@^2.0.0: 520 | version "2.0.0" 521 | resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-2.0.0.tgz#6219a85616520491f35788bdbf1447a99c7e6b0e" 522 | integrity sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4= 523 | dependencies: 524 | is-utf8 "^0.2.0" 525 | 526 | strip-bom@^3.0.0: 527 | version "3.0.0" 528 | resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-3.0.0.tgz#2334c18e9c759f7bdd56fdef7e9ae3d588e68ed3" 529 | integrity sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM= 530 | 531 | strip-indent@^1.0.1: 532 | version "1.0.1" 533 | resolved "https://registry.yarnpkg.com/strip-indent/-/strip-indent-1.0.1.tgz#0c7962a6adefa7bbd4ac366460a638552ae1a0a2" 534 | integrity sha1-DHlipq3vp7vUrDZkYKY4VSrhoKI= 535 | dependencies: 536 | get-stdin "^4.0.1" 537 | 538 | strip-json-comments@^2.0.0: 539 | version "2.0.1" 540 | resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" 541 | integrity sha1-PFMZQukIwml8DsNEhYwobHygpgo= 542 | 543 | to-regex-range@^5.0.1: 544 | version "5.0.1" 545 | resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4" 546 | integrity sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ== 547 | dependencies: 548 | is-number "^7.0.0" 549 | 550 | tree-kill@^1.2.2: 551 | version "1.2.2" 552 | resolved "https://registry.yarnpkg.com/tree-kill/-/tree-kill-1.2.2.tgz#4ca09a9092c88b73a7cdc5e8a01b507b0790a0cc" 553 | integrity sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A== 554 | 555 | trim-newlines@^1.0.0: 556 | version "1.0.0" 557 | resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-1.0.0.tgz#5887966bb582a4503a41eb524f7d35011815a613" 558 | integrity sha1-WIeWa7WCpFA6QetST301ARgVphM= 559 | 560 | ts-node-dev@^1.0.0: 561 | version "1.0.0" 562 | resolved "https://registry.yarnpkg.com/ts-node-dev/-/ts-node-dev-1.0.0.tgz#24a2270d225c29ce269de2a31f88b1b259fc84cb" 563 | integrity sha512-leA/3TgGtnVU77fGngBwVZztqyDRXirytR7dMtMWZS5b2hGpLl+VDnB0F/gf3A+HEPSzS/KwxgXFP7/LtgX4MQ== 564 | dependencies: 565 | chokidar "^3.4.0" 566 | dateformat "~1.0.4-1.2.3" 567 | dynamic-dedupe "^0.3.0" 568 | minimist "^1.2.5" 569 | mkdirp "^1.0.4" 570 | resolve "^1.0.0" 571 | rimraf "^2.6.1" 572 | source-map-support "^0.5.12" 573 | tree-kill "^1.2.2" 574 | ts-node "^9.0.0" 575 | tsconfig "^7.0.0" 576 | 577 | ts-node@^9.0.0: 578 | version "9.0.0" 579 | resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-9.0.0.tgz#e7699d2a110cc8c0d3b831715e417688683460b3" 580 | integrity sha512-/TqB4SnererCDR/vb4S/QvSZvzQMJN8daAslg7MeaiHvD8rDZsSfXmNeNumyZZzMned72Xoq/isQljYSt8Ynfg== 581 | dependencies: 582 | arg "^4.1.0" 583 | diff "^4.0.1" 584 | make-error "^1.1.1" 585 | source-map-support "^0.5.17" 586 | yn "3.1.1" 587 | 588 | ts-toolbelt@^8.0.7: 589 | version "8.0.7" 590 | resolved "https://registry.yarnpkg.com/ts-toolbelt/-/ts-toolbelt-8.0.7.tgz#4dad2928831a811ee17dbdab6eb1919fc0a295bf" 591 | integrity sha512-KICHyKxc5Nu34kyoODrEe2+zvuQQaubTJz7pnC5RQ19TH/Jged1xv+h8LBrouaSD310m75oAljYs59LNHkLDkQ== 592 | 593 | tsconfig@^7.0.0: 594 | version "7.0.0" 595 | resolved "https://registry.yarnpkg.com/tsconfig/-/tsconfig-7.0.0.tgz#84538875a4dc216e5c4a5432b3a4dec3d54e91b7" 596 | integrity sha512-vZXmzPrL+EmC4T/4rVlT2jNVMWCi/O4DIiSj3UHg1OE5kCKbk4mfrXc6dZksLgRM/TZlKnousKH9bbTazUWRRw== 597 | dependencies: 598 | "@types/strip-bom" "^3.0.0" 599 | "@types/strip-json-comments" "0.0.30" 600 | strip-bom "^3.0.0" 601 | strip-json-comments "^2.0.0" 602 | 603 | typescript@^4.1.2: 604 | version "4.1.2" 605 | resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.1.2.tgz#6369ef22516fe5e10304aae5a5c4862db55380e9" 606 | integrity sha512-thGloWsGH3SOxv1SoY7QojKi0tc+8FnOmiarEGMbd/lar7QOEd3hvlx3Fp5y6FlDUGl9L+pd4n2e+oToGMmhRQ== 607 | 608 | validate-npm-package-license@^3.0.1: 609 | version "3.0.4" 610 | resolved "https://registry.yarnpkg.com/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz#fc91f6b9c7ba15c857f4cb2c5defeec39d4f410a" 611 | integrity sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew== 612 | dependencies: 613 | spdx-correct "^3.0.0" 614 | spdx-expression-parse "^3.0.0" 615 | 616 | wrappy@1: 617 | version "1.0.2" 618 | resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" 619 | integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8= 620 | 621 | xtend@^4.0.0: 622 | version "4.0.2" 623 | resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.2.tgz#bb72779f5fa465186b1f438f674fa347fdb5db54" 624 | integrity sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ== 625 | 626 | yn@3.1.1: 627 | version "3.1.1" 628 | resolved "https://registry.yarnpkg.com/yn/-/yn-3.1.1.tgz#1e87401a09d767c1d5eab26a6e4c185182d2eb50" 629 | integrity sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q== 630 | -------------------------------------------------------------------------------- /examples/eslintrc.ts: -------------------------------------------------------------------------------- 1 | import {ResolvedJsonSchema} from "../src"; 2 | 3 | // TODO: Currently broken 4 | export const schema = { 5 | title: "JSON schema for ESLint configuration files", 6 | $schema: "http://json-schema.org/draft-04/schema#", 7 | type: "object", 8 | definitions: { 9 | rule: { 10 | oneOf: [ 11 | { 12 | description: 13 | "ESLint rule\n\n0 - turns the rule off\n1 - turn the rule on as a warning (doesn't affect exit code)\n2 - turn the rule on as an error (exit code is 1 when triggered)\n", 14 | type: "integer", 15 | minimum: 0, 16 | maximum: 2, 17 | }, 18 | { 19 | description: 20 | 'ESLint rule\n\n"off" - turns the rule off\n"warn" - turn the rule on as a warning (doesn\'t affect exit code)\n"error" - turn the rule on as an error (exit code is 1 when triggered)\n', 21 | type: "string", 22 | enum: ["off", "warn", "error"], 23 | }, 24 | { 25 | type: "array", 26 | }, 27 | ], 28 | }, 29 | possibleErrors: { 30 | properties: { 31 | "comma-dangle": { 32 | $ref: "#/definitions/rule", 33 | description: "Require or disallow trailing commas", 34 | }, 35 | "for-direction": { 36 | $ref: "#/definitions/rule", 37 | description: 38 | "Enforce “for” loop update clause moving the counter in the right direction", 39 | }, 40 | "getter-return": { 41 | $ref: "#/definitions/rule", 42 | description: "Enforce return statements in getters", 43 | }, 44 | "no-await-in-loop": { 45 | $ref: "#/definitions/rule", 46 | description: "Disallow await inside of loops", 47 | }, 48 | "no-compare-neg-zero": { 49 | $ref: "#/definitions/rule", 50 | description: "Disallow comparing against -0", 51 | }, 52 | "no-cond-assign": { 53 | $ref: "#/definitions/rule", 54 | description: 55 | "Disallow assignment operators in conditional expressions", 56 | }, 57 | "no-console": { 58 | $ref: "#/definitions/rule", 59 | description: "Disallow the use of console", 60 | }, 61 | "no-constant-condition": { 62 | $ref: "#/definitions/rule", 63 | description: "Disallow constant expressions in conditions", 64 | }, 65 | "no-control-regex": { 66 | $ref: "#/definitions/rule", 67 | description: "Disallow control characters in regular expressions", 68 | }, 69 | "no-debugger": { 70 | $ref: "#/definitions/rule", 71 | description: "Disallow the use of debugger", 72 | }, 73 | "no-dupe-args": { 74 | $ref: "#/definitions/rule", 75 | description: "Disallow duplicate arguments in function definitions", 76 | }, 77 | "no-dupe-keys": { 78 | $ref: "#/definitions/rule", 79 | description: "Disallow duplicate keys in object literals", 80 | }, 81 | "no-duplicate-case": { 82 | $ref: "#/definitions/rule", 83 | description: "Disallow duplicate case labels", 84 | }, 85 | "no-empty": { 86 | $ref: "#/definitions/rule", 87 | description: "Disallow empty block statements", 88 | }, 89 | "no-empty-character-class": { 90 | $ref: "#/definitions/rule", 91 | description: 92 | "Disallow empty character classes in regular expressions", 93 | }, 94 | "no-ex-assign": { 95 | $ref: "#/definitions/rule", 96 | description: "Disallow reassigning exceptions in catch clauses", 97 | }, 98 | "no-extra-boolean-cast": { 99 | $ref: "#/definitions/rule", 100 | description: "Disallow unnecessary boolean casts", 101 | }, 102 | "no-extra-parens": { 103 | $ref: "#/definitions/rule", 104 | description: "Disallow unnecessary parentheses", 105 | }, 106 | "no-extra-semi": { 107 | $ref: "#/definitions/rule", 108 | description: "Disallow unnecessary semicolons", 109 | }, 110 | "no-func-assign": { 111 | $ref: "#/definitions/rule", 112 | description: "Disallow reassigning function declarations", 113 | }, 114 | "no-inner-declarations": { 115 | $ref: "#/definitions/rule", 116 | description: "Disallow function or var declarations in nested blocks", 117 | }, 118 | "no-invalid-regexp": { 119 | $ref: "#/definitions/rule", 120 | description: 121 | "Disallow invalid regular expression strings in RegExp constructors", 122 | }, 123 | "no-irregular-whitespace": { 124 | $ref: "#/definitions/rule", 125 | description: 126 | "Disallow irregular whitespace outside of strings and comments", 127 | }, 128 | "no-negated-in-lhs": { 129 | $ref: "#/definitions/rule", 130 | description: 131 | "Disallow negating the left operand in in expressions (deprecated)", 132 | }, 133 | "no-obj-calls": { 134 | $ref: "#/definitions/rule", 135 | description: "Disallow calling global object properties as functions", 136 | }, 137 | "no-prototype-builtins": { 138 | $ref: "#/definitions/rule", 139 | description: 140 | "Disallow calling some Object.prototype methods directly on objects", 141 | }, 142 | "no-regex-spaces": { 143 | $ref: "#/definitions/rule", 144 | description: "Disallow multiple spaces in regular expressions", 145 | }, 146 | "no-sparse-arrays": { 147 | $ref: "#/definitions/rule", 148 | description: "Disallow sparse arrays", 149 | }, 150 | "no-template-curly-in-string": { 151 | $ref: "#/definitions/rule", 152 | description: 153 | "Disallow template literal placeholder syntax in regular strings", 154 | }, 155 | "no-unexpected-multiline": { 156 | $ref: "#/definitions/rule", 157 | description: "Disallow confusing multiline expressions", 158 | }, 159 | "no-unreachable": { 160 | $ref: "#/definitions/rule", 161 | description: 162 | "Disallow unreachable code after return, throw, continue, and break statements", 163 | }, 164 | "no-unsafe-finally": { 165 | $ref: "#/definitions/rule", 166 | description: "Disallow control flow statements in finally blocks", 167 | }, 168 | "no-unsafe-negation": { 169 | $ref: "#/definitions/rule", 170 | description: 171 | "Disallow negating the left operand of relational operators", 172 | }, 173 | "use-isnan": { 174 | $ref: "#/definitions/rule", 175 | description: "Require calls to isNaN() when checking for NaN", 176 | }, 177 | "valid-jsdoc": { 178 | $ref: "#/definitions/rule", 179 | description: "Enforce valid JSDoc comments", 180 | }, 181 | "valid-typeof": { 182 | $ref: "#/definitions/rule", 183 | description: 184 | "Enforce comparing typeof expressions against valid strings", 185 | }, 186 | }, 187 | }, 188 | bestPractices: { 189 | properties: { 190 | "accessor-pairs": { 191 | $ref: "#/definitions/rule", 192 | description: "Enforce getter and setter pairs in objects", 193 | }, 194 | "array-callback-return": { 195 | $ref: "#/definitions/rule", 196 | description: 197 | "Enforce return statements in callbacks of array methods", 198 | }, 199 | "block-scoped-var": { 200 | $ref: "#/definitions/rule", 201 | description: 202 | "Enforce the use of variables within the scope they are defined", 203 | }, 204 | "class-methods-use-this": { 205 | $ref: "#/definitions/rule", 206 | description: "Enforce that class methods utilize this", 207 | }, 208 | complexity: { 209 | $ref: "#/definitions/rule", 210 | description: 211 | "Enforce a maximum cyclomatic complexity allowed in a program", 212 | }, 213 | "consistent-return": { 214 | $ref: "#/definitions/rule", 215 | description: 216 | "Require return statements to either always or never specify values", 217 | }, 218 | curly: { 219 | $ref: "#/definitions/rule", 220 | description: 221 | "Enforce consistent brace style for all control statements", 222 | }, 223 | "default-case": { 224 | $ref: "#/definitions/rule", 225 | description: "Require default cases in switch statements", 226 | }, 227 | "dot-location": { 228 | $ref: "#/definitions/rule", 229 | description: "Enforce consistent newlines before and after dots", 230 | }, 231 | "dot-notation": { 232 | $ref: "#/definitions/rule", 233 | description: "Enforce dot notation whenever possible", 234 | }, 235 | eqeqeq: { 236 | $ref: "#/definitions/rule", 237 | description: "Require the use of === and !==", 238 | }, 239 | "guard-for-in": { 240 | $ref: "#/definitions/rule", 241 | description: "Require for-in loops to include an if statement", 242 | }, 243 | "no-alert": { 244 | $ref: "#/definitions/rule", 245 | description: "Disallow the use of alert, confirm, and prompt", 246 | }, 247 | "no-caller": { 248 | $ref: "#/definitions/rule", 249 | description: 250 | "Disallow the use of arguments.caller or arguments.callee", 251 | }, 252 | "no-case-declarations": { 253 | $ref: "#/definitions/rule", 254 | description: "Disallow lexical declarations in case clauses", 255 | }, 256 | "no-div-regex": { 257 | $ref: "#/definitions/rule", 258 | description: 259 | "Disallow division operators explicitly at the beginning of regular expressions", 260 | }, 261 | "no-else-return": { 262 | $ref: "#/definitions/rule", 263 | description: 264 | "Disallow else blocks after return statements in if statements", 265 | }, 266 | "no-empty-function": { 267 | $ref: "#/definitions/rule", 268 | description: "Disallow empty functions", 269 | }, 270 | "no-empty-pattern": { 271 | $ref: "#/definitions/rule", 272 | description: "Disallow empty destructuring patterns", 273 | }, 274 | "no-eq-null": { 275 | $ref: "#/definitions/rule", 276 | description: 277 | "Disallow null comparisons without type-checking operators", 278 | }, 279 | "no-eval": { 280 | $ref: "#/definitions/rule", 281 | description: "Disallow the use of eval()", 282 | }, 283 | "no-extend-native": { 284 | $ref: "#/definitions/rule", 285 | description: "Disallow extending native types", 286 | }, 287 | "no-extra-bind": { 288 | $ref: "#/definitions/rule", 289 | description: "Disallow unnecessary calls to .bind()", 290 | }, 291 | "no-extra-label": { 292 | $ref: "#/definitions/rule", 293 | description: "Disallow unnecessary labels", 294 | }, 295 | "no-fallthrough": { 296 | $ref: "#/definitions/rule", 297 | description: "Disallow fallthrough of case statements", 298 | }, 299 | "no-floating-decimal": { 300 | $ref: "#/definitions/rule", 301 | description: 302 | "Disallow leading or trailing decimal points in numeric literals", 303 | }, 304 | "no-global-assign": { 305 | $ref: "#/definitions/rule", 306 | description: 307 | "Disallow assignments to native objects or read-only global variables", 308 | }, 309 | "no-implicit-coercion": { 310 | $ref: "#/definitions/rule", 311 | description: "Disallow shorthand type conversions", 312 | }, 313 | "no-implicit-globals": { 314 | $ref: "#/definitions/rule", 315 | description: 316 | "Disallow var and named function declarations in the global scope", 317 | }, 318 | "no-implied-eval": { 319 | $ref: "#/definitions/rule", 320 | description: "Disallow the use of eval()-like methods", 321 | }, 322 | "no-invalid-this": { 323 | $ref: "#/definitions/rule", 324 | description: 325 | "Disallow this keywords outside of classes or class-like objects", 326 | }, 327 | "no-iterator": { 328 | $ref: "#/definitions/rule", 329 | description: "Disallow the use of the __iterator__ property", 330 | }, 331 | "no-labels": { 332 | $ref: "#/definitions/rule", 333 | description: "Disallow labeled statements", 334 | }, 335 | "no-lone-blocks": { 336 | $ref: "#/definitions/rule", 337 | description: "Disallow unnecessary nested blocks", 338 | }, 339 | "no-loop-func": { 340 | $ref: "#/definitions/rule", 341 | description: 342 | "Disallow function declarations and expressions inside loop statements", 343 | }, 344 | "no-magic-numbers": { 345 | $ref: "#/definitions/rule", 346 | description: "Disallow magic numbers", 347 | }, 348 | "no-multi-spaces": { 349 | $ref: "#/definitions/rule", 350 | description: "Disallow multiple spaces", 351 | }, 352 | "no-multi-str": { 353 | $ref: "#/definitions/rule", 354 | description: "Disallow multiline strings", 355 | }, 356 | "no-native-reassign": {$ref: "#/definitions/rule"}, 357 | "no-new": { 358 | $ref: "#/definitions/rule", 359 | description: 360 | "Disallow new operators outside of assignments or comparisons", 361 | }, 362 | "no-new-func": { 363 | $ref: "#/definitions/rule", 364 | description: "Disallow new operators with the Function object", 365 | }, 366 | "no-new-wrappers": { 367 | $ref: "#/definitions/rule", 368 | description: 369 | "Disallow new operators with the String, Number, and Boolean objects", 370 | }, 371 | "no-octal": { 372 | $ref: "#/definitions/rule", 373 | description: "Disallow octal literals", 374 | }, 375 | "no-octal-escape": { 376 | $ref: "#/definitions/rule", 377 | description: "Disallow octal escape sequences in string literals", 378 | }, 379 | "no-param-reassign": { 380 | $ref: "#/definitions/rule", 381 | description: "Disallow reassigning function parameters", 382 | }, 383 | "no-proto": { 384 | $ref: "#/definitions/rule", 385 | description: "Disallow the use of the __proto__ property", 386 | }, 387 | "no-redeclare": { 388 | $ref: "#/definitions/rule", 389 | description: "Disallow var redeclaration", 390 | }, 391 | "no-restricted-properties": { 392 | $ref: "#/definitions/rule", 393 | description: "Disallow certain properties on certain objects", 394 | }, 395 | "no-return-assign": { 396 | $ref: "#/definitions/rule", 397 | description: "Disallow assignment operators in return statements", 398 | }, 399 | "no-return-await": { 400 | $ref: "#/definitions/rule", 401 | description: "Disallow unnecessary return await", 402 | }, 403 | "no-script-url": { 404 | $ref: "#/definitions/rule", 405 | description: "Disallow javascript: urls", 406 | }, 407 | "no-self-assign": { 408 | $ref: "#/definitions/rule", 409 | description: 410 | "Disallow assignments where both sides are exactly the same", 411 | }, 412 | "no-self-compare": { 413 | $ref: "#/definitions/rule", 414 | description: 415 | "Disallow comparisons where both sides are exactly the same", 416 | }, 417 | "no-sequences": { 418 | $ref: "#/definitions/rule", 419 | description: "Disallow comma operators", 420 | }, 421 | "no-throw-literal": { 422 | $ref: "#/definitions/rule", 423 | description: "Disallow throwing literals as exceptions", 424 | }, 425 | "no-unmodified-loop-condition": { 426 | $ref: "#/definitions/rule", 427 | description: "Disallow unmodified loop conditions", 428 | }, 429 | "no-unused-expressions": { 430 | $ref: "#/definitions/rule", 431 | description: "Disallow unused expressions", 432 | }, 433 | "no-unused-labels": { 434 | $ref: "#/definitions/rule", 435 | description: "Disallow unused labels", 436 | }, 437 | "no-useless-call": { 438 | $ref: "#/definitions/rule", 439 | description: "Disallow unnecessary calls to .call() and .apply()", 440 | }, 441 | "no-useless-concat": { 442 | $ref: "#/definitions/rule", 443 | description: 444 | "Disallow unnecessary concatenation of literals or template literals", 445 | }, 446 | "no-useless-escape": { 447 | $ref: "#/definitions/rule", 448 | description: "Disallow unnecessary escape characters", 449 | }, 450 | "no-useless-return": { 451 | $ref: "#/definitions/rule", 452 | description: "Disallow redundant return statements", 453 | }, 454 | "no-void": { 455 | $ref: "#/definitions/rule", 456 | description: "Disallow void operators", 457 | }, 458 | "no-warning-comments": { 459 | $ref: "#/definitions/rule", 460 | description: "Disallow specified warning terms in comments", 461 | }, 462 | "no-with": { 463 | $ref: "#/definitions/rule", 464 | description: "Disallow with statements", 465 | }, 466 | "prefer-promise-reject-errors": { 467 | $ref: "#/definitions/rule", 468 | description: 469 | "Require using Error objects as Promise rejection reasons", 470 | }, 471 | radix: { 472 | $ref: "#/definitions/rule", 473 | description: 474 | "Enforce the consistent use of the radix argument when using parseInt()", 475 | }, 476 | "require-await": { 477 | $ref: "#/definitions/rule", 478 | description: 479 | "Disallow async functions which have no await expression", 480 | }, 481 | "vars-on-top": { 482 | $ref: "#/definitions/rule", 483 | description: 484 | "Require var declarations be placed at the top of their containing scope", 485 | }, 486 | "wrap-iife": { 487 | $ref: "#/definitions/rule", 488 | description: 489 | "Require parentheses around immediate function invocations", 490 | }, 491 | yoda: { 492 | $ref: "#/definitions/rule", 493 | description: "Require or Disallow “Yoda” conditions", 494 | }, 495 | }, 496 | }, 497 | strictMode: { 498 | properties: { 499 | strict: { 500 | $ref: "#/definitions/rule", 501 | description: "require or disallow strict mode directives", 502 | }, 503 | }, 504 | }, 505 | variables: { 506 | properties: { 507 | "init-declarations": { 508 | $ref: "#/definitions/rule", 509 | description: "Require or disallow initialization in var declarations", 510 | }, 511 | "no-catch-shadow": { 512 | $ref: "#/definitions/rule", 513 | description: 514 | "Disallow catch clause parameters from shadowing variables in the outer scope", 515 | }, 516 | "no-delete-var": { 517 | $ref: "#/definitions/rule", 518 | description: "Disallow deleting variables", 519 | }, 520 | "no-label-var": { 521 | $ref: "#/definitions/rule", 522 | description: "Disallow labels that share a name with a variable", 523 | }, 524 | "no-restricted-globals": { 525 | $ref: "#/definitions/rule", 526 | description: "Disallow specified global variables", 527 | }, 528 | "no-shadow": { 529 | $ref: "#/definitions/rule", 530 | description: 531 | "Disallow var declarations from shadowing variables in the outer scope", 532 | }, 533 | "no-shadow-restricted-names": { 534 | $ref: "#/definitions/rule", 535 | description: "Disallow identifiers from shadowing restricted names", 536 | }, 537 | "no-undef": { 538 | $ref: "#/definitions/rule", 539 | description: 540 | "Disallow the use of undeclared variables unless mentioned in /*global */ comments", 541 | }, 542 | "no-undefined": { 543 | $ref: "#/definitions/rule", 544 | description: "Disallow the use of undefined as an identifier", 545 | }, 546 | "no-undef-init": { 547 | $ref: "#/definitions/rule", 548 | description: "Disallow initializing variables to undefined", 549 | }, 550 | "no-unused-vars": { 551 | $ref: "#/definitions/rule", 552 | description: "Disallow unused variables", 553 | }, 554 | "no-use-before-define": { 555 | $ref: "#/definitions/rule", 556 | description: "Disallow the use of variables before they are defined", 557 | }, 558 | }, 559 | }, 560 | nodeAndCommonJs: { 561 | properties: { 562 | "callback-return": { 563 | $ref: "#/definitions/rule", 564 | description: "Require return statements after callbacks", 565 | }, 566 | "global-require": { 567 | $ref: "#/definitions/rule", 568 | description: 569 | "Require require() calls to be placed at top-level module scope", 570 | }, 571 | "handle-callback-err": { 572 | $ref: "#/definitions/rule", 573 | description: "Require error handling in callbacks", 574 | }, 575 | "no-buffer-constructor": { 576 | $ref: "#/definitions/rule", 577 | description: "Disallow use of the Buffer() constructor", 578 | }, 579 | "no-mixed-requires": { 580 | $ref: "#/definitions/rule", 581 | description: 582 | "Disallow require calls to be mixed with regular var declarations", 583 | }, 584 | "no-new-require": { 585 | $ref: "#/definitions/rule", 586 | description: "Disallow new operators with calls to require", 587 | }, 588 | "no-path-concat": { 589 | $ref: "#/definitions/rule", 590 | description: 591 | "Disallow string concatenation with __dirname and __filename", 592 | }, 593 | "no-process-env": { 594 | $ref: "#/definitions/rule", 595 | description: "Disallow the use of process.env", 596 | }, 597 | "no-process-exit": { 598 | $ref: "#/definitions/rule", 599 | description: "Disallow the use of process.exit()", 600 | }, 601 | "no-restricted-modules": { 602 | $ref: "#/definitions/rule", 603 | description: "Disallow specified modules when loaded by require", 604 | }, 605 | "no-sync": { 606 | $ref: "#/definitions/rule", 607 | description: "Disallow synchronous methods", 608 | }, 609 | }, 610 | }, 611 | stylisticIssues: { 612 | properties: { 613 | "array-bracket-newline": { 614 | $ref: "#/definitions/rule", 615 | description: 616 | "Enforce line breaks after opening and before closing array brackets", 617 | }, 618 | "array-bracket-spacing": { 619 | $ref: "#/definitions/rule", 620 | description: "Enforce consistent spacing inside array brackets", 621 | }, 622 | "array-element-newline": { 623 | $ref: "#/definitions/rule", 624 | description: "Enforce line breaks after each array element", 625 | }, 626 | "block-spacing": { 627 | $ref: "#/definitions/rule", 628 | description: "Enforce consistent spacing inside single-line blocks", 629 | }, 630 | "brace-style": { 631 | $ref: "#/definitions/rule", 632 | description: "Enforce consistent brace style for blocks", 633 | }, 634 | camelcase: { 635 | $ref: "#/definitions/rule", 636 | description: "Enforce camelcase naming convention", 637 | }, 638 | "capitalized-comments": { 639 | $ref: "#/definitions/rule", 640 | description: 641 | "Enforce or disallow capitalization of the first letter of a comment", 642 | }, 643 | "comma-dangle": { 644 | $ref: "#/definitions/rule", 645 | description: "Require or disallow trailing commas", 646 | }, 647 | "comma-spacing": { 648 | $ref: "#/definitions/rule", 649 | description: "Enforce consistent spacing before and after commas", 650 | }, 651 | "comma-style": { 652 | $ref: "#/definitions/rule", 653 | description: "Enforce consistent comma style", 654 | }, 655 | "computed-property-spacing": { 656 | $ref: "#/definitions/rule", 657 | description: 658 | "Enforce consistent spacing inside computed property brackets", 659 | }, 660 | "consistent-this": { 661 | $ref: "#/definitions/rule", 662 | description: 663 | "Enforce consistent naming when capturing the current execution context", 664 | }, 665 | "eol-last": { 666 | $ref: "#/definitions/rule", 667 | description: "Enforce at least one newline at the end of files", 668 | }, 669 | "func-call-spacing": { 670 | $ref: "#/definitions/rule", 671 | description: 672 | "Require or disallow spacing between function identifiers and their invocations", 673 | }, 674 | "func-name-matching": { 675 | $ref: "#/definitions/rule", 676 | description: 677 | "Require function names to match the name of the variable or property to which they are assigned", 678 | }, 679 | "func-names": { 680 | $ref: "#/definitions/rule", 681 | description: "Require or disallow named function expressions", 682 | }, 683 | "func-style": { 684 | $ref: "#/definitions/rule", 685 | description: 686 | "Enforce the consistent use of either function declarations or expressions", 687 | }, 688 | "function-call-argument-newline": { 689 | $ref: "#/definitions/rule", 690 | description: 691 | "Enforce line breaks between arguments of a function call", 692 | }, 693 | "function-paren-newline": { 694 | $ref: "#/definitions/rule", 695 | description: 696 | "Enforce consistent line breaks inside function parentheses", 697 | }, 698 | "id-blacklist": { 699 | $ref: "#/definitions/rule", 700 | description: "Disallow specified identifiers", 701 | }, 702 | "id-length": { 703 | $ref: "#/definitions/rule", 704 | description: "Enforce minimum and maximum identifier lengths", 705 | }, 706 | "id-match": { 707 | $ref: "#/definitions/rule", 708 | description: 709 | "Require identifiers to match a specified regular expression", 710 | }, 711 | "implicit-arrow-linebreak": { 712 | $ref: "#/definitions/rule", 713 | description: "Enforce the location of arrow function bodies", 714 | }, 715 | indent: { 716 | $ref: "#/definitions/rule", 717 | description: "Enforce consistent indentation", 718 | }, 719 | "indent-legacy": { 720 | $ref: "#/definitions/rule", 721 | description: "Enforce consistent indentation (legacy, deprecated)", 722 | }, 723 | "jsx-quotes": { 724 | $ref: "#/definitions/rule", 725 | description: 726 | "Enforce the consistent use of either double or single quotes in JSX attributes", 727 | }, 728 | "key-spacing": { 729 | $ref: "#/definitions/rule", 730 | description: 731 | "Enforce consistent spacing between keys and values in object literal properties", 732 | }, 733 | "keyword-spacing": { 734 | $ref: "#/definitions/rule", 735 | description: "Enforce consistent spacing before and after keywords", 736 | }, 737 | "line-comment-position": { 738 | $ref: "#/definitions/rule", 739 | description: "Enforce position of line comments", 740 | }, 741 | "lines-between-class-members": { 742 | $ref: "#/definitions/rule", 743 | description: 744 | "Require or disallow an empty line between class members", 745 | }, 746 | "linebreak-style": { 747 | $ref: "#/definitions/rule", 748 | description: "Enforce consistent linebreak style", 749 | }, 750 | "lines-around-comment": { 751 | $ref: "#/definitions/rule", 752 | description: "Require empty lines around comments", 753 | }, 754 | "lines-around-directive": { 755 | $ref: "#/definitions/rule", 756 | description: "Require or disallow newlines around directives", 757 | }, 758 | "max-depth": { 759 | $ref: "#/definitions/rule", 760 | description: "Enforce a maximum depth that blocks can be nested", 761 | }, 762 | "max-len": { 763 | $ref: "#/definitions/rule", 764 | description: "Enforce a maximum line length", 765 | }, 766 | "max-lines": { 767 | $ref: "#/definitions/rule", 768 | description: "Enforce a maximum number of lines per file", 769 | }, 770 | "max-nested-callbacks": { 771 | $ref: "#/definitions/rule", 772 | description: "Enforce a maximum depth that callbacks can be nested", 773 | }, 774 | "max-params": { 775 | $ref: "#/definitions/rule", 776 | description: 777 | "Enforce a maximum number of parameters in function definitions", 778 | }, 779 | "max-statements": { 780 | $ref: "#/definitions/rule", 781 | description: 782 | "Enforce a maximum number of statements allowed in function blocks", 783 | }, 784 | "max-statements-per-line": { 785 | $ref: "#/definitions/rule", 786 | description: 787 | "Enforce a maximum number of statements allowed per line", 788 | }, 789 | "multiline-comment-style": { 790 | $ref: "#/definitions/rule", 791 | description: "Enforce a particular style for multiline comments", 792 | }, 793 | "multiline-ternary": { 794 | $ref: "#/definitions/rule", 795 | description: 796 | "Enforce newlines between operands of ternary expressions", 797 | }, 798 | "new-cap": { 799 | $ref: "#/definitions/rule", 800 | description: 801 | "Require constructor function names to begin with a capital letter", 802 | }, 803 | "newline-after-var": { 804 | $ref: "#/definitions/rule", 805 | description: 806 | "Require or disallow an empty line after var declarations", 807 | }, 808 | "newline-before-return": { 809 | $ref: "#/definitions/rule", 810 | description: "Require an empty line before return statements", 811 | }, 812 | "newline-per-chained-call": { 813 | $ref: "#/definitions/rule", 814 | description: "Require a newline after each call in a method chain", 815 | }, 816 | "new-parens": { 817 | $ref: "#/definitions/rule", 818 | description: 819 | "Require parentheses when invoking a constructor with no arguments", 820 | }, 821 | "no-array-constructor": { 822 | $ref: "#/definitions/rule", 823 | description: "Disallow Array constructors", 824 | }, 825 | "no-bitwise": { 826 | $ref: "#/definitions/rule", 827 | description: "Disallow bitwise operators", 828 | }, 829 | "no-continue": { 830 | $ref: "#/definitions/rule", 831 | description: "Disallow continue statements", 832 | }, 833 | "no-inline-comments": { 834 | $ref: "#/definitions/rule", 835 | description: "Disallow inline comments after code", 836 | }, 837 | "no-lonely-if": { 838 | $ref: "#/definitions/rule", 839 | description: 840 | "Disallow if statements as the only statement in else blocks", 841 | }, 842 | "no-mixed-operators": { 843 | $ref: "#/definitions/rule", 844 | description: "Disallow mixed binary operators", 845 | }, 846 | "no-mixed-spaces-and-tabs": { 847 | $ref: "#/definitions/rule", 848 | description: "Disallow mixed spaces and tabs for indentation", 849 | }, 850 | "no-multi-assign": { 851 | $ref: "#/definitions/rule", 852 | description: "Disallow use of chained assignment expressions", 853 | }, 854 | "no-multiple-empty-lines": { 855 | $ref: "#/definitions/rule", 856 | description: "Disallow multiple empty lines", 857 | }, 858 | "no-negated-condition": { 859 | $ref: "#/definitions/rule", 860 | description: "Disallow negated conditions", 861 | }, 862 | "no-nested-ternary": { 863 | $ref: "#/definitions/rule", 864 | description: "Disallow nested ternary expressions", 865 | }, 866 | "no-new-object": { 867 | $ref: "#/definitions/rule", 868 | description: "Disallow Object constructors", 869 | }, 870 | "no-plusplus": { 871 | $ref: "#/definitions/rule", 872 | description: "Disallow the unary operators ++ and --", 873 | }, 874 | "no-restricted-syntax": { 875 | $ref: "#/definitions/rule", 876 | description: "Disallow specified syntax", 877 | }, 878 | "no-spaced-func": {$ref: "#/definitions/rule"}, 879 | "no-tabs": { 880 | $ref: "#/definitions/rule", 881 | description: "Disallow tabs in file", 882 | }, 883 | "no-ternary": { 884 | $ref: "#/definitions/rule", 885 | description: "Disallow ternary operators", 886 | }, 887 | "no-trailing-spaces": { 888 | $ref: "#/definitions/rule", 889 | description: "Disallow trailing whitespace at the end of lines", 890 | }, 891 | "no-underscore-dangle": { 892 | $ref: "#/definitions/rule", 893 | description: "Disallow dangling underscores in identifiers", 894 | }, 895 | "no-unneeded-ternary": { 896 | $ref: "#/definitions/rule", 897 | description: 898 | "Disallow ternary operators when simpler alternatives exist", 899 | }, 900 | "no-whitespace-before-property": { 901 | $ref: "#/definitions/rule", 902 | description: "Disallow whitespace before properties", 903 | }, 904 | "nonblock-statement-body-position": { 905 | $ref: "#/definitions/rule", 906 | description: "Enforce the location of single-line statements", 907 | }, 908 | "object-curly-newline": { 909 | $ref: "#/definitions/rule", 910 | description: "Enforce consistent line breaks inside braces", 911 | }, 912 | "object-curly-spacing": { 913 | $ref: "#/definitions/rule", 914 | description: "Enforce consistent spacing inside braces", 915 | }, 916 | "object-property-newline": { 917 | $ref: "#/definitions/rule", 918 | description: "Enforce placing object properties on separate lines", 919 | }, 920 | "object-shorthand": {$ref: "#/definitions/rule"}, 921 | "one-var": { 922 | $ref: "#/definitions/rule", 923 | description: 924 | "Enforce variables to be declared either together or separately in functions", 925 | }, 926 | "one-var-declaration-per-line": { 927 | $ref: "#/definitions/rule", 928 | description: "Require or disallow newlines around var declarations", 929 | }, 930 | "operator-assignment": { 931 | $ref: "#/definitions/rule", 932 | description: 933 | "Require or disallow assignment operator shorthand where possible", 934 | }, 935 | "operator-linebreak": { 936 | $ref: "#/definitions/rule", 937 | description: "Enforce consistent linebreak style for operators", 938 | }, 939 | "padded-blocks": { 940 | $ref: "#/definitions/rule", 941 | description: "Require or disallow padding within blocks", 942 | }, 943 | "padding-line-between-statements": { 944 | $ref: "#/definitions/rule", 945 | description: "Require or disallow padding lines between statements", 946 | }, 947 | "quote-props": { 948 | $ref: "#/definitions/rule", 949 | description: "Require quotes around object literal property names", 950 | }, 951 | quotes: { 952 | $ref: "#/definitions/rule", 953 | description: 954 | "Enforce the consistent use of either backticks, double, or single quotes", 955 | }, 956 | "require-jsdoc": { 957 | $ref: "#/definitions/rule", 958 | description: "Require JSDoc comments", 959 | }, 960 | semi: { 961 | $ref: "#/definitions/rule", 962 | description: "Require or disallow semicolons instead of ASI", 963 | }, 964 | "semi-spacing": { 965 | $ref: "#/definitions/rule", 966 | description: "Enforce consistent spacing before and after semicolons", 967 | }, 968 | "semi-style": { 969 | $ref: "#/definitions/rule", 970 | description: "Enforce location of semicolons", 971 | }, 972 | "sort-keys": { 973 | $ref: "#/definitions/rule", 974 | description: "Requires object keys to be sorted", 975 | }, 976 | "sort-vars": { 977 | $ref: "#/definitions/rule", 978 | description: 979 | "Require variables within the same declaration block to be sorted", 980 | }, 981 | "space-before-blocks": { 982 | $ref: "#/definitions/rule", 983 | description: "Enforce consistent spacing before blocks", 984 | }, 985 | "space-before-function-paren": { 986 | $ref: "#/definitions/rule", 987 | description: 988 | "Enforce consistent spacing before function definition opening parenthesis", 989 | }, 990 | "spaced-comment": { 991 | $ref: "#/definitions/rule", 992 | description: 993 | "Enforce consistent spacing after the // or /* in a comment", 994 | }, 995 | "space-infix-ops": { 996 | $ref: "#/definitions/rule", 997 | description: "Require spacing around operators", 998 | }, 999 | "space-in-parens": { 1000 | $ref: "#/definitions/rule", 1001 | description: "Enforce consistent spacing inside parentheses", 1002 | }, 1003 | "space-unary-ops": { 1004 | $ref: "#/definitions/rule", 1005 | description: 1006 | "Enforce consistent spacing before or after unary operators", 1007 | }, 1008 | "switch-colon-spacing": { 1009 | $ref: "#/definitions/rule", 1010 | description: "Enforce spacing around colons of switch statements", 1011 | }, 1012 | "template-tag-spacing": { 1013 | $ref: "#/definitions/rule", 1014 | description: 1015 | "Require or disallow spacing between template tags and their literals", 1016 | }, 1017 | "unicode-bom": { 1018 | $ref: "#/definitions/rule", 1019 | description: "Require or disallow Unicode byte order mark (BOM)", 1020 | }, 1021 | "wrap-regex": { 1022 | $ref: "#/definitions/rule", 1023 | description: "Require parenthesis around regex literals", 1024 | }, 1025 | }, 1026 | }, 1027 | ecmaScript6: { 1028 | properties: { 1029 | "arrow-body-style": { 1030 | $ref: "#/definitions/rule", 1031 | description: "Require braces around arrow function bodies", 1032 | }, 1033 | "arrow-parens": { 1034 | $ref: "#/definitions/rule", 1035 | description: "Require parentheses around arrow function arguments", 1036 | }, 1037 | "arrow-spacing": { 1038 | $ref: "#/definitions/rule", 1039 | description: 1040 | "Enforce consistent spacing before and after the arrow in arrow functions", 1041 | }, 1042 | "constructor-super": { 1043 | $ref: "#/definitions/rule", 1044 | description: "Require super() calls in constructors", 1045 | }, 1046 | "generator-star-spacing": { 1047 | $ref: "#/definitions/rule", 1048 | description: 1049 | "Enforce consistent spacing around * operators in generator functions", 1050 | }, 1051 | "no-class-assign": { 1052 | $ref: "#/definitions/rule", 1053 | description: "Disallow reassigning class members", 1054 | }, 1055 | "no-confusing-arrow": { 1056 | $ref: "#/definitions/rule", 1057 | description: 1058 | "Disallow arrow functions where they could be confused with comparisons", 1059 | }, 1060 | "no-const-assign": { 1061 | $ref: "#/definitions/rule", 1062 | description: "Disallow reassigning const variables", 1063 | }, 1064 | "no-dupe-class-members": { 1065 | $ref: "#/definitions/rule", 1066 | description: "Disallow duplicate class members", 1067 | }, 1068 | "no-duplicate-imports": { 1069 | $ref: "#/definitions/rule", 1070 | description: "Disallow duplicate module imports", 1071 | }, 1072 | "no-new-symbol": { 1073 | $ref: "#/definitions/rule", 1074 | description: "Disallow new operators with the Symbol object", 1075 | }, 1076 | "no-restricted-imports": { 1077 | $ref: "#/definitions/rule", 1078 | description: "Disallow specified modules when loaded by import", 1079 | }, 1080 | "no-this-before-super": { 1081 | $ref: "#/definitions/rule", 1082 | description: 1083 | "Disallow this/super before calling super() in constructors", 1084 | }, 1085 | "no-useless-computed-key": { 1086 | $ref: "#/definitions/rule", 1087 | description: 1088 | "Disallow unnecessary computed property keys in object literals", 1089 | }, 1090 | "no-useless-constructor": { 1091 | $ref: "#/definitions/rule", 1092 | description: "Disallow unnecessary constructors", 1093 | }, 1094 | "no-useless-rename": { 1095 | $ref: "#/definitions/rule", 1096 | description: 1097 | "Disallow renaming import, export, and destructured assignments to the same name", 1098 | }, 1099 | "no-var": { 1100 | $ref: "#/definitions/rule", 1101 | description: "Require let or const instead of var", 1102 | }, 1103 | "object-shorthand": { 1104 | $ref: "#/definitions/rule", 1105 | description: 1106 | "Require or disallow method and property shorthand syntax for object literals", 1107 | }, 1108 | "prefer-arrow-callback": { 1109 | $ref: "#/definitions/rule", 1110 | description: "Require arrow functions as callbacks", 1111 | }, 1112 | "prefer-const": { 1113 | $ref: "#/definitions/rule", 1114 | description: 1115 | "Require const declarations for variables that are never reassigned after declared", 1116 | }, 1117 | "prefer-destructuring": { 1118 | $ref: "#/definitions/rule", 1119 | description: "Require destructuring from arrays and/or objects", 1120 | }, 1121 | "prefer-numeric-literals": { 1122 | $ref: "#/definitions/rule", 1123 | description: 1124 | "Disallow parseInt() in favor of binary, octal, and hexadecimal literals", 1125 | }, 1126 | "prefer-reflect": { 1127 | $ref: "#/definitions/rule", 1128 | description: "Require Reflect methods where applicable", 1129 | }, 1130 | "prefer-rest-params": { 1131 | $ref: "#/definitions/rule", 1132 | description: "Require rest parameters instead of arguments", 1133 | }, 1134 | "prefer-spread": { 1135 | $ref: "#/definitions/rule", 1136 | description: "Require spread operators instead of .apply()", 1137 | }, 1138 | "prefer-template": { 1139 | $ref: "#/definitions/rule", 1140 | description: 1141 | "Require template literals instead of string concatenation", 1142 | }, 1143 | "require-yield": { 1144 | $ref: "#/definitions/rule", 1145 | description: "Require generator functions to contain yield", 1146 | }, 1147 | "rest-spread-spacing": { 1148 | $ref: "#/definitions/rule", 1149 | description: 1150 | "Enforce spacing between rest and spread operators and their expressions", 1151 | }, 1152 | "sort-imports": { 1153 | $ref: "#/definitions/rule", 1154 | description: "Enforce sorted import declarations within modules", 1155 | }, 1156 | "symbol-description": { 1157 | $ref: "#/definitions/rule", 1158 | description: "Require symbol descriptions", 1159 | }, 1160 | "template-curly-spacing": { 1161 | $ref: "#/definitions/rule", 1162 | description: 1163 | "Require or disallow spacing around embedded expressions of template strings", 1164 | }, 1165 | "yield-star-spacing": { 1166 | $ref: "#/definitions/rule", 1167 | description: 1168 | "Require or disallow spacing around the * in yield* expressions", 1169 | }, 1170 | }, 1171 | }, 1172 | legacy: { 1173 | properties: { 1174 | "max-depth": {$ref: "#/definitions/rule"}, 1175 | "max-len": {$ref: "#/definitions/rule"}, 1176 | "max-params": {$ref: "#/definitions/rule"}, 1177 | "max-statements": {$ref: "#/definitions/rule"}, 1178 | "no-bitwise": {$ref: "#/definitions/rule"}, 1179 | "no-plusplus": {$ref: "#/definitions/rule"}, 1180 | }, 1181 | }, 1182 | }, 1183 | 1184 | properties: { 1185 | ecmaFeatures: { 1186 | description: 1187 | "By default, ESLint supports only ECMAScript 5 syntax. You can override that setting to enable support for ECMAScript 6 as well as JSX by using configuration settings.", 1188 | type: "object", 1189 | 1190 | properties: { 1191 | arrowFunctions: {type: "boolean"}, 1192 | binaryLiterals: {type: "boolean"}, 1193 | blockBindings: {type: "boolean"}, 1194 | classes: {type: "boolean"}, 1195 | defaultParams: {type: "boolean"}, 1196 | destructuring: {type: "boolean"}, 1197 | experimentalObjectRestSpread: { 1198 | type: "boolean", 1199 | description: 1200 | "Enables support for the experimental object rest/spread properties (IMPORTANT: This is an experimental feature that may change significantly in the future. It’s recommended that you do not write rules relying on this functionality unless you are willing to incur maintenance cost when it changes.)", 1201 | }, 1202 | forOf: {type: "boolean"}, 1203 | generators: {type: "boolean"}, 1204 | globalReturn: { 1205 | type: "boolean", 1206 | description: "allow return statements in the global scope", 1207 | }, 1208 | impliedStrict: { 1209 | type: "boolean", 1210 | description: 1211 | "enable global strict mode (if ecmaVersion is 5 or greater)", 1212 | }, 1213 | jsx: {type: "boolean", description: "enable JSX"}, 1214 | modules: {type: "boolean"}, 1215 | objectLiteralComputedProperties: {type: "boolean"}, 1216 | objectLiteralDuplicateProperties: {type: "boolean"}, 1217 | objectLiteralShorthandMethods: {type: "boolean"}, 1218 | objectLiteralShorthandProperties: {type: "boolean"}, 1219 | octalLiterals: {type: "boolean"}, 1220 | regexUFlag: {type: "boolean"}, 1221 | regexYFlag: {type: "boolean"}, 1222 | restParams: {type: "boolean"}, 1223 | spread: {type: "boolean"}, 1224 | superInFunctions: {type: "boolean"}, 1225 | templateStrings: {type: "boolean"}, 1226 | unicodeCodePointEscapes: {type: "boolean"}, 1227 | }, 1228 | }, 1229 | env: { 1230 | description: 1231 | "An environment defines global variables that are predefined.", 1232 | type: "object", 1233 | 1234 | properties: { 1235 | amd: { 1236 | type: "boolean", 1237 | description: 1238 | "defines require() and define() as global variables as per the amd spec", 1239 | }, 1240 | applescript: { 1241 | type: "boolean", 1242 | description: "AppleScript global variables", 1243 | }, 1244 | atomtest: { 1245 | type: "boolean", 1246 | description: "Atom test helper globals", 1247 | }, 1248 | browser: { 1249 | type: "boolean", 1250 | description: "browser global variables", 1251 | }, 1252 | commonjs: { 1253 | type: "boolean", 1254 | description: 1255 | "CommonJS global variables and CommonJS scoping (use this for browser-only code that uses Browserify/WebPack)", 1256 | }, 1257 | "shared-node-browser": { 1258 | type: "boolean", 1259 | description: "Globals common to both Node and Browser", 1260 | }, 1261 | embertest: { 1262 | type: "boolean", 1263 | description: "Ember test helper globals", 1264 | }, 1265 | es6: { 1266 | type: "boolean", 1267 | description: "enable all ECMAScript 6 features except for modules", 1268 | }, 1269 | greasemonkey: { 1270 | type: "boolean", 1271 | description: "GreaseMonkey globals", 1272 | }, 1273 | jasmine: { 1274 | type: "boolean", 1275 | description: 1276 | "adds all of the Jasmine testing global variables for version 1.3 and 2.0", 1277 | }, 1278 | jest: { 1279 | type: "boolean", 1280 | description: "Jest global variables", 1281 | }, 1282 | jquery: { 1283 | type: "boolean", 1284 | description: "jQuery global variables", 1285 | }, 1286 | meteor: { 1287 | type: "boolean", 1288 | description: "Meteor global variables", 1289 | }, 1290 | mocha: { 1291 | type: "boolean", 1292 | description: "adds all of the Mocha test global variables", 1293 | }, 1294 | mongo: { 1295 | type: "boolean", 1296 | description: "MongoDB global variables", 1297 | }, 1298 | nashorn: { 1299 | type: "boolean", 1300 | description: "Java 8 Nashorn global variables", 1301 | }, 1302 | node: { 1303 | type: "boolean", 1304 | description: "Node.js global variables and Node.js scoping", 1305 | }, 1306 | phantomjs: { 1307 | type: "boolean", 1308 | description: "PhantomJS global variables", 1309 | }, 1310 | prototypejs: { 1311 | type: "boolean", 1312 | description: "Prototype.js global variables", 1313 | }, 1314 | protractor: { 1315 | type: "boolean", 1316 | description: "Protractor global variables", 1317 | }, 1318 | qunit: { 1319 | type: "boolean", 1320 | description: "QUnit global variables", 1321 | }, 1322 | serviceworker: { 1323 | type: "boolean", 1324 | description: "Service Worker global variables", 1325 | }, 1326 | shelljs: { 1327 | type: "boolean", 1328 | description: "ShellJS global variables", 1329 | }, 1330 | webextensions: { 1331 | type: "boolean", 1332 | description: "WebExtensions globals", 1333 | }, 1334 | worker: { 1335 | type: "boolean", 1336 | description: "web workers global variables", 1337 | }, 1338 | }, 1339 | }, 1340 | extends: { 1341 | description: 1342 | "If you want to extend a specific configuration file, you can use the extends property and specify the path to the file. The path can be either relative or absolute.", 1343 | type: ["string", "array"], 1344 | items: { 1345 | type: "string", 1346 | }, 1347 | }, 1348 | globals: { 1349 | description: 1350 | "Set each global variable name equal to true to allow the variable to be overwritten or false to disallow overwriting.", 1351 | type: "object", 1352 | 1353 | additionalProperties: { 1354 | oneOf: [ 1355 | { 1356 | type: "string", 1357 | enum: ["readonly", "writable", "off"], 1358 | }, 1359 | { 1360 | description: 1361 | 'The values false|"readable" and true|"writeable" are deprecated, they are equivalent to "readonly" and "writable", respectively.', 1362 | type: "boolean", 1363 | }, 1364 | ], 1365 | }, 1366 | }, 1367 | noInlineConfig: { 1368 | description: "Prevent comments from changing config or rules", 1369 | type: "boolean", 1370 | }, 1371 | parser: { 1372 | type: "string", 1373 | }, 1374 | parserOptions: { 1375 | description: "The JavaScript language options to be supported", 1376 | type: "object", 1377 | properties: { 1378 | ecmaFeatures: { 1379 | $ref: "#/properties/ecmaFeatures", 1380 | }, 1381 | ecmaVersion: { 1382 | enum: [ 1383 | 3, 1384 | 5, 1385 | 6, 1386 | 2015, 1387 | 7, 1388 | 2016, 1389 | 8, 1390 | 2017, 1391 | 9, 1392 | 2018, 1393 | 10, 1394 | 2019, 1395 | 11, 1396 | 2020, 1397 | 12, 1398 | 2021, 1399 | ], 1400 | default: 11, 1401 | description: 1402 | "Set to 3, 5, 6, 7, 8, 9, 10, 11 (default) or 12 to specify the version of ECMAScript syntax you want to use. You can also set to 2015 (same as 6), 2016 (same as 7), 2017 (same as 8), 2018 (same as 9), 2019 (same as 10), 2020 (same as 11) or 2021 (same as 12) to use the year-based naming.", 1403 | }, 1404 | sourceType: { 1405 | enum: ["script", "module"], 1406 | default: "script", 1407 | description: 1408 | 'set to "script" (default) or "module" if your code is in ECMAScript modules', 1409 | }, 1410 | }, 1411 | }, 1412 | plugins: { 1413 | description: 1414 | "ESLint supports the use of third-party plugins. Before using the plugin, you have to install it using npm.", 1415 | type: "array", 1416 | items: { 1417 | type: "string", 1418 | }, 1419 | }, 1420 | root: { 1421 | description: 1422 | "By default, ESLint will look for configuration files in all parent folders up to the root directory. This can be useful if you want all of your projects to follow a certain convention, but can sometimes lead to unexpected results. To limit ESLint to a specific project, set this to `true` in a configuration in the root of your project.", 1423 | type: "boolean", 1424 | }, 1425 | ignorePatterns: { 1426 | description: 1427 | "Tell ESLint to ignore specific files and directories. Each value uses the same pattern as the `.eslintignore` file.", 1428 | type: ["string", "array"], 1429 | items: { 1430 | type: "string", 1431 | }, 1432 | }, 1433 | rules: { 1434 | description: 1435 | "ESLint comes with a large number of rules. You can modify which rules your project uses either using configuration comments or configuration files.", 1436 | type: "object", 1437 | 1438 | allOf: [ 1439 | {$ref: "#/definitions/possibleErrors"}, 1440 | {$ref: "#/definitions/bestPractices"}, 1441 | {$ref: "#/definitions/strictMode"}, 1442 | {$ref: "#/definitions/variables"}, 1443 | {$ref: "#/definitions/nodeAndCommonJs"}, 1444 | {$ref: "#/definitions/stylisticIssues"}, 1445 | {$ref: "#/definitions/ecmaScript6"}, 1446 | {$ref: "#/definitions/legacy"}, 1447 | ], 1448 | }, 1449 | settings: { 1450 | description: 1451 | "ESLint supports adding shared settings into configuration file. You can add settings object to ESLint configuration file and it will be supplied to every rule that will be executed. This may be useful if you are adding custom rules and want them to have access to the same information and be easily configurable.", 1452 | type: "object", 1453 | }, 1454 | overrides: { 1455 | type: "array", 1456 | description: 1457 | "Allows to override configuration for files and folders, specified by glob patterns", 1458 | items: { 1459 | type: "object", 1460 | properties: { 1461 | files: { 1462 | description: 1463 | "Glob pattern for files to apply 'overrides' configuration, relative to the directory of the config file", 1464 | oneOf: [ 1465 | { 1466 | type: "string", 1467 | }, 1468 | { 1469 | minItems: 1, 1470 | type: "array", 1471 | items: { 1472 | type: "string", 1473 | }, 1474 | }, 1475 | ], 1476 | }, 1477 | extends: { 1478 | description: 1479 | "If you want to extend a specific configuration file, you can use the extends property and specify the path to the file. The path can be either relative or absolute.", 1480 | type: ["string", "array"], 1481 | items: { 1482 | type: "string", 1483 | }, 1484 | }, 1485 | excludedFiles: { 1486 | description: 1487 | "If a file matches any of the 'excludedFiles' glob patterns, the 'overrides' configuration won’t apply", 1488 | oneOf: [ 1489 | { 1490 | type: "string", 1491 | }, 1492 | { 1493 | type: "array", 1494 | items: { 1495 | type: "string", 1496 | }, 1497 | }, 1498 | ], 1499 | }, 1500 | ecmaFeatures: { 1501 | $ref: "#/properties/ecmaFeatures", 1502 | }, 1503 | env: { 1504 | $ref: "#/properties/env", 1505 | }, 1506 | globals: { 1507 | $ref: "#/properties/globals", 1508 | }, 1509 | parser: { 1510 | $ref: "#/properties/parser", 1511 | }, 1512 | parserOptions: { 1513 | $ref: "#/properties/parserOptions", 1514 | }, 1515 | plugins: { 1516 | $ref: "#/properties/plugins", 1517 | }, 1518 | processor: { 1519 | description: 1520 | "To specify a processor, specify the plugin name and processor name joined by a forward slash", 1521 | type: "string", 1522 | }, 1523 | rules: { 1524 | $ref: "#/properties/rules", 1525 | }, 1526 | settings: { 1527 | $ref: "#/properties/settings", 1528 | }, 1529 | }, 1530 | additionalProperties: false, 1531 | required: ["files"], 1532 | }, 1533 | }, 1534 | }, 1535 | }; 1536 | 1537 | type EslintConfig = ResolvedJsonSchema; 1538 | 1539 | /* 1540 | var OFF = 0, 1541 | WARN = 1, 1542 | ERROR = 2; 1543 | 1544 | const example: EslintConfig = { 1545 | env: { 1546 | es6: true, 1547 | }, 1548 | 1549 | ecmaFeatures: { 1550 | // env=es6 doesn't include modules, which we are using 1551 | modules: true, 1552 | }, 1553 | 1554 | extends: "eslint:recommended", 1555 | 1556 | rules: { 1557 | // Possible Errors (overrides from recommended set) 1558 | "no-extra-parens": ERROR, 1559 | "no-unexpected-multiline": ERROR, 1560 | // All JSDoc comments must be valid 1561 | "valid-jsdoc": [ 1562 | ERROR, 1563 | { 1564 | requireReturn: false, 1565 | requireReturnDescription: false, 1566 | requireParamDescription: true, 1567 | prefer: { 1568 | return: "returns", 1569 | }, 1570 | }, 1571 | ], 1572 | 1573 | // Best Practices 1574 | 1575 | // Allowed a getter without setter, but all setters require getters 1576 | "accessor-pairs": [ 1577 | ERROR, 1578 | { 1579 | getWithoutSet: false, 1580 | setWithoutGet: true, 1581 | }, 1582 | ], 1583 | "block-scoped-var": WARN, 1584 | "consistent-return": ERROR, 1585 | curly: ERROR, 1586 | "default-case": WARN, 1587 | // the dot goes with the property when doing multiline 1588 | "dot-location": [WARN, "property"], 1589 | "dot-notation": WARN, 1590 | eqeqeq: [ERROR, "smart"], 1591 | "guard-for-in": WARN, 1592 | "no-alert": ERROR, 1593 | "no-caller": ERROR, 1594 | "no-case-declarations": WARN, 1595 | "no-div-regex": WARN, 1596 | "no-else-return": WARN, 1597 | "no-empty-label": WARN, 1598 | "no-empty-pattern": WARN, 1599 | "no-eq-null": WARN, 1600 | "no-eval": ERROR, 1601 | "no-extend-native": ERROR, 1602 | "no-extra-bind": WARN, 1603 | "no-floating-decimal": WARN, 1604 | "no-implicit-coercion": [ 1605 | WARN, 1606 | { 1607 | boolean: true, 1608 | number: true, 1609 | string: true, 1610 | }, 1611 | ], 1612 | "no-implied-eval": ERROR, 1613 | "no-invalid-this": ERROR, 1614 | "no-iterator": ERROR, 1615 | "no-labels": WARN, 1616 | "no-lone-blocks": WARN, 1617 | "no-loop-func": ERROR, 1618 | "no-magic-numbers": WARN, 1619 | "no-multi-spaces": ERROR, 1620 | "no-multi-str": WARN, 1621 | "no-native-reassign": ERROR, 1622 | "no-new-func": ERROR, 1623 | "no-new-wrappers": ERROR, 1624 | "no-new": ERROR, 1625 | "no-octal-escape": ERROR, 1626 | "no-param-reassign": ERROR, 1627 | "no-process-env": WARN, 1628 | "no-proto": ERROR, 1629 | "no-redeclare": ERROR, 1630 | "no-return-assign": ERROR, 1631 | "no-script-url": ERROR, 1632 | "no-self-compare": ERROR, 1633 | "no-throw-literal": ERROR, 1634 | "no-unused-expressions": ERROR, 1635 | "no-useless-call": ERROR, 1636 | "no-useless-concat": ERROR, 1637 | "no-void": WARN, 1638 | // Produce warnings when something is commented as TODO or FIXME 1639 | "no-warning-comments": [ 1640 | WARN, 1641 | { 1642 | terms: ["TODO", "FIXME"], 1643 | location: "start", 1644 | }, 1645 | ], 1646 | "no-with": WARN, 1647 | radix: WARN, 1648 | "vars-on-top": ERROR, 1649 | // Enforces the style of wrapped functions 1650 | "wrap-iife": [ERROR, "outside"], 1651 | yoda: ERROR, 1652 | 1653 | // Strict Mode - for ES6, never use strict. 1654 | strict: [ERROR, "never"], 1655 | 1656 | // Variables 1657 | "init-declarations": [ERROR, "always"], 1658 | "no-catch-shadow": WARN, 1659 | "no-delete-var": ERROR, 1660 | "no-label-var": ERROR, 1661 | "no-shadow-restricted-names": ERROR, 1662 | "no-shadow": WARN, 1663 | // We require all vars to be initialized (see init-declarations) 1664 | // If we NEED a var to be initialized to undefined, it needs to be explicit 1665 | "no-undef-init": OFF, 1666 | "no-undef": ERROR, 1667 | "no-undefined": OFF, 1668 | "no-unused-vars": WARN, 1669 | // Disallow hoisting - let & const don't allow hoisting anyhow 1670 | "no-use-before-define": ERROR, 1671 | 1672 | // Node.js and CommonJS 1673 | "callback-return": [WARN, ["callback", "next"]], 1674 | "global-require": ERROR, 1675 | "handle-callback-err": WARN, 1676 | "no-mixed-requires": WARN, 1677 | "no-new-require": ERROR, 1678 | // Use path.concat instead 1679 | "no-path-concat": ERROR, 1680 | "no-process-exit": ERROR, 1681 | "no-restricted-modules": OFF, 1682 | "no-sync": WARN, 1683 | 1684 | // ECMAScript 6 support 1685 | "arrow-body-style": [ERROR, "always"], 1686 | "arrow-parens": [ERROR, "always"], 1687 | "arrow-spacing": [ERROR, {before: true, after: true}], 1688 | "constructor-super": ERROR, 1689 | "generator-star-spacing": [ERROR, "before"], 1690 | "no-arrow-condition": ERROR, 1691 | "no-class-assign": ERROR, 1692 | "no-const-assign": ERROR, 1693 | "no-dupe-class-members": ERROR, 1694 | "no-this-before-super": ERROR, 1695 | "no-var": WARN, 1696 | "object-shorthand": [WARN, "never"], 1697 | "prefer-arrow-callback": WARN, 1698 | "prefer-spread": WARN, 1699 | "prefer-template": WARN, 1700 | "require-yield": ERROR, 1701 | 1702 | // Stylistic - everything here is a warning because of style. 1703 | "array-bracket-spacing": [WARN, "always"], 1704 | "block-spacing": [WARN, "always"], 1705 | "brace-style": [WARN, "1tbs", {allowSingleLine: false}], 1706 | camelcase: WARN, 1707 | "comma-spacing": [WARN, {before: false, after: true}], 1708 | "comma-style": [WARN, "last"], 1709 | "computed-property-spacing": [WARN, "never"], 1710 | "consistent-this": [WARN, "self"], 1711 | "eol-last": WARN, 1712 | "func-names": WARN, 1713 | "func-style": [WARN, "declaration"], 1714 | "id-length": [WARN, {min: 2, max: 32}], 1715 | indent: [WARN, 4], 1716 | "jsx-quotes": [WARN, "prefer-double"], 1717 | "linebreak-style": [WARN, "unix"], 1718 | "lines-around-comment": [WARN, {beforeBlockComment: true}], 1719 | "max-depth": [WARN, 8], 1720 | "max-len": [WARN, 132], 1721 | "max-nested-callbacks": [WARN, 8], 1722 | "max-params": [WARN, 8], 1723 | "new-cap": WARN, 1724 | "new-parens": WARN, 1725 | "no-array-constructor": WARN, 1726 | "no-bitwise": OFF, 1727 | "no-continue": OFF, 1728 | "no-inline-comments": OFF, 1729 | "no-lonely-if": WARN, 1730 | "no-mixed-spaces-and-tabs": WARN, 1731 | "no-multiple-empty-lines": WARN, 1732 | "no-negated-condition": OFF, 1733 | "no-nested-ternary": WARN, 1734 | "no-new-object": WARN, 1735 | "no-plusplus": OFF, 1736 | "no-spaced-func": WARN, 1737 | "no-ternary": OFF, 1738 | "no-trailing-spaces": WARN, 1739 | "no-underscore-dangle": WARN, 1740 | "no-unneeded-ternary": WARN, 1741 | "object-curly-spacing": [WARN, "always"], 1742 | "one-var": OFF, 1743 | "operator-assignment": [WARN, "never"], 1744 | "operator-linebreak": [WARN, "after"], 1745 | "padded-blocks": [WARN, "never"], 1746 | "quote-props": [WARN, "consistent-as-needed"], 1747 | quotes: [WARN, "single"], 1748 | "require-jsdoc": [ 1749 | WARN, 1750 | { 1751 | require: { 1752 | FunctionDeclaration: true, 1753 | MethodDefinition: true, 1754 | ClassDeclaration: false, 1755 | }, 1756 | }, 1757 | ], 1758 | "semi-spacing": [WARN, {before: false, after: true}], 1759 | semi: [ERROR, "always"], 1760 | "sort-vars": OFF, 1761 | "space-after-keywords": [WARN, "always"], 1762 | "space-before-blocks": [WARN, "always"], 1763 | "space-before-function-paren": [WARN, "never"], 1764 | "space-before-keywords": [WARN, "always"], 1765 | "space-in-parens": [WARN, "never"], 1766 | "space-infix-ops": [WARN, {int32Hint: true}], 1767 | "space-return-throw-case": ERROR, 1768 | "space-unary-ops": ERROR, 1769 | "spaced-comment": [WARN, "always"], 1770 | "wrap-regex": WARN, 1771 | }, 1772 | }; 1773 | */ 1774 | --------------------------------------------------------------------------------