VOOZH about

URL: https://www.digitalocean.com/community/tutorials/linting-and-formatting-with-eslint-in-vs-code?comment=98786

โ‡ฑ How To Lint and Format Code with ESLint in Visual Studio Code | DigitalOcean


How To Lint and Format Code with ESLint in Visual Studio Code

Updated on March 12, 2026

By Anish Singh Walia

Sr Technical Content Strategist and Team Lead

๐Ÿ‘ How To Lint and Format Code with ESLint in Visual Studio Code

Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.

Learn more about our products

About the author

๐Ÿ‘ Anish Singh Walia
Anish Singh Walia
Author
Sr Technical Content Strategist and Team Lead
See author profile

I help Businesses scale with AI x SEO x (authentic) Content that revives traffic and keeps leads flowing | 3,000,000+ Average monthly readers on Medium | Sr Technical Writer(Team Lead) @ DigitalOcean | Ex-Cloud Consultant @ AMEX | Ex-Site Reliability Engineer(DevOps)@Nutanix

Still looking for an answer?

Was this helpful?

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Thanks for this simple, effective introduction to ESLint, especially the section on configuring autofix in VS Code - ESLintโ€™s endless tab warnings were driving me round the twist.

Thank you for this, really helps me. Been searching around and this one is the best.

Formatting on save works for some eslint rules (indent, comma-dangle, quotes, semi) BUT doesnโ€™t seem to work for other (max-len for example). Having the following rules in .eslintrc:

"rules": {
 "indent": [
 "error",
 2
 ],
 "quotes": [
 "error",
 "single"
 ],
 "semi": [
 "error",
 "always"
 ],
 "comma-dangle": [
 "error",
 "never"
 ],
 "max-len": [
 "error",
 {
 "code": 90
 }
 ]
}

When I save the file, it does change all double quotes to single quotes, sets proper indentation, adds semi-colons and removes trailing commas, all good. BUT if I have a code line that exceeds the max-length of 90, it does not break that line (although it is underlined and it shows the linting error). And itโ€™s not a line of one long string, itโ€™s simply this:

const someArray = ['asdasd', 'asdasdfgdswgsgs', 'asduhasjkdhkasudhku', 'akhjsdggasfygasfykgas', 'hgashdg', ['a', 'b', 'c']];

It does not format that :(

Everyone whoโ€™s looking for eslint not working on save file.

eslint working with cli and not with save, make sure that this is added. "editor.formatOnSave": true

Everyone whoโ€™s here saying eslint working with cli and not with save, make sure that this is added. "editor.formatOnSave": true

๐Ÿ‘ Creative Commons
This work is licensed under a Creative Commons Attribution-NonCommercial- ShareAlike 4.0 International License.
  • Deploy on DigitalOcean

    Click below to sign up for DigitalOcean's virtual machines, Databases, and AIML products.

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and AI-native businesses

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOceanโ€™s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow โ€” whether you're running one virtual machine or ten thousand.

Start building today

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

ยฉ 2026 DigitalOcean, LLC.Sitemap.
Dark mode is coming soon.