Skip to content

Commit

Permalink
fix(stylelint) removing createRuleTester from exports
Browse files Browse the repository at this point in the history
This export has been removed in version 12 of stylelint.
stylelint/stylelint#4385
https://github.com/stylelint/stylelint/releases/tag/12.0.0
  • Loading branch information
lucavb committed Oct 14, 2021
1 parent dd6776a commit b8ee40e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 64 deletions.
37 changes: 0 additions & 37 deletions types/stylelint/index.d.ts
Expand Up @@ -139,40 +139,3 @@ export function createPlugin(
ruleName: string,
plugin: Plugin
): any;

export interface RuleTesterResult {
expected: number;
actual: number;
description: string;
}

export interface RuleTesterTest {
code: string;
description?: string | undefined;
}

export interface RuleTesterTestRejected extends RuleTesterTest {
line?: number | undefined;
column?: number | undefined;
only?: boolean | undefined;
message?: string | undefined;
}

export interface RuleTesterSchema {
ruleName: string;
syntax?: SyntaxType | undefined;
config?: any;
accept?: RuleTesterTest[] | undefined;
reject?: RuleTesterTestRejected[] | undefined;
}

export interface RuleTesterContext {
comparisonCount: number;
completeAssertionDescription: string;
caseDescription: string;
only?: boolean | undefined;
}

export function createRuleTester(
fn: (result: Promise<RuleTesterResult[]>, context: RuleTesterContext) => void
): (rule: Plugin, schema: RuleTesterSchema) => void;
32 changes: 5 additions & 27 deletions types/stylelint/stylelint-tests.ts
@@ -1,16 +1,13 @@
import {
LinterOptions,
createPlugin,
FormatterType,
SyntaxType,
lint,
LintResult,
LinterOptions,
LinterResult,
createPlugin,
utils,
createRuleTester,
RuleTesterContext,
RuleTesterResult,
LintResult,
Plugin,
SyntaxType,
utils,
Warning,
} from 'stylelint';

Expand Down Expand Up @@ -77,22 +74,3 @@ const testPlugin: Plugin = (options) => {
};

createPlugin(ruleName, testPlugin);

const tester = createRuleTester(
(result: Promise<RuleTesterResult[]>, context: RuleTesterContext) => {
return;
}
);

tester(testPlugin, {
ruleName: 'foo',
config: [true, 1],
accept: [
{ code: 'test' },
{ code: 'test2', description: 'testing' }
],
reject: [
{ code: 'testreject', line: 1, column: 1 },
{ code: 'test2reject', message: 'x', line: 1, column: 1 }
]
});

0 comments on commit b8ee40e

Please sign in to comment.