Convert Figma logo to code with AI

eslint logojs

Monorepo for the JS language tools.

2,275
193
2,275
6

Top Related Projects

49,046

Prettier is an opinionated code formatter.

8,975

JSHint is a tool that helps to detect errors and potential problems in your JavaScript code

29,051

🌟 JavaScript Style Guide, with linter & automatic code fixer

5,909

:vertical_traffic_light: An extensible linter for the TypeScript language

7,645

❤️ JavaScript/TypeScript linter (ESLint wrapper) with great defaults

A JavaScript checker and optimizer.

Quick Overview

ESLint/js is a monorepo containing the core ESLint library and its official JavaScript-related plugins and parsers. It provides a pluggable linting utility for JavaScript, helping developers identify and fix problems in their code. The project aims to make code more consistent and avoid bugs.

Pros

  • Highly configurable and customizable
  • Large ecosystem of plugins and rules
  • Supports modern JavaScript features and syntax
  • Integrates well with various development environments and build tools

Cons

  • Can be complex to set up and configure for beginners
  • Performance can be slow on large codebases
  • Some rules may conflict with each other or personal coding preferences
  • Keeping up with frequent updates and changes can be challenging

Code Examples

  1. Basic ESLint configuration:
module.exports = {
  env: {
    browser: true,
    es2021: true,
  },
  extends: 'eslint:recommended',
  parserOptions: {
    ecmaVersion: 'latest',
    sourceType: 'module',
  },
  rules: {
    'indent': ['error', 2],
    'linebreak-style': ['error', 'unix'],
    'quotes': ['error', 'single'],
    'semi': ['error', 'always'],
  },
};
  1. Using ESLint programmatically:
const { ESLint } = require('eslint');

async function lintFiles() {
  const eslint = new ESLint();
  const results = await eslint.lintFiles(['src/**/*.js']);
  const formatter = await eslint.loadFormatter('stylish');
  const resultText = formatter.format(results);
  console.log(resultText);
}

lintFiles().catch((error) => {
  process.exitCode = 1;
  console.error(error);
});
  1. Disabling ESLint for specific lines:
// eslint-disable-next-line no-console
console.log('This line will not trigger a warning');

/* eslint-disable */
// These lines will not be linted
const x = 1;
const y = 2;
/* eslint-enable */

Getting Started

  1. Install ESLint:

    npm install eslint --save-dev
    
  2. Initialize ESLint configuration:

    npx eslint --init
    
  3. Run ESLint on your files:

    npx eslint yourfile.js
    
  4. Add a script to your package.json:

    {
      "scripts": {
        "lint": "eslint ."
      }
    }
    
  5. Run the linter:

    npm run lint
    

Competitor Comparisons

49,046

Prettier is an opinionated code formatter.

Pros of Prettier

  • Opinionated formatting with minimal configuration required
  • Supports a wide range of file types beyond JavaScript
  • Integrates seamlessly with most editors and build tools

Cons of Prettier

  • Less flexibility in customizing code style
  • May conflict with existing team coding standards
  • Limited ability to enforce code quality rules

Code Comparison

ESLint (js):

function example(foo,bar) {
  if(foo) {
    return bar;
  }
}

Prettier:

function example(foo, bar) {
  if (foo) {
    return bar;
  }
}

Summary

Prettier focuses on code formatting with a "one-way" approach, while ESLint (js) offers more comprehensive linting and style enforcement. Prettier excels in simplicity and consistency across projects, but sacrifices some customization options. ESLint (js) provides greater flexibility in defining and enforcing coding standards, but requires more setup and configuration.

Both tools can be used together, with Prettier handling formatting and ESLint focusing on code quality rules. This combination often provides the best of both worlds for many development teams.

8,975

JSHint is a tool that helps to detect errors and potential problems in your JavaScript code

Pros of JSHint

  • Simpler configuration and setup process
  • Faster parsing and linting speed for large codebases
  • Better support for legacy JavaScript environments

Cons of JSHint

  • Less frequent updates and maintenance
  • Fewer customization options and rules
  • Limited support for modern JavaScript features and frameworks

Code Comparison

JSHint configuration example:

{
  "esversion": 6,
  "node": true,
  "strict": true
}

ESLint configuration example:

{
  "parserOptions": {
    "ecmaVersion": 2021
  },
  "env": {
    "node": true
  },
  "rules": {
    "strict": ["error", "global"]
  }
}

Summary

JSHint is a simpler, faster linting tool that works well for legacy projects and developers who prefer a straightforward setup. However, it lacks the extensive customization options and modern JavaScript support that ESLint offers.

ESLint, on the other hand, provides a more comprehensive and flexible linting experience, with a wider range of rules and better support for modern JavaScript features and frameworks. It's more actively maintained and has a larger community, but may have a steeper learning curve for configuration.

The choice between JSHint and ESLint depends on project requirements, team preferences, and the complexity of the codebase. ESLint is generally recommended for new projects and those using modern JavaScript features, while JSHint may be suitable for simpler or legacy codebases.

29,051

🌟 JavaScript Style Guide, with linter & automatic code fixer

Pros of Standard

  • Zero configuration required, works out of the box
  • Opinionated style guide enforces consistency across projects
  • Simpler setup process for new developers

