StackOverflow - javascript, eslint, eslint-config-airbnb, airbnb-js-styleguide
ESLint with Airbnb style guide does not work for all rules
Recently I started checking all various JavaScript style guides and I liked Airbnb the best. However, when I configured ESLint with Airbnb style guide, I noticed that some rules defined in their docs are not checked at all. For example: Group all your consts and then group all your lets . Use shortcuts for booleans, but explicit comparisons for strings and numbers. Use // for single line comments. Place single line comments on a newline above the subject of the comment. Put an empty line before the comment unless itβs on the first line of a block. So, if you take this code as an example: const array = [1, 2, 3, 4, 5]; let foo = 'foo'; const bar = 'bar'; if (array.length) { console.log('Bar:', bar); // Chaniging foo foo = 'baz'; console.log('Foo:', foo); } The linter should throw 3 errors: I didn't group all consts and then all lets , I defined them sequentially. I didn't use explicit comparation in if statement - array.length > 0 . I didn't add new line before my comment. However, linter does not throw any error.
Was this helpful?
Related Articles
Have a different question?
Can't find the answer you're looking for? Submit your own question to our community.
ποΈ Get Weekly OTA Fixes
New answers, vendor issues, and updates β straight to your inbox.