Commit 221113b4 authored by David Sveningsson's avatar David Sveningsson
Browse files

fix(rules): rule options uses `Partial<T>`

parent fa58dcf6
Pipeline #235253770 passed with stages
in 9 minutes and 56 seconds
......@@ -134,7 +134,7 @@ const defaults: RuleOptions = {
};
class MyRule extends Rule<void, RuleOptions> {
constructor(options: RuleOptions) {
constructor(options: Partial<RuleOptions>) {
/* assign default values if not provided by user */
super({ ...defaults, ...options });
}
......
......@@ -40,7 +40,7 @@ const description: Record<Style, string | null> = {
};
export default class AllowedLinks extends Rule<Style, RuleOptions> {
public constructor(options: RuleOptions) {
public constructor(options: Partial<RuleOptions>) {
super({ ...defaults, ...options });
}
......
......@@ -14,7 +14,7 @@ const defaults: RuleOptions = {
export default class ClassPattern extends Rule<void, RuleOptions> {
private pattern: RegExp;
public constructor(options: RuleOptions) {
public constructor(options: Partial<RuleOptions>) {
super({ ...defaults, ...options });
this.pattern = parsePattern(this.options.pattern);
}
......
......@@ -15,7 +15,7 @@ const defaults: RuleOptions = {
export default class ElementCase extends Rule<void, RuleOptions> {
private style: CaseStyle;
public constructor(options: RuleOptions) {
public constructor(options: Partial<RuleOptions>) {
super({ ...defaults, ...options });
this.style = new CaseStyle(this.options.style, "element-case");
}
......
......@@ -23,7 +23,7 @@ const defaults: RuleOptions = {
export default class ElementName extends Rule<Context, RuleOptions> {
private pattern: RegExp;
public constructor(options: RuleOptions) {
public constructor(options: Partial<RuleOptions>) {
super({ ...defaults, ...options });
// eslint-disable-next-line security/detect-non-literal-regexp
......
......@@ -14,7 +14,7 @@ const defaults: RuleOptions = {
export default class IdPattern extends Rule<void, RuleOptions> {
private pattern: RegExp;
public constructor(options: RuleOptions) {
public constructor(options: Partial<RuleOptions>) {
super({ ...defaults, ...options });
this.pattern = parsePattern(this.options.pattern);
}
......
......@@ -11,7 +11,7 @@ const defaults: RuleOptions = {
export default class LongTitle extends Rule<void, RuleOptions> {
private maxlength: number;
public constructor(options: RuleOptions) {
public constructor(options: Partial<RuleOptions>) {
super({ ...defaults, ...options });
this.maxlength = this.options.maxlength;
}
......
......@@ -17,7 +17,7 @@ const defaults: RuleOptions = {
};
export default class NoAutoplay extends Rule<RuleContext, RuleOptions> {
public constructor(options: RuleOptions) {
public constructor(options: Partial<RuleOptions>) {
super({ ...defaults, ...options });
}
......
......@@ -12,7 +12,7 @@ const defaults: RuleOptions = {
};
export default class NoInlineStyle extends Rule<void, RuleOptions> {
public constructor(options: RuleOptions) {
public constructor(options: Partial<RuleOptions>) {
super({ ...defaults, ...options });
}
......
......@@ -28,7 +28,7 @@ const replacementTable: Map<string, string> = new Map([
export default class NoRawCharacters extends Rule<void, RuleOptions> {
private relaxed: boolean;
public constructor(options: RuleOptions) {
public constructor(options: Partial<RuleOptions>) {
super({ ...defaults, ...options });
this.relaxed = this.options.relaxed;
}
......
......@@ -14,7 +14,7 @@ const defaults: RuleOptions = {
};
export default class NoSelfClosing extends Rule<string, RuleOptions> {
public constructor(options: RuleOptions) {
public constructor(options: Partial<RuleOptions>) {
super({ ...defaults, ...options });
}
......
......@@ -25,7 +25,7 @@ const defaults: RuleOptions = {
};
export default class PreferButton extends Rule<RuleContext, RuleOptions> {
public constructor(options: RuleOptions) {
public constructor(options: Partial<RuleOptions>) {
super({ ...defaults, ...options });
}
......
......@@ -44,7 +44,7 @@ const defaults: RuleOptions = {
};
export default class PreferNativeElement extends Rule<RuleContext, RuleOptions> {
public constructor(options: RuleOptions) {
public constructor(options: Partial<RuleOptions>) {
super({ ...defaults, ...options });
}
......
......@@ -21,7 +21,7 @@ const supportSri: { [key: string]: string } = {
export default class RequireSri extends Rule<void, RuleOptions> {
private target: Target;
public constructor(options: RuleOptions) {
public constructor(options: Partial<RuleOptions>) {
super({ ...defaults, ...options });
this.target = this.options.target;
}
......
......@@ -23,7 +23,7 @@ interface RuleOptions {
export default class VoidStyle extends Rule<RuleContext, RuleOptions> {
private style: Style;
public constructor(options: RuleOptions) {
public constructor(options: Partial<RuleOptions>) {
super({ ...defaults, ...options });
this.style = parseStyle(this.options.style);
}
......
......@@ -32,7 +32,7 @@ export default class Void extends Rule<void, RuleOptions> {
};
}
public constructor(options: RuleOptions) {
public constructor(options: Partial<RuleOptions>) {
super({ ...defaults, ...options });
this.style = parseStyle(this.options.style);
}
......
......@@ -21,7 +21,7 @@ export default class H37 extends Rule<void, RuleOptions> {
};
}
public constructor(options: RuleOptions) {
public constructor(options: Partial<RuleOptions>) {
super({ ...defaults, ...options });
/* ensure alias is array */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment