From 3b5e19328fcf2594f33fc91a22f86442d643569a Mon Sep 17 00:00:00 2001 From: Lucas Garron Date: Tue, 12 Sep 2023 13:31:46 -0700 Subject: [PATCH] Add `biome` for JS formatting and linting. Note that this only covers the `script` directory, as https://github.com/cubing/icons/pull/112#issuecomment-1716382942 will remove the old build script. --- Makefile | 2 +- biome.json | 13 ++++ package-lock.json | 174 ++++++++++++++++++++++++++++++++++++++++++++++ package.json | 5 +- script/stub.js | 1 + 5 files changed, 193 insertions(+), 2 deletions(-) create mode 100644 biome.json create mode 100644 script/stub.js diff --git a/Makefile b/Makefile index 4718781..df71e78 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ # https://github.com/lgarron/Makefile-scripts # Note: the first command becomes the default `make` target. -NPM_COMMANDS = build watch dev version postversion +NPM_COMMANDS = build watch dev version postversion lint format .PHONY: $(NPM_COMMANDS) $(NPM_COMMANDS): diff --git a/biome.json b/biome.json new file mode 100644 index 0000000..450d2e0 --- /dev/null +++ b/biome.json @@ -0,0 +1,13 @@ +{ + "formatter": { + "indentStyle": "space", + "indentSize": 2 + }, + "linter": { + "enabled": true, + "rules": { + "recommended": true + } + } +} + diff --git a/package-lock.json b/package-lock.json index be2b6d3..899e4dd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,6 +12,7 @@ "@babel/core": "^7.10.5", "@babel/preset-env": "^7.10.4", "@babel/register": "^7.10.5", + "@biomejs/biome": "^1.1.2", "bufferstreams": "^3.0.0", "del": "^5.1.0", "gulp": "^4.0.2", @@ -1197,6 +1198,123 @@ "to-fast-properties": "^2.0.0" } }, + "node_modules/@biomejs/biome": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@biomejs/biome/-/biome-1.1.2.tgz", + "integrity": "sha512-JEVWchqo0Xhl86IJgOh0xESWnNRUXBUDByCBR8TA4lIPzm/6U6Tv77+MblNkZ8MvwCtP6PlBNGdQcGKKabtuHA==", + "dev": true, + "hasInstallScript": true, + "bin": { + "biome": "bin/biome" + }, + "engines": { + "node": ">=14.*" + }, + "optionalDependencies": { + "@biomejs/cli-darwin-arm64": "1.1.2", + "@biomejs/cli-darwin-x64": "1.1.2", + "@biomejs/cli-linux-arm64": "1.1.2", + "@biomejs/cli-linux-x64": "1.1.2", + "@biomejs/cli-win32-arm64": "1.1.2", + "@biomejs/cli-win32-x64": "1.1.2" + } + }, + "node_modules/@biomejs/cli-darwin-arm64": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@biomejs/cli-darwin-arm64/-/cli-darwin-arm64-1.1.2.tgz", + "integrity": "sha512-YyqWeNZchPxlvxtdo2vMBkzrwllaNS3+DZ6j01mUCVIZE9kAzF/edMV2O38L2AEtnRLU1TI1f71Jai3ThILClg==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=14.*" + } + }, + "node_modules/@biomejs/cli-darwin-x64": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@biomejs/cli-darwin-x64/-/cli-darwin-x64-1.1.2.tgz", + "integrity": "sha512-Sofxcu50AHJyQS6Xx3OF2egQQ7Un5YFVF5/umNFa+kSNrrCu/ucmzrk8FcGS2dOSs4L2LqD6ZDWjvbcikjzLYQ==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=14.*" + } + }, + "node_modules/@biomejs/cli-linux-arm64": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-arm64/-/cli-linux-arm64-1.1.2.tgz", + "integrity": "sha512-wtaQgpoVMZEKf1GlDlFGAJP1j6gnh4L4kJN8PQPOBAdKIUZ/YSjqVp0z28vli5xCQ57xCn1gH4Xoqw2gVYu1tQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=14.*" + } + }, + "node_modules/@biomejs/cli-linux-x64": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-x64/-/cli-linux-x64-1.1.2.tgz", + "integrity": "sha512-TYIUjCXbY+kxnJgv8GESplMagB1GdOcMV21JGRATqnhUI4BvG6sjs3gfi+sdjLBQdbHhsISXW3yfUlv07HKqhg==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=14.*" + } + }, + "node_modules/@biomejs/cli-win32-arm64": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@biomejs/cli-win32-arm64/-/cli-win32-arm64-1.1.2.tgz", + "integrity": "sha512-yApn85KuJ+Ty5zxbqWnaifX4ONtZG+snu12RNKi8fxSVVCXzQ/k2PfsWQbsyvCG05qshSvNKtM54cuf+vhUIsw==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=14.*" + } + }, + "node_modules/@biomejs/cli-win32-x64": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@biomejs/cli-win32-x64/-/cli-win32-x64-1.1.2.tgz", + "integrity": "sha512-qebNvIrFj2TJ+K0JVGo1HkgV2y5jis6aOZDC1SWuk53GnqjSLdR+p1v86ZByOjYr1v+tjc67EXmEepk06VVvpA==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=14.*" + } + }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.3.tgz", @@ -9776,6 +9894,62 @@ "to-fast-properties": "^2.0.0" } }, + "@biomejs/biome": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@biomejs/biome/-/biome-1.1.2.tgz", + "integrity": "sha512-JEVWchqo0Xhl86IJgOh0xESWnNRUXBUDByCBR8TA4lIPzm/6U6Tv77+MblNkZ8MvwCtP6PlBNGdQcGKKabtuHA==", + "dev": true, + "requires": { + "@biomejs/cli-darwin-arm64": "1.1.2", + "@biomejs/cli-darwin-x64": "1.1.2", + "@biomejs/cli-linux-arm64": "1.1.2", + "@biomejs/cli-linux-x64": "1.1.2", + "@biomejs/cli-win32-arm64": "1.1.2", + "@biomejs/cli-win32-x64": "1.1.2" + } + }, + "@biomejs/cli-darwin-arm64": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@biomejs/cli-darwin-arm64/-/cli-darwin-arm64-1.1.2.tgz", + "integrity": "sha512-YyqWeNZchPxlvxtdo2vMBkzrwllaNS3+DZ6j01mUCVIZE9kAzF/edMV2O38L2AEtnRLU1TI1f71Jai3ThILClg==", + "dev": true, + "optional": true + }, + "@biomejs/cli-darwin-x64": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@biomejs/cli-darwin-x64/-/cli-darwin-x64-1.1.2.tgz", + "integrity": "sha512-Sofxcu50AHJyQS6Xx3OF2egQQ7Un5YFVF5/umNFa+kSNrrCu/ucmzrk8FcGS2dOSs4L2LqD6ZDWjvbcikjzLYQ==", + "dev": true, + "optional": true + }, + "@biomejs/cli-linux-arm64": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-arm64/-/cli-linux-arm64-1.1.2.tgz", + "integrity": "sha512-wtaQgpoVMZEKf1GlDlFGAJP1j6gnh4L4kJN8PQPOBAdKIUZ/YSjqVp0z28vli5xCQ57xCn1gH4Xoqw2gVYu1tQ==", + "dev": true, + "optional": true + }, + "@biomejs/cli-linux-x64": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-x64/-/cli-linux-x64-1.1.2.tgz", + "integrity": "sha512-TYIUjCXbY+kxnJgv8GESplMagB1GdOcMV21JGRATqnhUI4BvG6sjs3gfi+sdjLBQdbHhsISXW3yfUlv07HKqhg==", + "dev": true, + "optional": true + }, + "@biomejs/cli-win32-arm64": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@biomejs/cli-win32-arm64/-/cli-win32-arm64-1.1.2.tgz", + "integrity": "sha512-yApn85KuJ+Ty5zxbqWnaifX4ONtZG+snu12RNKi8fxSVVCXzQ/k2PfsWQbsyvCG05qshSvNKtM54cuf+vhUIsw==", + "dev": true, + "optional": true + }, + "@biomejs/cli-win32-x64": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@biomejs/cli-win32-x64/-/cli-win32-x64-1.1.2.tgz", + "integrity": "sha512-qebNvIrFj2TJ+K0JVGo1HkgV2y5jis6aOZDC1SWuk53GnqjSLdR+p1v86ZByOjYr1v+tjc67EXmEepk06VVvpA==", + "dev": true, + "optional": true + }, "@nodelib/fs.scandir": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.3.tgz", diff --git a/package.json b/package.json index 60d5325..85fa7fb 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "@babel/core": "^7.10.5", "@babel/preset-env": "^7.10.4", "@babel/register": "^7.10.5", + "@biomejs/biome": "^1.1.2", "bufferstreams": "^3.0.0", "del": "^5.1.0", "gulp": "^4.0.2", @@ -22,7 +23,9 @@ "watch": "gulp watch", "dev": "npm run watch", "version": "npm run build", - "postversion": "git push --follow-tags git@github.com:cubing/icons.git HEAD:main && npm publish" + "postversion": "git push --follow-tags git@github.com:cubing/icons.git HEAD:main && npm publish", + "lint": "npx @biomejs/biome check ./script", + "format": "npx @biomejs/biome format --write ./script" }, "repository": { "type": "git", diff --git a/script/stub.js b/script/stub.js new file mode 100644 index 0000000..1e2e6f8 --- /dev/null +++ b/script/stub.js @@ -0,0 +1 @@ +// This is a stub until https://github.com/cubing/icons/pull/112 lands.