Skip to content

Commit

Permalink
chore: add biome to sort imports and format code (#712)
Browse files Browse the repository at this point in the history
* Format with Biome

* fix broken files

* fix one more broken file

* how did I break so many files

---------

Co-authored-by: Princesseuh <[email protected]>
  • Loading branch information
ematipico and Princesseuh authored Feb 8, 2024
1 parent 12ed6dc commit 7cc3dc1
Show file tree
Hide file tree
Showing 36 changed files with 431 additions and 363 deletions.
56 changes: 28 additions & 28 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
module.exports = {
parser: '@typescript-eslint/parser',
extends: ['plugin:@typescript-eslint/recommended', 'prettier'],
plugins: ['@typescript-eslint', 'prettier'],
rules: {
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/camelcase': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/no-this-alias': 'off',
'no-console': ['error', { allow: ['warn', 'error', 'info'] }],
'no-shadow': 'off',
'@typescript-eslint/no-shadow': ['error'],
'prefer-const': 'off',
// 'require-jsdoc': 'error', // re-enable this to enforce JSDoc for all functions
},
overrides: [
{
files: ['**/scripts/**', '**/bin/**'],
rules: {
'no-console': 'off',
},
},
],
parser: '@typescript-eslint/parser',
extends: ['plugin:@typescript-eslint/recommended', 'prettier'],
plugins: ['@typescript-eslint', 'prettier'],
rules: {
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/camelcase': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/no-this-alias': 'off',
'no-console': ['error', { allow: ['warn', 'error', 'info'] }],
'no-shadow': 'off',
'@typescript-eslint/no-shadow': ['error'],
'prefer-const': 'off',
// 'require-jsdoc': 'error', // re-enable this to enforce JSDoc for all functions
},
overrides: [
{
files: ['**/scripts/**', '**/bin/**'],
rules: {
'no-console': 'off',
},
},
],
};
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ package-lock.json
*.vsix
packages/vscode/meta.json
.tool-versions

.idea/
.zed
# .vscode files other than at top-level
**/.vscode

Expand Down
9 changes: 9 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,13 @@
**/.vscode-test
.github
.changeset
.idea/
pnpm-lock.yaml


*.js
*.ts
*.mjs
*.cjs
*.json
*.jsonc
16 changes: 0 additions & 16 deletions .prettierrc.json

This file was deleted.

38 changes: 38 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
"files": {
"ignore": [
"**/dist/**/*",
"**/node_modules/**/*",
"**/fixtures/**/*",
"**/.vscode-test/**/*",
".github",
".changeset",
".idea/"
],
"ignoreUnknown": true
},
"formatter": {
"lineWidth": 100
},
"javascript": {
"formatter": {
"quoteStyle": "single",
"trailingComma": "es5"
}
},
"json": {
"formatter": {
"indentStyle": "space"
},
"parser": {
"allowComments": true
}
},
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": false
}
}
22 changes: 10 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,21 @@
"dev": "turbo run dev --filter=\"@astrojs/**\" --filter=\"astro-vscode\" --parallel --no-cache",
"test": "turbo run test --filter=\"@astrojs/**\" --filter=astro-vscode",
"test:skip-vs": "turbo run test --filter=\"@astrojs/language-server\" --filter=\"@astrojs/check\"",
"format": "pnpm run format:code",
"format:ci": "pnpm run format:imports && pnpm run format:code",
"format:code": "prettier -w . --cache",
"format:imports": "organize-imports-cli ./packages/*/tsconfig.json",
"format:ci": "pnpm run format",
"format": "biome check --apply ./ && prettier -w \"**/*\" --ignore-unknown --cache",
"lint": "eslint . --ext .js,.ts,.mjs,.cjs"
},
"devDependencies": {
"@biomejs/biome": "1.5.3",
"@changesets/cli": "^2.26.1",
"@typescript-eslint/eslint-plugin": "^5.59.9",
"@typescript-eslint/parser": "^5.59.9",
"eslint": "^8.42.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-prettier": "^4.2.1",
"prettier": "^3.0.0",
"@typescript-eslint/eslint-plugin": "^6.21.0",
"@typescript-eslint/parser": "^6.21.0",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"prettier": "^3.2.5",
"turbo": "1.10.2",
"typescript": "^5.2.2",
"organize-imports-cli": "^0.10.0"
"typescript": "^5.2.2"
},
"engines": {
"node": ">=16.12.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/astro-check/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { createRequire } from 'node:module';
import path from 'node:path';
import { AstroCheck } from '@astrojs/language-server';
import { watch } from 'chokidar';
import { bold, dim, red, yellow } from 'kleur/colors';
import { createRequire } from 'node:module';
import path from 'node:path';
import yargs from 'yargs';
import { hideBin } from 'yargs/helpers';
import { options } from './options.js';
Expand Down
2 changes: 1 addition & 1 deletion packages/astro-check/test/bin.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect } from 'chai';
import { spawnSync } from 'child_process';
import { expect } from 'chai';
import { describe, it } from 'mocha';

