🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

jest-runner-stylelint

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jest-runner-stylelint

Stylelint runner for Jest

2.3.7
latest
Source
npm
Version published
Weekly downloads
6.4K
-31.09%
Maintainers
1
Weekly downloads
 
Created
Source

Build Status npm version codecov Mentioned in Awesome Jest

jest-runner-stylelint

Stylelint runner for Jest

Usage

Install

Install jest, jest-runner-stylelint, and stylelint

npm install --save-dev jest jest-runner-stylelint stylelint

# or with yarn

yarn add --dev jest jest-runner-stylelint stylelint

Configure stylelint

You must have stylelint configured before it'll lint any of your files. Please follow the stylelint documentation on configuration to create your config.

Add it to your Jest config

Using Built-in Preset

This package includes a Jest preset which configures Jest to run stylelint on all files supported by styleint. To use it set the following in your package.json:

{
  "jest": {
    "preset": "jest-runner-stylelint"
  }
}

or jest.config.js:

module.exports = {
  preset: "jest-runner-stylelint",
};

Manually

In your package.json

{
  "jest": {
    "runner": "stylelint",
    "moduleFileExtensions": [
      "css",
      "sass",
      "scss",
      "less",
      "sss",
      "htm",
      "html",
      "md",
      "markdown",
      "mdx",
      "js",
      "jsx",
      "ts",
      "tsx",
      "vue"
    ],
    "testMatch": [
      "**/*.css",
      "**/*.sass",
      "**/*.scss",
      "**/*.less",
      "**/*.sss",
      "**/*.htm",
      "**/*.html",
      "**/*.md",
      "**/*.markdown",
      "**/*.mdx",
      "**/*.js",
      "**/*.jsx",
      "**/*.ts",
      "**/*.tsx",
      "**/*.vue"
    ]
  }
}

Or in jest.config.js

module.exports = {
  runner: "stylelint",
  moduleFileExtensions: [
    "css",
    "sass",
    "scss",
    "less",
    "sss",
    "htm",
    "html",
    "md",
    "markdown",
    "mdx",
    "js",
    "jsx",
    "ts",
    "tsx",
    "vue",
  ],
  testMatch: [
    "**/*.css",
    "**/*.sass",
    "**/*.scss",
    "**/*.less",
    "**/*.sss",
    "**/*.htm",
    "**/*.html",
    "**/*.md",
    "**/*.markdown",
    "**/*.mdx",
    "**/*.js",
    "**/*.jsx",
    "**/*.ts",
    "**/*.tsx",
    "**/*.vue",
  ],
};

Run Jest

npx jest

# or with yarn

yarn jest

Toggle --fix in watch mode

jest-stylelint-runner comes with a watch plugin that allows you to toggle the --fix value while in watch mode without having to update your configuration.

To use this watch plugin simply add this to your Jest configuration.

{
  watchPlugins: ['jest-runner-stylelint/watch-fix'],
}

After this run Jest in watch mode and you will see the following line in your watch usage menu.

 › Press F to override Stylelint --fix.

Options

This project uses cosmiconfig, so you can provide config via:

  • a jest-runner-stylelint property in your package.json
  • a jest-runner-stylelint.config.js JS file
  • a .jest-runner-stylelintrc JSON file

In package.json

{
  "jest-runner-stylelint": {
    "cliOptions": {
      // Options here
    }
  }
}

or in jest-runner-stylelint.config.js

module.exports = {
  cliOptions: {
    // Options here
  },
};

cliOptions

Follow the stylelint documentation on configuration to create your cli options.

FAQs

Package last updated on 21 Aug 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts