パッケージの詳細

stylelint-tape

csstools213CC0-1.05.0.1

Test stylelint plugins

postcss, css, postcss-plugin, test

readme

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)
);

更新履歴

Changes to stylelint-tape

5.0.1 (March 6, 2024)

  • Remove exports field from package.json

5.0.0 (March 3, 2024)

  • Pure ESM

4.0.0 (March 3, 2024)

  • Exit 1 when tests fail (major) #2

3.0.0 (June 22, 2022)

  • Updated: log-update to 4 (major)

2.0.0 (May 24, 2019)

  • Updated: log-update to 3.2.0 (major)
  • Updated: peer stylelint to 10 (major)
  • Updated: Node 8+ compatibility (major)

1.0.2 (February 27, 2019)

  • Fixed an issue where warnings could not evaluate strings or key-value pairs.

1.0.1 (September 29, 2018)

  • Fixed an issue where warnings were ignored if no warnings were encountered.

1.0.0 (September 29, 2018)

  • Initial version