Stylelint Recommended Config for Vue

1.6.1 · active · verified Sun Apr 19

This package provides the recommended shareable Stylelint configuration specifically tailored for Vue.js single-file components. It extends the `stylelint-config-recommended` base configuration and automatically integrates `postcss-html` to enable parsing of `<style>` blocks within `.vue` files. The current stable version is 1.6.1, with releases typically occurring to align with new Stylelint versions, address Vue-specific parsing edge cases, or incorporate updates from its base configurations. Its key differentiator is providing an opinionated, out-of-the-box setup that handles the complexities of linting CSS within Vue SFCs, including support for preprocessors like SCSS when combined with additional configurations.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart sets up Stylelint with `stylelint-config-recommended-vue` for basic Vue SFC linting, including installation and a runnable script.

{
  "name": "my-vue-project",
  "version": "0.1.0",
  "devDependencies": {
    "postcss-html": "^1.0.0",
    "stylelint": "^16.0.0",
    "stylelint-config-recommended-vue": "^1.6.1"
  },
  "scripts": {
    "lint:style": "stylelint \"**/*.{vue,css,scss}\"
  }
}
// package.json

// .stylelintrc.json
{
  "extends": "stylelint-config-recommended-vue"
}

// src/App.vue
<template>
  <div class="container">
    <p>Hello Vue Stylelint!</p>
  </div>
</template>

<script>
export default {
  name: 'App'
};
</script>

<style scoped>
.container {
  color: #333;
  font-size: 16px;
  padding: 10px;
  background-color: #f0f0f0;
}
p {
  margin-bottom: 0;
}
</style>

# To run:
npm install
npm run lint:style

view raw JSON →