How to use @unocss/eslint-config in withNuxt() #409
Unanswered
chuckntaylor
asked this question in
Q&A
Replies: 2 comments
-
I was able to fix this by installing // @ts-check
import antfu from '@antfu/eslint-config'
import withNuxt from './.nuxt/eslint.config.mjs'
export default withNuxt(
antfu({
unocss: true,
})
)
// Your custom configs here However, I would still be very much interested in knowing how I might have gone about this otherwise. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Here's my ESLint configuration – hope it helps! @chuckntaylor import withNuxt from './.nuxt/eslint.config.mjs'
import pluginPrettier from 'eslint-plugin-prettier'
import unocss from '@unocss/eslint-config/flat'
// If there is only one config, you can simply add unocss like this:
export default withNuxt(unocss)
// If there are other configs, add them into withNuxt:
export default withNuxt(
// Add unocss rules
unocss,
// Customize unocss rules if needed
{
rules: {
'unocss/order': 'error', // Default is 'warn'
'unocss/order-attributify': 'error' // Default is 'warn'
},
},
// Add other rules: prettier
{
plugins: {
prettier: pluginPrettier,
},
rules: {
'prettier/prettier': [
'error',
{
endOfLine: 'auto',
},
],
},
}
) Here are testing examples: <!-- ESLint will alert 'noCSS utilities are not orderedeslint[unocss/order]' -->
<div class="m-4 p-2 bg-red-500 text-white rounded" />
<!-- ESLint will alert 'UnoCSS attributes are not orderedeslint[unocss/order-attributify]'-->
<div text-white p-2 m-4 bg-red-500 /> |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Last night I decided to take the plunge and update eslint to utilize the new flat configuration. After a bit of trial and error, it seemed easiest to use the Nuxt eslint module. I am now trying to get the @unocss/eslint-config running again.
In their docs, it says for the flat configuration:
How might I adapt this to the
export default withNuxt()
inside the generatedeslint.config.mjs
?I have tried
But I get the following error:
Beta Was this translation helpful? Give feedback.
All reactions