Merge pull request #1939 from umap-project/from-prettier-to-biome

chore: setup Biome to replace Prettier
This commit is contained in:
David Larlet 2024-06-25 16:04:10 -04:00 committed by GitHub
commit d9d39778e7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 274 additions and 27 deletions

View file

@ -86,8 +86,8 @@ tx_pull:
jsdir = umap/static/umap/js/ jsdir = umap/static/umap/js/
filepath = "${jsdir}*.js" filepath = "${jsdir}*.js"
.PHONY: pretty .PHONY: pretty
pretty: ## Apply PrettierJS to all JS files (or specified `filepath`) pretty: ## Apply Biome to all JS files (or specified `jsdir`)
./node_modules/prettier/bin-prettier.js --write ${filepath} ./node_modules/@biomejs/biome/bin/biome check --write ${jsdir}
.PHONY: lebab .PHONY: lebab
lebab: ## Convert JS `filepath` to modern syntax with Lebab, then prettify lebab: ## Convert JS `filepath` to modern syntax with Lebab, then prettify

41
biome.json Normal file
View file

@ -0,0 +1,41 @@
{
"formatter": {
"enabled": true,
"formatWithErrors": false,
"ignore": [],
"attributePosition": "auto",
"indentStyle": "space",
"indentWidth": 2,
"lineEnding": "lf",
"lineWidth": 88
},
"linter": {
"enabled": true,
"rules": {
"style": {
"useBlockStatements": "warn",
"noShoutyConstants": "warn"
}
}
},
"javascript": {
"formatter": {
"arrowParentheses":"always",
"bracketSameLine": false,
"bracketSpacing": true,
"jsxQuoteStyle": "double",
"quoteProperties": "asNeeded",
"quoteStyle": "single",
"semicolons": "asNeeded",
"trailingCommas": "es5"
}
},
"json": {
"formatter": {
"trailingCommas": "none"
}
},
"organizeImports": {
"enabled": true
}
}

View file

