Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions internal/core/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ var CommentsByNormedExt = map[string]map[string]string{
"blockStart": `(\{-.*)`,
"blockEnd": `(.*-\})`,
},
".nix": {
"inline": `(#.+)`,
"blockStart": `(/\*.*)`,
"blockEnd": `(.*\*/)`,
},
}

// FormatByExtension associates a file extension with its "normed" extension
Expand Down Expand Up @@ -92,6 +97,7 @@ var FormatByExtension = map[string][]string{
`\.(?:yaml|yml)$`: {".yml", "data"},
`\.(?:json)$`: {".json", "data"},
`\.(?:toml)$`: {".toml", "data"},
`\.(?:nix)$`: {".nix", "code"},
}

// FormatFromExt takes a file extension and returns its [normExt, format]
Expand Down
10 changes: 10 additions & 0 deletions testdata/features/lint.feature
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@ Feature: Lint
test.proto:31:1:vale.Annotations:'NOTE' left in text
"""

Scenario: Lint a Nix file
When I lint "test.nix"
Then the output should contain exactly:
"""
test.nix:3:3:vale.Annotations:'NOTE' left in text
test.nix:7:5:vale.Annotations:'XXX' left in text
test.nix:10:6:vale.Annotations:'NOTE' left in text
test.nix:17:7:vale.Annotations:'TODO' left in text
"""

Scenario: Lint an Org file
When I lint "test.org"
Then the output should contain exactly:
Expand Down
30 changes: 30 additions & 0 deletions testdata/fixtures/formats/test.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{ pkgs ? import <nixpkgs> {} }:

# NOTE: This is a sample Nix configuration file
let
myVar = "hello world";

# XXX: This needs to be fixed later
brokenFunction = x: y: x + y + 1;

/* NOTE: Multi-line comment
that spans multiple lines
*/
myPackage = pkgs.stdenv.mkDerivation {
pname = "example";
version = "1.0.0";

# TODO: Add proper source
src = ./.;

buildPhase = ''
echo "Building..."
'';
};
in
{
inherit myPackage;

# should not match in code
xxx = "XXX";
}