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

New project with ESLint/Prettier, warnings and errors #274

Closed
Extarys opened this issue Jul 2, 2019 · 26 comments
Closed

New project with ESLint/Prettier, warnings and errors #274

Extarys opened this issue Jul 2, 2019 · 26 comments
Assignees

Comments

@Extarys
Copy link

Extarys commented Jul 2, 2019

I just run the create-nuxt-app and I checked ESLint and Prettier and right of the bat I have those errors.
Is it normal? Am I missing something?

I searched here, I'm sorry if I missed an answer.

 ERROR  in ./pages/index.vue                                                       friendly-errors 21:04:29

Module Error (from ./node_modules/eslint-loader/index.js):                         friendly-errors 21:04:29

/media/DarkHawk/srv/NodesProjects/NJS-domains/pages/index.vue
  5:25  warning  Expected 1 line break after opening tag (`<h1>`), but no line breaks found                                                                                                                                                                        vue/singleline-html-element-content-newline
  5:36  warning  Expected 1 line break before closing tag (`</h1>`), but no line breaks found                                                                                                                                                                      vue/singleline-html-element-content-newline
  6:28  warning  Expected 1 line break after opening tag (`<h2>`), but no line breaks found                                                                                                                                                                        vue/singleline-html-element-content-newline
  6:55  warning  Expected 1 line break before closing tag (`</h2>`), but no line breaks found                                                                                                                                                                      vue/singleline-html-element-content-newline
  8:76  error    Replace `>Documentation</a` with `⏎··········>Documentation</a⏎········`                                                                                                                                                                          prettier/prettier
  9:11  error    Replace `·href="https://github.com/nuxt/nuxt.js"·target="_blank"·class="button--grey">GitHub</a` with `⏎··········href="https://github.com/nuxt/nuxt.js"⏎··········target="_blank"⏎··········class="button--grey"⏎··········>GitHub</a⏎········`  prettier/prettier

✖ 6 problems (2 errors, 4 warnings)
  2 errors and 4 warnings potentially fixable with the `--fix` option.

                                                                                   friendly-errors 21:04:29
 @ ./.nuxt/router.js 13:24-15:3
 @ ./.nuxt/index.js
 @ ./.nuxt/client.js
 @ multi eventsource-polyfill webpack-hot-middleware/client?reload=true&timeout=30000&ansiColors=&overlayStyles=&name=client&path=/__webpack_hmr/client ./.nuxt/client.js
@clarkdo
Copy link
Member

clarkdo commented Jul 2, 2019

This should be fixed in next version

@Extarys
Copy link
Author

Extarys commented Jul 2, 2019

Thanks @clarkdo.
I activated fixing on save, but after modification the changes rolls back. Is it a configuration file missing for prettier/eslint in the folder? Or is it my settings in VS Code that can mess with this?

@clarkdo
Copy link
Member

clarkdo commented Jul 2, 2019

It’s because the default templates were not well formatted, now the template files are all formatted in create-nuxt-app repo.

@Extarys
Copy link
Author

Extarys commented Jul 2, 2019

Ohh I see, is there a way to test that? You said it was going to be in the next release?
I could never make prettier and vue work ok together I don't know why and I'm kind of lost on how to fix this 😄

@clarkdo
Copy link
Member

clarkdo commented Jul 2, 2019

The prettier formatting on save should work together with your vscode plugin setting, you should check the doc of the plugin you’re using.
For example editor.formatOnSave in https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode

@Extarys
Copy link
Author

Extarys commented Jul 2, 2019

Oh ok awesome, thanks!

@Extarys Extarys closed this as completed Jul 2, 2019
@Extarys
Copy link
Author

Extarys commented Jul 2, 2019

Well, I have prettier and vetur installed. It doesn't seem that there is an option for "Read the config file provided inside the project's folder" kind of thing.

Even yarn run lint -- --fix messed up and made things worse.

