N
Nuxt2mo ago
Tincan

(fixed) Cannot get esling.config.mjs to generate when installing eslint module

I'm trying to get the nuxt/eslint module working on my nuxt 3 project. I've installed and created the eslint.config.mjs file with contents as per the docs. As far as I can tell this file it references should be created when I install the module, but i cannot get it to
import withNuxt from "./.nuxt/eslint.config.mjs"

export default withNuxt()
import withNuxt from "./.nuxt/eslint.config.mjs"

export default withNuxt()
My package.json is as follows
{
"private": true,
"type": "module",
"scripts": {
"build": "nuxt build",
"dev": "nuxt dev",
"generate": "nuxt generate",
"preview": "nuxt preview",
"postinstall": "patch-package & nuxt prepare",
"lint": "eslint .",
"lintfix": "eslint . --fix",
"lintfixdry": "eslint . --fix-dry-run",
"format": "prettier . --write --ignore-unknown",
"prepare": "husky install",
"stylelint": "npx stylelint \"**/*.{css,scss,vue}\"",
"stylelintfix": "npx stylelint \"**/*.{css,scss,vue}\" --fix"
},
"devDependencies": {
"@nuxt/eslint": "^0.6.0",
"@nuxt/image": "^1.0.0",
"@nuxtjs/i18n": "^8.0.0-beta.10",
"@nuxtjs/stylelint-module": "^5.2.0",
"@nuxtjs/tailwindcss": "^6.6.0",
"@nuxtjs/turnstile": "^0.6.3",
"@types/markdown-it": "^12.2.3",
"@vueuse/core": "^9.13.0",
"@vueuse/nuxt": "^9.13.0",
"eslint": "^9.13.0",
"husky": "^8.0.3",
"lint-staged": "^15.2.0",
"markdown-it": "^13.0.1",
"nuxt": "^3.2.3",
"postcss-html": "^1.7.0",
"prettier": "^3.2.4",
"prettier-plugin-tailwindcss": "^0.5.11",
"sass": "^1.59.2",
"sass-loader": "^13.2.0",
"stylelint": "^16.10.0",
"stylelint-config-recommended-vue": "^1.5.0",
"stylelint-config-standard-scss": "^13.1.0",
"stylelint-config-tailwindcss": "^0.0.7",
"typescript": "^5.6.3"
},
...
}
{
"private": true,
"type": "module",
"scripts": {
"build": "nuxt build",
"dev": "nuxt dev",
"generate": "nuxt generate",
"preview": "nuxt preview",
"postinstall": "patch-package & nuxt prepare",
"lint": "eslint .",
"lintfix": "eslint . --fix",
"lintfixdry": "eslint . --fix-dry-run",
"format": "prettier . --write --ignore-unknown",
"prepare": "husky install",
"stylelint": "npx stylelint \"**/*.{css,scss,vue}\"",
"stylelintfix": "npx stylelint \"**/*.{css,scss,vue}\" --fix"
},
"devDependencies": {
"@nuxt/eslint": "^0.6.0",
"@nuxt/image": "^1.0.0",
"@nuxtjs/i18n": "^8.0.0-beta.10",
"@nuxtjs/stylelint-module": "^5.2.0",
"@nuxtjs/tailwindcss": "^6.6.0",
"@nuxtjs/turnstile": "^0.6.3",
"@types/markdown-it": "^12.2.3",
"@vueuse/core": "^9.13.0",
"@vueuse/nuxt": "^9.13.0",
"eslint": "^9.13.0",
"husky": "^8.0.3",
"lint-staged": "^15.2.0",
"markdown-it": "^13.0.1",
"nuxt": "^3.2.3",
"postcss-html": "^1.7.0",
"prettier": "^3.2.4",
"prettier-plugin-tailwindcss": "^0.5.11",
"sass": "^1.59.2",
"sass-loader": "^13.2.0",
"stylelint": "^16.10.0",
"stylelint-config-recommended-vue": "^1.5.0",
"stylelint-config-standard-scss": "^13.1.0",
"stylelint-config-tailwindcss": "^0.0.7",
"typescript": "^5.6.3"
},
...
}
versions eslint 9.13, nuxt/eslint 0.6.0, node v20.9.0 I've tried removing and adding the eslint related packages
6 Replies
kapa.ai
kapa.ai2mo ago
Hi @Tincan. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Based on the information provided in the knowledge sources, I can help you with your issue regarding the ESLint module in your Nuxt 3 project. It seems that you're having trouble generating the eslint.config.mjs file automatically. Let's address this step by step: 1. First, it's important to note that the ESLint module should automatically generate the eslint.config.mjs file when you start your Nuxt app, as mentioned in the Quick Setup guide (https://eslint.nuxt.com/packages/module#quick-setup). 2. To ensure this auto-generation happens, make sure you have added the @nuxt/eslint module to your nuxt.config.ts file:
export default defineNuxtConfig({
modules: [
'@nuxt/eslint'
],
eslint: {
// options here
}
})
export default defineNuxtConfig({
modules: [
'@nuxt/eslint'
],
eslint: {
// options here
}
})
3. If you haven't already, try running your Nuxt app using nuxt dev or npm run dev (depending on your setup). This should trigger the auto-generation of the eslint.config.mjs file. 4. If the file is still not being generated, you can try disabling the auto-init feature and manually create the file. Add the following to your nuxt.config.ts:
export default defineNuxtConfig({
modules: [
'@nuxt/eslint'
],
eslint: {
config: {
autoInit: false // disable auto-init
}
}
})
export default defineNuxtConfig({
modules: [
'@nuxt/eslint'
],
eslint: {
config: {
autoInit: false // disable auto-init
}
}
})
Then, create the eslint.config.mjs file manually in your project root with the following content:
import withNuxt from './.nuxt/eslint.config.mjs'

