How to supress specific linter warnings

I’m sure this has been asked before, but I can’t for the life of me find any forum posts or official documentation on configuration of the linter.

I recall there exists a config file but I can’t seem to find any documentation on this either.

Could somebody point me in the right direction?

I want to suppress these warnings:

  In the use of type constructor or class ‘Monad’
  (imported from Prelude, but defined in DA.Internal.Compatible):
  Deprecated: "Daml compatibility helper, use 'Action' instead of 'Monad'"
1 Like

Ah sorted, I needed to search for “dlint”. For example:

1 Like

Note that the error above is a deprecation warning not a DLint hint so the linked post does not apply. You can disable the warning here but only at the level of the full file not more granular. To do so, add the following to the top of your file:

{-# OPTIONS -Wno-deprecations #-}
2 Likes

To suppress specific linter warnings, follow these steps:

  1. Copy the “name” of the warning. The name appears in the linter message. See the example below.

  2. Open (or create) a .dlint.yaml file in the same folder that contains the daml.yaml file.

  3. Add a line for each message you want to disable, placing the name in curly braces. For example:

    ignore: { name: Use === for better error messages }
    ignore: { name: Use isNone }
    

    Notice that the name is not placed within quotation or apostrophe marks.

  4. If using Visual Studio Code then restart it.


Here is an example of a linter message and its name.


Edit: Thanks, Gary, for noting that name: should be included. Fixed!

1 Like

That’s a great tip, thank you @WallaceKelly :+1:t2:

The syntax is actually (note the name:):

ignore: {name: Use === for better error messages}

You can find examples of valid syntax in the default .dlint.yaml generated as part of most daml templates:

$ daml new t
Created a new project in "t" based on the template "skeleton".
$ cat t/.dlint.yaml
# This file controls the behaviour of the dlint linting tool. Below are two
# examples of how to enable or disable a rule.

# This rule is enabled by default. Uncomment to disable.
#- ignore: {name: Use fewer imports}

# This rule is disabled by default. Uncomment to enable.
#- suggest: {name: Use module export list}
$
2 Likes