SimenB / stylint

Improve your Stylus code with Stylint
https://simenb.github.io/stylint/
GNU General Public License v2.0
348 stars 62 forks source link

Vue support? #420

Open owm111 opened 6 years ago

owm111 commented 6 years ago

I was wondering if there is a way to (properly) lint Vue single-file components using Stylint.

Whenever I try to send .vue file through Stylint, it lints the file, but not in the way intended: screenshot from 2017-08-10 15-46-20 ...linting the entire file, not just the <style lang="stylus">...</style> tag (where the stylus is held).

Is there a way to enable or install this feature (similar to ESLint's eslint-plugin-html, which allows similar linting of JS in .html files, and by extension .vue files), or is it not a feature of Stylint?


dre1080 commented 6 years ago

Any updates on this?

thanasisliako commented 6 years ago

After a lot of failure and reading thoroughly vue-loader's docs I found that you can use stylint-loader as a preloader in the vue-loader configuration. So given that the styles in the vue components are inside <style lang="stylus"> add the following in vue-loader's options object:

  preLoaders: {
    stylus: 'stylint-loader'
  }
SimenB commented 6 years ago

PR most certainly welcome for docs illustrating usage with different bundlers and frameworks!

iliyaZelenko commented 5 years ago

I used webpack 4 with stylint 1.5.9 and tried to add this rule in rules:

        {
          enforce: 'pre',
          test: /\.styl(us)?$/,
          loader: 'stylint',
          exclude: /(node_modules)/
        }

image

Perhaps stylint is not compatible with webpack 4.

Badalik commented 5 years ago

Did not solve the problem?

Badalik commented 5 years ago

I wrote a webpack plugin that supports .styl and .vue files

owm111 commented 5 years ago

Honestly, it has been so long since I've opened this issue, I can't remember what my use case was. However, this issue being as old as it is, I am tempted to just make a PR, probably editing the parser, using the same method as @Badalik (it appears to work from reading the code), to finally put this issue to bed.

Since I have time today, I'll give it a whirl.

owm111 commented 5 years ago

Well, I tried, unsuccessfully. Even if it did work, I wouldn't know how to write unit tests for it.