E
E
Evgeny Popov2019-07-27 17:52:28
JavaScript
Evgeny Popov, 2019-07-27 17:52:28

Can I use only "eslint --fix" to format code? Or is prettier still necessary?

I'm trying to set up a linter for the project, as well as automatic error correction.
For js, as usual, there is the well-known Eslint, which highlights errors, and Prettier, which formats the code depending on the settings of prettier and Eslint itself.
At the same time, Eslint itself has a command - "eslint --fix" which, at first glance, did a good job of automatically fixing errors. But then I do not quite understand why prettier is needed if Eslint has the same functionality?
Should I use Prettier in 2019 then? Or does Prettier complement Eslint's functionality?

"scripts": {
    "format": "prettier --single-quote --semi=false --write \"{src,server,webpack}/**/*.js\" && eslint --fix src server webpack",
    "lint:css": "stylelint src/**/*.scss",
    "lint-css:fix": "stylelint src/**/*.scss --fix && prettier --write src/**/*.scss",
    "lint:js": "eslint src src/**/*.js",
    "lint-js:fix": "eslint src src/**/*.js --fix",
  },

I didn't notice the difference between format and lint-js:fix.
I have the same question for the stylelint and prettier bundle.
Didn't see the difference between "stylelint src/**/*.scss --fix && prettier --write src/**/*.scss" or just "stylelint src/**/*.scss --fix"

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pavel Pikat, 2019-07-27
@PavelPikat

For Angular, they usually use TSLint - an analogue of ESLint, only for TypeScript. And, accordingly, TSLint rules are configured for Angular projects in the tslint.json file, or they use a ready-made set of rules right away, for example https://www.npmjs.com/package/angular-tslint-rules .
Personally, for example, I don't use Prettier at all.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question