-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tslint-loader@3.6.0 throws some warning with webpack 4 + vue-loader #105
Comments
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. |
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/,
});
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!
The text was updated successfully, but these errors were encountered: