Skip to content

Commit 6fb82e4

Browse files
authored
Merge pull request #432 from oxcabe/fix/biome-rome-confusion
feat: create "biome" hook, preserve "rome" hook as alias
2 parents 8e1b839 + 9052a48 commit 6fb82e4

File tree

2 files changed

+60
-51
lines changed

2 files changed

+60
-51
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -208,10 +208,11 @@ clang-format supports.
208208

209209
### JavaScript/TypeScript
210210

211+
- [biome](https://biomejs.dev/)
211212
- denofmt: Runs `deno fmt`
212213
- denolint: Runs `deno lint`
213214
- [eslint](https://github.com/eslint/eslint)
214-
- [rome](https://github.com/rome/tools)
215+
- rome: (alias to the biome hook)
215216

216217
### Python
217218

modules/hooks.nix

+58-50
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,11 @@ in
4545
"vale" = [ "configPath" "flags" ];
4646
"yamllint" = [ "configPath" ];
4747
})
48+
# Rename `rome` hook to `biome`, since `biome` was being used in both hooks
49+
++ [ (mkRenamedOptionModule [ "settings" "rome" ] [ "hooks" "biome" "settings" ]) ]
4850
# Rename the remaining `settings.<name>` to `hooks.<name>.settings`
4951
++ map (name: mkRenamedOptionModule [ "settings" name ] [ "hooks" name "settings" ])
50-
[ "ansible-lint" "autoflake" "clippy" "cmake-format" "credo" "deadnix" "denofmt" "denolint" "dune-fmt" "eslint" "flake8" "headache" "hlint" "hpack" "isort" "latexindent" "lychee" "mkdocs-linkcheck" "mypy" "nixfmt" "ormolu" "php-cs-fixer" "phpcbf" "phpcs" "phpstan" "prettier" "psalm" "pylint" "pyright" "pyupgrade" "revive" "rome" "statix" ];
52+
[ "ansible-lint" "autoflake" "biome" "clippy" "cmake-format" "credo" "deadnix" "denofmt" "denolint" "dune-fmt" "eslint" "flake8" "headache" "hlint" "hpack" "isort" "latexindent" "lychee" "mkdocs-linkcheck" "mypy" "nixfmt" "ormolu" "php-cs-fixer" "phpcbf" "phpcs" "phpstan" "prettier" "psalm" "pylint" "pyright" "pyupgrade" "revive" "statix" ];
5153

5254
options.hookModule = lib.mkOption {
5355
type = types.deferredModule;
@@ -155,6 +157,36 @@ in
155157
};
156158
};
157159
};
160+
biome = mkOption {
161+
description = lib.mdDoc "biome hook";
162+
type = types.submodule {
163+
imports = [ hookModule ];
164+
options.settings = {
165+
binPath =
166+
mkOption {
167+
type = types.nullOr types.path;
168+
description = lib.mdDoc "`biome` binary path. E.g. if you want to use the `biome` in `node_modules`, use `./node_modules/.bin/biome`.";
169+
default = null;
170+
defaultText = "\${tools.biome}/bin/biome";
171+
};
172+
173+
write =
174+
mkOption {
175+
type = types.bool;
176+
description = lib.mdDoc "Whether to edit files inplace.";
177+
default = true;
178+
};
179+
180+
configPath = mkOption {
181+
type = types.str;
182+
description = lib.mdDoc "Path to the configuration JSON file";
183+
# an empty string translates to use default configuration of the
184+
# underlying biome binary (i.e biome.json if exists)
185+
default = "";
186+
};
187+
};
188+
};
189+
};
158190
black = mkOption {
159191
description = lib.mdDoc "black hook";
160192
type = types.submodule {
@@ -1292,36 +1324,6 @@ in
12921324
};
12931325
};
12941326
};
1295-
rome = mkOption {
1296-
description = lib.mdDoc "rome hook";
1297-
type = types.submodule {
1298-
imports = [ hookModule ];
1299-
options.settings = {
1300-
binPath =
1301-
mkOption {
1302-
type = types.nullOr types.path;
1303-
description = lib.mdDoc "`rome` binary path. E.g. if you want to use the `rome` in `node_modules`, use `./node_modules/.bin/rome`.";
1304-
default = null;
1305-
defaultText = "\${tools.biome}/bin/biome";
1306-
};
1307-
1308-
write =
1309-
mkOption {
1310-
type = types.bool;
1311-
description = lib.mdDoc "Whether to edit files inplace.";
1312-
default = true;
1313-
};
1314-
1315-
configPath = mkOption {
1316-
type = types.str;
1317-
description = lib.mdDoc "Path to the configuration JSON file";
1318-
# an empty string translates to use default configuration of the
1319-
# underlying rome binary (i.e rome.json if exists)
1320-
default = "";
1321-
};
1322-
};
1323-
};
1324-
};
13251327
rustfmt = mkOption {
13261328
description = lib.mdDoc ''
13271329
Additional rustfmt settings
@@ -1656,9 +1658,14 @@ in
16561658
};
16571659
};
16581660

1661+
config.warnings =
1662+
lib.optional cfg.hooks.rome.enable ''
1663+
The hook `hooks.rome` has been renamed to `hooks.biome`.
1664+
'';
1665+
16591666
# PLEASE keep this sorted alphabetically.
16601667
config.hooks = mapAttrs (_: mapAttrs (_: mkDefault))
1661-
{
1668+
rec {
16621669
actionlint =
16631670
{
16641671
name = "actionlint";
@@ -1722,6 +1729,24 @@ in
17221729
"${binPath} ${hooks.autoflake.settings.flags}";
17231730
types = [ "python" ];
17241731
};
1732+
biome =
1733+
{
1734+
name = "biome";
1735+
description = "A toolchain for web projects, aimed to provide functionalities to maintain them";
1736+
types_or = [ "javascript" "jsx" "ts" "tsx" "json" ];
1737+
1738+
package = tools.biome;
1739+
entry =
1740+
let
1741+
binPath = migrateBinPathToPackage hooks.biome "/bin/biome";
1742+
cmdArgs =
1743+
mkCmdArgs [
1744+
[ (hooks.biome.settings.write) "--apply" ]
1745+
[ (hooks.biome.settings.configPath != "") "--config-path ${hooks.biome.settings.configPath}" ]
1746+
];
1747+
in
1748+
"${binPath} check ${cmdArgs}";
1749+
};
17251750
bats =
17261751
{
17271752
name = "bats";
@@ -3086,24 +3111,7 @@ lib.escapeShellArgs (lib.concatMap (ext: [ "--ghc-opt" "-X${ext}" ]) hooks.ormol
30863111
"${hooks.ripsecrets.package}/bin/ripsecrets ${cmdArgs}";
30873112
types = [ "text" ];
30883113
};
3089-
rome =
3090-
{
3091-
name = "rome";
3092-
description = "Unified developer tools for JavaScript, TypeScript, and the web";
3093-
types_or = [ "javascript" "jsx" "ts" "tsx" "json" ];
3094-
3095-
package = tools.biome;
3096-
entry =
3097-
let
3098-
binPath = migrateBinPathToPackage hooks.rome "/bin/biome";
3099-
cmdArgs =
3100-
mkCmdArgs [
3101-
[ (hooks.rome.settings.write) "--apply" ]
3102-
[ (hooks.rome.settings.configPath != "") "--config-path ${hooks.rome.settings.configPath}" ]
3103-
];
3104-
in
3105-
"${binPath} check ${cmdArgs}";
3106-
};
3114+
rome = biome;
31073115
ruff =
31083116
{
31093117
name = "ruff";

0 commit comments

Comments
 (0)