htmlhint-loader icon indicating copy to clipboard operation
htmlhint-loader copied to clipboard

Angular inline templates

Open mwld opened this issue 8 years ago • 0 comments

Hi there,

I am using Angular inline templates in my project and I would like to lint them with HTMLHint via htmlhint-loader.

It works with this configuration:

            {
                enforce: "pre",
                test: /\.ts$/,
                loader: "htmlhint-loader",
                include: [...],
                options: {
                    configFile: [...],
                    failOnError: false,
                    failOnWarning: false,
                }
            },

The actual HTML part within inline templates is situated inside a template variable in those *.ts files. I guess htmlhint-loader is currently linting the whole file including the TypeScript code. This probably causes the following loader plugin error when the linter finds something what it thinks is an error:

Error: at lint ([...]\node_modules\htmlhint-loader\index.js:115:15) at fs.readFile ([...]\node_modules\htmlhint-loader\index.js:163:11) at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:528:3) @ ./assets/scripts/ts/modules/shared/shared.module.ts 81:39-113 @ ./assets/scripts/ts/modules/app/app.module.ts @ ./assets/scripts/ts/modules/app/standalone-app.module.ts @ ./assets/scripts/ts/main.jit.ts

I would like to know if it is somehow possible to tell htmlhint-loader that it should only lint the template part within those files. (Maybe something like the regExp option of file-loader to only target a part of the loaded file.)

mwld avatar Aug 29 '18 12:08 mwld