Socket
Socket
Sign inDemoInstall

@types/eslint

Package Overview
Dependencies
2
Maintainers
1
Versions
83
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/eslint


Version published
Weekly downloads
16M
decreased by-20.56%
Maintainers
1
Created
Weekly downloads
 

Package description

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

Readme

Source

Installation

npm install --save @types/eslint

Summary

This package contains type definitions for eslint (https://eslint.org).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped.git/tree/master/types/eslint

Additional Details

  • Last updated: Tue, 08 May 2018 16:41:34 GMT
  • Dependencies: json-schema, estree
  • Global values: none

Credits

These definitions were written by Pierre-Marie Dartus https://github.com/pmdartus, Jed Fox https://github.com/j-f1, Saad Quadri https://github.com/saadq.

FAQs

Last updated on 08 May 2018

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc