1. stylelint-config-html
The shareable HTML config for Stylelint.
stylelint-config-html
Package: stylelint-config-html
Created by: ota-meshi
Last modified: Thu, 07 Jul 2022 13:08:41 GMT
Version: 1.1.0
License: MIT
Downloads: 1,059,272
Repository: https://github.com/ota-meshi/stylelint-config-html

Install

npm install stylelint-config-html
yarn add stylelint-config-html

stylelint-config-html

NPM license
NPM version
NPM downloads
NPM downloads
Build Status

The shareable HTML (and HTML-like) config for Stylelint.

This config bundles the postcss-html custom syntax and configures it.
If you use this config in your Stylelint config, HTML, XML, Vue, Svelte, Astro, and PHP files will be parsable. The Stylelint rules you have configured will be able to check these files.

Requirements

  • Stylelint v14.0.0 and above
    This config cannot be used with Stylelint v13 and below. Also, if you are using Stylelint v13, you do not need to use this config.

Stylelint v14 and above has been changed to not bundle non-CSS parsing such as HTML. The goal of this config is to make Stylelint v14 work with HTML (and HTML-like) files, like Stylelint v13.

To see this config, please read the config itself.

stylelint-config-recommended-vue / stylelint-config-standard-vue

The shareable config for Vue.
If you want to check Vue files, consider using this as well. It is useful because it contains the config for Vue.

postcss-html

PostCSS syntax for parsing HTML (and HTML-like).
If you have problems with parses using this config, please open the new issue in that repository.

:cd: Installation

 npm install --save-dev postcss-html stylelint-config-html

:book: Usage

Set your stylelint config to:

 {
  "extends": "stylelint-config-html"
}

Note: This config enables HTML (and HTML-like) syntax parsing.

If you want to enable parsing for only specific language, use each language config as follows:

 {
  "extends": [
    "stylelint-config-html/html",
    "stylelint-config-html/xml",
    "stylelint-config-html/vue",
    "stylelint-config-html/svelte",
    "stylelint-config-html/astro",
    "stylelint-config-html/php"
  ]
}

:computer: Editor integrations

Visual Studio Code

Use the stylelint.vscode-stylelint extension that Stylelint provides officially.

You have to configure the stylelint.validate option of the extension to check .html, .vue, .svelte, and HTML-like files, because the extension does not check the *.html and HTML-like file by default.

Example .vscode/settings.json:

{
  "stylelint.validate": [
      ...,
      // ↓ Add "html" language.
      "html",
      // ↓ Add "vue" language.
      "vue",
      // ↓ Add "svelte" language.
      "svelte",
      // ↓ Add "astro" language.
      "astro",
  ]

:lock: License

See the LICENSE file for license rights and limitations (MIT).

RELATED POST

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin