我试图修改我的gruntfile但是我的缩进有很多错误。空格是否总是对gruntfiles很重要?什么是解决这些错误的最佳方法,计算空格?
$ grunt
Running "newer:jshint" (newer) task
Running "newer:jshint:all" (newer) task
Running "jshint:all" (jshint) task
Gruntfile.js
line 33 col 11 Expected 'options' to have an indentation at 9 instead at 11.
line 36 col 7 Expected '}' to have an indentation at 9 instead at 7.
line 37 col 7 Expected 'js' to have an indentation at 9 instead at 7.
line 38 col 9 Expected 'files' to have an indentation at 11 instead at 9.
line 39 col 9 Expected 'tasks' to have an indentation at 11 instead at 9.
line 40 col 9 Expected 'options' to have an indentation at 11 instead at 9.
line 41 col 11 Expected 'livereload' to have an indentation at 13 instead at 11.
line 42 col 9 Expected '}' to have an indentation at 11 instead at 9.
line 43 col 7 Expected '}' to have an indentation at 9 instead at 7.
line 43 col 9 Trailing whitespace.
line 44 col 7 Expected 'compass' to have an indentation at 9 instead at 7.
line 45 col 9 Expected 'files' to have an indentation at 11 instead at 9.
line 46 col 9 Expected 'tasks' to have an indentation at 11 instead at 9.
line 47 col 7 Expected '}' to have an indentation at 9 instead at 7.
line 48 col 7 Expected 'gruntfile' to have an indentation at 9 instead at 7.
line 49 col 9 Expected 'files' to have an indentation at 11 instead at 9.
line 50 col 7 Expected '}' to have an indentation at 9 instead at 7.
line 51 col 7 Expected 'livereload' to have an indentation at 9 instead at 7.
line 52 col 9 Expected 'options' to have an indentation at 11 instead at 9.
line 53 col 11 Expected 'livereload' to have an indentation at 13 instead at 11.
line 54 col 9 Expected '}' to have an indentation at 11 instead at 9.
line 55 col 9 Expected 'files' to have an indentation at 11 instead at 9.
line 56 col 11 Expected '<%= yeoman.app %>/{,*/}*.html' to have an indentation at 13 instead at 11.
line 57 col 11 Expected '.tmp/styles/{,*/}*.css' to have an indentation at 13 instead at 11.
line 58 col 11 Expected '<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}' to have an indentation at 13 instead at 11.
line 59 col 9 Expected ']' to have an indentation at 11 instead at 9.
line 60 col 7 Expected '}' to have an indentation at 9 instead at 7.
line 61 col 5 Expected '}' to have an indentation at 7 instead at 5.
line 64 col 5 Expected 'connect' to have an indentation at 7 instead at 5.
line 65 col 7 Expected 'options' to have an indentation at 9 instead at 7.
line 66 col 9 Expected 'port' to have an indentation at 11 instead at 9.
line 68 col 9 Expected 'hostname' to have an indentation at 11 instead at 9.
line 69 col 9 Expected 'livereload' to have an indentation at 11 instead at 9.
line 70 col 7 Expected '}' to have an indentation at 9 instead at 7.
line 71 col 7 Expected 'livereload' to have an indentation at 9 instead at 7.
line 72 col 9 Expected 'options' to have an indentation at 11 instead at 9.
line 73 col 11 Expected 'open' to have an indentation at 13 instead at 11.
line 74 col 11 Expected 'base' to have an indentation at 13 instead at 11.
line 75 col 13 Expected '.tmp' to have an indentation at 15 instead at 13.
line 76 col 13 Expected '<%= yeoman.app %>' to have an indentation at 15 instead at 13.
line 77 col 11 Expected ']' to have an indentation at 13 instead at 11.
line 78 col 9 Expected '}' to have an indentation at 11 instead at 9.
line 79 col 7 Expected '}' to have an indentation at 9 instead at 7.
line 80 col 7 Expected 'test' to have an indentation at 9 instead at 7.
line 81 col 9 Expected 'options' to have an indentation at 11 instead at 9.
line 82 col 11 Expected 'port' to have an indentation at 13 instead at 11.
line 83 col 11 Expected 'base' to have an indentation at 13 instead at 11.
line 84 col 13 Expected '.tmp' to have an indentation at 15 instead at 13.
line 85 col 13 Expected 'test' to have an indentation at 15 instead at 13.
line 86 col 13 Expected '<%= yeoman.app %>' to have an indentation at 15 instead at 13.
line 86 col 13 Too many errors. (21% scanned).
✖ 51 problems
Warning: Task "jshint:all" failed. Use --force to continue.
答案 0 :(得分:6)
注释掉.jshintrc文件中的'indent'属性,或者也可以在package.json中注释掉。对“缩进”这个词进行全局查找应该可以帮到那里。
我发现空格确实增加了代码的可读性,尤其是JS。这么多,我不知道它应该被揭示,特别是因为它对JS的执行方式没有影响。
答案 1 :(得分:2)
您可能会从'lint'获取缩进错误。
如果您有'eslintrc'文件,则可以删除以下行 来自规则键值对
'缩进:[2,2,{“SwitchCase”:1}],'