diff --git a/internal/core/format.go b/internal/core/format.go index d64b855be..5faf24bbe 100755 --- a/internal/core/format.go +++ b/internal/core/format.go @@ -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 @@ -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] diff --git a/testdata/features/lint.feature b/testdata/features/lint.feature index 185b04b59..02754ad56 100755 --- a/testdata/features/lint.feature +++ b/testdata/features/lint.feature @@ -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: diff --git a/testdata/fixtures/formats/test.nix b/testdata/fixtures/formats/test.nix new file mode 100644 index 000000000..2b0a4734b --- /dev/null +++ b/testdata/fixtures/formats/test.nix @@ -0,0 +1,30 @@ +{ pkgs ? import {} }: + +# 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"; +}