Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@eslint/js

Package Overview
Dependencies
Maintainers
2
Versions
54
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@eslint/js

ESLint JavaScript language implementation

  • 9.16.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
33M
increased by1.5%
Maintainers
2
Weekly downloads
 
Created

What is @eslint/js?

@eslint/js is a package that provides the core functionality of ESLint, a popular JavaScript linter. It allows developers to analyze their JavaScript code to find and fix problems based on a set of rules. The package is highly configurable and can be extended with custom rules and plugins.

What are @eslint/js's main functionalities?

Linting JavaScript Code

This code demonstrates how to use @eslint/js to lint JavaScript files in the 'src' directory. It initializes an ESLint instance, lints the files, formats the results using the 'stylish' formatter, and prints the formatted results.

const { ESLint } = require('@eslint/js');

(async function main() {
  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);
})();

Custom Configuration

This code shows how to use @eslint/js with a custom configuration. It sets specific rules to enforce no console statements and require semicolons at the end of statements.

const { ESLint } = require('@eslint/js');

(async function main() {
  const eslint = new ESLint({
    overrideConfig: {
      rules: {
        'no-console': 'error',
        'semi': ['error', 'always']
      }
    }
  });
  const results = await eslint.lintFiles(['src/**/*.js']);
  const formatter = await eslint.loadFormatter('stylish');
  const resultText = formatter.format(results);
  console.log(resultText);
})();

Using Plugins

This code demonstrates how to use @eslint/js with the React plugin. It configures ESLint to use rules specific to React, such as ensuring that React variables are used correctly in JSX files.

const { ESLint } = require('@eslint/js');

(async function main() {
  const eslint = new ESLint({
    overrideConfig: {
      plugins: ['react'],
      rules: {
        'react/jsx-uses-react': 'error',
        'react/jsx-uses-vars': 'error'
      }
    }
  });
  const results = await eslint.lintFiles(['src/**/*.jsx']);
  const formatter = await eslint.loadFormatter('stylish');
  const resultText = formatter.format(results);
  console.log(resultText);
})();

Other packages similar to @eslint/js

Keywords

FAQs

Package last updated on 29 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc