
Product
Introducing Reachability for PHP
Reachability analysis for PHP is now available in experimental, helping teams identify which vulnerabilities are actually exploitable.
eslint-plugin-ts-ban-snippets
Advanced tools
Ban snippets of TypeScript from your project, using a custom eslint rule 'ts-ban-snippets'.
Ban snippets of TypeScript from your project, using a custom eslint rule 'ts-ban-snippets'.
examples: "return void reject", "it.only", "debugger".
This is an eslint port of tslint-ban-snippets
The rule is quite flexible and could potentially avoid having to create multiple custom eslint rules.
This plugin requires your project to use TypeScript (>=4.1.3).
yarn add eslint-plugin-ts-ban-snippets --dev
The plugin relies on TypeScript compiler services to resolve types.
The following examples show how to configure banned snippets in the .eslintrc file(s) of your project.
note: in the .eslintrc file, you need to set your tsconfig.json file in your eslint configuration via parserOptions:
{
"plugins": ["ts-ban-snippets"],
"parserOptions": {
"project": "./tsconfig.json"
}
}
.eslintrcThis example detects use of return void reject or return void resolve and raises an error.
{
"plugins": ["ts-ban-snippets"],
"parserOptions": {
"project": "./tsconfig.json"
},
"rules": {
"ts-ban-snippets/ts-ban-snippets": [
"error",
{
"banned": [
{
"snippets": ["return void reject", "return void resolve"],
"message": "Please do not return void - instead place the return statement on the following line."
}
]
}
]
}
}
.eslintrcThis example also detects use of return void reject or return void resolve and raises an error - but using a regular expression.
{
"plugins": ["ts-ban-snippets"],
"parserOptions": {
"project": "./tsconfig.json"
},
"rules": {
"ts-ban-snippets/ts-ban-snippets": [
"error",
{
"banned": [
{
"regexSnippets": ["return void [reject|resolve]"],
"message": "Please do not return void - instead place the return statement on the following line."
}
]
}
]
}
}
.eslintrc with multiple banned snippetsThis example has a list of banned snippets:
return void reject or return void resolveit.only or describe.onlyit.skip or test suites via describe.skip{
"plugins": ["ts-ban-snippets"],
"parserOptions": {
"project": "./tsconfig.json"
},
"rules": {
"ts-ban-snippets/ts-ban-snippets": [
"error",
{
"banned": [
{
"snippets": ["return void reject", "return void resolve"],
"message": "Please do not return void - instead place the return statement on the following line."
},
{
"snippets": ["it.only", "describe.only"],
"message": "Do not enable only some tests."
},
{
"snippets": ["it.skip", "describe.skip"],
"message": "Do not skip tests."
}
]
}
]
}
}
.eslintrc with included and excluded pathsThis example has one banned snippet (return void reject or return void resolve).
Only files with a path that contains my-component and does not contain excluded are scanned.
{
"plugins": ["ts-ban-snippets"],
"parserOptions": {
"project": "./tsconfig.json"
},
"rules": {
"ts-ban-snippets/ts-ban-snippets": [
"error",
{
"banned": [
{
"snippets": ["return void reject", "return void resolve"],
"message": "Please do not return void - instead place the return statement on the following line.",
"includePaths": ["my-component"],
"excludePaths": ["excluded"]
}
]
}
]
}
}
For working tests, please see the unit tests.
For a real code example, see the test harness. In particular, the .eslintrc file.
Original work by Sean Ryan - mr.sean.ryan(at gmail.com)
This project is licensed under the MIT License - see the LICENSE file for details
For available options and for examples, see the Rule doc:
FAQs
Ban snippets of TypeScript from your project, using a custom eslint rule 'ts-ban-snippets'.
The npm package eslint-plugin-ts-ban-snippets receives a total of 4 weekly downloads. As such, eslint-plugin-ts-ban-snippets popularity was classified as not popular.
We found that eslint-plugin-ts-ban-snippets demonstrated a not healthy version release cadence and project activity because the last version was released 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.

Product
Reachability analysis for PHP is now available in experimental, helping teams identify which vulnerabilities are actually exploitable.

Product
Export Socket alert data to your own cloud storage in JSON, CSV, or Parquet, with flexible snapshot or incremental delivery.

Research
/Security News
Bitwarden CLI 2026.4.0 was compromised in the Checkmarx supply chain campaign after attackers abused a GitHub Action in Bitwarden’s CI/CD pipeline.