-
-
Notifications
You must be signed in to change notification settings - Fork 248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(core): improve ruleset typings #2132
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
export { assertValidRuleset, RulesetValidationError } from './validation/index'; | ||
export { getDiagnosticSeverity } from './utils'; | ||
export { createRulesetFunction, SchemaDefinition as RulesetFunctionSchemaDefinition } from './rulesetFunction'; | ||
export { getDiagnosticSeverity } from './utils/severity'; | ||
export { createRulesetFunction, SchemaDefinition as RulesetFunctionSchemaDefinition } from './function'; | ||
export { Format } from './format'; | ||
export { RulesetDefinition, RuleDefinition, ParserOptions, HumanReadableDiagnosticSeverity } from './types'; | ||
export { Ruleset } from './ruleset'; | ||
export { Rule } from './rule'; | ||
export { Ruleset, StringifiedRuleset } from './ruleset'; | ||
export { Rule, StringifiedRule } from './rule'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import { DiagnosticSeverity } from '@stoplight/types'; | ||
import { Format } from './format'; | ||
import { RulesetFunction, RulesetFunctionWithValidator } from '../types'; | ||
import { FormatsSet } from './utils/formatsSet'; | ||
import type { DiagnosticSeverity } from '@stoplight/types'; | ||
import type { Format } from './format'; | ||
import type { RulesetFunction, RulesetFunctionWithValidator } from '../types'; | ||
import type { Formats } from './formats'; | ||
|
||
export type HumanReadableDiagnosticSeverity = 'error' | 'warn' | 'info' | 'hint' | 'off'; | ||
export type FileRuleSeverityDefinition = DiagnosticSeverity | HumanReadableDiagnosticSeverity | boolean; | ||
|
@@ -17,7 +17,7 @@ export type ParserOptions = { | |
export type RuleDefinition = { | ||
type?: 'validation' | 'style'; | ||
|
||
formats?: Format[]; | ||
formats?: Formats | Format[]; | ||
|
||
documentationUrl?: string; | ||
|
||
|
@@ -81,7 +81,7 @@ export type RulesetOverridesDefinition = ReadonlyArray<{ files: string[] } & Rul | |
export type RulesetScopedAliasDefinition = { | ||
description?: string; | ||
targets: { | ||
formats: FormatsSet | Format[]; | ||
formats: Formats | Format[]; | ||
given: string[]; | ||
}[]; | ||
}; | ||
|
@@ -92,7 +92,7 @@ export type RulesetDefinition = Readonly< | |
{ | ||
documentationUrl?: string; | ||
description?: string; | ||
formats?: FormatsSet | Format[]; | ||
formats?: Formats | Format[]; | ||
parserOptions?: Partial<ParserOptions>; | ||
overrides?: RulesetOverridesDefinition; | ||
aliases?: RulesetAliasesDefinition; | ||
|
@@ -112,3 +112,10 @@ export type RulesetDefinition = Readonly< | |
} | ||
> | ||
>; | ||
|
||
// eslint-disable-next-line @typescript-eslint/ban-types | ||
export type Stringifable<T> = T extends object | ||
? { | ||
[P in keyof T]: Stringifable<T[P]> | { toJSON?(): Stringifable<T[P]> }; | ||
} | ||
: T; | ||
Comment on lines
+116
to
+121
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Neat |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
{ | ||
"include": [], | ||
"extends": "./tsconfig.json", | ||
"composite": true, | ||
"compilerOptions": { | ||
"composite": true | ||
}, | ||
Comment on lines
-4
to
+6
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤦♂️ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, luckily newer TS caught this |
||
"references": [ | ||
{ | ||
"path": "./packages/cli/tsconfig.build.json" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Plans to bump to 13 in the other spectral packages?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I intend to do it