javascript-tutorial / en.javascript.info

Modern JavaScript Tutorial
https://javascript.info
Other
23.35k stars 3.84k forks source link

Misleading coding style practice #3746

Open Mandeep56Singh opened 1 month ago

Mandeep56Singh commented 1 month ago

Thanks for making javascript.info, I am learning a lot from it. I have encounter some issue regarding coding style guide and as I daily visitor of beloved javascript.info I held responsibility for contributing toward this learning source, so that new developers will not misguided by some mistakes.

on this article It says Linting tools are for styling while it's completely false Linting tools like eslint are for setting rules for your code

For example, if you enabled the ESLint logical-assignment-operators rule on the snippet from Formatting, you’d receive a message and suggested fix like:

- friend = friend || "me";
+ friend ||= "me";
Assignment (=) can be replaced with operator assignment (||=).

while formatting tools like prettier are the one used for styling code. Using Linting tools for styling is bad idea they are very slow because that's not Linting tools job to do.

Please visit these links to know the insights Configuring ESLint, Prettier, and TypeScript Together video link

I recommend Including the learning of above resources in javascript.info coding style section it would be a great help. you can even make a separate section for it, these things help developers so much.

joaquinelio commented 1 month ago

About using lint for styling, I don't see it as a bad idea, lint is almost mandatory for quality, so no harm in using it to do styling too.

Maybe you're right it's important to clarify the primary focus of linters is quality

As a minimum I would change "... automatically check the style and QUALITY of your code..." then adjust a little the paragraph that follows it.

Mandeep56Singh commented 1 month ago

@joaquinelio thanks for replying have you visited the resources that I have listed ? please watch this video link at 13:11 timestamps This video is from one of best contributor of typsecript and eslint i.e. JoshuaKGoldberg Linters and formatters aren't the same. Linters and formatter works differently . Most of developers uses prettier for formatting and Eslint rule checking. Both uses different algorithm, we can use linters for styling but they are slow . The right tool is formatter.