Closed stephenjason89 closed 3 years ago
What is your eslint config, and what is the full error message? Make sure you are using @typescript-eslint/parser.
Hello, thank you for the fast reply, "@nuxtjs/eslint-config-typescript": "^6.0.1",
The whole error
my whole eslintrc.js is this
```
module.exports = {
root: true,
env: {
browser: true,
node: true,
es6: true,
},
parserOptions: {
parser: 'babel-eslint',
},
extends: ['@nuxtjs', 'prettier', 'plugin:prettier/recommended', 'plugin:nuxt/recommended'],
plugins: ['prettier'],
ignorePatterns: '**/*.d.ts', <----------- I am not sure adding this is the right way to remove the error
// add your custom rules here
rules: {
'vue/component-name-in-template-casing': ['error', 'PascalCase'],
'vue/html-self-closing': [
'error',
{
html: {
void: 'always',
},
},
],
'vue/v-bind-style': ['error', 'shorthand'],
'vue/v-on-style': ['error', 'shorthand'],
'vue/v-slot-style': ['error'],
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'prefer-const': [
'error',
{
destructuring: 'all',
},
],
'import/no-named-as-default': 0,
},
}
And here is the script i am running
"lint:js": "eslint --ext .ts,.js,.vue --ignore-path .gitignore .",
adding parser: '@typescript-eslint/parser', on my eslintrc.js
results in an error
normal eslint works fine by the way, i am just new to typescript and wanted to setup everything before learning it .
Thank you for your time
Found what was causing it.
it was this line from my eslintrc.js is it okay to remove this?
parserOptions: {
parser: 'babel-eslint',
},
@stephenjason89 Yes, you should replace it with the parser I linked in my previous comment.
Thank you @danielroe Everything is working perfectly now 🙂
I actually just removed it
I saw it in this doc
Would there be any difference defining the parser?
Great! 😊
Is there a difference if i add the parser or not? I'm new to this and i don't know what to expect with the parser defined and not
If you use the nuxt typescript eslint preset, then you don't need to explicitly define the parser.
Thank you for the reply 🙂
creating a vue-shim.d.ts on the root directory throws
ESLINT ERROR Parsing error: Imports within a
declare module
body must always beimport type
orimport typeof
.Please let me know how to fix this
Thank you