Skip to content

[Linting Rule] Unused Definitions

github-actions[bot] edited this page Nov 8, 2026 · 1 revision

Generated from 'wiki-linter.ts' on 2026-11-07, 14:38:02 UTC (v2.17.3), do not edit directly.

Unused Definitions [overview]

smell quickfix readability

This rule is a best-effort rule.

Finds definitions that are never used.
This linting rule is implemented in src/linter/rules/unused-definition.ts.

Configuration

Linting rules can be configured by passing a configuration object to the linter query as shown in the example below. The unused-definitions rule accepts the following configuration options:

  • excludeExportedDefinitions
    Whether to suppress definitions that the analyzed project exports via its NAMESPACE (the package's public API). flowR cannot observe external callers, so exported names would otherwise be reported as (uncertain) false positives.
  • includeFunctionDefinitions
    Whether to include (potentially anonymous) function definitions in the search (e.g., should we report uncalled anonymous functions?).

Examples

x <- 42
y <- 3
print(x)

The linting query can be used to run this rule on the above example:

[ { "type": "linter",   "rules": [ { "name": "unused-definitions",     "config": {} } ] } ]

Results (prettified and summarized):

Query: linter (3 ms)
   ╰ Unused Definitions (unused-definitions):
       ╰ uncertain:
           ╰ Definition of y at 3.1 (1 quick fix(es) available)

More examples are the test cases in test/functionality/linter/lint-unused-definition.test.ts.

Clone this wiki locally

⌂ 换网址