Skip to content

Commit

Permalink
Consistent type imports and exports in AGTree
Browse files Browse the repository at this point in the history
Merge in ADGUARD-FILTERS/tsurlfilter from fix/agtree-type-imports to master

Squashed commit of the following:

commit 146385b
Merge: 62a3415 fd3ec59
Author: scripthunter7 <[email protected]>
Date:   Thu Aug 10 09:31:51 2023 +0200

    Merge branch 'master' into fix/agtree-type-imports

commit 62a3415
Author: scripthunter7 <[email protected]>
Date:   Wed Aug 9 12:25:29 2023 +0200

    Fix linter errors

commit 755feac
Author: scripthunter7 <[email protected]>
Date:   Wed Aug 9 12:24:53 2023 +0200

    Update ESLint config
  • Loading branch information
scripthunter7 committed Aug 10, 2023
1 parent fd3ec59 commit 02e795e
Show file tree
Hide file tree
Showing 54 changed files with 138 additions and 124 deletions.
13 changes: 13 additions & 0 deletions packages/agtree/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,18 @@ module.exports = {
],
'arrow-body-style': 'off',
'no-await-in-loop': 'off',
// Force proper import and export of types
'@typescript-eslint/consistent-type-imports': [
'error',
{
fixStyle: 'inline-type-imports',
},
],
'@typescript-eslint/consistent-type-exports': [
'error',
{
fixMixedExportsWithInlineTypeSpecifier: true,
},
],
},
};
2 changes: 1 addition & 1 deletion packages/agtree/src/ast-utils/modifiers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import cloneDeep from 'clone-deep';

import { Modifier, ModifierList } from '../parser/common';
import { type Modifier, type ModifierList } from '../parser/common';
import { isUndefined } from '../utils/common';

/**
Expand Down
4 changes: 2 additions & 2 deletions packages/agtree/src/ast-utils/scriptlets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

import cloneDeep from 'clone-deep';

import { ParameterList } from '../parser/common';
import { QuoteType, setStringQuoteType } from '../utils/quotes';
import { type ParameterList } from '../parser/common';
import { type QuoteType, setStringQuoteType } from '../utils/quotes';

/**
* Get name of the scriptlet from the scriptlet node
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/* eslint-disable @typescript-eslint/no-unused-vars */

import { NotImplementedError } from '../../errors/not-implemented-error';
import { Node } from '../../parser/common';
import { type Node } from '../../parser/common';
import { ConverterBase } from './converter-base';

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/agtree/src/converter/comment/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import cloneDeep from 'clone-deep';

import { AnyCommentRule, CommentMarker, CommentRuleType } from '../../parser/common';
import { type AnyCommentRule, CommentMarker, CommentRuleType } from '../../parser/common';
import { SPACE } from '../../utils/constants';
import { RuleConverterBase } from '../base-interfaces/rule-converter-base';

Expand Down
4 changes: 2 additions & 2 deletions packages/agtree/src/converter/cosmetic/css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
*/

import cloneDeep from 'clone-deep';
import { SelectorList, fromPlainObject } from '@adguard/ecss-tree';
import { type SelectorList, fromPlainObject } from '@adguard/ecss-tree';

import { CosmeticRuleSeparator, CssInjectionRule } from '../../parser/common';
import { CosmeticRuleSeparator, type CssInjectionRule } from '../../parser/common';
import { RuleConverterBase } from '../base-interfaces/rule-converter-base';
import { CssSelectorConverter } from '../css';
import { AdblockSyntax } from '../../utils/adblockers';
Expand Down
4 changes: 2 additions & 2 deletions packages/agtree/src/converter/cosmetic/element-hiding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
*/

import cloneDeep from 'clone-deep';
import { SelectorList, fromPlainObject } from '@adguard/ecss-tree';
import { type SelectorList, fromPlainObject } from '@adguard/ecss-tree';

