An extensible linting tool for Motoko
Download the latest release from GitHub
# Linting all Motoko files underneath the current directory
lintoko -r rules
# Linting a single file
lintoko -r rules src/actor.mo
# Linting all files in the `src` and `test` directories
lintoko -r rules src testSpecify rules with the -r flag. The tool will look for rules in the specified directory. You can pass multiple directories
lintoko -r my-rules -r more-rulesSome rules also specify automatic fixes. These can be applied by passing the --fix flag.
Rules are specified as TOML files. For example this rule forbids the usage of let-else:
name = "no-let-else"
description = "Do not use let-else. Use a switch instead."
query = """
(let_else_dec) @error
"""The "query" field contains a Tree-sitter query that matches a parse tree produced by the motoko tree-sitter grammar.
Look at the rules in example-rules for more complex examples.
Copyright 2025 DFINITY Stiftung
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.