@ -33,7 +33,7 @@ make develop
For JavaScript, here is the tooling we use: For JavaScript, here is the tooling we use:
- Format your code with [Prettier](https://prettier.io/) - Format your code with [Biome](https://biomejs.dev/)
- Be sure to configure your editor to insert new lines at the end of files. - Be sure to configure your editor to insert new lines at the end of files.
### Hack! ### Hack!

250
package-lock.json generated
View file

@ -39,6 +39,7 @@
"tokml": "0.4.0" "tokml": "0.4.0"
}, },
"devDependencies": { "devDependencies": {
"@biomejs/biome": "1.8.2",
"chai": "^3.3.0", "chai": "^3.3.0",
"eslint": "^8.56.0", "eslint": "^8.56.0",
"eslint-plugin-compat": "^4.2.0", "eslint-plugin-compat": "^4.2.0",
@ -47,7 +48,6 @@
"lebab": "^3.2.1", "lebab": "^3.2.1",
"mocha": "^10.3.0", "mocha": "^10.3.0",
"optimist": "~0.4.0", "optimist": "~0.4.0",
"prettier": "^2.8.8",
"sinon": "^15.1.0", "sinon": "^15.1.0",
"uglify-js": "~3.17.4" "uglify-js": "~3.17.4"
} }
@ -492,6 +492,161 @@
"node": ">=6.9.0" "node": ">=6.9.0"
} }
}, },
"node_modules/@biomejs/biome": {
"version": "1.8.2",
"resolved": "https://registry.npmjs.org/@biomejs/biome/-/biome-1.8.2.tgz",
"integrity": "sha512-XafCzLgs0xbH0bCjYKxQ63ig2V86fZQMq1jiy5pyLToWk9aHxA8GAUxyBtklPHtPYZPGEPOYglQHj4jyfUp+Iw==",
"dev": true,
"hasInstallScript": true,
"bin": {
"biome": "bin/biome"
},
"engines": {
"node": ">=14.21.3"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/biome"
},
"optionalDependencies": {
"@biomejs/cli-darwin-arm64": "1.8.2",
"@biomejs/cli-darwin-x64": "1.8.2",
"@biomejs/cli-linux-arm64": "1.8.2",
"@biomejs/cli-linux-arm64-musl": "1.8.2",
"@biomejs/cli-linux-x64": "1.8.2",
"@biomejs/cli-linux-x64-musl": "1.8.2",
"@biomejs/cli-win32-arm64": "1.8.2",
"@biomejs/cli-win32-x64": "1.8.2"
}
},
"node_modules/@biomejs/cli-darwin-arm64": {
"version": "1.8.2",
"resolved": "https://registry.npmjs.org/@biomejs/cli-darwin-arm64/-/cli-darwin-arm64-1.8.2.tgz",
"integrity": "sha512-l9msLsTcSIAPqMsPIhodQmb50sEfaXPLQ0YW4cdj6INmd8iaOh/V9NceQb2366vACTJgcWDQ2RzlvURek1T68g==",
"cpu": [
"arm64"
],
"dev": true,
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">=14.21.3"
}
},
"node_modules/@biomejs/cli-darwin-x64": {
"version": "1.8.2",
"resolved": "https://registry.npmjs.org/@biomejs/cli-darwin-x64/-/cli-darwin-x64-1.8.2.tgz",
"integrity": "sha512-Fc4y/FuIxRSiB3TJ+y27vFDE/HJt4QgBuymktsIKEcBZvnKfsRjxvzVDunccRn4xbKgepnp+fn6BoS+ZIg/I3Q==",
"cpu": [
"x64"
],
"dev": true,
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">=14.21.3"
}
},
"node_modules/@biomejs/cli-linux-arm64": {
"version": "1.8.2",
"resolved": "https://registry.npmjs.org/@biomejs/cli-linux-arm64/-/cli-linux-arm64-1.8.2.tgz",
"integrity": "sha512-Q99qwP0qibkZxm2kfnt37OxeIlliDYf5ogi3zX9ij2DULzc+KtPA9Uj0wCljcJofOBsBYaHc7597Q+Bf/251ww==",
"cpu": [
"arm64"
],
"dev": true,
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=14.21.3"
}
},
"node_modules/@biomejs/cli-linux-arm64-musl": {
"version": "1.8.2",
"resolved": "https://registry.npmjs.org/@biomejs/cli-linux-arm64-musl/-/cli-linux-arm64-musl-1.8.2.tgz",
"integrity": "sha512-WpT41QJJvkZa1eZq0WmD513zkC6AYaMI39HJKmKeiUeX2NZirG+bxv1YRDhqkns1NbBqo3+qrJqBkPmOW+xAVA==",
"cpu": [
"arm64"
],
"dev": true,
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=14.21.3"
}
},
"node_modules/@biomejs/cli-linux-x64": {
"version": "1.8.2",
"resolved": "https://registry.npmjs.org/@biomejs/cli-linux-x64/-/cli-linux-x64-1.8.2.tgz",
"integrity": "sha512-bjhhUVFchFid2gOjrvBe4fg8BShcpyFQTHuB/QQnfGxs1ddrGP30yq3fHfc6S6MoCcz9Tjd3Zzq1EfWfyy5iHA==",
"cpu": [
"x64"
],
"dev": true,
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=14.21.3"
}
},
"node_modules/@biomejs/cli-linux-x64-musl": {
"version": "1.8.2",
"resolved": "https://registry.npmjs.org/@biomejs/cli-linux-x64-musl/-/cli-linux-x64-musl-1.8.2.tgz",
"integrity": "sha512-rk1Wj4d3LIlAlIAS1m2jlyfOjkNbuY1lfwKvWIAeZC51yDMzwhRD7cReE5PE+jqLDtq60PX38hDPeKd7nA1S6A==",
"cpu": [
"x64"
],
"dev": true,
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=14.21.3"
}
},
"node_modules/@biomejs/cli-win32-arm64": {
"version": "1.8.2",
"resolved": "https://registry.npmjs.org/@biomejs/cli-win32-arm64/-/cli-win32-arm64-1.8.2.tgz",
"integrity": "sha512-EUbqmCmNWT5xhnxHrCAEBzJB1AnLqxTYoRjlxiCMzGvsy5jQzhCanJ8CT9kNsApW3pfPWBWkoTa7qrwWmwnEGA==",
"cpu": [
"arm64"
],
"dev": true,
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">=14.21.3"
}
},
"node_modules/@biomejs/cli-win32-x64": {
"version": "1.8.2",
"resolved": "https://registry.npmjs.org/@biomejs/cli-win32-x64/-/cli-win32-x64-1.8.2.tgz",
"integrity": "sha512-n9H5oRUCk1uNezMgyJh9+hZdtfD8PXLLeq8DUzTycIhl0I1BulIoZ/uxWgRVDFDwAR1JHu1AykISCRFNGnc4iA==",
"cpu": [
"x64"
],
"dev": true,
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">=14.21.3"
}
},
"node_modules/@eslint-community/eslint-utils": { "node_modules/@eslint-community/eslint-utils": {
"version": "4.4.0", "version": "4.4.0",
"resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz",
@ -3525,21 +3680,6 @@
"node": ">= 0.8.0" "node": ">= 0.8.0"
} }
}, },
"node_modules/prettier": {
"version": "2.8.8",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.8.tgz",
"integrity": "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==",
"dev": true,
"bin": {
"prettier": "bin-prettier.js"
},
"engines": {
"node": ">=10.13.0"
},
"funding": {
"url": "https://github.com/prettier/prettier?sponsor=1"
}
},
"node_modules/process-nextick-args": { "node_modules/process-nextick-args": {
"version": "1.0.7", "version": "1.0.7",
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz",
@ -4909,6 +5049,78 @@
"to-fast-properties": "^2.0.0" "to-fast-properties": "^2.0.0"
} }
}, },
"@biomejs/biome": {
"version": "1.8.2",
"resolved": "https://registry.npmjs.org/@biomejs/biome/-/biome-1.8.2.tgz",
"integrity": "sha512-XafCzLgs0xbH0bCjYKxQ63ig2V86fZQMq1jiy5pyLToWk9aHxA8GAUxyBtklPHtPYZPGEPOYglQHj4jyfUp+Iw==",
"dev": true,
"requires": {
"@biomejs/cli-darwin-arm64": "1.8.2",
"@biomejs/cli-darwin-x64": "1.8.2",
"@biomejs/cli-linux-arm64": "1.8.2",
"@biomejs/cli-linux-arm64-musl": "1.8.2",
"@biomejs/cli-linux-x64": "1.8.2",
"@biomejs/cli-linux-x64-musl": "1.8.2",
"@biomejs/cli-win32-arm64": "1.8.2",
"@biomejs/cli-win32-x64": "1.8.2"
}
},
"@biomejs/cli-darwin-arm64": {
"version": "1.8.2",
"resolved": "https://registry.npmjs.org/@biomejs/cli-darwin-arm64/-/cli-darwin-arm64-1.8.2.tgz",
"integrity": "sha512-l9msLsTcSIAPqMsPIhodQmb50sEfaXPLQ0YW4cdj6INmd8iaOh/V9NceQb2366vACTJgcWDQ2RzlvURek1T68g==",
"dev": true,
"optional": true
},
"@biomejs/cli-darwin-x64": {
"version": "1.8.2",
"resolved": "https://registry.npmjs.org/@biomejs/cli-darwin-x64/-/cli-darwin-x64-1.8.2.tgz",
"integrity": "sha512-Fc4y/FuIxRSiB3TJ+y27vFDE/HJt4QgBuymktsIKEcBZvnKfsRjxvzVDunccRn4xbKgepnp+fn6BoS+ZIg/I3Q==",
"dev": true,
"optional": true
},
"@biomejs/cli-linux-arm64": {
"version": "1.8.2",
"resolved": "https://registry.npmjs.org/@biomejs/cli-linux-arm64/-/cli-linux-arm64-1.8.2.tgz",
"integrity": "sha512-Q99qwP0qibkZxm2kfnt37OxeIlliDYf5ogi3zX9ij2DULzc+KtPA9Uj0wCljcJofOBsBYaHc7597Q+Bf/251ww==",
"dev": true,
"optional": true
},
"@biomejs/cli-linux-arm64-musl": {
"version": "1.8.2",
"resolved": "https://registry.npmjs.org/@biomejs/cli-linux-arm64-musl/-/cli-linux-arm64-musl-1.8.2.tgz",
"integrity": "sha512-WpT41QJJvkZa1eZq0WmD513zkC6AYaMI39HJKmKeiUeX2NZirG+bxv1YRDhqkns1NbBqo3+qrJqBkPmOW+xAVA==",
"dev": true,
"optional": true
},
"@biomejs/cli-linux-x64": {
"version": "1.8.2",
"resolved": "https://registry.npmjs.org/@biomejs/cli-linux-x64/-/cli-linux-x64-1.8.2.tgz",
"integrity": "sha512-bjhhUVFchFid2gOjrvBe4fg8BShcpyFQTHuB/QQnfGxs1ddrGP30yq3fHfc6S6MoCcz9Tjd3Zzq1EfWfyy5iHA==",
"dev": true,
"optional": true
},
"@biomejs/cli-linux-x64-musl": {
"version": "1.8.2",
"resolved": "https://registry.npmjs.org/@biomejs/cli-linux-x64-musl/-/cli-linux-x64-musl-1.8.2.tgz",
"integrity": "sha512-rk1Wj4d3LIlAlIAS1m2jlyfOjkNbuY1lfwKvWIAeZC51yDMzwhRD7cReE5PE+jqLDtq60PX38hDPeKd7nA1S6A==",
"dev": true,
"optional": true
},
"@biomejs/cli-win32-arm64": {
"version": "1.8.2",
"resolved": "https://registry.npmjs.org/@biomejs/cli-win32-arm64/-/cli-win32-arm64-1.8.2.tgz",
"integrity": "sha512-EUbqmCmNWT5xhnxHrCAEBzJB1AnLqxTYoRjlxiCMzGvsy5jQzhCanJ8CT9kNsApW3pfPWBWkoTa7qrwWmwnEGA==",
"dev": true,
"optional": true
},
"@biomejs/cli-win32-x64": {
"version": "1.8.2",
"resolved": "https://registry.npmjs.org/@biomejs/cli-win32-x64/-/cli-win32-x64-1.8.2.tgz",
"integrity": "sha512-n9H5oRUCk1uNezMgyJh9+hZdtfD8PXLLeq8DUzTycIhl0I1BulIoZ/uxWgRVDFDwAR1JHu1AykISCRFNGnc4iA==",
"dev": true,
"optional": true
},
"@eslint-community/eslint-utils": { "@eslint-community/eslint-utils": {
"version": "4.4.0", "version": "4.4.0",
"resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz",
@ -7237,12 +7449,6 @@
"integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==",
"dev": true "dev": true
}, },
"prettier": {
"version": "2.8.8",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.8.tgz",
"integrity": "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==",
"dev": true
},
"process-nextick-args": { "process-nextick-args": {
"version": "1.0.7", "version": "1.0.7",
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz",

View file

@ -7,6 +7,7 @@
"test": "test" "test": "test"
}, },
"devDependencies": { "devDependencies": {
"@biomejs/biome": "1.8.2",
"chai": "^3.3.0", "chai": "^3.3.0",
"eslint": "^8.56.0", "eslint": "^8.56.0",
"eslint-plugin-compat": "^4.2.0", "eslint-plugin-compat": "^4.2.0",
@ -15,7 +16,6 @@
"lebab": "^3.2.1", "lebab": "^3.2.1",
"mocha": "^10.3.0", "mocha": "^10.3.0",
"optimist": "~0.4.0", "optimist": "~0.4.0",
"prettier": "^2.8.8",
"sinon": "^15.1.0", "sinon": "^15.1.0",
"uglify-js": "~3.17.4" "uglify-js": "~3.17.4"
}, },

View file

@ -9,7 +9,7 @@ from rjsmin import jsmin
class UmapManifestStaticFilesStorage(ManifestStaticFilesStorage): class UmapManifestStaticFilesStorage(ManifestStaticFilesStorage):
support_js_module_import_aggregation = True support_js_module_import_aggregation = True
# We remove `;` at the end of all regexps to match our prettier config. # We remove `;` at the end of all regexps to match our biome config.
_js_module_import_aggregation_patterns = ( _js_module_import_aggregation_patterns = (
"*.js", "*.js",
( (