Skip to content

Commit

Permalink
fix(types): return this rather than the class (#360)
Browse files Browse the repository at this point in the history
  • Loading branch information
WilcoFiers committed Sep 9, 2021
1 parent f9d021b commit 7999891
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 32 deletions.
22 changes: 11 additions & 11 deletions packages/playwright/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ export default class AxeBuilder {
* Selector to include in analysis.
* This may be called any number of times.
* @param String selector
* @returns AxeBuilder
* @returns this
*/

public include(selector: string): AxeBuilder {
public include(selector: string): this {
this.includes.push(selector);
return this;
}
Expand All @@ -50,10 +50,10 @@ export default class AxeBuilder {
* Selector to exclude in analysis.
* This may be called any number of times.
* @param String selector
* @returns AxeBuilder
* @returns this
*/

public exclude(selector: string): AxeBuilder {
public exclude(selector: string): this {
this.excludes.push(selector);
return this;
}
Expand All @@ -64,7 +64,7 @@ export default class AxeBuilder {
* @returns AxeBuilder
*/

public options(options: RunOptions): AxeBuilder {
public options(options: RunOptions): this {
this.option = options;
return this;
}
Expand All @@ -73,10 +73,10 @@ export default class AxeBuilder {
* Limit analysis to only the specified rules.
* Cannot be used with `AxeBuilder#withTags`
* @param String|Array rules
* @returns AxeBuilder
* @returns this
*/

public withRules(rules: string | string[]): AxeBuilder {
public withRules(rules: string | string[]): this {
rules = Array.isArray(rules) ? rules : [rules];
/* istanbul ignore next */
this.option = this.option || {};
Expand All @@ -92,10 +92,10 @@ export default class AxeBuilder {
* Limit analysis to only specified tags.
* Cannot be used with `AxeBuilder#withRules`
* @param String|Array tags
* @returns AxeBuilder
* @returns this
*/

public withTags(tags: string | string[]): AxeBuilder {
public withTags(tags: string | string[]): this {
tags = Array.isArray(tags) ? tags : [tags];
/* istanbul ignore next */
this.option = this.option || {};
Expand All @@ -109,10 +109,10 @@ export default class AxeBuilder {
/**
* Set the list of rules to skip when running an analysis.
* @param String|Array rules
* @returns AxeBuilder
* @returns this
*/

public disableRules(rules: string | string[]): AxeBuilder {
public disableRules(rules: string | string[]): this {
rules = Array.isArray(rules) ? rules : [rules];
/* istanbul ignore next */
this.option = this.option || {};
Expand Down
28 changes: 14 additions & 14 deletions packages/webdriverio/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ export default class AxeBuilder {
* Disable injecting axe-core into frame(s) matching the
* given CSS `selector`. This method may be called any number of times.
* @param {String} selector
* @returns {AxeBuilder}
* @returns {this}
*/

public disableFrame(selector: string): AxeBuilder {
public disableFrame(selector: string): this {
this.disableFrameSelectors.push(cssesc(selector));
return this;
}
Expand All @@ -61,10 +61,10 @@ export default class AxeBuilder {
* Selector to include in analysis.
* This may be called any number of times.
* @param {String} selector
* @returns {AxeBuilder}
* @returns {this}
*/

public include(selector: string): AxeBuilder {
public include(selector: string): this {
this.includes.push(selector);
return this;
}
Expand All @@ -73,21 +73,21 @@ export default class AxeBuilder {
* Selector to exclude in analysis.
* This may be called any number of times.
* @param {String} selector
* @returns {AxeBuilder}
* @returns {this}
*/

public exclude(selector: string): AxeBuilder {
public exclude(selector: string): this {
this.excludes.push(selector);
return this;
}

/**
* Set options to be passed into axe-core
* @param {RunOptions} options
* @returns {AxeBuilder}
* @returns {this}
*/

public options(options: RunOptions): AxeBuilder {
public options(options: RunOptions): this {
this.option = options;
return this;
}
Expand All @@ -96,10 +96,10 @@ export default class AxeBuilder {
* Limit analysis to only the specified rules.
* Cannot be used with `AxeBuilder#withTags`
* @param {String|Array} rules
* @returns {AxeBuilder}
* @returns {this}
*/

public withRules(rules: string | string[]): AxeBuilder {
public withRules(rules: string | string[]): this {
rules = Array.isArray(rules) ? rules : [rules];
/* istanbul ignore next */
this.option = this.option || {};
Expand All @@ -115,10 +115,10 @@ export default class AxeBuilder {
* Limit analysis to only specified tags.
* Cannot be used with `AxeBuilder#withRules`
* @param {String|Array} tags
* @returns {AxeBuilder}
* @returns {this}
*/

public withTags(tags: string | string[]): AxeBuilder {
public withTags(tags: string | string[]): this {
tags = Array.isArray(tags) ? tags : [tags];
/* istanbul ignore next */
this.option = this.option || {};
Expand All @@ -132,10 +132,10 @@ export default class AxeBuilder {
/**
* Set the list of rules to skip when running an analysis.
* @param {String|Array} rules
* @returns {AxeBuilder}
* @returns {this}
*/

public disableRules(rules: string | string[]): AxeBuilder {
public disableRules(rules: string | string[]): this {
rules = Array.isArray(rules) ? rules : [rules];
/* istanbul ignore next */
this.option = this.option || {};
Expand Down
14 changes: 7 additions & 7 deletions packages/webdriverjs/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class AxeBuilder {
* Selector to include in analysis.
* This may be called any number of times.
*/
public include(selector: string): AxeBuilder {
public include(selector: string): this {
this.includes.push(selector);
return this;
}
Expand All @@ -50,15 +50,15 @@ class AxeBuilder {
* Selector to exclude in analysis.
* This may be called any number of times.
*/
public exclude(selector: string): AxeBuilder {
public exclude(selector: string): this {
this.excludes.push(selector);
return this;
}

/**
* Set options to be passed into axe-core
*/
public options(options: RunOptions): AxeBuilder {
public options(options: RunOptions): this {
this.option = options;
return this;
}
Expand All @@ -67,7 +67,7 @@ class AxeBuilder {
* Limit analysis to only the specified rules.
* Cannot be used with `AxeBuilder#withTags`
*/
public withRules(rules: string | string[]): AxeBuilder {
public withRules(rules: string | string[]): this {
rules = Array.isArray(rules) ? rules : [rules];
this.option.runOnly = {
type: 'rule',
Expand All @@ -81,7 +81,7 @@ class AxeBuilder {
* Limit analysis to only specified tags.
* Cannot be used with `AxeBuilder#withRules`
*/
public withTags(tags: string | string[]): AxeBuilder {
public withTags(tags: string | string[]): this {
tags = Array.isArray(tags) ? tags : [tags];
this.option.runOnly = {
type: 'tag',
Expand All @@ -93,7 +93,7 @@ class AxeBuilder {
/**
* Set the list of rules to skip when running an analysis.
*/
public disableRules(rules: string | string[]): AxeBuilder {
public disableRules(rules: string | string[]): this {
rules = Array.isArray(rules) ? rules : [rules];
this.option.rules = {};
for (const rule of rules) {
Expand All @@ -106,7 +106,7 @@ class AxeBuilder {
* Set configuration for `axe-core`.
* This value is passed directly to `axe.configure()`
*/
public configure(config: Spec): AxeBuilder {
public configure(config: Spec): this {
if (typeof config !== 'object') {
throw new Error(
'AxeBuilder needs an object to configure. See axe-core configure API.'
Expand Down

0 comments on commit 7999891

Please sign in to comment.