Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
@types/eslint
Advanced tools
TypeScript definitions for 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.
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;
This package provides a set of ESLint rules that are specific to TypeScript. It works in conjunction with @typescript-eslint/parser to lint TypeScript code. Compared to @types/eslint, it focuses more on providing TypeScript-specific linting rules rather than type definitions.
TSLint is an extensible static analysis tool that checks TypeScript code for readability, maintainability, and functionality errors. While TSLint is deprecated in favor of ESLint with TypeScript support, it served a similar purpose to @types/eslint by providing linting capabilities for TypeScript.
This package provides a TypeScript configuration for ESLint based on Airbnb's style guide. It is a shareable ESLint configuration that includes TypeScript support, making it easier to set up ESLint with TypeScript. Unlike @types/eslint, it focuses on providing a pre-configured set of rules rather than type definitions.
npm install --save @types/eslint
This package contains type definitions for eslint (https://eslint.org).
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/eslint.
These definitions were written by Pierre-Marie Dartus, Jed Fox, Saad Quadri, Jason Kwok, Brad Zacher, JounQin, and Bryan Mishkin.
FAQs
TypeScript definitions for eslint
The npm package @types/eslint receives a total of 13,879,061 weekly downloads. As such, @types/eslint popularity was classified as popular.
We found that @types/eslint demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.