Help us understand the problem. What is going on with this article?

Nuxt.js で .vue ファイルの SCSS に Lint を適用する

概要

.vue ファイル内の style にも Lint を当てるメモ :pencil:

(node-sasssass-loader で既に scss が利用できている状態を想定)

詳細

インスコ

yarn add -D stylelint stylelint-scss stylelint-config-standard stylelint-webpack-plugin

はい :beers:

stylelint-webpack-plugin を適用

nuxt.config.js で webpack の設定を流し込む。

nuxt.config.js
const StylelintPlugin = require('stylelint-webpack-plugin')

module.exports = {

  // 略

  build: {
    /*
    ** Run StyleLint on save
    */
    extend(config, { isDev, isClient }) {
      if (isDev && isClient) {
        config.plugins.push(new StylelintPlugin({
          files: [
            '**/*.vue',
            '**/*.scss',
          ],
        }))
      }
    },
  },
}

stylelint-scss を適用

.stylelintrc.json
{
  "plugins": [
    "stylelint-scss"
  ],
  "extends": "stylelint-config-standard",
  "rules": {
    "scss/dollar-variable-colon-space-after": "always"
  }
}

これで保存のたびにチェックできる。
気持ち良い :innocent:

参照

Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away