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 9cca7c4 commit 8c8ad15
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 59 deletions.
37 changes: 0 additions & 37 deletions types/stylelint/index.d.ts
Expand Up @@ -128,40 +128,3 @@ export type Plugin = (
) => (root: postcss.Root, result: postcss.Result) => void | PromiseLike<void>;

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;
27 changes: 5 additions & 22 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 @@ -80,17 +77,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 8c8ad15

Please sign in to comment.