Giter Club home page Giter Club logo

Comments (2)

agcty avatar agcty commented on June 1, 2024 1

Hi! You're very welcome.
ESLint and Prettier are two different things and you need both.

The way it works is this:
The ESLint extension just highlights errors (it pretty much only shows red squiggly lines) in vscode but doesn't really know what an error is or when to show an error.

In the project root you will find a file called .eslintrc.json which gets read by the ESLint extension so that it knows which rules throw errors, warnings, etc., this is also the file where you can add new rules, remove old ones etc.

Now If you look closely at the rules you will find a rule called prettier/prettier which is set to throw errors. But what are the differences between prettier and eslint?

Prettier is a code formatter that removes extra whitespace, sets correct indents, line-breaks, etc. It does not really have anything to do with showing you errors (that's what linters are for, e.g eslint). However, you can tell eslint that you want to treat non-formatted code as an error. The cool thing about this is that eslint can automatically fix these formatting errors with prettier.

To conclude:
ESLint extension shows the red squiggly lines (you absolutely need that)
.eslintrc.json tells the extension what an error even is (that's highly opinionated most of the times)
prettier can format your code to make it look better, but isn't itself an error
however, we set it to show errors so eslint can fix it automatically

Note: in addition, there is a file called .vscode/settings.json which tells the eslint extension to run auto-fixing every time you save a file

Another note: In the readme I recommend to also install the Prettier extension which is not really needed for this project because the dependency is already installed but it's very handy if you work on plain js code without dependencies etc.

If you have any more questions please just ask! :)

from nextjs-advanced-starter.

BaankeyBihari avatar BaankeyBihari commented on June 1, 2024

Thank you, for the clarification.

from nextjs-advanced-starter.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.