export default withNuxt(
// your custom flat configs go here
)
import withNuxt from './.nuxt/eslint.config.mjs'

export default withNuxt(
// your custom flat configs go here
)
5. It's worth noting that you're using ESLint v9.13.0, which is a very recent version. The Nuxt ESLint module is designed to work with ESLint v8.45.0 and later, so your version should be compatible. However, if you continue to have issues, you might want to try downgrading to a stable v8 release of ESLint to see if that resolves the problem. 6. Lastly, make sure you have run nuxt prepare after installing the module, as this step is necessary to generate some of the configuration files. If you've followed these steps and are still encountering issues, it might be helpful to check the Nuxt DevTools panel to inspect the resolved ESLint flat config, as suggested in the Quick Setup guide (https://eslint.nuxt.com/packages/module#quick-setup). If the problem persists, you may need to reach out to the Nuxt community or file an issue on the @nuxt/eslint GitHub repository (https://github.com/nuxt/eslint) for further assistance, as there might be a specific issue with your setup that isn't covered in the available documentation. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai2mo ago
<@311921181668147200> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
Tincan
TincanOP2mo ago
Fixed. I delete the eslint.config.mjs in the root of my project and when running yarn dev it generated that file again and this time it generated the one I was missing in .nuxt/ @kapa.ai ive installed stylelint nuxt module and when i run pnpm dev, im getting a no config provided for a vue file. Stylelint nuxt module should not be running on vue files by default
kapa.ai
kapa.ai2mo ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- I apologize, but I don't have specific information about the Stylelint Nuxt module in the provided knowledge sources. The documents mainly focus on ESLint configuration for Nuxt and don't contain details about Stylelint integration or its default behavior with Vue files. To provide an accurate answer about the Stylelint Nuxt module and its default configuration for Vue files, I would need more specific information from the Stylelint Nuxt module documentation or official sources. If you're experiencing unexpected behavior with the Stylelint Nuxt module, I recommend checking the official documentation for that specific module or reaching out to its maintainers for support. They would be best equipped to address why Stylelint might be running on Vue files if that's not the intended default behavior. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai2mo ago
<@311921181668147200> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
kapa.ai
kapa.ai2mo ago
Sorry @Tincan, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
Want results from more Discord servers?
Add your server