Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: format with Biome #79

Merged
merged 5 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
184 changes: 92 additions & 92 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,98 +1,98 @@
const { builtinModules } = require('module');

module.exports = {
extends: [
'plugin:@typescript-eslint/recommended-type-checked',
'plugin:@typescript-eslint/stylistic-type-checked',
'prettier',
],
parser: '@typescript-eslint/parser',
parserOptions: {
project: ['./packages/*/tsconfig.json', './tsconfig.eslint.json'],
tsconfigRootDir: __dirname,
},
plugins: ['@typescript-eslint', 'prettier', 'no-only-tests'],
rules: {
// These off/configured-differently-by-default rules fit well for us
'@typescript-eslint/array-type': ['error', { default: 'array-simple' }],
'@typescript-eslint/no-unused-vars': [
'error',
{ argsIgnorePattern: '^_', ignoreRestSiblings: true },
],
'no-only-tests/no-only-tests': 'error',
'@typescript-eslint/no-shadow': ['error'],
'no-console': 'warn',
extends: [
'plugin:@typescript-eslint/recommended-type-checked',
'plugin:@typescript-eslint/stylistic-type-checked',
'prettier',
],
parser: '@typescript-eslint/parser',
parserOptions: {
project: ['./packages/*/tsconfig.json', './tsconfig.eslint.json'],
tsconfigRootDir: __dirname,
},
plugins: ['@typescript-eslint', 'prettier', 'no-only-tests'],
rules: {
// These off/configured-differently-by-default rules fit well for us
'@typescript-eslint/array-type': ['error', { default: 'array-simple' }],
'@typescript-eslint/no-unused-vars': [
'error',
{ argsIgnorePattern: '^_', ignoreRestSiblings: true },
],
'no-only-tests/no-only-tests': 'error',
'@typescript-eslint/no-shadow': ['error'],
'no-console': 'warn',

// Todo: do we want these?
'@typescript-eslint/array-type': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/class-literal-property-style': 'off',
'@typescript-eslint/consistent-indexed-object-style': 'off',
'@typescript-eslint/consistent-type-definitions': 'off',
'@typescript-eslint/dot-notation': 'off',
'@typescript-eslint/no-base-to-string': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-floating-promises': 'off',
'@typescript-eslint/no-misused-promises': 'off',
'@typescript-eslint/no-redundant-type-constituents': 'off',
'@typescript-eslint/no-this-alias': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/prefer-nullish-coalescing': 'off',
'@typescript-eslint/prefer-optional-chain': 'off',
'@typescript-eslint/prefer-string-starts-ends-with': 'off',
'@typescript-eslint/require-await': 'off',
'@typescript-eslint/restrict-plus-operands': 'off',
'@typescript-eslint/restrict-template-expressions': 'off',
'@typescript-eslint/sort-type-constituents': 'off',
'@typescript-eslint/unbound-method': 'off',
'@typescript-eslint/no-explicit-any': 'off',
// Todo: do we want these?
'@typescript-eslint/array-type': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/class-literal-property-style': 'off',
'@typescript-eslint/consistent-indexed-object-style': 'off',
'@typescript-eslint/consistent-type-definitions': 'off',
'@typescript-eslint/dot-notation': 'off',
'@typescript-eslint/no-base-to-string': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-floating-promises': 'off',
'@typescript-eslint/no-misused-promises': 'off',
'@typescript-eslint/no-redundant-type-constituents': 'off',
'@typescript-eslint/no-this-alias': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/prefer-nullish-coalescing': 'off',
'@typescript-eslint/prefer-optional-chain': 'off',
'@typescript-eslint/prefer-string-starts-ends-with': 'off',
'@typescript-eslint/require-await': 'off',
'@typescript-eslint/restrict-plus-operands': 'off',
'@typescript-eslint/restrict-template-expressions': 'off',
'@typescript-eslint/sort-type-constituents': 'off',
'@typescript-eslint/unbound-method': 'off',
'@typescript-eslint/no-explicit-any': 'off',

// These rules enabled by the preset configs don't work well for us
'@typescript-eslint/await-thenable': 'off',
'prefer-const': 'off',
},
overrides: [
{
// Ensure Node builtins aren't included in Astro's server runtime
files: ['packages/astro/src/runtime/**/*.ts'],
rules: {
'no-restricted-imports': [
'error',
{
paths: [...builtinModules],
patterns: ['node:*'],
},
],
},
},
{
files: ['packages/**/test/*.js', 'packages/**/*.js'],
env: {
mocha: true,
},
globals: {
globalThis: false, // false means read-only
},
rules: {
'no-console': 'off',
},
},
{
files: ['packages/integrations/**/*.ts'],
rules: {
'no-console': ['error', { allow: ['warn', 'error', 'info', 'debug'] }],
},
},
{
files: ['benchmark/**/*.js'],
rules: {
'@typescript-eslint/no-unused-vars': 'off',
'no-console': 'off',
},
},
],
// These rules enabled by the preset configs don't work well for us
'@typescript-eslint/await-thenable': 'off',
'prefer-const': 'off',
},
overrides: [
{
// Ensure Node builtins aren't included in Astro's server runtime
files: ['packages/astro/src/runtime/**/*.ts'],
rules: {
'no-restricted-imports': [
'error',
{
paths: [...builtinModules],
patterns: ['node:*'],
},
],
},
},
{
files: ['packages/**/test/*.js', 'packages/**/*.js'],
env: {
mocha: true,
},
globals: {
globalThis: false, // false means read-only
},
rules: {
'no-console': 'off',
},
},
{
files: ['packages/integrations/**/*.ts'],
rules: {
'no-console': ['error', { allow: ['warn', 'error', 'info', 'debug'] }],
},
},
{
files: ['benchmark/**/*.js'],
rules: {
'@typescript-eslint/no-unused-vars': 'off',
'no-console': 'off',
},
},
],
};
7 changes: 7 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,10 @@

