-
-
Notifications
You must be signed in to change notification settings - Fork 526
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
5,980 additions
and
418 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
//! Migrations for Biome v2 | ||
use crate::run_cli; | ||
use crate::snap_test::{assert_cli_snapshot, SnapshotPayload}; | ||
use biome_console::BufferConsole; | ||
use biome_fs::MemoryFileSystem; | ||
use bpaf::Args; | ||
use camino::Utf8Path; | ||
|
||
#[test] | ||
fn should_successfully_migrate_knip() { | ||
let mut fs = MemoryFileSystem::default(); | ||
let mut console = BufferConsole::default(); | ||
|
||
let configuration_path = Utf8Path::new("biome.json"); | ||
fs.insert( | ||
configuration_path.into(), | ||
r#"{ | ||
"$schema": "https://biomejs.dev/schemas/1.8.3/schema.json", | ||
"files": { | ||
"ignore": [ | ||
"**/dist", | ||
"**/tmp", | ||
"**/fixtures", | ||
"packages/knip/package.json", | ||
"packages/knip/vendor/bash-parser/index.js", | ||
"packages/docs/.astro" | ||
] | ||
}, | ||
"organizeImports": { | ||
"enabled": true | ||
}, | ||
"linter": { | ||
"enabled": true, | ||
"rules": { | ||
"recommended": true, | ||
"correctness": { | ||
"noUnusedVariables": "error", | ||
"noUnusedImports": "error" | ||
}, | ||
"complexity": { | ||
"useLiteralKeys": "off" | ||
}, | ||
"nursery": { | ||
"noRestrictedImports": { | ||
"level": "error", | ||
"options": { | ||
"paths": { | ||
"node:path": "Please use src/util/path.js instead.", | ||
"path": "Please use src/util/path.js instead." | ||
} | ||
} | ||
} | ||
}, | ||
"style": { | ||
"noParameterAssign": "off", | ||
"useNodeAssertStrict": "error" | ||
}, | ||
"suspicious": { | ||
"noConsoleLog": "error", | ||
"noExplicitAny": "off" | ||
} | ||
} | ||
}, | ||
"formatter": { | ||
"enabled": true, | ||
"lineWidth": 120, | ||
"indentStyle": "space", | ||
"formatWithErrors": true | ||
}, | ||
"javascript": { | ||
"formatter": { | ||
"quoteStyle": "single", | ||
"arrowParentheses": "asNeeded", | ||
"trailingCommas": "es5" | ||
} | ||
}, | ||
"json": { | ||
"formatter": { | ||
"lineWidth": 80 | ||
} | ||
}, | ||
"css": { | ||
"formatter": { | ||
"quoteStyle": "single" | ||
} | ||
}, | ||
"overrides": [ | ||
{ | ||
"include": ["*.astro"], | ||
"linter": { | ||
"rules": { | ||
"correctness": { | ||
"noUnusedVariables": "off", | ||
"noUnusedImports": "off" | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
"include": [ | ||
"packages/docs", | ||
"packages/knip/scripts", | ||
"packages/knip/src/cli.ts", | ||
"packages/knip/src/reporters", | ||
"packages/knip/src/util/cli-arguments.ts", | ||
"packages/knip/src/util/debug.ts" | ||
], | ||
"linter": { | ||
"rules": { | ||
"suspicious": { | ||
"noConsoleLog": "off" | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
"include": ["packages/knip/fixtures"], | ||
"organizeImports": { | ||
"enabled": false | ||
}, | ||
"linter": { | ||
"rules": { | ||
"correctness": { | ||
"noUnusedVariables": "off", | ||
"noUnusedImports": "off" | ||
}, | ||
"style": { | ||
"useImportType": "off" | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
"include": ["packages/knip/test/util/get-inputs-from-scripts.test.ts"], | ||
"formatter": { | ||
"lineWidth": 200 | ||
} | ||
} | ||
] | ||
}"# | ||
.as_bytes(), | ||
); | ||
|
||
let (fs, result) = run_cli( | ||
fs, | ||
&mut console, | ||
Args::from(["migrate", "--write"].as_slice()), | ||
); | ||
|
||
assert!(result.is_ok(), "run_cli returned {result:?}"); | ||
|
||
assert_cli_snapshot(SnapshotPayload::new( | ||
module_path!(), | ||
"should_successfully_migrate_knip", | ||
fs, | ||
console, | ||
result, | ||
)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
173 changes: 173 additions & 0 deletions
173
crates/biome_cli/tests/snapshots/main_cases_migrate_v2/should_successfully_migrate_knip.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,173 @@ | ||
--- | ||
source: crates/biome_cli/tests/snap_test.rs | ||
expression: redactor(content) | ||
snapshot_kind: text | ||
--- | ||
## `biome.json` | ||
|
||
```json | ||
{ | ||
"$schema": "https://biomejs.dev/schemas/1.8.3/schema.json", | ||
"files": { | ||
"includes": [ | ||
"**", | ||
"!**/dist", | ||
"!**/tmp", | ||
"!**/fixtures", | ||
"!**/packages/knip/package.json", | ||
"!**/packages/knip/vendor/bash-parser/index.js", | ||
"!**/packages/docs/.astro" | ||
] | ||
}, | ||
"organizeImports": { | ||
"enabled": true | ||
}, | ||
"linter": { | ||
"enabled": true, | ||
"rules": { | ||
"style": { | ||
"noParameterAssign": "off", | ||
"useNodeAssertStrict": "error", | ||
"useLiteralEnumMembers": "error", | ||
"noArguments": "error", | ||
"useShorthandFunctionType": "error", | ||
"useExportType": "error", | ||
"useDefaultParameterLast": "error", | ||
"noCommaOperator": "error", | ||
"useSingleVarDeclarator": "error", | ||
"useNodejsImportProtocol": "error", | ||
"useConst": "error", | ||
"noNonNullAssertion": "error", | ||
"noInferrableTypes": "error", | ||
"useExponentiationOperator": "error", | ||
"noUselessElse": "error", | ||
"useSelfClosingElements": "error", | ||
"useNumberNamespace": "error", | ||
"useAsConstAssertion": "error", | ||
"noUnusedTemplateLiteral": "error", | ||
"useNumericLiterals": "error", | ||
"useTemplate": "error", | ||
"useEnumInitializers": "error" | ||
}, | ||
"nursery": { | ||
"noRestrictedImports": { | ||
"level": "error", | ||
"options": { | ||
"paths": { | ||
"node:path": "Please use src/util/path.js instead.", | ||
"path": "Please use src/util/path.js instead." | ||
} | ||
} | ||
} | ||
}, | ||
"complexity": { | ||
"useLiteralKeys": "off" | ||
}, | ||
"suspicious": { | ||
"noConsole": { | ||
"level": "error", | ||
"options": { | ||
"allow": ["log"] | ||
} | ||
}, | ||
"noExplicitAny": "off" | ||
}, | ||
"correctness": { | ||
"noUnusedVariables": "error", | ||
"noUnusedImports": "error" | ||
} | ||
} | ||
}, | ||
"formatter": { | ||
"enabled": true, | ||
"lineWidth": 120, | ||
"indentStyle": "space", | ||
"formatWithErrors": true | ||
}, | ||
"javascript": { | ||
"formatter": { | ||
"quoteStyle": "single", | ||
"arrowParentheses": "asNeeded", | ||
"trailingCommas": "es5" | ||
} | ||
}, | ||
"json": { | ||
"formatter": { | ||
"lineWidth": 80 | ||
} | ||
}, | ||
"css": { | ||
"formatter": { | ||
"quoteStyle": "single" | ||
} | ||
}, | ||
"overrides": [ | ||
{ | ||
"includes": ["**/*.astro"], | ||
"linter": { | ||
"rules": { | ||
"correctness": { | ||
"noUnusedVariables": "off", | ||
"noUnusedImports": "off" | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
"includes": [ | ||
"**/packages/docs/**", | ||
"**/packages/knip/scripts/**", | ||
"**/packages/knip/src/cli.ts", | ||
"**/packages/knip/src/reporters/**", | ||
"**/packages/knip/src/util/cli-arguments.ts", | ||
"**/packages/knip/src/util/debug.ts" | ||
], | ||
"linter": { | ||
"rules": { | ||
"suspicious": { | ||
"noConsole": { | ||
"level": "off", | ||
"options": { | ||
"allow": ["log"] | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
"includes": ["**/packages/knip/fixtures/**"], | ||
"assist": { | ||
"source": { | ||
"organizeImports": "off" | ||
} | ||
}, | ||
"linter": { | ||
"rules": { | ||
"correctness": { | ||
"noUnusedVariables": "off", | ||
"noUnusedImports": "off" | ||
}, | ||
"style": { | ||
"useImportType": "off" | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
"includes": [ | ||
"**/packages/knip/test/util/get-inputs-from-scripts.test.ts" | ||
], | ||
"formatter": { | ||
"lineWidth": 200 | ||
} | ||
} | ||
] | ||
} | ||
``` | ||
|
||
# Emitted Messages | ||
|
||
```block | ||
The configuration biome.json has been successfully migrated. | ||
``` |
Oops, something went wrong.