sass-lint: Error in terminal following what seems to be a successful linting operation

I run my sass-lint command and get a list of errors but at the end get an error, details below.

What version of Sass Lint are you using? 1.10.2

Please include any relevant parts of your configuration sass-lint.yml

# Linter Options
options:
  # Don't merge default rules
  merge-default-rules: false
  max-warnings: 0
# File Options
files:
  include: 'stye/scss/**/*.s+(a|c)ss'
  ignore:
    - 'style/scss/variables.scss'
    - 'node_modules/**/*'
# Rule Configuration
rules:
  class-name-format:
    - 2
    -
      allow-leading-underscore: false
      convention: hyphenatedlowercase
  shorthand-values: 2
  extends-before-mixins: 2
  extends-before-declarations: 2
  empty-line-between-blocks:
    - 2
    -
      include: true
      allow-single-line-rulesets: false
  force-pseudo-nesting: 0
  hex-notation:
    - 2
    -
      style: lowercase
  leading-zero:
    - 2
    -
      include: true
  placeholder-in-extend: 2
  mixins-before-declarations:
    - 2
    -
      exclude:
        - breakpoint
        - mq
  nesting-depth:
    - 2
    -
      max-depth: 2
  no-warn: 2
  no-debug: 2
  no-ids: 0
  no-invalid-hex: 2
  no-important: 2
  no-misspelled-properties: 2
  no-qualifying-elements:
    - 0
    -
      allow-element-with-attribute: true
  no-trailing-whitespace: 2
  no-trailing-zero: 2
  one-declaration-per-line: 2
  quotes:
    - 2
    -
      style: single
  indentation:
    - 0
    -
      size: 2
  property-sort-order:
    - 0
    -
      order:
        - display
        - margin
      ignore-custom-properties: true
  single-line-per-selector: 2
  space-after-colon: 2
  space-before-brace:
    - 2
    -
      include: true
  space-before-colon:
    - 2
    -
      include: false
  trailing-semicolon:
    - 2
    -
      include: true
  url-quotes: 2
  variable-for-property:
    - 2
    -
      properties:
        - color
        - background-color
        - border-color
        - font-family
  zero-unit:
    - 2
    -
      include: false

What did you do? Please include the actual source code causing the issue. Ran sass-lint -config .sass-lint.yml './style/scss/**/*.scss' -verbose -no-exit

What did you expect to happen? Linting with no error

What actually happened? Please include any error messages given to you by Sass Lint. Got the following error in the terminal:

/Users/aholderman/Sites/devdesktop/manifest-dev/docroot/themes/manifest/node_modules/sass-lint/index.js:313
    throw new exceptions.SassLintFailureError(errorCount.count + ' errors were detected in \n- ' + errorCount.files.join('\n- '));
    ^
Error
    at Function.sassLint.failOnError (/Users/aholderman/Sites/devdesktop/manifest-dev/docroot/themes/manifest/node_modules/sass-lint/index.js:313:11)
    at detectPattern (/Users/aholderman/Sites/devdesktop/manifest-dev/docroot/themes/manifest/node_modules/sass-lint/bin/sass-lint.js:31:10)
    at /Users/aholderman/Sites/devdesktop/manifest-dev/docroot/themes/manifest/node_modules/sass-lint/bin/sass-lint.js:83:5
    at Array.forEach (native)
    at Object.<anonymous> (/Users/aholderman/Sites/devdesktop/manifest-dev/docroot/themes/manifest/node_modules/sass-lint/bin/sass-lint.js:82:16)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)

About this issue

  • Original URL
  • State: open
  • Created 7 years ago
  • Reactions: 6
  • Comments: 17 (3 by maintainers)

Commits related to this issue

Most upvoted comments

this is fixed by using the following code around this line

  if (program.exit) {
    try{
      lint.failOnError(detects, configOptions, configPath);
    }catch (e){
      console.error(e.message);
    }
    process.exit(exitCode);
  }
  • nicer print to console when there’s errors
  • exits with non-zero code if there’s errors

I would submit a pull request, but i’m not going to jump through all the hoops mentioned in the contributing file. Anyone may take this code and use it, put it in this project, or just go into your own node_modules/sass-lint/bin/sass-lint.js and make the corrections. If you’re wondering why you’re not seeing the actually lint errors, apparently: this module is silent by default, and you must supply the --verbose flag in the CLI if you want to see what went wrong. (Which I think is pretty stupid).

Also, how does something like this take 7 months to implement? I diagnosed in ~20mins and coded it in 2?

Hey there! Any updates about this issue? It’s pretty annoying and a patch has already been submitted, so maybe it could be merged 😃

I’ve made a PR to fix this issue. In the meantime I also noticed that when using the --no-exit flag, the exception is not thrown to stdout. Could be a workaround if you need it.

Thanks @rbf I will look into this for sure. we’re going to do a little overhaul of a few things shortly and these errors / Cli are on the list.