# Files
pnpm-lock.yaml

*.js
*.ts
*.mjs
*.cjs
*.json
*.jsonc
3 changes: 3 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["biomejs.biome"]
}
26 changes: 24 additions & 2 deletions biome.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,29 @@
{
"$schema": "https://biomejs.dev/schemas/1.4.0/schema.json",
"$schema": "https://biomejs.dev/schemas/1.4.1/schema.json",
"files": {
"ignore": [
"**/dist",
"**/node_modules",
"**/fixtures",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason why we ignore the fixtures?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ematipico there was a reason, but I can't remember it.
I'm happy to enable it for fixtures :)

"**/vendor",
"**/.vercel",
"**/.changeset"
],
"ignoreUnknown": true
},
"formatter": {
"enabled": false
"lineWidth": 100
},
"javascript": {
"formatter": {
"quoteStyle": "single",
"trailingComma": "es5"
}
},
"json": {
"formatter": {
"indentStyle": "space"
}
},
"organizeImports": {
"enabled": true
Expand Down
8 changes: 3 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@
"release": "pnpm run build && changeset publish",
"build": "turbo run build --filter=\"@astrojs/*\"",
"build:ci": "turbo run build:ci --filter=\"@astrojs/*\"",
"format": "pnpm run format:code",
"format:ci": "pnpm run format:imports && pnpm run format:code",
"format:code": "prettier -w \"**/*\" --ignore-unknown --cache",
"format:imports": "biome check --apply ./packages",
"format:ci": "pnpm run format",
"format": "biome check --apply ./ && prettier -w \"**/*\" --ignore-unknown --cache",
"test": "turbo run test --concurrency=1 --filter=astro --filter=create-astro --filter=\"@astrojs/*\"",
"benchmark": "astro-benchmark",
"lint": "eslint . --report-unused-disable-directives",
Expand Down Expand Up @@ -47,7 +45,7 @@
},
"devDependencies": {
"@astrojs/check": "^0.3.1",
"@biomejs/biome": "^1.4.0",
"@biomejs/biome": "1.4.1",
"@changesets/changelog-github": "^0.4.8",
"@changesets/cli": "^2.26.2",
"@types/node": "^18.17.8",
Expand Down
4 changes: 2 additions & 2 deletions packages/cloudflare/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -555,8 +555,8 @@ export default function createIntegration(args?: Options): AstroIntegration {
const winningStrategy = notFoundIsSSR
? excludeStrategy
: includeStrategyLength <= excludeStrategyLength
? includeStrategy
: excludeStrategy;
? includeStrategy
Copy link
Member Author

@ematipico ematipico Dec 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EDIT: this is the new formatting of ternaries in Prettier 3.1

: excludeStrategy;

await fs.promises.writeFile(
new URL('./_routes.json', _config.outDir),
Expand Down
7 changes: 6 additions & 1 deletion packages/test-utils/test-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,12 @@ export async function parseCliDevStart(proc) {
const messages = stdout
.split('\n')
.filter((ln) => !!ln.trim())
.map((ln) => ln.replace(/[🚀┃]/g, '').replace(/\s+/g, ' ').trim());
.map((ln) =>
ln
.replace(/[🚀┃]/g, '')
.replace(/\s+/g, ' ')
.trim()
);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I personally dislike that it is not formatted like:

.map((ln) =>
	ln.replace(/[🚀┃]/g, '').replace(/\s+/g, ' ').trim()
);

Copy link
Member Author

@ematipico ematipico Dec 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bug, I will report it back in the Biome repository. Also, I think we have more fixes in the pipeline coming in the next release.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return { messages };
}
Expand Down
44 changes: 22 additions & 22 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion prettier.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default {
plugins: ['prettier-plugin-astro'],
overrides: [
{
files: ['.*', '*.json', '*.md', '*.toml', '*.yml'],
files: ['*.md', '*.toml', '*.yml'],
options: {
useTabs: false,
},
Expand Down
Loading