Not detecting errors
Huseyin-Yilmaz-98 opened this issue · 4 comments
Hello. I just upgraded my project to Nuxt 3 and am trying to setup Eslint. This is my .eslint.cjs file:
module.exports = {
"root": true,
"parser": "vue-eslint-parser",
"parserOptions": {
"parser": "@typescript-eslint/parser"
},
"env": {
"browser": true,
"node": true
},
"extends": [
"@nuxtjs/eslint-config-typescript"
],
"rules": {
"no-console": "off",
"no-undef": "off",
"vue/no-v-html": "off",
"vue/require-default-prop": "off",
"vue/max-attributes-per-line": "off",
"vue/attributes-order": "off",
"vue/valid-template-root": "off",
"vue/require-component-is": "off",
"vue/order-in-components": "off",
"vue/html-indent": "off",
"vue/comment-directive": "off",
"@typescript-eslint/no-unused-vars": "off",
"space-before-function-paren": ["error", {
"anonymous": "always",
"named": "never",
"asyncArrow": "always"
}],
"array-callback-return": "off",
"object-shorthand": "off",
"import/default": "off",
"vue/multi-word-component-names": "off",
"vue/no-deprecated-v-on-native-modifier": "off",
"vue/v-on-event-hyphenation": "off",
"vue/this-in-template": "off",
"vue/first-attribute-linebreak": "off",
"unicorn/prefer-includes": "off",
"vue/require-explicit-emits": "off"
}
}
And in my package.json, I have "lint": "eslint --ext .js,.vue,.ts --ignore-path .gitignore .",
. When I run npm run lint
it detects all errors just as I want.
I have eslint version ^8.41.0
and @nuxtjs/eslint-module
version ^4.1.0
. I added the module to the nuxt.config.ts
file as follows:
modules: [
'@nuxtjs/eslint-module',
'@nuxt/image-edge'
],
When I run nuxt dev
, I don't get any errors from eslint even though I get them when I run npm run lint
. I tried to play with the module options like include
or extensions
but it just does not react. To test if the module is being loaded, I set the overrideConfigFile
to '.eslintrc.js'
and it told me that this file does not exist so I know that the module is being loaded. Then I changed it to '.eslintrc.cjs'
and the error is gone but I still don't get any logs from Eslint.
Hi @Huseyin-Yilmaz-98
Could you provide a minimal reproduction?
Hi @Huseyin-Yilmaz-98 Could you provide a minimal reproduction?
Unfortunately I cannot share a lot of code as this is a commercial project but I think the problem is related to Webpack. When I changed nuxt config to use vite, I saw the message from the module but when I changed it back to webpack, the message disappeared again. If there is any specific part of the config you would like me to share, I could do it.
Hello, I'm having the same issue. I get all the errors in the console but not in the browser.
I tried the exclude
option and it does work correctly, but when using the option include
it is only sending me back the app.vue
errors, not the rest such as the pages/about.vue
:
nuxt.config.js
modules: [
'@nuxtjs/eslint-module'
],
eslint: {
cache: false,
lintOnStart: false,
failOnWarning: true,
failOnError: true,
include: [
'{layouts,pages,components}/*/*.vue',
'{layouts,pages,components}/**/*.vue'
]
}
eslintrc.cjs
module.exports = {
root: true,
env: {
browser: true,
es2021: true,
node: true
},
extends: [
'@nuxtjs/eslint-config',
'plugin:vue/vue3-recommended',
'plugin:nuxt/recommended'
],
parserOptions: {
parser: '@babel/eslint-parser',
requireConfigFile: false,
ecmaVersion: 'latest',
sourceType: 'module'
},
rules: {
'no-undef': 'off',
'vue/component-tags-order': [
'error',
{
order: ['template', 'script', 'style']
}
],
'vue/html-self-closing': [
'error',
{
html: {
void: 'any',
normal: 'always',
component: 'always'
},
svg: 'always',
math: 'always'
}
],
'no-console': [
'error',
{
allow: [
'info',
'warn',
'dir',
'timeLog',
'assert',
'clear',
'count',
'countReset',
'group',
'groupEnd',
'table',
'dirxml',
'error',
'groupCollapsed',
'Console',
'profile',
'profileEnd',
'timeStamp',
'context'
]
}
],
'vue/max-attributes-per-line': [
'error',
{
singleline: {
max: 1
},
multiline: {
max: 2
}
}
]
},
overrides: [
{
files: ['pages/**/*.vue', 'layouts/*.vue'],
rules: {
'vue/multi-word-component-names': 'off'
}
}
]
}
package.json
"devDependencies": {
"@babel/eslint-parser": "^7.23.3",
"@nuxt/devtools": "latest",
"@nuxtjs/eslint-config": "^12.0.0",
"@nuxtjs/eslint-module": "^4.1.0",
"eslint": "^8.53.0",
"eslint-plugin-nuxt": "^4.0.0",
"eslint-plugin-vue": "^9.18.1",
"nuxt": "^3.8.1",
"vue": "^3.3.8",
"vue-router": "^4.2.5"
}
Thank you for the help!
We temporarily closed this due to the lack of enough information. We could not identify whether it was a bug or a userland misconfiguration with the given info.
Please provide a minimal reproduction to reopen the issue.
Thanks.