Wondering what’s next for npm?Check out our public roadmap! »

    stylelint-jest-rule-tester
    TypeScript icon, indicating that this package has built-in type declarations

    2.1.1 • Public • Published

    Stylelint Rule Tester

    This is not an official stylelint package.

    Simple function written in TypeScript to test custom stylelint plugin rules.

    Largely influenced by jest-preset-stylelint/getTestRule.js.

    Usage

    This is from this project's test file.

    import {testRule} from 'stylelint-jest-rule-tester';
    import {visibilityRule} from './visibility.rule';
     
    testRule({
        // replace this name with your rule's name
        ruleName: visibilityRule.ruleName,
        description: 'should work primary option in array',
        ruleOptions: [true],
        // a plugin must be supplied so that stylelint can find the rule you want to test
        linterOptions: {config: {plugins: ['./dist/test/plugins.js']}},
        fix: true,
        accept: [
            {
                code: 'a { color: pink; }',
            },
        ],
        reject: [
            {
                code: 'a { color: pink; visibility: hidden; }',
                fixed: 'a { color: pink; }',
                message: visibilityRule.message,
            },
        ],
    });

    Install

    npm i stylelint-jest-rule-tester

    DownloadsWeekly Downloads

    667

    Version

    2.1.1

    License

    MIT

    Unpacked Size

    9.67 kB

    Total Files

    5

    Last publish

    Collaborators

    • avatar