{"id":18980974,"url":"https://github.com/htmlhint/htmlhint-loader","last_synced_at":"2026-03-15T22:35:31.294Z","repository":{"id":1077697,"uuid":"38707011","full_name":"htmlhint/htmlhint-loader","owner":"htmlhint","description":"A webpack loader for htmlhint","archived":false,"fork":false,"pushed_at":"2023-01-04T00:24:28.000Z","size":1324,"stargazers_count":20,"open_issues_count":20,"forks_count":8,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-16T15:15:28.691Z","etag":null,"topics":["htmlhint","loader","loader-plugin","webpack","webpack-loader","webpack-plugin","webpack4"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/htmlhint.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-07-07T18:31:17.000Z","updated_at":"2023-10-13T00:38:57.000Z","dependencies_parsed_at":"2023-01-13T10:55:03.837Z","dependency_job_id":null,"html_url":"https://github.com/htmlhint/htmlhint-loader","commit_stats":null,"previous_names":["mattlewis92/htmlhint-loader"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/htmlhint%2Fhtmlhint-loader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/htmlhint%2Fhtmlhint-loader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/htmlhint%2Fhtmlhint-loader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/htmlhint%2Fhtmlhint-loader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/htmlhint","download_url":"https://codeload.github.com/htmlhint/htmlhint-loader/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249779287,"owners_count":21324392,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["htmlhint","loader","loader-plugin","webpack","webpack-loader","webpack-plugin","webpack4"],"created_at":"2024-11-08T16:08:21.574Z","updated_at":"2026-03-15T22:35:31.289Z","avatar_url":"https://github.com/htmlhint.png","language":"JavaScript","readme":"\u003ch1 align=\"center\"\u003e\n  \u003cbr\u003e\n  HTMLHint Loader\n  \u003cbr\u003e\n\u003c/h1\u003e\n\n\u003ch4 align=\"center\"\u003eA Webpack loader for HTMLHint\u003c/h4\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://codecov.io/gh/htmlhint/htmlhint-loader\"\u003e\n    \u003cimg src=\"https://codecov.io/gh/htmlhint/htmlhint-loader/branch/master/graph/badge.svg\" alt=\"Codecov\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/htmlhint-loader\"\u003e\n    \u003cimg src=\"https://img.shields.io/npm/dm/htmlhint-loader.svg\" alt=\"NPM count\"\u003e\n  \u003c/a\u003e\n  \u003cimg src=\"https://badgen.net/badge/license/MIT/green\" alt=\"MIT Licence\" /\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"#install\"\u003eHow To Use\u003c/a\u003e • \u003ca href=\"/CONTRIBUTING.md\"\u003eContributing\u003c/a\u003e • \u003ca href=\"https://htmlhint.com\"\u003eWebsite\u003c/a\u003e\n\u003c/p\u003e\n\n## Table of Contents\n\n- **[Install](#install)**\n- **[Usage](#usage)**\n- **[Options](#options)**\n\n## Install\n\n```\nnpm install htmlhint-loader\n```\n\n## Usage\n\n```javascript\nmodule.exports = {\n  module: {\n    rules: [{\n      enforce: 'pre',\n      test: /\\.html/,\n      loader: 'htmlhint-loader',\n      exclude: /node_modules/\n    }]\n  }\n}\n```\n\n### Options\n\nYou can directly pass some [htmlhint rules](https://github.com/thedaviddias/HTMLHint/wiki/Rules) by\n\n- Adding a query string to the loader for this loader usage only\n\n```javascript\nmodule.exports = {\n  module: {\n    rules: [{\n      enforce: 'pre',\n      test: /\\.html/,\n      loader: 'htmlhint-loader?{tagname-lowercase: true}',\n      exclude: /node_modules/\n    }]\n  }\n}\n```\n\n- Adding a `htmlhint` entry in your webpack loader options:\n\n```javascript\nmodule.exports = {\n  module: {\n    rules: [{\n      enforce: 'pre',\n      test: /\\.html/,\n      loader: 'htmlhint-loader',\n      exclude: /node_modules/,\n      options: {\n        configFile: 'path/.htmlhintrc'\n      }\n    }]\n  }\n}\n```\n\n#### `configFile`\n\nA path to a json file containing the set of htmlhint rules you would like applied to this project. *By default all rules are turned off and it is up to you to enable them.*\n\nExample file:\n```javascript\n{\n  \"tagname-lowercase\": true,\n  \"attr-lowercase\": true,\n  \"attr-value-double-quotes\": true\n}\n```\n\n#### `formatter` (default: a function that pretty prints any warnings and errors)\n\nThe function is called with an array of messages direct for htmlhint and must return a string.\n\n#### `emitAs` (default: `null`)\n\nWhat to emit errors and warnings as. Set to `warning` to always emit errors as warnings and `error` to always emit warnings as errors. By default the plugin will auto detect whether to emit as a warning or an error.\n\n#### `failOnError` (default `false`)\n\nWhether to force webpack to fail the build on a htmlhint error\n\n#### `failOnWarning` (default `false`)\n\nWhether to force webpack to fail the build on a htmlhint warning\n\n#### `customRules`\n\nAny custom rules you would like added to htmlhint. Specify as an array like so:\n```javascript\nmodule.exports = {\n  module: {\n    rules: [{\n      enforce: 'pre',\n      test: /\\.html/,\n      loader: 'htmlhint-loader',\n      exclude: /node_modules/,\n      options: {\n        customRules: [{\n          id: 'my-rule-name',\n          description: 'Example description',\n          init: function(parser, reporter) {\n            //see htmlhint docs / source for what to put here\n          }\n        }]\n      }\n    }]\n  }\n}\n```\n\n#### `rulesDir`\n\nYou can add a path to a folder containing your custom rules.\nSee below for the format of the rule, it is not the same as HTMLHINT - you can pass a value to a rule.\n```javascript\n// webpack config\nmodule.exports = {\n  module: {\n    rules: [{\n      enforce: 'pre',\n      test: /\\.html/,\n      loader: 'htmlhint-loader',\n      exclude: /node_modules/,\n      options: {\n        rulesDir: path.join(__dirname, 'rules/'),\n        'my-new-rule': 'this is pass to the rule (option)'\n      }\n    }]\n  }\n}\n```\n\n```javascript\n// rules/myNewRule.js\nconst id = 'my-new-rule';\n\nmodule.exports = {\n  id,\n  rule: function(HTMLHint, option /* = 'this is pass to the rule (option)' */) {\n    HTMLHint.addRule({\n      id,\n      description: 'my-new-rule',\n      init: () =\u003e {\n        //see htmlhint docs / source for what to put here\n      }\n    });\n  }\n};\n```\n\n##### `outputReport` (default: `false`)\nWrite the output of the errors to a file, for example a checkstyle xml file for use for reporting on Jenkins CI\n\nThe `filePath` is relative to the webpack config: output.path\nThe use of [name] is supported when linting multiple files.\nYou can pass in a different formatter for the output file, if none is passed in the default/configured formatter will be used\n\n```javascript\nmodule.exports = {\n  module: {\n    rules: [{\n      enforce: 'pre',\n      test: /\\.html/,\n      loader: 'htmlhint-loader',\n      exclude: /node_modules/,\n      options: {\n        outputReport: {\n          filePath: 'checkstyle-[name].xml',\n          formatter(messages) {\n            // convert messages to a string that will be written to the file\n            return messagesFormattedToString;\n          }\n        }\n      }\n    }]\n  }\n}\n```\n\n## Licence\n\nProject initially created by [@mattlewis](https://github.com/mattlewis92) and transferred to the [HTMLHint](https://github.com/htmlhint) organization.\n\n\u003ca href=\"https://htmlhint.com\"\u003e\u003cimg src=\"https://raw.githubusercontent.com/htmlhint/htmlhint/develop/src/img/htmlhint.png\" alt=\"Logo HTMLHint\" width=\"65\"\u003e\u003c/a\u003e\n\n[MIT License](./LICENSE)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhtmlhint%2Fhtmlhint-loader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhtmlhint%2Fhtmlhint-loader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhtmlhint%2Fhtmlhint-loader/lists"}