subbed
subbed2d ago

how to specify lint rules in deno.json?

hello. how can i specify the deno lint rules inside the deno.json file? if that is not possible, and they can only be passed via the cli, is there some other way to specify multiple of them in a single command? i would prefer not to write 105 flags.
10 Replies
subbed
subbed2d ago
i think i found it. it's under lint.rules.include then perhaps my question is, is there a list of defaults somewhere? maybe the recommended are the defaults?
bartlomieju
bartlomieju2d ago
Yup! Recommended are the defaults You can find the list here: https://lint.deno.land/ If you select the checkbox at the top you will see non-recommended rules too
subbed
subbed2d ago
hmm, it does not seem to respect any of the specified rules. i also passed the config file in with --config, though it is in the default location of ./deno.json. am i doing something wrong?
{
"lint": {
"include": ["src"],
"rules": {
"tags": ["recommended"],
"include": [
"camelcase",
"default-param-last",
"eqeqeq",
"explicit-function-return-type",
"explicit-module-boundary-types",
"guard-for-in",
"no-await-in-loop",
"no-boolean-literal-for-arguments",
"no-eval",
"no-inferrable-types",
"no-non-null-asserted-optional-chain",
"no-non-null-assertion",
"no-self-compare",
"no-sparse-arrays",
"no-sync-fn-in-async-fn",
"no-throw-literal",
"no-top-level-await",
"no-undef",
"prefer-ascii",
"single-var-declarator",
"triple-slash-reference",
"verbatim-module-syntax"
]
}
}
}
{
"lint": {
"include": ["src"],
"rules": {
"tags": ["recommended"],
"include": [
"camelcase",
"default-param-last",
"eqeqeq",
"explicit-function-return-type",
"explicit-module-boundary-types",
"guard-for-in",
"no-await-in-loop",
"no-boolean-literal-for-arguments",
"no-eval",
"no-inferrable-types",
"no-non-null-asserted-optional-chain",
"no-non-null-assertion",
"no-self-compare",
"no-sparse-arrays",
"no-sync-fn-in-async-fn",
"no-throw-literal",
"no-top-level-await",
"no-undef",
"prefer-ascii",
"single-var-declarator",
"triple-slash-reference",
"verbatim-module-syntax"
]
}
}
}
i also tried without the "tags": ["recommended"] field, but it is the same
bartlomieju
bartlomieju2d ago
Can you show some screenshot?
subbed
subbed2d ago
of course
No description
No description
No description
subbed
subbed2d ago
rootHandler not having the Response return type should error out
bartlomieju
bartlomieju2d ago
What if you add non-camel-case variable - eg. const hello_there = "hello"; Is it also not geting flagged?
subbed
subbed8h ago
ok, i tried a few of them out, including the camelcase you mention, and all seem to work except the explicit-function-return-type if this does turn out to be a bug, it will be that much funnier, since i opened a previous issue as a bug, but referenced it as a deno check issue, not a deno lint issue :^) i'll open up an issue on github
subbed
subbed8h ago
GitHub
deno lint does not enforce explicit-function-return-type · Issue #2...
deno 2.0.0 (stable, release, x86_64-unknown-linux-gnu) v8 12.9.202.13-rusty typescript 5.6.2 deno lint does not enforce the explicit-function-return-type rule. Assuming the following deno.json snip...
bartlomieju
bartlomieju7h ago
Thanks!