Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

csstools/stylelint-tape

stylelint-tape stylelint

NPM Version Build Status Support Chat

stylelint-tape lets you test stylelint plugins.

Usage

Add stylelint-tape to your project:

npm install stylelint-tape --save-dev

Add a .tape.js file with tests:

module.exports = {
 'your/rule': [
 // test the # of warnings
 {
 source: 'body { top: 0 }',
 warnings: 1
 },
 // test for specific warnings
 {
 source: 'body { top: 0; left: 0 }',
 warnings: [
 'Unexpected "top" property.',
 'Unexpected "left" property.'
 ]
 },
 // test with arguments
 {
 source: 'body { top: 0 }',
 args: "always",
 warnings: 1
 },
 {
 source: 'body { top: 0 }',
 args: [ "always", { except: "top" } ]
 },
 // test autofixes
 {
 source: 'body { top: 0 }',
 expect: 'body { inset-block-start: 0 }'
 }
 ]
}

Use stylelint-tape in package.json to test your plugin:

{
 "scripts": {
 "test:plugin": "stylelint-tape"
 }
}
npm run test:plugin

Or, use it within Node.

const stylelintTape = require('stylelint-tape');
const plugin = require('path/to/plugin');
stylelintTape({ plugin: 'path/to/plugin.js' }, {
 'your/rule': [
 {
 source: 'body { top: 0 }',
 warnings: 1
 }
 ]
}).then(
 () => console.log('tests passed'),
 error => console.error('tests failed', error)
);

About

Test stylelint plugins

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

AltStyle によって変換されたページ (->オリジナル) /