Skip to content

Commit

Permalink
feat(core): include 'description' for ruleset (#2000)
Browse files Browse the repository at this point in the history
  • Loading branch information
jgreen44 committed Dec 14, 2021
1 parent 2fd923e commit aacae2c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/core/src/meta/ruleset.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"format": "url",
"errorMessage": "must be a valid URL"
},
"description": { "type": "string" },
"rules": {
"type": "object",
"additionalProperties": {
Expand Down
15 changes: 15 additions & 0 deletions packages/core/src/ruleset/__tests__/validation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,21 @@ Error at #/rules/rule-with-invalid-enum/severity: the value has to be one of: 0,
).not.toThrow();
});

it.each([false, 2, null])('given invalid %s description in a ruleset, throws', description => {
expect(assertValidRuleset.bind(null, { description, rules: {} })).toThrow(
new RulesetValidationError('Error at #/description: must be string'),
);
});

it('recognizes valid description in a ruleset', () => {
expect(
assertValidRuleset.bind(null, {
description: 'This is the ruleset description',
rules: {},
}),
).not.toThrow();
});

it.each(['error', 'warn', 'info', 'hint', 'off'])('recognizes human-readable %s severity', severity => {
expect(
assertValidRuleset.bind(null, {
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/ruleset/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export type RulesetAliasesDefinition = Record<string, string | RulesetScopedAlia
export type RulesetDefinition = Readonly<
{
documentationUrl?: string;
description?: string;
formats?: Format<any>[];
parserOptions?: Partial<ParserOptions>;
overrides?: RulesetOverridesDefinition;
Expand Down

0 comments on commit aacae2c

Please sign in to comment.