JSX File:
import React from "react";
import TemplateWrapper from "../layouts/index";
const IndexPage = () => (
<TemplateWrapper>
<h1>Hi people</h1>
<p>Welcome to your Blog.</p>
<p>Now go build something great.</p>
</TemplateWrapper>
);
export default IndexPage; // error Insert `⏎` prettier/prettier
ESLint config:
{
"root": true,
"env": {
"browser": true,
"es6": true,
"node": true,
"jest": true
},
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true,
"modules": true
}
},
"plugins": ["react", "react-hooks", "jsx-a11y", "import"],
"extends": [
"airbnb",
"eslint:recommended",
"plugin:prettier/recommended",
"prettier/react",
"prettier/standard",
"plugin:react/recommended",
"plugin:import/errors",
"plugin:import/warnings",
"plugin:jsx-a11y/recommended"
],
"settings": {
"react": {
"version": "detect"
}
},
"rules": {
"no-unused-vars": ["warn"],
"prettier/prettier": ["error", {"singleQuote": false}],
// "prettier/prettier": ["error", {"singleQuote": false}],
"react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }],
"react/jsx-uses-react": 1,
"react/jsx-uses-vars": 1,
"react/react-in-jsx-scope": 1,
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "warn",
"react/display-name": 0,
"react/prop-types": [0, { "ignore": ["children"] }],
"jsx-a11y/anchor-is-valid": 0
}
}
Prettier config:
{
"trailingComma": "none",
"semi": true,
"tabWidth": 2,
"singleQuote": false,
"bracketSpacing": true,
"jsxBracketSameLine": true
}
I just had the same problem with the difference being that linting worked locally (using Windows) but failed on the Linux CI machine. Solved it by adding
to the rules section in
.eslintrc
just disable or transform in a warning, in your eslintrc rules
Sounds like you need to insert a trailing new line at the end of your file.
Adding
"plugins": ["prettier"]
in.eslintrc
andPrintWidth controls the width of printer and It lets you add words in same line and will not complain to add a new line.
One of prettier’s standard formattings is that files must end with a newline character as per the POSIX Standard. There is no option for change that.
This has solved my problem in Vue.
In
package.json
😉I used Snaptags solution and worked temporally and then came back. Manage to fix it by following full installation steps on https://github.com/prettier/eslint-plugin-prettier Now I don’t have Vscode + Prettier + Eslint fighting each other.
For others that find this, the correct solution we’ve found is to make sure that the CI linter’s
prettier
version matches the one on your local environment. In our case, we found that our local machines were running1.19.1
but the CI suite was running2.0.5
which have major improvements to the way line lengths are handled/trimmed.Hi - I found this post because I’m getting the same error… in nvim. I hit return and can only guess that I have the newline at the end of the line… Here is the error I’m getting… is there something I need to configure (encoding) perhaps?
Thank you in advance for taking a quick look.
- E