Skip to content

Lint configuration cannot set rules for a group of files #35

Description

@romankurakin

config :volt, :lint applies plugins and rules to every file in the run. oxlint's own configuration format has overrides, which apply rules to a subset of files. Volt has no equivalent.

A project that needs one rule relaxed in one directory must also install the npm oxlint.

Environment

  • :volt 0.17.11
  • :oxc 0.17.8
  • Elixir 1.20.4, Erlang/OTP 29

What already maps over

Everything else translates cleanly. Categories go through rules, and discovery is configurable:

config :volt, :lint,
  root: ".",
  sources: ["assets/js/**/*.js", "assets/colocated/dev/*/*/*.js"],
  ignore: ["assets/colocated/*/*/index.js"],
  plugins: [:typescript, :unicorn, :oxc],
  rules: %{"correctness" => :deny, "style" => :deny}

What is missing

Two cases come up in an ordinary Phoenix project.

Phoenix writes colocated hooks into a directory named after the module. The file name is a number and a hash. unicorn/filename-case flags every one of them, and the project cannot rename them.

The second case is a module that deliberately mirrors a third-party API. A helper around Element.closest/1 returns null on purpose. unicorn/no-null has to be off in that file and on everywhere else.

In .oxlintrc.json each of these is three lines:

"overrides": [
  {
    "files": ["assets/colocated/**/*.js"],
    "rules": { "unicorn/filename-case": "off" }
  }
]

With config :volt, :lint the only way to silence these is to turn the rule off everywhere. That also turns it off for the files that should keep it.

Expected

config :volt, :lint,
  rules: %{"correctness" => :deny},
  overrides: [
    %{
      files: ["assets/colocated/**/*.js"],
      rules: %{"unicorn/filename-case" => :allow}
    }
  ]

OXC.Lint.run/3 already takes rules per call. Volt builds the file list itself, so it could resolve the rules per file.

Related

env has the same shape in .oxlintrc.json and the same need. One build-time script may run in Node while everything else runs in a browser. Volt cannot express that either.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions