javascript - Grunt.js : htmlhint - targeting all html files

标签 javascript gruntjs

我已按照有关如何安装它的说明进行操作,我的 Gruntfile.js 现在如下所示:

module.exports = function(grunt){
require("matchdep").filterDev("grunt-*").forEach(grunt.loadNpmTasks);
grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    htmlhint: {
        build: {
            options: {
                'tag-pair': true,
                'tagname-lowercase': true,
                'attr-lowercase': true,
                'attr-value-double-quotes': true,
                'doctype-first': true,
                'spec-char-escape': true,
                'id-unique': true,
                'head-script-disabled': true,
                'style-disabled': true
            },
            src: ['index.html']
        }
    }
});

grunt.registerTask('default', []);
};

我想定位项目文件夹中的所有 .html 文件,该文件夹由带有 html 的不同目录组成。

我如何定位所有这些?

最佳答案

您可以在 src 部分使用通配符。

来自 htmlhint docs :

htmlhint: {
  html1: {
    options: {
      'tag-pair': true
    },
    src: ['path/to/**/*.html']
  }
}

以上代码将定位指定路径内任何目录中的任何 .html 文件。

您还可以指定多个路径,如下所示:

src: ['dir1/*.html', 'dir2/*.html', 'dir3/**/*.html']

关于javascript - Grunt.js : htmlhint - targeting all html files,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26323210/

相关文章:

javascript - 如何使正则表达式不导致 “catastrophic backtracking” ?

javascript - Web 控制台命令不起作用

javascript - 如何保存HTML页面的状态(jQuery修改后)

javascript - 在 Windows 上使用 node.js 参数运行 grunt 任务

gruntjs - 在新文件上 Grunt Imagemin

javascript - NPM 无法转换 SASS

php - jquery ajax 返回值没有按预期响应

javascript - 无法读取 JavaScript 中的 http header 值

gruntjs - 是否可以在监视任务之后运行任务?

javascript - grunt "test command"在 npm init 上做了什么