ICode9

精准搜索请尝试: 精确搜索
首页 > 编程语言> 文章详细

从Coffeescript生成的Javascript不是lint准备好了吗? – >在Yeoman / Grunt中引发Lint错误

2019-06-24 16:24:54  阅读:228  来源: 互联网

标签:javascript coffeescript gruntjs yeoman


目前我正在努力改进构建网络应用程序的工作流程.
安装了Yeoman后,命令“grunt”为我提供了一个很好的方法来组合和缩小我的javascript文件.
我的main.js文件是从很多coffeescript文件生成的,我之前手动做过.由于文件依赖性,我没有使用编译coffeescript的集成方法. (还行吧)

但问题出在这里:
当我现在尝试运行“grunt”时,它从我生成的js文件中给出了“lint”错误,如:

line 3   col 3    Missing "use strict" statement.
line 3   col 3    Expected 'var' to have an indentation at 5 instead at 3.
line 4   col 102  Expected '{' and instead saw 'child'.
line 4   col 233  A constructor name should start with an uppercase letter.

Warning: Task "jshint:all" failed. Use --force to continue.

如果我 – 强制它继续,outcoming dest文件夹中的main.js仍为空

我能做什么?我认为编译的coffeescript是“lint ready”javascript?

要编译我的coffeescript文件,我使用“rehab”:
https://www.npmjs.org/package/rehab

它为我提供了这个Cakefile:

{exec, spawn} = require 'child_process'
Rehab = require 'rehab'

build = ->
      console.log "Building project from src/*.coffee to app/scripts/main.js"

      files = new Rehab().process 'src'
      files = files.join " "

      join_to_single_file = "--join app/scripts/main.js"
      compile_from_files = "--compile #{files}"

      exec "coffee #{join_to_single_file} #{compile_from_files}", (err, stdout, stderr) ->
        throw err if err

task 'build', 'Build coffee2js using Rehab', sbuild = ->
  build()

更新:

如果我理解正确,我的main.js文件将永远不会传递jshint,所以我必须从yeoman / grunt删除检查以进一步?我从gruntfile.js中删除了这一行:

// Make sure code styles are up to par and there are no obvious mistakes
    jshint: {
        options: {
            jshintrc: '.jshintrc',
            reporter: require('jshint-stylish')
        },
        all: [
            'Gruntfile.js',
          // removed  '<%= yeoman.app %>/scripts/{,*/}*.js',
            '!<%= yeoman.app %>/scripts/vendor/*',
            'test/spec/{,*/}*.js'
        ]
    },

现在我没有错误,如果运行“咕噜”,但我在dest文件夹中的输出仍包含一个空的main.js

标签:javascript,coffeescript,gruntjs,yeoman
来源: https://codeday.me/bug/20190624/1279812.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有