question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Prettier and Eslint not working

See original GitHub issue

Hi,

For some reason eslint and prettier is not working correctly. I have used these same config for all projects, and i just clone from my github when i need to setup a new project, however in this occasion its not working.

App.js:

import React, { Component } from "react";
import logo from "./logo.svg"; // Erros here as its using " instead of ';
import "./App.css";

class App extends Component {
  render() {
    return (
      <div className="App"> // prettier says should be tabs not spaces but it doesnt fix it!

      </div>
    );
  }
}

export default App;

.eslintrc:

{
  "extends": "react-app",
  "plugins": ["prettier"],
  "rules": {
    "prettier/prettier": [
      "error",
      {
        "useTabs": true,
        "tabWidth": 4,
        "singleQuote": true,
        "object-curly-spacing": ["error", "always"],
        "array-bracket-spacing": ["error", "always"],
        "computed-property-spacing": ["error", "always"]
      }
    ],
    "comma-dangle": [
      "error",
      {
        "arrays": "never",
        "objects": "never",
        "imports": "never",
        "exports": "never",
        "functions": "ignore"
      }
    ]
  }
}

package.json:

{
  "name": "create-react-app-base",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "enzyme": "^3.8.0",
    "enzyme-adapter-react-16": "^1.7.1",
    "eslint-plugin-prettier": "^3.0.1",
    "prettier": "^1.6.4",
    "react": "^16.6.3",
    "react-dom": "^16.6.3",
    "react-scripts": "2.1.1",
    "react-test-renderer": "^16.6.3",
    "styled-components": "^4.1.3"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": [
    ">0.2%",
    "not dead",
    "not ie <= 11",
    "not op_mini all"
  ]
}

As i said, these config settings work on my projects using Vscode on mac, but using vscode on windows prettier rules are not being applied on save.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:7
  • Comments:8

github_iconTop GitHub Comments

3reactions
nataliamelissascommented, May 26, 2019

Also experiencing this issue. Followed this article step by step:

https://dev.to/robertcoopercode/using-eslint-and-prettier-in-a-typescript-project-53jb

1reaction
ryb73commented, Mar 24, 2020

I ran into something like this and the problem was a conflict with the @typescript-eslint/indent rule. Turning it off fixed it:

"@typescript-eslint/indent": "off",
Read more comments on GitHub >

github_iconTop Results From Across the Web

Prettier doesn't format based on my eslint config - Stack Overflow
Unfortunately, it didn't work either. Eslint was suggesting no semi-colon but my prettier extension was adding semi-colon to line endings. So I ...
Read more >
How to make ESLint work with Prettier avoiding conflicts and ...
First of all you have to install ESLint plugin in VS Code. Either you can use the extension tab in VS Code or...
Read more >
Integrating with Linters - Prettier
Linters usually contain not only code quality rules, but also stylistic rules. ... immediately lint files by running, for example, eslint --fix on...
Read more >
Using Prettier and ESLint to automate formatting and fixing ...
Learn how to use ESLint and Prettier together to automatically format and fix JavaScript code in your projects.
Read more >
How to use Prettier with ESLint - Robin Wieruch
As mentioned earlier, whereas Prettier takes care of your code formatting, ESLint takes care of your code style. The former does everything ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found