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

"Root level" !global flag throws "Please check validity of the block" error #305

Closed
jdsteinbach opened this issue Oct 14, 2015 · 16 comments
Closed

Comments

@jdsteinbach
Copy link

Starting to use sass-lint for the first time & hitting an error.

Here's my system stats
sass-lint: 1.3.0
gulp-sass-lint: 1.0.1
gulp: 3.9.0
npm: 2.11.2
OS X 10.11 El Capitan

Get this error message when I run in it:

/repo_path/node_modules/gulp-sass-lint/node_modules/sass-lint/lib/groot.js:21
    throw new Error('Parsing error' + fileInfo + ': ' + e.message);
          ^
Error: Parsing error at web/wp-content/themes/nursingorg-theme/assets/src/scss/_settings.scss: Please check validity of the block starting from line #108
    at module.exports (/repo_path/node_modules/gulp-sass-lint/node_modules/sass-lint/lib/groot.js:21:11)
    at Function.sassLint.lintText (/repo_path/node_modules/gulp-sass-lint/node_modules/sass-lint/index.js:36:13)
    at DestroyableTransform._transform (/repo_path/node_modules/gulp-sass-lint/index.js:32:27)
    at DestroyableTransform.Transform._read (/repo_path/node_modules/gulp-sass-lint/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:172:10)
    at DestroyableTransform.Transform._write (/repo_path/node_modules/gulp-sass-lint/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:160:12)
    at doWrite (/repo_path/node_modules/gulp-sass-lint/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:326:12)
    at writeOrBuffer (/repo_path/node_modules/gulp-sass-lint/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:312:5)
    at DestroyableTransform.Writable.write (/repo_path/node_modules/gulp-sass-lint/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:239:11)
    at write (/repo_path/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:623:24)

Here's the Sass source in that block starting from line #108 in _settings.scss:

$lap:   new-breakpoint(min-width $lap-start $lap-cols)!global;

And here's my Gulp task running this process:

var sassLint = require('gulp-sass-lint');

gulp.task('lint:sass', function() {
  gulp.src(_src_dir + '/scss/**/*.scss')
    .pipe( $.sassLint() )
    .pipe( $.sassLint.format() )
    .pipe( $.sassLint.failOnError() );
});

Finally, here's sass-lint.yml in case that's helpful:

#########################
## Sample Sass Lint File
#########################
# Linter Options
options:
  # Don't merge default rules
  merge-default-rules: false
  # Set the formatter to 'html'
  formatter: html
  # Output file instead of logging results
  # output-file: 'linters/sass-lint.html'
# File Options
files:
  include: 'web/wp-contents/themes/*/src/scss/**/*.s+(a|c)ss'
  ignore:
    - ''
# Rule Configuration
rules:
  extends-before-mixins: 2
  extends-before-declarations: 2
  placeholders-in-extend: 2
  mixins-before-declarations:
    - 2
    -
      exclude:
        - breakpoint
        - mq

  no-warn: 1
  no-debug: 1
  no-ids: 2
  no-important: 2
  hex-notation:
    - 2
    -
      style: uppercase
  indentation:
    - 2
    -
      size: 2
  variable-for-property:
    - 2
    -
      properties:
        - margin
        - content

After I removed all the !global flags, sass-lint worked wonderfully. Which makes sense: that part of _settings.scss is using !global the wrong way. Those vars are already global since they're not in a block. Someone probably meant !default. If it's possible, I'd prefer sass-lint tell us we're using it wrongly, not error out.

@DanPurdy DanPurdy added the bug label Oct 14, 2015
@DanPurdy
Copy link
Member

Looking at the error this may be a problem with the AST we use to parse, there's an upcoming release scheduled that should fix a few of the problems but I'll look into it to make sure.

Error codes and a slightly more graceful way of handling errors is definitely on the cards for 1.4.0 at the moment.

@bgriffith
Copy link
Member

Can confirm that it's an issue with the AST #56

Can also confirm that it's fixed in the latest beta, so once we implement v3 of gonazles-pe global flags will be support

@jgerigmeyer
Copy link

Similar issue with !optional.

@bgriffith
Copy link
Member

Yep, can confirm and recent beta of gonzales-pe has support for !optional too!

@strarsis
Copy link

strarsis commented Nov 8, 2015

Same issue here.

@nirazul
Copy link

nirazul commented Nov 10, 2015

started to use sass-lint and also ran into this error.
unfortunately, this prevents me from further integrating/testing it.

sass-lint: 1.3.2
gulp-sass-lint: 1.0.1

@DanPurdy
Copy link
Member

Hi @nirazul I'm afraid we're still just waiting for our AST to update a little bit more and then we'll be getting support for this out and about.

@nirazul
Copy link

nirazul commented Nov 16, 2015

sounds great, i'm looking forward to using it :)

@JohnAlbin
Copy link

@DanPurdy Can you point at the issue in sass-lint queue where "updating gonzales-pe AST" is being worked on? I'd like to track that issue directly rather than this and the many other bugs that are caused by the current, buggy version of the AST. I searched the queue but couldn't find an issue.

@DanPurdy
Copy link
Member

@JohnAlbin there isn't one issue I'm afraid, we don't maintain Gonzales ourselves and it's not clear at the moment when we'll see any further progress with it. We've been running all of our tests and every issue that's been raised directly against the new builds of gonzales whenever there's a release but unfortunately it's just not stable enough for us to make the move at the moment.

@JohnAlbin
Copy link

Thanks for the info, @DanPurdy!

@matkovsky
Copy link

I have a few lines with calculations and variables in my SCSS file, and those throw this error as well.

background-position: calc(50% + #{$grid-gutter-width / 2}) top;

@jdsteinbach
Copy link
Author

@matkovsky This is a "bad" solution for now, but I've found that using unquote("calc(100% - #{$x / 2})") produces the same output w/o errors. That said, I feel pretty conflicted about writing that kind of confusing/unnecessary Sass in order to get around a (hopefully temporary!) Gonzales AST bug.

@ngryman
Copy link
Contributor

ngryman commented Feb 16, 2016

Hi guys,

Any news on this? Not being able to use !global is a blocker for me 😭 .

@DanPurdy
Copy link
Member

Very shortly once #495 is complete

@bgriffith
Copy link
Member

This has been fixed in 1.6, as well as !optional flag.

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

No branches or pull requests

9 participants