Employee Spotlight
From Academia to Industry
Philipp Burckhardt recounts his journey from childhood computer fascinations, to building an e-learning platform at Carnegie Mellon University, and on to his current role at Socket.
@typescript-eslint/parser
Advanced tools
Package description
The @typescript-eslint/parser is an ESLint parser that allows for the analysis and linting of TypeScript code. It is part of the TypeScript-ESLint project, which aims to bring ESLint's powerful static analysis capabilities to TypeScript codebases. The parser converts TypeScript source code into an ESTree-compatible form so that it can be used by ESLint for linting and other code analysis tasks.
Parsing TypeScript code
This feature allows the parser to read TypeScript files and produce an abstract syntax tree (AST) that is compatible with ESLint, enabling it to understand and lint TypeScript syntax.
const { ESLint } = require('eslint');
async function main() {
const eslint = new ESLint({
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 2020,
sourceType: 'module',
project: './tsconfig.json'
}
});
const results = await eslint.lintFiles(['src/**/*.ts']);
// Handle the results
}
main();
Integration with ESLint rules
The parser can be used in conjunction with ESLint rules, including those specifically designed for TypeScript, to enforce code quality and style guidelines.
module.exports = {
parser: '@typescript-eslint/parser',
extends: [
'plugin:@typescript-eslint/recommended'
],
rules: {
'@typescript-eslint/no-unused-vars': 'error',
'@typescript-eslint/explicit-function-return-type': 'warn'
}
};
This package contains a set of ESLint rules that are specifically tailored for TypeScript. It is often used together with @typescript-eslint/parser to provide a complete linting solution for TypeScript codebases.
babel-eslint is an ESLint parser that allows you to lint all valid Babel code with ESLint. While it is not specifically designed for TypeScript, it can be used to lint code that uses Babel for transpilation, including TypeScript when used with the appropriate Babel plugins.
This is a deprecated package that was used to provide ESLint rules for TypeScript before the TypeScript-ESLint project was created. It has been replaced by the @typescript-eslint/parser and typescript-eslint/eslint-plugin packages.
Changelog
6.9.0 (2023-10-23)
parser
fallback logic (#7754) (34c23e0)this: void
parameter (#7696) (6398d3f), closes #7538You can read about our versioning strategy and releases on our website.
Readme
@typescript-eslint/parser
An ESLint parser which leverages TypeScript ESTree to allow for ESLint to lint TypeScript source code.
š See https://typescript-eslint.io/packages/parser for documentation on this package.
See https://typescript-eslint.io for general documentation on typescript-eslint, the tooling that allows you to run ESLint and Prettier on TypeScript code.
FAQs
An ESLint custom parser which leverages TypeScript ESTree
The npm package @typescript-eslint/parser receives a total of 32,059,565 weekly downloads. As such, @typescript-eslint/parser popularity was classified as popular.
We found that @typescript-eslint/parser demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.Ā It has 2 open source maintainers 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.
Employee Spotlight
Philipp Burckhardt recounts his journey from childhood computer fascinations, to building an e-learning platform at Carnegie Mellon University, and on to his current role at Socket.
Security News
Git dependencies in open source packages can introduce significant risks, including lack of version control, stability issues, dependency drift, and difficulty in auditing, making them potential targets for supply chain attacks.
Security News
Node.js has added experimental support for TypeScript, a move that highlights the growing importance of TypeScript in modern development.