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

@eslint/core

Package Overview
Dependencies
Maintainers
2
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@eslint/core

Runtime-agnostic core of ESLint

  • 0.8.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4.2M
increased by6.19%
Maintainers
2
Weekly downloads
 
Created

What is @eslint/core?

@eslint/core is the core library for ESLint, a tool for identifying and fixing problems in JavaScript code. It provides the core functionality needed to lint JavaScript code, including parsing, rule application, and reporting.

What are @eslint/core's main functionalities?

Linting JavaScript Code

This feature allows you to lint JavaScript files using ESLint. The code sample demonstrates how to use the ESLint class to lint files in a project, returning results that include any linting errors or warnings.

const { ESLint } = require("@eslint/core");

(async function main() {
  const eslint = new ESLint();
  const results = await eslint.lintFiles(["src/**/*.js"]);
  console.log(results);
})();

Custom Rule Definition

This feature allows you to define custom linting rules. The code sample shows how to create a custom rule that reports an error when the identifier 'foo' is used, and how to apply this rule using ESLint.

const { ESLint } = require("@eslint/core");

const customRule = {
  create(context) {
    return {
      Identifier(node) {
        if (node.name === 'foo') {
          context.report({ node, message: "Avoid using 'foo' as an identifier." });
        }
      }
    };
  }
};

(async function main() {
  const eslint = new ESLint({
    overrideConfig: {
      rules: {
        'no-foo': ['error', customRule]
      }
    }
  });
  const results = await eslint.lintText("const foo = 1;");
  console.log(results);
})();

Configuring ESLint

This feature allows you to configure ESLint with specific environments, rules, and configurations. The code sample demonstrates how to set up ESLint with a custom configuration, including environment settings and specific rules.

const { ESLint } = require("@eslint/core");

(async function main() {
  const eslint = new ESLint({
    overrideConfig: {
      env: {
        browser: true,
        node: true
      },
      extends: "eslint:recommended",
      rules: {
        semi: ["error", "always"]
      }
    }
  });
  const results = await eslint.lintFiles(["src/**/*.js"]);
  console.log(results);
})();

Other packages similar to @eslint/core

Keywords

FAQs

Package last updated on 28 Oct 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