Need advice about which tool to choose?Ask the StackShare community!
ESLint vs JSLint: What are the differences?
ESLint and JSLint are both widely used tools for linting and analyzing JavaScript code. Let's explore the key differences between them.
Architecture: ESLint is built to be more modular and pluggable, allowing developers to customize and extend its functionality through plugins and configurations. On the other hand, JSLint is a more opinionated and rigid tool with a fixed set of rules and configurations.
Community Support: ESLint has a larger and more active community compared to JSLint, which means that it has a wider range of available plugins, rules, and integrations. This community-driven support ensures that ESLint stays up-to-date with the latest best practices and language features.
Configurability: ESLint offers a high degree of configurability, allowing developers to fine-tune the linting rules according to their project's specific requirements. JSLint, on the other hand, provides limited configuration options, making it less flexible for complex or specific use cases.
Browser Compatibility: JSLint focuses primarily on enforcing rules that ensure compatibility with older JavaScript versions and common browser pitfalls. ESLint, on the other hand, has better support for ECMAScript standards and modern JavaScript features, making it more suitable for modern web development.
Integration and Tooling: ESLint integrates well with various development tools and editors, offering smooth integrations and plugins for popular code editors like Visual Studio Code. JSLint, while it can be integrated to some extent, doesn't have as extensive tooling support as ESLint.
License: ESLint is open source and licensed under the MIT License, which allows for more freedom in using and modifying the tool. JSLint, however, has a more restrictive license that places certain limitations on its use and distribution.
In summary, ESLint is highly configurable and extensible, allowing developers to customize rules and plugins according to their project's needs, while JSLint follows a more opinionated approach with strict and predefined rules. Additionally, ESLint has gained broader adoption in the JavaScript community due to its flexibility and compatibility with modern development workflows, whereas JSLint is known for its simplicity and strict adherence to Douglas Crockford's coding style guidelines.
Scenario: I want to integrate Prettier in our code base which is currently using ESLint (for .js and .scss both). The project is using gulp.
It doesn't feel quite right to me to use ESLint, I wonder if it would be better to use Stylelint or Sass Lint instead.
I completed integrating ESLint + Prettier, Planning to do the same with [ Stylelint || Sasslint || EsLint] + Prettier.
And have gulp 'fix' on file save (Watcher).
Any recommendation is appreciated.
In the case of .js files I would recommend using both Eslint and Prettier.
You can set up Prettier as an Eslint rule using the following plugin:
https://github.com/prettier/eslint-plugin-prettier
And in order to avoid conflicts between Prettier and Eslint, you can use this config:
https://github.com/prettier/eslint-config-prettier
Which turns off all Eslint rules that are unnecessary or might conflict with Prettier.
you don't actually have to choose between these tools as they have vastly different purposes. i think its more a matter of understanding how to use them.
while eslint and stylelint are used to notify you about code quality issues, to guide you to write better code, prettier automatically handles code formatting (without notifying me). nothing else.
prettier and eslint both officially discourage using the eslint-plugin-prettier way, as these tools actually do very different things. autofixing with linters on watch isnt a great idea either. auto-fixing should only be done intentionally. you're not alone though, as a lot of devs set this up wrong.
i encourage you to think about what problem you're trying to solve and configure accordingly.
for my teams i set it up like this: - eslint, stylelint, prettier locally installed for cli use and ide support - eslint config prettier (code formatting rules are not eslints business, so dont warn me about it) - vscode workspace config: format on save - separate npm scripts for linting, and formatting - precommit hooks (husky)
so you can easily integrate with gulp. its just js after all ;)
Pura vida! Well, I had a similar issue and at the end I decided to use Stylelint + Prettier for that job, in our case, we wanted that our linting process includes the SCSS files and not only the JS file, base on that we concluded that using only ESLint to do both things wasn't the best option, so, we integrated prettier with Stylelint, and for that we used a neat plugin that allowed us to use Prettier inside Stylelint here is the link, https://github.com/prettier/stylelint-prettier#recommended-configuration, I hope that this can help you, hasta pronto!, :)
Pros of ESLint
- Consistent javascript - opinions don't matter anymore8
- Free6
- IDE Integration6
- Customizable4
- Focuses code review on quality not style2
- Broad ecosystem of support & users2