如何基于SASS的lint缩进?

时间:2018-03-02 14:26:45

标签: sass eslint

我正在尝试为我的项目添加SugarSS linting。我已经将lint-staged命令添加到我的package.json:

npm run lint-staged

当我运行✖ prettier --write found some errors. Please fix them and try committing again. [error] path/to/style.sass: SyntaxError: Unexpected token, expected ";" (3:16) [error] 1 | h1.question [error] 2 | overflow: visible [error] > 3 | padding-right: 12px [error] | ^ [error] 4 | color: #333 [error] 5 | [error] 6 | #questions h4 npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! my_project@1.0.0 lint-staged: `$(yarn bin)/lint-staged` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the my_project@1.0.0 lint-staged script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. 时,它会输出

path/to/style.sass

似乎eslint尝试使用新的SASS 3语法来抓取<head> <script type = "text/javascript" src = "https://www.gstatic.com/charts/loader.js"> </script> <script type = "text/javascript"> google.charts.load('current', {packages: ['corechart']}); </script> <script language = "JavaScript"> function drawChart() { // Define the chart to be drawn. var data = google.visualization.arrayToDataTable([ ['Year','Orange','Orange2','Blue','Blue2','Green','Green2','Purple','Purple2','Brown','Brown2','Grey', 'Grey2', {role: 'annotation'}], ['2007',0,2,0,0,0,0,0,0,0,0,0,0,''], ['2008',0,0,0,1,0,0,0,0,0,0,1,0,''], ['2009',0,0,0,0,0,0,0,0,0,0,0,0,''], ['2010',0,0,0,1,0,0,1,0,0,0,0,1,''], ['2011',0,0,0,0,0,0,0,0,0,0,0,0,''], ['2012',0,0,0,0,0,0,0,0,1,0,5,0,''], ['2013',0,0,2,0,0,0,0,0,3,0,0,0,''], ['2014',0,0,0,0,0,0,0,0,0,0,0,0,''], ['2015',0,0,0,2,0,0,0,0,1,0,1,0,''], ['2016',0,2,0,0,0,1,0,0,4,0,0,0,''], ['2017',1,0,0,1,0,0,0,2,0,0,0,0,''] ]); var colors = [ { color: 'ff884d' }, { color: 'ffddcc' }, { color: '3366ff' }, { color: '99b3ff' }, { color: '33ff77' }, { color: 'b3ffcc' }, { color: 'd633ff' }, { color: 'f0b3ff' }, { color: 'e6ccb3' }, { color: 'ac7339' }, { color: 'c0c0c0' }, { color: 'e6e6e6' }, ]; var options = { isStacked:true, series: colors, bar: {groupWidth: "90%"}, legend: {position:'top', textStyle: {fontSize: 9}}, chartArea: { width: "100%"}, axes: { y: { 0: { side: 'left', label: 'Count'} }} }; // Instantiate and draw the chart. var chart = new google.visualization.ColumnChart(document.getElementById('publicbarchart')); chart.draw(data, options); } google.charts.setOnLoadCallback(drawChart); </script> </head> <body> <div id="publicbarchart" style="width: 900px; height: 300px;"></div> </body>

如何在package.json中设置SugarSS语法的linting?感谢

1 个答案:

答案 0 :(得分:0)

我能够通过以下设置为SugarSS设置棉绒:

# .stylelintrc
{
  "extends": "stylelint-config-sugarss-recommended"
}

在package.json中

{
  "devDependencies": {
    "stylelint-config-sugarss-recommended": "^1.1.0"
    ...
  },
  "scripts": {
    "lint-staged": "$(yarn bin)/lint-staged"
  },
  "lint-staged": {
    "app/assets/styles/**/*.sass": [
      "stylelint --fix --syntax sugarss",
      "git add"
    ],
    ...
  },
  "pre-commit": [
    "lint-staged"
  ]
}