I thought the plugins read the config files .prettierrc and .eslingrc.js provided by create-nuxt-app... 😕

@clarkdo
Copy link
Member

clarkdo commented Jul 2, 2019

Can you provide me a repo and steps?

I can have a look tmr, it’s 1 am now😿

@Extarys
Copy link
Author

Extarys commented Jul 2, 2019

Oh damn, go get some sleep :)

@Extarys
Copy link
Author

Extarys commented Jul 3, 2019

I modified .eslintrc.js:

extends: [
    'prettier',
    'prettier/vue',
    '@nuxtjs',
    'plugin:nuxt/recommended',
    'plugin:vue/essential',
    'eslint:recommended'
  ],

VS Code extentions: Vetur, Eslint.
Config:

{
  "editor.formatOnSave": true,
  "eslint.alwaysShowStatus": true,
  "eslint.autoFixOnSave": true,
  "eslint.packageManager": "yarn",
  "eslint.validate": [
    "javascript",
    "javascriptreact",
    {
      "language": "vue",
      "autoFix": true
    }
  ],
  "[vue]": {
    "editor.formatOnSave": false
  }
}

TADA! 🎆

@wuhhh
Copy link

wuhhh commented Jul 3, 2019

Installing Nuxt without eslint & prettier and following the steps here https://medium.com/@gogl.alex/how-to-properly-set-up-eslint-with-prettier-for-vue-or-nuxt-in-vscode-e42532099a9c gave me a perfect working setup. Hope it helps :)

@Extarys
Copy link
Author

Extarys commented Jul 4, 2019

Thanks @wuhhh I'll bookmark the link in case I format my computer, again. 😆

@tircomnicu
Copy link

Thank you @wuhhh

@pixelomo
Copy link

god I hate eslint breaking things

@DerekHill
Copy link

DerekHill commented Nov 20, 2019

I recently created a new nuxt app using npx create-nuxt-app and got these prettier warnings.

This install included "eslint-config-prettier": "^4.1.0" per

"eslint-config-prettier": "^4.1.0",

Updating eslint-config-prettier to ^6.7.0 seemed to fix the issue.

@xgqfrms
Copy link

xgqfrms commented Dec 3, 2019

what's wrong with this?

how to disabled prettier?

image

@clarkdo
Copy link
Member

clarkdo commented Dec 3, 2019

From the console, errors look like related to indentation.

@xgqfrms I'll open a pr to fix this.

@clarkdo clarkdo self-assigned this Dec 3, 2019
@xgqfrms
Copy link

xgqfrms commented Dec 3, 2019

@clarkdo I think it should be a warning, not an error which will be broken the app, that's not too good for the beginner.

@clarkdo
Copy link
Member

clarkdo commented Dec 3, 2019

As I mentioned above, I'll open a pr to fix this, there should have no error in this file 😃

@rajeshdh
Copy link

Adding

"scripts": {
  "lintfix": "eslint --fix --ext .js,.vue --ignore-path .gitignore ."
}

to my package.json file fixed it for me.

Now running npm run lintfix fixes all the errors.

@dosstx
Copy link

dosstx commented Dec 14, 2019

The above issue fixed it for me, too. Thanks.

@baptistecs
Copy link

For me the issue was the VS Code config, I have had to set:
"vetur.format.defaultFormatter.html": "prettier"
instead of the default value:
"vetur.format.defaultFormatter.html": "prettyhtml"

@Developer-Rocha
Copy link

@rajeshdh Thanks bro. It's work for me.

@andriilive
Copy link

Issue appear only on JavaScript Setup
TypeScript seems ok

@kasvith
Copy link

kasvith commented Sep 6, 2020

Still having the issue

@fabiom91
Copy link

The prettier formatting on save should work together with your vscode plugin setting, you should check the doc of the plugin you’re using.
For example editor.formatOnSave in https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode

This solved the error for me! Thanks

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

No branches or pull requests