import { CosmeticRuleSeparator, ElementHidingRule } from '../../parser/common';
import { CosmeticRuleSeparator, type ElementHidingRule } from '../../parser/common';
import { CssTree } from '../../utils/csstree';
import { RuleConverterBase } from '../base-interfaces/rule-converter-base';
import { CssSelectorConverter } from '../css';
Expand Down
4 changes: 2 additions & 2 deletions packages/agtree/src/converter/cosmetic/html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
* @file HTML filtering rule converter
*/

import { SelectorPlain } from '@adguard/ecss-tree';
import { type SelectorPlain } from '@adguard/ecss-tree';
import cloneDeep from 'clone-deep';

import {
CosmeticRuleSeparator,
CosmeticRuleType,
HtmlFilteringRule,
type HtmlFilteringRule,
RuleCategory,
} from '../../parser/common';
import { AdblockSyntax } from '../../utils/adblockers';
Expand Down
4 changes: 2 additions & 2 deletions packages/agtree/src/converter/cosmetic/rule-modifiers/adg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
* @file Cosmetic rule modifier converter from uBO to ADG
*/

import { ModifierList } from '../../../parser/common';
import { type ModifierList } from '../../../parser/common';
import { RuleConversionError } from '../../../errors/rule-conversion-error';
import { ConverterFunction } from '../../base-interfaces/converter-function';
import { type ConverterFunction } from '../../base-interfaces/converter-function';
import { createModifierListNode, createModifierNode } from '../../../ast-utils/modifiers';
import { RegExpUtils } from '../../../utils/regexp';
import {
Expand Down
2 changes: 1 addition & 1 deletion packages/agtree/src/converter/cosmetic/scriptlet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import cloneDeep from 'clone-deep';

import { CosmeticRuleSeparator, ParameterList, ScriptletInjectionRule } from '../../parser/common';
import { CosmeticRuleSeparator, type ParameterList, type ScriptletInjectionRule } from '../../parser/common';
import { RuleConverterBase } from '../base-interfaces/rule-converter-base';
import { AdgScriptletConverter } from './scriptlets/adg';
import { AdblockSyntax } from '../../utils/adblockers';
Expand Down
4 changes: 2 additions & 2 deletions packages/agtree/src/converter/cosmetic/scriptlets/adg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import cloneDeep from 'clone-deep';

import { QuoteType, setStringQuoteType } from '../../../utils/quotes';
import { getScriptletName, setScriptletName, setScriptletQuoteType } from '../../../ast-utils/scriptlets';
import { ParameterList } from '../../../parser/common';
import { ConverterFunction } from '../../base-interfaces/converter-function';
import { type ParameterList } from '../../../parser/common';
import { type ConverterFunction } from '../../base-interfaces/converter-function';

const ABP_SCRIPTLET_PREFIX = 'abp-';
const UBO_SCRIPTLET_PREFIX = 'ubo-';
Expand Down
6 changes: 3 additions & 3 deletions packages/agtree/src/converter/css/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {
CssNode,
type CssNode,
List,
PseudoClassSelector,
SelectorList,
type PseudoClassSelector,
type SelectorList,
walk,
} from '@adguard/ecss-tree';
import cloneDeep from 'clone-deep';
Expand Down
2 changes: 1 addition & 1 deletion packages/agtree/src/converter/filter-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import { RuleConverter } from '.';
import { createFilterListNode } from '../ast-utils/filter-list';
import { FilterList } from '../parser/common';
import { type FilterList } from '../parser/common';
import { ConverterBase } from './base-interfaces/converter-base';

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/agtree/src/converter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import cloneDeep from 'clone-deep';

import { AnyRule, RuleCategory } from '../parser/common';
import { type AnyRule, RuleCategory } from '../parser/common';
import { CommentRuleConverter } from './comment';
import { CosmeticRuleConverter } from './cosmetic';
import { NetworkRuleConverter } from './network';
Expand Down
2 changes: 1 addition & 1 deletion packages/agtree/src/converter/network/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import cloneDeep from 'clone-deep';

import { NetworkRule } from '../../parser/common';
import { type NetworkRule } from '../../parser/common';
import { NetworkRuleModifierListConverter } from '../misc/network-rule-modifier';
import { RuleConverterBase } from '../base-interfaces/rule-converter-base';

Expand Down
2 changes: 1 addition & 1 deletion packages/agtree/src/errors/adblock-syntax-error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @file Customized syntax error class for Adblock Filter Parser.
*/

import { LocationRange } from '../parser/common';
import { type LocationRange } from '../parser/common';

const ERROR_NAME = 'AdblockSyntaxError';

Expand Down
6 changes: 3 additions & 3 deletions packages/agtree/src/parser/comment/agent-rule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import {
} from '../../utils/constants';
import { StringUtils } from '../../utils/string';
import {
AgentCommentRule,
Location,
type AgentCommentRule,
type Location,
defaultLocation,
CommentRuleType,
RuleCategory,
Agent,
type Agent,
} from '../common';
import { AgentParser } from './agent';
import { AdblockSyntaxError } from '../../errors/adblock-syntax-error';
Expand Down
6 changes: 3 additions & 3 deletions packages/agtree/src/parser/comment/hint-rule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import {
import { StringUtils } from '../../utils/string';
import {
CommentRuleType,
Hint,
HintCommentRule,
Location,
type Hint,
type HintCommentRule,
type Location,
RuleCategory,
defaultLocation,
} from '../common';
Expand Down
6 changes: 3 additions & 3 deletions packages/agtree/src/parser/comment/hint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import {
} from '../../utils/constants';
import { StringUtils } from '../../utils/string';
import {
Hint,
Location,
Value,
type Hint,
type Location,
type Value,
defaultLocation,
} from '../common';
import { AdblockSyntaxError } from '../../errors/adblock-syntax-error';
Expand Down
6 changes: 3 additions & 3 deletions packages/agtree/src/parser/comment/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { AdblockSyntax } from '../../utils/adblockers';
import { AgentCommentRuleParser } from './agent-rule';
import {
AnyCommentRule,
type AnyCommentRule,
CommentMarker,
CommentRuleType,
Location,
type Location,
RuleCategory,
Value,
type Value,
defaultLocation,
} from '../common';
import { ConfigCommentRuleParser } from './inline-config';
Expand Down
8 changes: 4 additions & 4 deletions packages/agtree/src/parser/comment/inline-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ import {
import {
CommentMarker,
CommentRuleType,
ConfigCommentRule,
Location,
ParameterList,
type ConfigCommentRule,
type Location,
type ParameterList,
RuleCategory,
Value,
type Value,
defaultLocation,
} from '../common';
import { StringUtils } from '../../utils/string';
Expand Down
6 changes: 3 additions & 3 deletions packages/agtree/src/parser/comment/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import { COLON, EMPTY, SPACE } from '../../utils/constants';
import {
CommentMarker,
CommentRuleType,
Location,
MetadataCommentRule,
type Location,
type MetadataCommentRule,
RuleCategory,
Value,
type Value,
defaultLocation,
} from '../common';
import { locRange } from '../../utils/location';
Expand Down
6 changes: 2 additions & 4 deletions packages/agtree/src/parser/comment/preprocessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,13 @@ import {
SPACE,
} from '../../utils/constants';
import { StringUtils } from '../../utils/string';
import {
import type {
AnyExpressionNode,
CommentRuleType,
Location,
PreProcessorCommentRule,
RuleCategory,
Value,
defaultLocation,
} from '../common';
import { CommentRuleType, RuleCategory, defaultLocation } from '../common';
import { LogicalExpressionParser } from '../misc/logical-expression';
import { AdblockSyntaxError } from '../../errors/adblock-syntax-error';
import { ParameterListParser } from '../misc/parameter-list';
Expand Down
12 changes: 6 additions & 6 deletions packages/agtree/src/parser/common.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import {
DeclarationListPlain,
FunctionNodePlain,
MediaQueryListPlain,
SelectorListPlain,
type DeclarationListPlain,
type FunctionNodePlain,
type MediaQueryListPlain,
type SelectorListPlain,
} from '@adguard/ecss-tree';

import { AdblockSyntax } from '../utils/adblockers';
import { CLASSIC_DOMAIN_SEPARATOR, MODIFIER_DOMAIN_SEPARATOR } from '../utils/constants';
import { type AdblockSyntax } from '../utils/adblockers';
import { type CLASSIC_DOMAIN_SEPARATOR, type MODIFIER_DOMAIN_SEPARATOR } from '../utils/constants';

/**
* Represents possible logical expression operators.
Expand Down
22 changes: 11 additions & 11 deletions packages/agtree/src/parser/cosmetic/body/css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
*/

import {
CssNode,
DeclarationList,
DeclarationListPlain,
DeclarationPlain,
type CssNode,
type DeclarationList,
type DeclarationListPlain,
type DeclarationPlain,
List,
MediaQueryList,
MediaQueryListPlain,
Rule,
Selector,
SelectorList,
SelectorListPlain,
type MediaQueryList,
type MediaQueryListPlain,
type Rule,
type Selector,
type SelectorList,
type SelectorListPlain,
fromPlainObject,
toPlainObject,
walk,
Expand All @@ -22,7 +22,7 @@ import {
import { AdblockSyntax } from '../../../utils/adblockers';
import { CssTree } from '../../../utils/csstree';
import { CssTreeNodeType, CssTreeParserContext } from '../../../utils/csstree-constants';
import { CssInjectionRuleBody, defaultLocation } from '../../common';
import { type CssInjectionRuleBody, defaultLocation } from '../../common';
import { AdblockSyntaxError } from '../../../errors/adblock-syntax-error';
import { locRange, shiftLoc } from '../../../utils/location';
import {
Expand Down
4 changes: 2 additions & 2 deletions packages/agtree/src/parser/cosmetic/body/elementhiding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
* @file Element hiding rule body parser
*/

import { fromPlainObject, SelectorList, SelectorListPlain } from '@adguard/ecss-tree';
import { fromPlainObject, type SelectorList, type SelectorListPlain } from '@adguard/ecss-tree';

import { CssTree } from '../../../utils/csstree';
import { CssTreeParserContext } from '../../../utils/csstree-constants';
import { defaultLocation, ElementHidingRuleBody } from '../../common';
import { defaultLocation, type ElementHidingRuleBody } from '../../common';
import { locRange } from '../../../utils/location';

/**
Expand Down
8 changes: 4 additions & 4 deletions packages/agtree/src/parser/cosmetic/body/html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@

import {
fromPlainObject,
FunctionNodePlain,
type FunctionNodePlain,
generate,
SelectorList,
SelectorListPlain,
type SelectorList,
type SelectorListPlain,
} from '@adguard/ecss-tree';

import { AdblockSyntax } from '../../../utils/adblockers';
import { EMPTY, ESCAPE_CHARACTER } from '../../../utils/constants';
import { CssTree } from '../../../utils/csstree';
import { CssTreeParserContext } from '../../../utils/csstree-constants';
import { DOUBLE_QUOTE_MARKER } from '../../../utils/string';
import { defaultLocation, HtmlFilteringRuleBody } from '../../common';
import { defaultLocation, type HtmlFilteringRuleBody } from '../../common';
import { locRange } from '../../../utils/location';
import { AdblockSyntaxError } from '../../../errors/adblock-syntax-error';

Expand Down
2 changes: 1 addition & 1 deletion packages/agtree/src/parser/cosmetic/body/scriptlet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { locRange, shiftLoc } from '../../../utils/location';
import { StringUtils } from '../../../utils/string';
import { AdblockSyntaxError } from '../../../errors/adblock-syntax-error';
import { ParameterListParser } from '../../misc/parameter-list';
import { ScriptletInjectionRuleBody, defaultLocation } from '../../common';
import { type ScriptletInjectionRuleBody, defaultLocation } from '../../common';

/**
* `ScriptletBodyParser` is responsible for parsing the body of a scriptlet rule.
Expand Down
Loading

0 comments on commit 02e795e

Please sign in to comment.