Open TaroKong opened 6 years ago
I have the same issues
same issue here, it need a custom parser option to handle the Vue SFC file
const vueParser = require('vue-parser')
module.exports = function(input, map) {
this.cacheable && this.cacheable();
var callback = this.async();
if (!semver.satisfies(Lint.Linter.VERSION, '>=4.0.0')) {
throw new Error('Tslint should be of version 4+');
}
var options = resolveOptions(this);
if (/<script.*lang="ts".*>([\s|\S]*)<\/script>/.test(input)) {
const _input = vueParser.parse(input, 'script', { lang: ['ts', 'tsx'] });
lint(this, _input, options);
} else {
lint(this, input, options);
}
callback(null, input, map);
};
@hilongjw is there a sample app on how to get this middleware to work?
I have the same issue. When I use vue sfc file , ts-loader will check the html in template tag, and css in style tag。 but I don't need ts-loader to check the html and css. how can I do ? @hilongjw
I have the same issue too. according to @hilongjw, I made a monkey patch to make it work by:
cfg.module.rules.push({
enforce: 'pre',
test: /\.(ts|vue)$/,
loader: 'tslint-loader',
exclude: /node_modules/,
});
to
cfg.module.rules.push({
enforce: 'pre',
test: /\.(ts|vue)$/,
loader: './my-tslint-loader.js', // here
exclude: /node_modules/,
});
my-tslint-loader.js
:const vueParser = require('vue-parser');
const tsLintLoader = require('tslint-loader');
module.exports = function(input, map) {
const that = Object.assign({}, this, {
async: () => {
const cb = this.async();
return function (err, _input, map) {
cb(err, input, map);
};
}
});
if (/<script lang=(ts|"ts"|'ts')>([\s|\S]*)<\/script>/.test(input)) {
const _input = vueParser.parse(input, 'script', { lang: ['ts', 'tsx'] });
// throw new Error(_input)
tsLintLoader.apply(that, [_input, map]);
} else {
tsLintLoader.apply(that, [input, map]);
}
};
@TaroKong did you figure out a workaround?
Hello, I got some warning!
This is a part of my webpack.module.rules config:
Codes of the vue file is like:
The warning is like:
If i delete the config of tslint-loader, everything will be ok!