describe('astro-check - binary', async () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/astro-check/test/check.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import path from 'path';
import { expect } from 'chai';
import { describe, it } from 'mocha';
import path from 'path';
import { check } from '../dist/index.js';

describe('astro-check - js api', async () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/language-server/src/check.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { existsSync } from 'node:fs';
import { pathToFileURL } from 'node:url';
import * as kit from '@volar/kit';
import { Diagnostic, DiagnosticSeverity } from '@volar/language-server';
import fg from 'fast-glob';
import { existsSync } from 'node:fs';
import { pathToFileURL } from 'node:url';
import { getLanguageModule } from './core/index.js';
import { getSvelteLanguageModule } from './core/svelte.js';
import { getVueLanguageModule } from './core/vue.js';
Expand Down
6 changes: 3 additions & 3 deletions packages/language-server/src/core/index.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import * as path from 'node:path';
import type { DiagnosticMessage } from '@astrojs/compiler/types';
import {
forEachEmbeddedCode,
type CodeMapping,
type ExtraServiceScript,
type LanguagePlugin,
type VirtualCode,
forEachEmbeddedCode,
} from '@volar/language-core';
import * as path from 'node:path';
import type ts from 'typescript';
import type { HTMLDocument } from 'vscode-html-languageservice';
import { getLanguageServerTypesDir, type AstroInstall } from '../utils.js';
import { type AstroInstall, getLanguageServerTypesDir } from '../utils.js';
import { astro2tsx } from './astro2tsx';
import { AstroMetadata, getAstroMetadata } from './parseAstro';
import { extractStylesheets } from './parseCSS';
Expand Down
6 changes: 3 additions & 3 deletions packages/language-server/src/core/parseCSS.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type { ParentNode, ParseResult } from '@astrojs/compiler/types';
import { is } from '@astrojs/compiler/utils';
import {
buildMappings,
Segment,
toString,
type CodeInformation,
Segment,
type VirtualCode,
buildMappings,
toString,
} from '@volar/language-core';
import type ts from 'typescript';
import type { HTMLDocument, Node } from 'vscode-html-languageservice';
Expand Down
4 changes: 2 additions & 2 deletions packages/language-server/src/core/parseJS.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type { ParentNode, ParseResult } from '@astrojs/compiler/types';
import { is } from '@astrojs/compiler/utils';
import {
buildMappings,
toString,
type CodeInformation,
type Segment,
type VirtualCode,
buildMappings,
toString,
} from '@volar/language-core';
import type ts from 'typescript';
import type { HTMLDocument, Node } from 'vscode-html-languageservice';
Expand Down
2 changes: 1 addition & 1 deletion packages/language-server/src/core/svelte.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {
forEachEmbeddedCode,
type CodeInformation,
type LanguagePlugin,
type Mapping,
type VirtualCode,
forEachEmbeddedCode,
} from '@volar/language-core';
import type ts from 'typescript';
import { framework2tsx } from './utils.js';
Expand Down
2 changes: 1 addition & 1 deletion packages/language-server/src/core/vue.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {
forEachEmbeddedCode,
type CodeInformation,
type LanguagePlugin,
type Mapping,
type VirtualCode,
forEachEmbeddedCode,
} from '@volar/language-core';
import type ts from 'typescript';
import { framework2tsx } from './utils.js';
Expand Down
2 changes: 1 addition & 1 deletion packages/language-server/src/languageServerPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { create as createEmmetService } from 'volar-service-emmet';
import { create as createPrettierService } from 'volar-service-prettier';
import { create as createTypeScriptTwoSlashService } from 'volar-service-typescript-twoslash-queries';

import type { createServerBase, ServerOptions } from '@volar/language-server/lib/server.js';
import type { ServerOptions, createServerBase } from '@volar/language-server/lib/server.js';
import { create as createAstroService } from './plugins/astro.js';
import { create as createHtmlService } from './plugins/html.js';
import { create as createTypescriptAddonsService } from './plugins/typescript-addons/index.js';
Expand Down
2 changes: 1 addition & 1 deletion packages/language-server/src/plugins/astro.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { dirname } from 'node:path';
import type { DiagnosticMessage } from '@astrojs/compiler/types';
import {
CodeLens,
Expand All @@ -12,7 +13,6 @@ import {
TextEdit,
} from '@volar/language-server';
import fg from 'fast-glob';
import { dirname } from 'node:path';
import type { Provide } from 'volar-service-typescript';
import type { TextDocument } from 'vscode-html-languageservice';
import { AstroVirtualCode } from '../core/index.js';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CompletionItemKind, TextEdit, type CompletionItem } from '@volar/language-server';
import { type CompletionItem, CompletionItemKind, TextEdit } from '@volar/language-server';
import type { FrontmatterStatus } from '../../core/parseAstro.js';

export function getSnippetCompletions(frontmatter: FrontmatterStatus): CompletionItem[] {
Expand Down
4 changes: 2 additions & 2 deletions packages/language-server/test/check/check.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expect } from 'chai';
import { before, describe, it } from 'mocha';
import os from 'node:os';
import path from 'node:path';
import { expect } from 'chai';
import { before, describe, it } from 'mocha';
import { AstroCheck, CheckResult } from '../../dist/check.js';

describe('AstroCheck', async () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/language-server/test/html/completions.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Position } from '@volar/language-server';
import { expect } from 'chai';
import { describe } from 'mocha';
import { getLanguageServer, type LanguageServer } from '../server.js';
import { type LanguageServer, getLanguageServer } from '../server.js';

describe('HTML - Completions', () => {
let languageServer: LanguageServer;
Expand Down
2 changes: 1 addition & 1 deletion packages/language-server/test/html/hover.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Position } from '@volar/language-server';
import { expect } from 'chai';
import { describe } from 'mocha';
import { getLanguageServer, type LanguageServer } from '../server.js';
import { type LanguageServer, getLanguageServer } from '../server.js';

describe('HTML - Hover', () => {
let languageServer: LanguageServer;
Expand Down
2 changes: 1 addition & 1 deletion packages/language-server/test/misc/format.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Range } from '@volar/language-server';
import { expect } from 'chai';
import { describe } from 'mocha';
import { getLanguageServer, type LanguageServer } from '../server.js';
import { type LanguageServer, getLanguageServer } from '../server.js';

describe('Formatting', () => {
let languageServer: LanguageServer;
Expand Down
2 changes: 1 addition & 1 deletion packages/language-server/test/server.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* eslint-disable no-console */
import { LanguageServerHandle, startLanguageServer } from '@volar/test-utils';
import { createHash } from 'node:crypto';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { LanguageServerHandle, startLanguageServer } from '@volar/test-utils';
import * as protocol from 'vscode-languageserver-protocol/node';
import type { TextDocument } from 'vscode-languageserver-textdocument';
import { URI } from 'vscode-uri';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Position } from '@volar/language-server';
import { expect } from 'chai';
import { before, describe, it } from 'mocha';
import { getLanguageServer, type LanguageServer } from '../server.js';
import { type LanguageServer, getLanguageServer } from '../server.js';

describe('TypeScript Addons - Completions', async () => {
let languageServer: LanguageServer;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Position } from '@volar/language-server';
import { expect } from 'chai';
import { before, describe, it } from 'mocha';
import { getLanguageServer, type LanguageServer } from '../server.js';
import { type LanguageServer, getLanguageServer } from '../server.js';

describe('TypeScript - Completions', async () => {
let languageServer: LanguageServer;
Expand Down
11 changes: 3 additions & 8 deletions packages/language-server/test/typescript/diagnostics.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
import {
DiagnosticSeverity,
FullDocumentDiagnosticReport,
Range,
type Diagnostic,
} from '@volar/language-server';
import * as path from 'path';
import { type Diagnostic, DiagnosticSeverity, Range } from '@volar/language-server';
import { expect } from 'chai';
import { before, describe, it } from 'mocha';
import { getLanguageServer, type LanguageServer } from '../server.js';
import * as path from 'path';
import { type LanguageServer, getLanguageServer } from '../server.js';

describe('TypeScript - Diagnostics', async () => {
let languageServer: LanguageServer;
Expand Down
1 change: 1 addition & 0 deletions packages/language-server/types/jsx-runtime-fallback.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// eslint-disable-next-line @typescript-eslint/triple-slash-reference
/// <reference path="astro-jsx.d.ts" />

declare module 'astro/jsx-runtime' {
Expand Down
Loading

0 comments on commit 7cc3dc1

Please sign in to comment.