diff --git a/.editorconfig b/.editorconfig index 961f8c5d4b..184babab9a 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,7 +1,9 @@ # https://editorconfig.org/#file-format-details +# top-most EditorConfig file root = true +[*] indent_style = space indent_size = 4 diff --git a/.vscode/settings.json b/.vscode/settings.json index 8e0bf5ca48..389908027d 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,14 +1,15 @@ { "editor.renderWhitespace": "boundary", + + "editor.defaultFormatter": "biomejs.biome", + "editor.formatOnSave": true, "editor.codeActionsOnSave": { - "source.fixAll": "explicit" + "quickfix.biome": "explicit" }, - "eslint.codeActionsOnSave.mode": "all", "files.trimTrailingWhitespace": true, - "todo-tree.filtering.excludeGlobs": [ - "**/dist/**", - ], - "typescript.format.enable": false, + + "todo-tree.filtering.excludeGlobs": ["**/dist/**"], + "typescript.validate.enable": true, "typescript.tsdk": "node_modules/typescript/lib", "typescript.tsserver.experimental.enableProjectDiagnostics": true, @@ -26,5 +27,5 @@ "typescript.inlayHints.parameterNames.enabled": "all", "typescript.inlayHints.parameterTypes.enabled": true, "typescript.inlayHints.propertyDeclarationTypes.enabled": true, - "typescript.inlayHints.variableTypes.enabled": true, -} \ No newline at end of file + "typescript.inlayHints.variableTypes.enabled": true +} diff --git a/biome.jsonc b/biome.jsonc new file mode 100644 index 0000000000..f05c1abb1e --- /dev/null +++ b/biome.jsonc @@ -0,0 +1,58 @@ +{ + "$schema": "https://biomejs.dev/schemas/1.9.4/schema.json", + "files": { + "ignoreUnknown": false, + "ignore": [ + "data/questions/", + "__genfiles__/", + "dist/", + "vendor/", + "storybook-static/", + "styles/khan-exercise.css" + ] + }, + "vcs": { + "clientKind": "git", + "useIgnoreFile": true + }, + "formatter": { + "enabled": true, + "useEditorconfig": true + }, + "organizeImports": { + "enabled": false + }, + "linter": { + "enabled": false, + "rules": { + "recommended": true + } + }, + "javascript": { + "formatter": { + "quoteStyle": "double", + "trailingCommas": "all", + + "bracketSpacing": false + } + }, + "overrides": [ + { + "include": [ + "tsconfig-build.json", + "tsconfig-common.json", + "tsconfig-shared.json", + "tsconfig.json" + ], + "json": { + "formatter": { + "trailingCommas": "all" + }, + "parser": { + "allowTrailingCommas": true, + "allowComments": true + } + } + } + ] +} diff --git a/config/test/log-on-fail-reporter.js b/config/test/log-on-fail-reporter.js index e7561e6b05..6e5d6159b8 100644 --- a/config/test/log-on-fail-reporter.js +++ b/config/test/log-on-fail-reporter.js @@ -22,7 +22,7 @@ class LogOnFailedTestReporter extends DefaultReporter { const testFailed = result.numFailingTests > 0; if (testFailed && consoleBuffer && consoleBuffer.length) { - // prettier-ignore + // biome-ignore format: keep these on the same line this.log( ` ${TITLE_BULLET}Console\n\n${getConsoleOutput( consoleBuffer, diff --git a/package.json b/package.json index 7daa76f1d3..89c34fb8d2 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "engines": { "node": ">=20" }, - "dependencies": { + "devDependencies": { "@babel/core": "^7.23.2", "@babel/eslint-parser": "^7.22.15", "@babel/eslint-plugin": "^7.22.10", @@ -22,6 +22,7 @@ "@babel/preset-env": "^7.23.2", "@babel/preset-react": "^7.22.12", "@babel/preset-typescript": "^7.23.2", + "@biomejs/biome": "1.9.4", "@changesets/changelog-github": "^0.4.8", "@changesets/cli": "^2.22.0", "@cypress/code-coverage": "^3.12.24", diff --git a/packages/perseus-linter/src/rule.ts b/packages/perseus-linter/src/rule.ts index 772745725d..d1efa910bb 100644 --- a/packages/perseus-linter/src/rule.ts +++ b/packages/perseus-linter/src/rule.ts @@ -164,7 +164,7 @@ type RuleCheckReturnType = // This is the return type of the lint detection function passed as the 4th // argument to the Rule() constructor. It can return null or a string or an // object containing a string and two numbers. -// prettier-ignore +// biome-ignore format: keep these on the same line // (prettier formats this in a way that ka-lint does not like) type LintTesterReturnType = string | { message: string, diff --git a/packages/perseus/src/perseus-types.ts b/packages/perseus/src/perseus-types.ts index 3b50bc88ad..dcae4cb78e 100644 --- a/packages/perseus/src/perseus-types.ts +++ b/packages/perseus/src/perseus-types.ts @@ -194,74 +194,77 @@ type WidgetOptions = { version?: Version; }; -// prettier-ignore +// biome-ignore format: keep these on the same line export type CategorizerWidget = WidgetOptions<'categorizer', PerseusCategorizerWidgetOptions>; -// prettier-ignore +// biome-ignore format: keep these on the same line export type CSProgramWidget = WidgetOptions<'cs-program', PerseusCSProgramWidgetOptions>; -// prettier-ignore +// biome-ignore format: keep these on the same line export type DefinitionWidget = WidgetOptions<'definition', PerseusDefinitionWidgetOptions>; -// prettier-ignore +// biome-ignore format: keep these on the same line export type DropdownWidget = WidgetOptions<'dropdown', PerseusDropdownWidgetOptions>; -// prettier-ignore +// biome-ignore format: keep these on the same line export type ExplanationWidget = WidgetOptions<'explanation', PerseusExplanationWidgetOptions>; -// prettier-ignore +// biome-ignore format: keep these on the same line export type ExpressionWidget = WidgetOptions<'expression', PerseusExpressionWidgetOptions>; -// prettier-ignore +// biome-ignore format: keep these on the same line export type GradedGroupSetWidget = WidgetOptions<'graded-group-set', PerseusGradedGroupSetWidgetOptions>; -// prettier-ignore +// biome-ignore format: keep these on the same line export type GradedGroupWidget = WidgetOptions<'graded-group', PerseusGradedGroupWidgetOptions>; -// prettier-ignore +// biome-ignore format: keep these on the same line export type GrapherWidget = WidgetOptions<'grapher', PerseusGrapherWidgetOptions>; -// prettier-ignore +// biome-ignore format: keep these on the same line export type GroupWidget = WidgetOptions<'group', PerseusGroupWidgetOptions>; -// prettier-ignore +// biome-ignore format: keep these on the same line export type IFrameWidget = WidgetOptions<'iframe', PerseusIFrameWidgetOptions>; -// prettier-ignore +// biome-ignore format: keep these on the same line export type ImageWidget = WidgetOptions<'image', PerseusImageWidgetOptions>; -// prettier-ignore +// biome-ignore format: keep these on the same line export type InteractionWidget = WidgetOptions<'interaction', PerseusInteractionWidgetOptions>; -// prettier-ignore +// biome-ignore format: keep these on the same line export type InteractiveGraphWidget = WidgetOptions<'interactive-graph', PerseusInteractiveGraphWidgetOptions>; -// prettier-ignore +// biome-ignore format: keep these on the same line export type LabelImageWidget = WidgetOptions<'label-image', PerseusLabelImageWidgetOptions>; -// prettier-ignore +// biome-ignore format: keep these on the same line export type MatcherWidget = WidgetOptions<'matcher', PerseusMatcherWidgetOptions>; -// prettier-ignore +// biome-ignore format: keep these on the same line export type MatrixWidget = WidgetOptions<'matrix', PerseusMatrixWidgetOptions>; -// prettier-ignore +// biome-ignore format: keep these on the same line export type MeasurerWidget = WidgetOptions<'measurer', PerseusMeasurerWidgetOptions>; -// prettier-ignore +// biome-ignore format: keep these on the same line export type NumberLineWidget = WidgetOptions<'number-line', PerseusNumberLineWidgetOptions>; -// prettier-ignore +// biome-ignore format: keep these on the same line export type NumericInputWidget = WidgetOptions<'numeric-input', PerseusNumericInputWidgetOptions>; -// prettier-ignore +// biome-ignore format: keep these on the same line export type OrdererWidget = WidgetOptions<'orderer', PerseusOrdererWidgetOptions>; -// prettier-ignore +// biome-ignore format: keep these on the same line export type PassageRefWidget = WidgetOptions<'passage-ref', PerseusPassageRefWidgetOptions>; -// prettier-ignore +// biome-ignore format: keep these on the same line export type PassageWidget = WidgetOptions<'passage', PerseusPassageWidgetOptions>; -// prettier-ignore +// biome-ignore format: keep these on the same line export type PhetSimulationWidget = WidgetOptions<'phet-simulation', PerseusPhetSimulationWidgetOptions>; -// prettier-ignore +// biome-ignore format: keep these on the same line export type PlotterWidget = WidgetOptions<'plotter', PerseusPlotterWidgetOptions>; -// prettier-ignore +// biome-ignore format: keep these on the same line export type PythonProgramWidget = WidgetOptions<'python-program', PerseusPythonProgramWidgetOptions>; -// prettier-ignore +// biome-ignore format: keep these on the same line export type RadioWidget = WidgetOptions<'radio', PerseusRadioWidgetOptions>; -// prettier-ignore +// biome-ignore format: keep these on the same line export type SorterWidget = WidgetOptions<'sorter', PerseusSorterWidgetOptions>; -// prettier-ignore +// biome-ignore format: keep these on the same line export type TableWidget = WidgetOptions<'table', PerseusTableWidgetOptions>; -// prettier-ignore +// biome-ignore format: keep these on the same line export type InputNumberWidget = WidgetOptions<'input-number', PerseusInputNumberWidgetOptions>; -// prettier-ignore +// biome-ignore format: keep these on the same line export type MoleculeRendererWidget = WidgetOptions<'molecule-renderer', PerseusMoleculeRendererWidgetOptions>; -// prettier-ignore +// biome-ignore format: keep these on the same line export type RefTargetWidget = WidgetOptions<'passage-ref-target', PerseusPassageRefTargetWidgetOptions>; -// prettier-ignore +// biome-ignore format: keep these on the same line export type VideoWidget = WidgetOptions<'video', PerseusVideoWidgetOptions>; //prettier-ignore -export type AutoCorrectWidget = WidgetOptions<'deprecated-standin', PerseusWidgetOptions>; +export type AutoCorrectWidget = WidgetOptions< + "deprecated-standin", + PerseusWidgetOptions +>; export type PerseusWidget = | CategorizerWidget diff --git a/packages/perseus/src/widgets/grapher/util.tsx b/packages/perseus/src/widgets/grapher/util.tsx index c077e438bd..ba9f96394a 100644 --- a/packages/perseus/src/widgets/grapher/util.tsx +++ b/packages/perseus/src/widgets/grapher/util.tsx @@ -635,7 +635,7 @@ export const allTypes: any = _.keys(functionTypeMapping); type FunctionTypeMappingKeys = keyof typeof functionTypeMapping; type ConditionalGraderType = - // prettier-ignore + // biome-ignore format: keep these on the same line T extends "linear" ? LinearType : T extends "quadratic" ? QuadraticType : T extends "sinusoid" ? SinusoidType diff --git a/yarn.lock b/yarn.lock index 49165c87f4..f8bface2d1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1452,6 +1452,60 @@ resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== +"@biomejs/biome@1.9.4": + version "1.9.4" + resolved "https://registry.yarnpkg.com/@biomejs/biome/-/biome-1.9.4.tgz#89766281cbc3a0aae865a7ff13d6aaffea2842bf" + integrity sha512-1rkd7G70+o9KkTn5KLmDYXihGoTaIGO9PIIN2ZB7UJxFrWw04CZHPYiMRjYsaDvVV7hP1dYNRLxSANLaBFGpog== + optionalDependencies: + "@biomejs/cli-darwin-arm64" "1.9.4" + "@biomejs/cli-darwin-x64" "1.9.4" + "@biomejs/cli-linux-arm64" "1.9.4" + "@biomejs/cli-linux-arm64-musl" "1.9.4" + "@biomejs/cli-linux-x64" "1.9.4" + "@biomejs/cli-linux-x64-musl" "1.9.4" + "@biomejs/cli-win32-arm64" "1.9.4" + "@biomejs/cli-win32-x64" "1.9.4" + +"@biomejs/cli-darwin-arm64@1.9.4": + version "1.9.4" + resolved "https://registry.yarnpkg.com/@biomejs/cli-darwin-arm64/-/cli-darwin-arm64-1.9.4.tgz#dfa376d23a54a2d8f17133c92f23c1bf2e62509f" + integrity sha512-bFBsPWrNvkdKrNCYeAp+xo2HecOGPAy9WyNyB/jKnnedgzl4W4Hb9ZMzYNbf8dMCGmUdSavlYHiR01QaYR58cw== + +"@biomejs/cli-darwin-x64@1.9.4": + version "1.9.4" + resolved "https://registry.yarnpkg.com/@biomejs/cli-darwin-x64/-/cli-darwin-x64-1.9.4.tgz#eafc2ce3849d385fc02238aad1ca4a73395a64d9" + integrity sha512-ngYBh/+bEedqkSevPVhLP4QfVPCpb+4BBe2p7Xs32dBgs7rh9nY2AIYUL6BgLw1JVXV8GlpKmb/hNiuIxfPfZg== + +"@biomejs/cli-linux-arm64-musl@1.9.4": + version "1.9.4" + resolved "https://registry.yarnpkg.com/@biomejs/cli-linux-arm64-musl/-/cli-linux-arm64-musl-1.9.4.tgz#d780c3e01758fc90f3268357e3f19163d1f84fca" + integrity sha512-v665Ct9WCRjGa8+kTr0CzApU0+XXtRgwmzIf1SeKSGAv+2scAlW6JR5PMFo6FzqqZ64Po79cKODKf3/AAmECqA== + +"@biomejs/cli-linux-arm64@1.9.4": + version "1.9.4" + resolved "https://registry.yarnpkg.com/@biomejs/cli-linux-arm64/-/cli-linux-arm64-1.9.4.tgz#8ed1dd0e89419a4b66a47f95aefb8c46ae6041c9" + integrity sha512-fJIW0+LYujdjUgJJuwesP4EjIBl/N/TcOX3IvIHJQNsAqvV2CHIogsmA94BPG6jZATS4Hi+xv4SkBBQSt1N4/g== + +"@biomejs/cli-linux-x64-musl@1.9.4": + version "1.9.4" + resolved "https://registry.yarnpkg.com/@biomejs/cli-linux-x64-musl/-/cli-linux-x64-musl-1.9.4.tgz#f36982b966bd671a36671e1de4417963d7db15fb" + integrity sha512-gEhi/jSBhZ2m6wjV530Yy8+fNqG8PAinM3oV7CyO+6c3CEh16Eizm21uHVsyVBEB6RIM8JHIl6AGYCv6Q6Q9Tg== + +"@biomejs/cli-linux-x64@1.9.4": + version "1.9.4" + resolved "https://registry.yarnpkg.com/@biomejs/cli-linux-x64/-/cli-linux-x64-1.9.4.tgz#a0a7f56680c76b8034ddc149dbf398bdd3a462e8" + integrity sha512-lRCJv/Vi3Vlwmbd6K+oQ0KhLHMAysN8lXoCI7XeHlxaajk06u7G+UsFSO01NAs5iYuWKmVZjmiOzJ0OJmGsMwg== + +"@biomejs/cli-win32-arm64@1.9.4": + version "1.9.4" + resolved "https://registry.yarnpkg.com/@biomejs/cli-win32-arm64/-/cli-win32-arm64-1.9.4.tgz#e2ef4e0084e76b7e26f0fc887c5ef1265ea56200" + integrity sha512-tlbhLk+WXZmgwoIKwHIHEBZUwxml7bRJgk0X2sPyNR3S93cdRq6XulAZRQJ17FYGGzWne0fgrXBKpl7l4M87Hg== + +"@biomejs/cli-win32-x64@1.9.4": + version "1.9.4" + resolved "https://registry.yarnpkg.com/@biomejs/cli-win32-x64/-/cli-win32-x64-1.9.4.tgz#4c7afa90e3970213599b4095e62f87e5972b2340" + integrity sha512-8Y5wMhVIPaWe6jw2H+KlEm4wP/f7EW3810ZLmDlrEEy5KvBsb9ECEfu/kMWD484ijfQ8+nIi0giMgu9g1UAuuA== + "@changesets/apply-release-plan@^6.0.0": version "6.0.0" resolved "https://registry.yarnpkg.com/@changesets/apply-release-plan/-/apply-release-plan-6.0.0.tgz#6c663ff99d919bba3902343d76c35cbbbb046520" @@ -15158,7 +15212,7 @@ string-length@^4.0.1: char-regex "^1.0.2" strip-ansi "^6.0.0" -"string-width-cjs@npm:string-width@^4.2.0", "string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.2, string-width@^4.2.3: +"string-width-cjs@npm:string-width@^4.2.0": version "4.2.3" resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== @@ -15176,6 +15230,15 @@ string-width@^1.0.1: is-fullwidth-code-point "^1.0.0" strip-ansi "^3.0.0" +"string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.2, string-width@^4.2.3: + version "4.2.3" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" + integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== + dependencies: + emoji-regex "^8.0.0" + is-fullwidth-code-point "^3.0.0" + strip-ansi "^6.0.1" + string-width@^5.0.1, string-width@^5.1.2: version "5.1.2" resolved "https://registry.yarnpkg.com/string-width/-/string-width-5.1.2.tgz#14f8daec6d81e7221d2a357e668cab73bdbca794" @@ -15260,7 +15323,7 @@ string_decoder@~1.1.1: dependencies: safe-buffer "~5.1.0" -"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1: +"strip-ansi-cjs@npm:strip-ansi@^6.0.1": version "6.0.1" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== @@ -15274,6 +15337,13 @@ strip-ansi@^3.0.0, strip-ansi@^3.0.1: dependencies: ansi-regex "^2.0.0" +strip-ansi@^6.0.0, strip-ansi@^6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" + integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== + dependencies: + ansi-regex "^5.0.1" + strip-ansi@^7.0.1: version "7.1.0" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45" @@ -16502,7 +16572,7 @@ wordwrap@^1.0.0: resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb" integrity sha512-gvVzJFlPycKc5dZN4yPkP8w7Dc37BtP1yczEneOb4uq34pXZcvrtRTmWV8W+Ume+XCxKgbjM+nevkyFPMybd4Q== -"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0: +"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0": version "7.0.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== @@ -16520,6 +16590,15 @@ wrap-ansi@^6.2.0: string-width "^4.1.0" strip-ansi "^6.0.0" +wrap-ansi@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" + integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== + dependencies: + ansi-styles "^4.0.0" + string-width "^4.1.0" + strip-ansi "^6.0.0" + wrap-ansi@^8.1.0: version "8.1.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214"