Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Globs not working...? #67

Closed
reintroducing opened this issue Dec 19, 2016 · 8 comments
Closed

Globs not working...? #67

reintroducing opened this issue Dec 19, 2016 · 8 comments

Comments

@reintroducing
Copy link

Hi, thank you for this plugin. I'm trying to run it in my project and the following works for a single file:

return gulp.src('./frontend/src/sass/components/_Alert.scss')
    .pipe(stylelint({
        syntax: 'scss',
        debug: true,
        reporters: [{
            formatter: 'string',
            console: true
        }]
    }));

I have an error in _Alert.scss that outputs properly.

However, if I try to run it on a glob of all the Sass files in that directory, as this, I get no errors and it seems as though it's passed properly when it shouldnt because of the error in _Alert.scss.

return gulp.src('./frontend/src/sass/components/*.scss')
    .pipe(stylelint({
        syntax: 'scss',
        debug: true,
        reporters: [{
            formatter: 'string',
            console: true
        }]
    }));

Am I missing something stupid here?

Thanks in advance.

@olegskl
Copy link
Owner

olegskl commented Dec 19, 2016

Hello. This is weird, I've just run a test and it seems to be working fine.

@reintroducing
Copy link
Author

Hmm, I can definitely confirm it's not running. Is there anything I can do to help troubleshoot? Would love to get this working. When I use stylelint directly through the CLI it works as expected on that path with the glob.

@olegskl
Copy link
Owner

olegskl commented Dec 19, 2016

Can you provide a small example which reproduces the issue? I have a test repository with several scss files and it's working fine. Actually, I have never tried running gulp without globs...

@reintroducing
Copy link
Author

Awesome, I am finishing my work day but will look at this tomorrow afternoon when I'm back in the office (have a doctor's appointment in the AM). I'll try my code in the test repo and see if it works. I suppose its worth nothing I'm using Gulp 3.9.1 rather than 4 but we'll see if that makes any difference.

@olegskl
Copy link
Owner

olegskl commented Dec 19, 2016

This should work the same in Gulp 3.x and 4.x (just tested).

Take care :)

@reintroducing
Copy link
Author

reintroducing commented Dec 19, 2016

Good to know. Of note as well is I just ran stylelint CLI on frontend/src/sass/**/*.scss and I'm getting this:

./node_modules/.bin/stylelint "frontend/src/sass/**/*.scss"
TypeError: Cannot read property 'isCalculationEnabled' of undefined
    at findOperators (/Users/mprzybylski/Work/SpotHero/SpotHero-Django/node_modules/stylelint-scss/dist/utils/sassValueParser/index.js:79:36)
    at /Users/mprzybylski/Work/SpotHero/SpotHero-Django/node_modules/stylelint-scss/dist/rules/operator-no-unspaced/index.js:192:47
    at /Users/mprzybylski/Work/SpotHero/SpotHero-Django/node_modules/stylelint/node_modules/postcss/lib/container.js:148:26
    at AtRule.each (/Users/mprzybylski/Work/SpotHero/SpotHero-Django/node_modules/stylelint/node_modules/postcss/lib/container.js:114:22)
    at AtRule.walk (/Users/mprzybylski/Work/SpotHero/SpotHero-Django/node_modules/stylelint/node_modules/postcss/lib/container.js:147:21)
    at /Users/mprzybylski/Work/SpotHero/SpotHero-Django/node_modules/stylelint/node_modules/postcss/lib/container.js:150:32
    at AtRule.each (/Users/mprzybylski/Work/SpotHero/SpotHero-Django/node_modules/stylelint/node_modules/postcss/lib/container.js:114:22)
    at AtRule.walk (/Users/mprzybylski/Work/SpotHero/SpotHero-Django/node_modules/stylelint/node_modules/postcss/lib/container.js:147:21)
    at /Users/mprzybylski/Work/SpotHero/SpotHero-Django/node_modules/stylelint/node_modules/postcss/lib/container.js:150:32
    at AtRule.each (/Users/mprzybylski/Work/SpotHero/SpotHero-Django/node_modules/stylelint/node_modules/postcss/lib/container.js:114:22)

Although this worked fine by just running a directory deeper:

./node_modules/.bin/stylelint "frontend/src/sass/components/*.scss"

I just tried the first one because I have more sass directories inside of sass/ than just components and I'm trying to pinpoint where a problem may be with the CLI.

@olegskl
Copy link
Owner

olegskl commented Dec 20, 2016

I haven't used stylelint-scss before, so I'm not sure about the origin of the issue there.

As for the issue with gulp-stylelint, if you can create a small repository (you can just fork gulp-stylelint-test) I will definitely take a look.

@reintroducing
Copy link
Author

reintroducing commented Dec 20, 2016

Alright, I just took some time to play with the test repo. Here are my findings:

  • On initial run as I just followed the instructions, I had 501 errors, not 0 like the repo says. They were formedia-feature-name-no-unknown. Not sure why that happened.
  • The plugin will not exclude globs that look like this (which was working correctly for me when I was using scss-lint): !./frontend/src/sass/vendor/* I'm not a globbing expert so I can't tell you which is correct but all I know is the prior plugin we used did exclude that. I had to convert it to this: !./frontend/src/sass/vendor/**/*.scss
  • And finally, here was my issue. Given the following lint method:
const sassLint = src => {
    return gulp.src(src)
        .pipe(stylelint({
            syntax: 'scss',
            reporters: [{
                formatter: 'string',
                console: true
            }],
            failAfterError: false
        }));
};

This was my actual task(s):

gulp.task('lint:sass:spothero', () => {
    sassLint([
        `${config.spothero.sass}/**/*.scss`,
        `${config.frontend.sass}/**/*.scss`,
        `!${config.spothero.sass}/desktop/jobs/_greenhouse.scss`,
        `!${config.spothero.sass}/utils/sprites/**/*.scss`,
        `!${config.frontend.sass}/vendor/**/*.scss`,
        `!${config.frontend.sass}/common/_icomoon.scss`,
        `!${config.frontend.sass}/utils/**/*.scss`
    ]);
});

Notice that the task itself does not return sassLint, it just runs it. With the prior linter that worked fine. By just adding a return to the front, it now works as expected. Extremely stupid, just like i said when I originally posted the issue :)

Thanks for all your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants