yoggyd
yoggyd15mo ago

how to configure deno lint with additional rules + options

Specifically I'd like to restrict some imports - is that possible with deno lint?
1 Reply
Deno AI Helper
Deno AI Helper15mo ago
According to the documentation, you can configure deno lint using a configuration file. However, there is no explicit mention of a rule that restricts certain imports. Here's how you can configure deno lint with additional rules and options: 1. Create a deno.json or deno.jsonc configuration file in your project root. 2. In this file, you can specify the linting rules under the lint property. For example:
{
"lint": {
"files": {
"include": ["src/"],
"exclude": ["src/testdata/"]
},
"rules": {
"tags": ["recommended"],
"include": ["ban-untagged-todo"],
"exclude": ["no-unused-vars"]
}
}
}
{
"lint": {
"files": {
"include": ["src/"],
"exclude": ["src/testdata/"]
},
"rules": {
"tags": ["recommended"],
"include": ["ban-untagged-todo"],
"exclude": ["no-unused-vars"]
}
}
}
In this example, the include property under rules is used to include specific rules not in the recommended set, and the exclude property is used to exclude certain rules. The files property is used to specify which files or directories to include or exclude from linting. However, the documentation does not provide a rule that restricts certain imports. You might want to look into using import maps to control how modules are imported, but this is not a linting feature and won't cause deno lint to throw an error when an unwanted import is used. Remember, the information provided here is based on the documentation's details and may not cover all possible use cases or third-party tools that might offer additional functionality.

Did you find this page helpful?