Skip to content

Commit

Permalink
AG-23891 export modifierValidator instance instead of the class
Browse files Browse the repository at this point in the history
Squashed commit of the following:

commit 6decb64
Author: Slava Leleka <[email protected]>
Date:   Mon Jul 31 16:10:07 2023 +0300

    export modifierValidator instance instead of the class
  • Loading branch information
slavaleleka committed Jul 31, 2023
1 parent 5c9457a commit 7de315b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 19 deletions.
2 changes: 1 addition & 1 deletion packages/agtree/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export { ParameterListParser } from './parser/misc/parameter-list';
export { PreProcessorCommentRuleParser } from './parser/comment/preprocessor';

// Validator
export { ModifierValidator } from './validator';
export { modifierValidator } from './validator';

// Converter
export { HtmlRuleConverter } from './converter/html';
Expand Down
4 changes: 3 additions & 1 deletion packages/agtree/src/validator/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ const getBlockerDocumentationLink = (
/**
* Modifier validator class.
*/
export class ModifierValidator {
class ModifierValidator {
/**
* Map of all modifiers data parsed from yaml files.
*/
Expand Down Expand Up @@ -312,3 +312,5 @@ export class ModifierValidator {
return getBlockerDocumentationLink(this.modifiersData, BLOCKER_PREFIX[AdblockSyntax.Abp], modifier);
};
}

export const modifierValidator = new ModifierValidator();
18 changes: 1 addition & 17 deletions packages/agtree/test/validator/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Modifier } from '../../src/parser/common';
import { ModifierParser } from '../../src/parser/misc/modifier';
import { ModifierValidator } from '../../src/validator';
import { modifierValidator } from '../../src/validator';
import { StringUtils } from '../../src/utils/string';
import { INVALID_ERROR_PREFIX } from '../../src/validator/constants';
import { AdblockSyntax } from '../../src/utils/adblockers';
Expand Down Expand Up @@ -33,8 +33,6 @@ const getModifier = (rawModifier: string | Modifier): Modifier => {
describe('ModifierValidator', () => {
describe('exists', () => {
describe('modifier as string type', () => {
const modifierValidator = new ModifierValidator();

const existentModifiers = [
'app',
'badfilter',
Expand Down Expand Up @@ -123,8 +121,6 @@ describe('ModifierValidator', () => {
});

describe('modifier as Modifier type', () => {
const modifierValidator = new ModifierValidator();

// 'loc' properties is skipped as not required for this test
const supportedModifiers = [
// app=com.test.app
Expand Down Expand Up @@ -171,8 +167,6 @@ describe('ModifierValidator', () => {
});

describe('validate for AdGuard', () => {
const modifierValidator = new ModifierValidator();

describe('fully supported', () => {
const supportedModifiers = [
'all',
Expand Down Expand Up @@ -327,8 +321,6 @@ describe('ModifierValidator', () => {
});

describe('validate for UblockOrigin', () => {
const modifierValidator = new ModifierValidator();

describe('supported', () => {
const supportedModifiers = [
'all',
Expand Down Expand Up @@ -458,8 +450,6 @@ describe('ModifierValidator', () => {
});

describe('validate for AdblockPlus', () => {
const modifierValidator = new ModifierValidator();

describe('supported', () => {
const supportedModifiers = [
'domain=example.com',
Expand Down Expand Up @@ -554,8 +544,6 @@ describe('ModifierValidator', () => {
});

describe('getAdgDocumentationLink', () => {
const modifierValidator = new ModifierValidator();

describe('has docs', () => {
const modifiers = [
'denyallow',
Expand Down Expand Up @@ -591,8 +579,6 @@ describe('ModifierValidator', () => {
});

describe('getUboDocumentationLink', () => {
const modifierValidator = new ModifierValidator();

describe('has docs', () => {
const modifiers = [
'cname',
Expand Down Expand Up @@ -628,8 +614,6 @@ describe('ModifierValidator', () => {
});

describe('getAbpDocumentationLink', () => {
const modifierValidator = new ModifierValidator();

describe('has docs', () => {
const modifiers = [
'domain=example.com',
Expand Down

0 comments on commit 7de315b

Please sign in to comment.