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

@types/eslint

Package Overview
Dependencies
Maintainers
1
Versions
87
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/eslint

TypeScript definitions for eslint

  • 9.6.1
  • ts4.8
  • ts4.9
  • ts5.0
  • ts5.1
  • ts5.2
  • ts5.3
  • ts5.4
  • ts5.5
  • ts5.6
  • ts5.7
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
17M
decreased by-12.63%
Maintainers
1
Weekly downloads
 
Created

What is @types/eslint?

@types/eslint provides TypeScript type definitions for the ESLint library, enabling developers to use ESLint with TypeScript more effectively. It helps in ensuring type safety and better autocompletion in IDEs.

What are @types/eslint's main functionalities?

Linting Configuration

This feature allows you to define and configure ESLint settings using TypeScript. The code sample demonstrates how to set up an ESLint configuration object with various settings like environment, parser, and rules.

const eslintConfig: ESLint.Config = {
  env: {
    browser: true,
    es2021: true
  },
  extends: [
    'eslint:recommended',
    'plugin:@typescript-eslint/recommended'
  ],
  parser: '@typescript-eslint/parser',
  parserOptions: {
    ecmaVersion: 12,
    sourceType: 'module'
  },
  rules: {
    'no-unused-vars': 'warn',
    'semi': ['error', 'always']
  }
};

Linting Programmatically

This feature allows you to run ESLint programmatically using TypeScript. The code sample shows how to create an ESLint instance and lint files, then output the linting results.

import { ESLint } from 'eslint';

const eslint = new ESLint({
  baseConfig: {
    extends: ['eslint:recommended']
  }
});

async function lintFiles(files: string[]) {
  const results = await eslint.lintFiles(files);
  results.forEach(result => {
    console.log(result.filePath);
    result.messages.forEach(msg => console.log(`${msg.line}:${msg.column} ${msg.message}`));
  });
}

lintFiles(['src/**/*.ts']);

Custom ESLint Rules

This feature allows you to define custom ESLint rules using TypeScript. The code sample demonstrates how to create a rule that disallows the use of console statements.

import { Rule } from 'eslint';

const noConsoleRule: Rule.RuleModule = {
  create(context) {
    return {
      CallExpression(node) {
        if (node.callee.type === 'MemberExpression' && node.callee.object.name === 'console') {
          context.report({ node, message: 'Unexpected console statement.' });
        }
      }
    };
  }
};

export default noConsoleRule;

Other packages similar to @types/eslint

FAQs

Package last updated on 26 Aug 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