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
False positives when using with Vue SFC #883
Comments
could you please post your tsconfig and eslint config as well? We've got tests for vue SFC and they're passing, so there might be something you're missing from the config. |
.eslintrc.jsmodule.exports = {
root: true,
// Rules order is important, please avoid shuffling them
extends: [
// Base ESLint recommended rules
'eslint:recommended',
// ESLint typescript rules
// See https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin#usage
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
// `plugin:vue/essential` by default, consider switching to `plugin:vue/strongly-recommended`
// or `plugin:vue/recommended` for stricter rules.
// See https://github.com/vuejs/eslint-plugin-vue#priority-a-essential-error-prevention
'plugin:vue/recommended',
// Usage with Prettier, provided by 'eslint-config-prettier'.
// https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin#usage-with-prettier
'prettier',
'prettier/@typescript-eslint',
'prettier/vue',
],
plugins: [
// Required to apply rules which need type information
'@typescript-eslint',
// Required to lint *.vue files
// See https://eslint.vuejs.org/user-guide/#why-doesn-t-it-work-on-vue-file
'vue',
// Prettier has not been included as plugin to avoid performance impact
// See https://github.com/typescript-eslint/typescript-eslint/issues/389#issuecomment-509292674
// Add it as an extension
],
// Must use parserOptions instead of "parser" to allow vue-eslint-parser to keep working
// See https://eslint.vuejs.org/user-guide/#how-to-use-custom-parser
// `parser: 'vue-eslint-parser'` is already included with any 'plugin:vue/**' config and should be omitted
parserOptions: {
// Needed to make the parser take into account 'vue' files
// See https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/parser#configuration
extraFileExtensions: ['.vue'],
parser: '@typescript-eslint/parser',
project: './tsconfig.json',
sourceType: 'module',
},
env: {
browser: true,
},
globals: {
ga: true, // Google Analytics
cordova: true,
__statics: true,
process: true,
},
// add your custom rules here
rules: {
'prefer-promise-reject-errors': 'off',
quotes: ['warn', 'single'],
// allow console.log during development only
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
// allow debugger during development only
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
// Custom
'vue/component-name-in-template-casing': ['error', 'kebab-case'],
'@typescript-eslint/explicit-function-return-type': 'off',
},
}; tsconfig.json{
"compilerOptions": {
"allowJs": true,
"baseUrl": ".",
"experimentalDecorators": true,
"module": "esnext",
"moduleResolution": "node",
"outDir": "./dist",
"sourceMap": true,
"strict": true,
"target": "es6"
},
"exclude": ["node_modules", "dist"]
} Seems to me that I don't have anything "less" to your test config, but I have a lot more. Quoting from one of the maintainers of
|
@IlCallo Not sure if it's the same issue, but I was getting lot's of |
Nope, didn't help |
I have the same problem. |
I'm having the same issue as well. |
I haven't had time to look into it. I'd love it if someone that's familiar with Vue could help look into it. As a workaround, you can set |
vuejs/eslint-plugin-vue#970 |
I got problems too, it seems to caused by the cache files. see here I am using this plugin for quite a long time. And this error is always appeared. |
@yyx990803, @sodatea, @Akryum, @LinusBorg, can you help us? |
/cc @mysticatea |
The PR #1083 can fix this issue. |
It'd be great if people could create a local build of that PR and link it in to see if it covers all of the use cases. @yoyo930021 - I'm just trepidatious because we've had many changes and tests that pass locally that don't work for vue users IRL. |
@bradzacher, I can verify that PR #1083 does resolve Here is my const path = require('path');
module.exports = {
root: true,
env: {
commonjs: true
},
plugins: [
'@typescript-eslint',
'vue'
],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'plugin:vue/recommended',
"plugin:prettier/recommended",
'prettier/@typescript-eslint',
'prettier/vue'
],
rules: {
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-inferrable-types': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unused-vars': ['warn', { 'argsIgnorePattern': '^_' }],
'@typescript-eslint/no-empty-function': ['warn'],
eqeqeq: 'warn'
},
parserOptions: {
parser: '@typescript-eslint/parser',
ecmaVersion: 2018,
sourceType: 'module',
project: path.resolve(__dirname, './tsconfig.json'),
extraFileExtensions: ['.vue'],
}
}; |
@bradzacher, I've also verified that PR #1083 resolves my eslint Vue issues. Here is my
|
Late to the party (pretty busy on a project), but I confirm too that issues are gone! |
What code were you trying to parse?
I'm using Quasar (Vue based, using SFCs) and there seems to be some kind of incompatibility between
typescript-eslint/parser
andvue-eslint-parser
.Related
vuejs/eslint-plugin-vue#944
vuejs/vue-eslint-parser#55
What did you expect to happen?
Linting working normally even in
.vue
files, given that it kind-of worked (with some limitations) pre v2.What actually happened?
All
.vue
files show a low levelParsing error: '>' expected
error.Most rules somewhat related to JS/TS into templates linting will also fail.
In my case every
v-if
,v-on
andv-bind
usage generate an error corresponding to the usage of that directive.Es.
Versions
@typescript-eslint/parser
2.0.0
vue-eslint-parser
6.0.4
eslint-plugin-vue
5.2.3
TypeScript
3.5.3
ESLint
6.2.0
node
10.15.3
npm
6.4.1
yarn
1.16.0
The text was updated successfully, but these errors were encountered: