Skip to content
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

[Docs] description in Prettier section is a little misleading #342

Closed
kingyue737 opened this issue Mar 20, 2024 · 5 comments
Closed

[Docs] description in Prettier section is a little misleading #342

kingyue737 opened this issue Mar 20, 2024 · 5 comments

Comments

@kingyue737
Copy link
Contributor

kingyue737 commented Mar 20, 2024

Environment

ignore

Package

None

Reproduction

ignore

Describe the bug

This module does not enable any stylistic/formatting rules by default. You can use Prettier alongside directly.

@nuxt/eslint includes some rules in eslint-plugin-vue which conflicts with prettier like vue/max-attributes-per-line. Therefore, we cannot use Prettier alongside "directly", still need to turn off those rules manually or via eslint-config-prettier.

Additional context

No response

Logs

No response

@antfu
Copy link
Member

antfu commented Mar 20, 2024

From my point of view I think it makes sense for us to disable vue/max-attributes-per-line (and any other formatting rules) by default

@meirroth
Copy link
Contributor

@antfu Thank you for adding the FAQs, really helpful!
I think Prettier section can use extra instructions or an example project with prettier working along side @nuxt/eslint, considering how popular Eslint + Prettier is.

@antfu antfu closed this as completed in ab6bca7 Mar 20, 2024
@meirroth
Copy link
Contributor

meirroth commented Apr 24, 2024

For anyone who comes across this issue looking to integrate Prettier with @nuxt/eslint (and @intlify/eslint-plugin-vue-i18n), here's my working config, after hours of trial and error:

import eslintConfigPrettier from 'eslint-config-prettier'
import prettierPlugin from 'eslint-plugin-prettier'
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended'
import vueI18n from '@intlify/eslint-plugin-vue-i18n'
import withNuxt from './.nuxt/eslint.config.mjs'

export default withNuxt([
  ...vueI18n.configs['flat/recommended'],
  {
    plugins: {
      prettier: prettierPlugin,
    },
    rules: {
      ...eslintConfigPrettier.rules,
      ...eslintPluginPrettierRecommended.rules,

      'no-console': 'warn',
      'vue/multi-word-component-names': 'off',
    },
    settings: {
      'vue-i18n': {
        localeDir: './localization/*.json',
        messageSyntaxVersion: '^9.0.0',
      },
    },
  },
])

Sources that helped:
#387 and https://eslint-plugin-vue-i18n.intlify.dev/started.html

@cannap
Copy link

cannap commented May 28, 2024

For anyone who comes across this issue looking to integrate Prettier with @nuxt/eslint (and @intlify/eslint-plugin-vue-i18n), here's my working config, after hours of trial and error:

import eslintConfigPrettier from 'eslint-config-prettier'
import prettierPlugin from 'eslint-plugin-prettier'
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended'
import vueI18n from '@intlify/eslint-plugin-vue-i18n'
import withNuxt from './.nuxt/eslint.config.mjs'

export default withNuxt([
  ...vueI18n.configs['flat/recommended'],
  {
    plugins: {
      prettier: prettierPlugin,
    },
    rules: {
      ...eslintConfigPrettier.rules,
      ...eslintPluginPrettierRecommended.rules,

      'no-console': 'warn',
      'vue/multi-word-component-names': 'off',
    },
    settings: {
      'vue-i18n': {
        localeDir: './localization/*.json',
        messageSyntaxVersion: '^9.0.0',
      },
    },
  },
])

Sources that helped: #387 and https://eslint-plugin-vue-i18n.intlify.dev/started.html

thanks this worked almost
i tried do i have to enable stylistic and formatter prettiert?

@meirroth
Copy link
Contributor

@cannap No need for stylistic if your using prettier. See here how I added and configured prettier to work with this module: meirroth/nuxtboiler@181618f

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants