Importing settings

How an Obsidian Linter data.json converts to lynter.yaml, what maps directly, what is dropped, and what lands in a commented block.

If you have an Obsidian Linter data.json, Lynter can convert it into lynter.yaml text. The converter is conservative. It maps the two settings that have a direct home, leaves interface-only settings behind, and keeps everything else as comments so nothing disappears without a trace. You can run it in the interactive converter at /import/, through the convert_data_json WebAssembly export, or through the library function config::migrate_data_json. The command line has no import subcommand.

What the converter does

The converter takes the text of a data.json and returns lynter.yaml text. It works in this order.

  1. If the input already parses as a valid lynter.yaml, it is returned unchanged. JSON is valid YAML, so a config written as JSON passes through as is.
  2. Otherwise the input must be valid JSON whose top level is an object. If not, the conversion fails with an error message. The WebAssembly export returns undefined in that case.
  3. The settings are sorted into mapped, left behind, and unmapped, as described below.
  4. The output starts with two comment lines, then version: 1, then the mapped sections, then the unmapped block if there is one.

The result is not validated, and rule ids and option names are copied as written. Paste the output into the playground, which reports config errors, or run lynter explain on a note before relying on it.

Sources crates/lynter-core/src/config/migrate.rs, crates/lynter-wasm/src/lib.rs, crates/lynter-cli/src/main.rs

What maps

In data.json In lynter.yaml Condition
ruleConfigs.<id> defaults.rules.<id> The value is an object, and enabled is absent or a boolean. The whole object is copied, including every option.
foldersToIgnore ignore.folders The value is a list of strings. An empty list writes nothing.

Rule ids are not renamed and options are not translated. A rule that Lynter ships under the same id and option names works as written. A rule id Lynter does not have is carried into defaults.rules as well, so review the result against rules overview.

Sources crates/lynter-core/src/config/migrate.rs, crates/lynter-core/tests/fixtures/migrate.json

What is left behind

These eleven keys hold interface state, such as save toggles, confirmation prompts, locale and logging. They are not carried over, and they do not appear in comments either: lintOnSave, displayChanged, suppressMessageWhenNoChange, suppressLintAllFilesConfirmationModal, suppressLintAllFilesInFolderConfirmationModal, settingsConvertedToConfigKeyValues, recordLintOnSaveLogs, lintOnFileChange, displayLintOnFileChangeNotice, linterLocale and logLevel.

Lynter's own plugin keeps its two interface settings, lint on save and show notices, in plugin settings and not in lynter.yaml. See the Obsidian plugin.

Sources crates/lynter-core/src/config/migrate.rs, plugin/src/settings.ts

What lands in the commented block

Everything else becomes a comment at the end of the file, one line per item, in the form # key: value, with the value written as compact JSON. The block begins with two comment lines saying these settings have no lynter.yaml equivalent and were kept as comments.

  • A ruleConfigs entry that is not an object, or whose enabled is not a boolean, is written as # ruleConfigs.<id>: ....
  • A ruleConfigs value that is not an object is written as # ruleConfigs: ....
  • A foldersToIgnore value that is not a list of strings is written as # foldersToIgnore: ....
  • Every other top-level key is written as # key: ..., in the order it appears in the input.

Comments are inert. Nothing in the block affects linting, and you can move a setting into the YAML by hand if Lynter has a place for it.

Sources crates/lynter-core/src/config/migrate.rs

Example

Input:

{"ruleConfigs":{"yaml-key-sort":{"enabled":true,"priority-keys":["a","b"]},"x":{"enabled":"yes"}},"foldersToIgnore":["templates"],"lintOnSave":true,"custom":{"a":1}}

Output:

# lynter.yaml generated by lynter from data.json.
# UI-only settings (save/notice/locale/log toggles) stay in data.json by design.
version: 1
defaults:
  rules:
    yaml-key-sort:
      enabled: true
      priority-keys:
        - a
        - b
ignore:
  folders:
    - templates

# unmapped: the data.json settings below have no lynter.yaml equivalent yet.
# They were carried over as comments so nothing is dropped silently.
# ruleConfigs.x: {"enabled":"yes"}
# custom: {"a":1}

lintOnSave is left behind, x has a non-boolean enabled so it becomes a comment, and custom has no mapping so it becomes a comment too. The two header comments and the unmapped notice are fixed text. Strings that would be misread as other YAML types, such as "1.5" or "- x", are written quoted, and empty lists and objects are written as [] and {}.

Sources crates/lynter-core/tests/fixtures/migrate.json, crates/lynter-core/src/config/migrate.rs

After you convert

Save the output as lynter.yaml at the root of your vault or project. Then paste it into the playground to check it, or run lynter explain on a note to see the rules that apply. Add scoping with scopes and profiles, and describe frontmatter with note types.

Sources docs/lynter-yaml.md, crates/lynter-core/src/config/validate.rs