Skip to content

Commit

Permalink
update biome things
Browse files Browse the repository at this point in the history
  • Loading branch information
AugustinMauroy committed Nov 21, 2024
1 parent 558162d commit 0d9698c
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"recommendations": [
"biomejs.biome"
]
}
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"editor.formatOnSave": true,
"editor.defaultFormatter": "biomejs.biome",
"javascript.updateImportsOnFileMove.enabled": "always",
"typescript.updateImportsOnFileMove.enabled": "always"
}
8 changes: 8 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,11 @@ CI will run lint & type checking and all included test files against all PRs.
> snapshots will be generated with the file extension `.snap.cjs`.
New recipes are added under `./recipes` in their own folder, succinctly named for what it does. General-purpose recipes have simple names like `correct-ts-specifiers`. A suite of migrations has a name like `migrate from 18 to 20`, and more specific migrations are named like `migrate fs.readFile from 18 to 20`.


## Before pushign a commit

- Do `node --run lint:fix` to fix linting issues
- Do `node --run format:fix` to format code
- Do `node --run test:types` to check types
- Do `node --run test` to run tests (it's should pass 😃)
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

This repository contains codemodes (automated migrations) for "userland" code. These are intended to facilitate adopting new features and upgrading source-code affected by breaking changes.

[![Formatted with Biome](https://img.shields.io/badge/Formatted_with-Biome-60a5fa?style=flat&logo=biome)](https://biomejs.dev/) [![Linted with Biome](https://img.shields.io/badge/Linted_with-Biome-60a5fa?style=flat&logo=biome)](https://biomejs.dev) [![Checked with Biome](https://img.shields.io/badge/Checked_with-Biome-60a5fa?style=flat&logo=biome)](https://biomejs.dev)

## Usage

> [!CAUTION]
Expand Down
21 changes: 17 additions & 4 deletions biome.jsonc
Original file line number Diff line number Diff line change
@@ -1,23 +1,36 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"formatter": {
"indentStyle": "tab",
"lineWidth": 100
},
// Rules for the linter
"linter": {
"rules": {
"style": {
"useImportType": "error"
}
}
},
// Language specific settings
"javascript": {
"formatter": {
"semicolons": "always",
"quoteStyle": "single",
"trailingCommas": "all"
},
"linter": {
"style": {
"useImportType": true
}
}
"enabled": true
}
},
"json": {
"formatter": {
"enabled": false
}
},
// VSC specific settings
"vcs": {
"enabled": true,
"clientKind": "git"
}
}
11 changes: 5 additions & 6 deletions build/snapshots.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import { basename, dirname, extname, join } from 'node:path';
import { snapshot } from 'node:test';


snapshot.setResolveSnapshotPath(generateSnapshotPath);
/**
* @param testFilePath '/tmp/foo.test.js'
* @returns '/tmp/foo.test.snap.cjs'
*/
function generateSnapshotPath(testFilePath?: string) {
if (!testFilePath) return '';
if (!testFilePath) return '';

const ext = extname(testFilePath);
const filename = basename(testFilePath, ext);
const base = dirname(testFilePath);
const ext = extname(testFilePath);
const filename = basename(testFilePath, ext);
const base = dirname(testFilePath);

return join(base, `${filename}.snap.cjs`);
return join(base, `${filename}.snap.cjs`);
}
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
"description": "A collection of migration recipes for userland code.",
"scripts": {
"test:e2e": "node --no-warnings --experimental-test-coverage --test-reporter=lcov --test-reporter-destination=./coverage.lcov --test-reporter=spec --test-reporter-destination=stdout --import './build/snapshots.ts' --test --test-coverage-include='recipes/**/*' --test-coverage-exclude='**/*.e2e.m(j|t)s' './packages/*/*.e2e.m(j|t)s'",
"lint": "biome lint ./recipes",
"lint": "biome lint ./",
"lint:fix": "biome lint --fix ./",
"format": "biome format ./",
"format:fix": "biome format --fix ./",
"test:types": "tsc",
"test:unit": "node --no-warnings --experimental-test-coverage --test-reporter=lcov --test-reporter-destination=./coverage.lcov --test-reporter=spec --test-reporter-destination=stdout --experimental-test-module-mocks --import './build/snapshots.ts' --test --test-coverage-include='recipes/**/*' --test-coverage-exclude='**/*.spec.m(j|t)s' --test-coverage-lines=0.8 './packages/*/*.spec.m(j|t)s'"
},
Expand Down

0 comments on commit 0d9698c

Please sign in to comment.