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.
@typescript-eslint/parser
Advanced tools
An ESLint custom parser which leverages TypeScript ESTree
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'
}
};
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.
@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
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.
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.