Cons of Standard

  • Less flexibility in customizing rules
  • Fewer rule options compared to ESLint
  • May not align with personal or team preferences for specific style choices

Code Comparison

Standard:

function example (arg1, arg2) {
  if (arg1 && arg2) {
    return true
  }
  return false
}

ESLint (with default config):

function example(arg1, arg2) {
  if (arg1 && arg2) {
    return true;
  }
  return false;
}

The main differences in this example are:

  • Standard uses no semicolons
  • Standard has a space before function parentheses
  • ESLint (default) uses semicolons and no space before function parentheses

Both Standard and ESLint aim to improve code quality and consistency, but they take different approaches. Standard provides a pre-configured set of rules with minimal setup, while ESLint offers more flexibility and customization options. The choice between the two often depends on project requirements, team preferences, and the desired level of control over coding style.

5,909

:vertical_traffic_light: An extensible linter for the TypeScript language

Pros of TSLint

  • Specifically designed for TypeScript, offering better integration with TS features
  • Includes built-in rules for TypeScript-specific syntax and patterns
  • Provides more detailed type-aware linting capabilities

Cons of TSLint

  • Deprecated in favor of ESLint with TypeScript support
  • Smaller ecosystem and fewer community-contributed rules
  • Less frequent updates and maintenance

Code Comparison

TSLint configuration:

{
  "rules": {
    "no-any": true,
    "no-unsafe-any": true,
    "strict-boolean-expressions": true
  }
}

ESLint configuration with TypeScript support:

{
  "parser": "@typescript-eslint/parser",
  "plugins": ["@typescript-eslint"],
  "rules": {
    "@typescript-eslint/no-explicit-any": "error",
    "@typescript-eslint/strict-boolean-expressions": "error"
  }
}

Both linters aim to improve code quality and consistency, but ESLint has become the preferred choice for both JavaScript and TypeScript projects. ESLint offers a more extensive plugin ecosystem, better performance, and ongoing development. While TSLint was once the go-to option for TypeScript projects, it has been deprecated, and users are encouraged to migrate to ESLint with TypeScript-specific plugins for continued support and improvements.

7,645

❤️ JavaScript/TypeScript linter (ESLint wrapper) with great defaults

Pros of XO

  • Zero-configuration: Works out of the box with sensible defaults
  • Opinionated: Enforces a consistent style without the need for extensive configuration
  • Includes additional rules and plugins by default, such as unicorn and import rules

Cons of XO

  • Less flexibility: Harder to customize rules for specific project needs
  • Smaller ecosystem: Fewer plugins and integrations compared to ESLint
  • Steeper learning curve for developers accustomed to ESLint's configuration options

Code Comparison

XO configuration:

{
  "extends": "xo"
}

ESLint configuration:

{
  "extends": "eslint:recommended",
  "rules": {
    // Custom rules and overrides
  }
}

XO focuses on providing a complete, opinionated linting solution with minimal setup, while ESLint offers more flexibility and customization options. XO is ideal for projects that want a quick start with consistent code style, whereas ESLint is better suited for projects requiring fine-grained control over linting rules and configurations.

Both tools aim to improve code quality and maintain consistency, but they cater to different preferences in terms of setup complexity and customization. The choice between XO and ESLint often depends on project requirements, team preferences, and the desired level of control over linting rules.

A JavaScript checker and optimizer.

Pros of Closure Compiler

  • Advanced code optimization and minification capabilities
  • Type checking and inference for improved code quality
  • Supports transpilation from modern JavaScript to older versions

Cons of Closure Compiler

  • Steeper learning curve and more complex setup
  • Less focus on code style and formatting
  • Slower compilation process for large projects

Code Comparison

Closure Compiler (annotated JavaScript):

/** @param {string} name */
function greet(name) {
  console.log('Hello, ' + name + '!');
}

ESLint (with configuration):

module.exports = {
  rules: {
    'no-console': 'warn',
    'quotes': ['error', 'single']
  }
};

Key Differences

  • ESLint focuses on code style, best practices, and potential errors
  • Closure Compiler emphasizes optimization and type checking
  • ESLint is more widely used for general JavaScript development
  • Closure Compiler is often employed in large-scale production environments

Use Cases

  • ESLint: Ideal for maintaining consistent code style across projects and teams
  • Closure Compiler: Best suited for optimizing and type-checking complex JavaScript applications

Community and Ecosystem

  • ESLint has a larger community and more third-party plugins
  • Closure Compiler is primarily maintained by Google and has a smaller, but dedicated user base

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

ESLint JS

Monorepo for the JS language tools.

Packages

This repository is the home of the following packages:

Security Policy

We work hard to ensure that the packages inside this repository are safe for everyone and that security issues are addressed quickly and responsibly. Read the full security policy.

Sponsors

The following companies, organizations, and individuals support ESLint's ongoing maintenance and development. Become a Sponsor to get your logo on our README and website.

Platinum Sponsors

Automattic Airbnb

Gold Sponsors

trunk.io

Silver Sponsors

JetBrains Liftoff American Express Workleap

Bronze Sponsors

Anagram Solver Icons8 Discord Nx HeroCoders Nextbase Starter Kit

Technology Sponsors

Netlify Algolia 1Password

NPM DownloadsLast 30 Days