Have sass-lint ignore a certain line?

前端 未结 4 719

I\'m using sass-lint with Gulp. How can I disable warnings for a particular style in my sass from the lint console output?

I\'ve found a similar question but I

4条回答
  •  伪装坚强ぢ
    2021-02-03 17:57

    As of sass-lint 1.10.0 it's been possible to disable sass-lint rules via source comments

    Below are the different permutations of this, intentionally almost identical to the scss-lint way before.

    Disable a rule for the entire file

    // sass-lint:disable border-zero
    p {
      border: none; // No lint reported
    }
    

    Disable more than 1 rule

    // sass-lint:disable border-zero, quotes
    p {
      border: none; // No lint reported
      content: "hello"; // No lint reported
    }
    

    Disable a rule for a single line

    p {
      border: none; // sass-lint:disable-line border-zero
    }
    

    Disable all lints within a block (and all contained blocks)

    p {
      // sass-lint:disable-block border-zero
      border: none; // No result reported
    }
    
    a {
      border: none; // Failing result reported
    }
    

    Disable and enable again

    // sass-lint:disable border-zero
    p {
      border: none; // No result reported
    }
    // sass-lint:enable border-zero
    
    a {
      border: none; // Failing result reported
    }
    

    Disable/enable all linters

    // sass-lint:disable-all
    p {
      border: none; // No result reported
    }
    // sass-lint:enable-all
    
    a {
      border: none; // Failing result reported
    }
    

    The sass-lint readme includes all of the details and the docs have been updated too.

    The grunt, gulp and atom plugins have all been updated too to require v1.10 and above so a quick reinstall of these or an update and you'll be ready to go.

    We're sorry it took so long to come out but we had to fix a few issues in our AST before we were confident of them being useful.

提交回复
热议问题