Skip to content

Commit

Permalink
chore: run biome
Browse files Browse the repository at this point in the history
  • Loading branch information
ribeirojose committed Sep 19, 2024
1 parent 1739c2d commit 74e60e8
Show file tree
Hide file tree
Showing 23 changed files with 12,389 additions and 228 deletions.
925 changes: 925 additions & 0 deletions .yarn/releases/yarn-4.5.0.cjs

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
compressionLevel: 0

defaultSemverRangePrefix: ''
defaultSemverRangePrefix: ""

enableGlobalCache: false

nmMode: hardlinks-local

nodeLinker: node-modules

npmRegistryServer: 'https://registry.npmjs.org/'
npmRegistryServer: "https://registry.npmjs.org/"

supportedArchitectures:
cpu:
Expand All @@ -17,3 +17,5 @@ supportedArchitectures:
- current
os:
- current

yarnPath: .yarn/releases/yarn-4.5.0.cjs
7 changes: 0 additions & 7 deletions apps/claim-vesting/.lintstagedrc.js

This file was deleted.

18 changes: 3 additions & 15 deletions apps/claim-vesting/lint-staged.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,14 @@
const {
concatFilesForPrettier,
getEslintFixCmd,
} = require('../../lint-staged.common.js');
} = require("../../lint-staged.common.js");

/**
* @type {Record<string, (filenames: string[]) => string | string[] | Promise<string | string[]>>}
*/
const rules = {
'**/*.{js,jsx,ts,tsx,mjs,cjs}': (filenames) => {
return getEslintFixCmd({
cwd: __dirname,
fix: true,
cache: true,
// when autofixing staged-files a good tip is to disable react-hooks/exhaustive-deps, cause
// a change here can potentially break things without proper visibility.
rules: ['react-hooks/exhaustive-deps: off'],
maxWarnings: 25,
files: filenames,
});
},
'**/*.{json,md,mdx,css,html,yml,yaml,scss}': (filenames) => {
return [`prettier --write ${concatFilesForPrettier(filenames)}`];
"**/*.{json,md,mdx,css,html,yml,yaml,scss}": (filenames) => {
return [`yarn biome check --write ${concatFilesForPrettier(filenames)}`];
},
};

Expand Down
4 changes: 2 additions & 2 deletions apps/claim-vesting/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
"lint:fix": "eslint '**/*.{ts,tsx}' --fix"
},
"dependencies": {
"@bleu/cow-hooks-ui": "workspace:*",
"@bleu/tsconfig": "workspace:*",
"@bleu/ui": "git+ssh://[email protected]:bleu/bleu-ui.git#main",
"@bleu/cow-hooks-ui": "workspace:*",
"next": "^14.2.12",
"react": "^18.3.1",
"react-dom": "^18.3.1"
},
"devDependencies": {
"@bleu/eslint-config": "workspace:^",
"@biomejs/biome": "1.9.2",
"@testing-library/jest-dom": "6.5.0",
"@testing-library/react": "^16.0.1",
"@testing-library/user-event": "14.5.2",
Expand Down
7 changes: 3 additions & 4 deletions apps/claim-vesting/postcss.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
// @link https://nextjs.org/docs/advanced-features/customizing-postcss-config
// @link https://tailwindcss.com/docs/using-with-preprocessors

const isProd = process.env.NODE_ENV === 'production';
import type { Config } from 'tailwindcss';
const isProd = process.env.NODE_ENV === "production";
import type { Config } from "tailwindcss";

const tailwindConfig: Config = {
plugins: {
tailwindcss: {},
...(isProd
? {
'postcss-preset-env': {
"postcss-preset-env": {
// https://github.com/csstools/postcss-plugins/tree/main/plugin-packs/postcss-preset-env#stability-and-portability
stage: 3,
autoprefixer: { grid: true },
Expand All @@ -20,5 +20,4 @@ const tailwindConfig: Config = {
},
};


export default tailwindConfig;
2 changes: 1 addition & 1 deletion apps/claim-vesting/src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import "#/global.css";

import * as React from "react";
import type * as React from "react";

export default function Layout({ children }: { children: React.ReactNode }) {
return (
Expand Down
6 changes: 5 additions & 1 deletion apps/claim-vesting/tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,9 @@

/** @type {import("tailwindcss").Config} */
module.exports = {
content: ["./src/**/*.{js,ts,jsx,tsx}", "./node_modules/@bleu/ui/dist/**/*", "../../packages/hooks-ui/src/**/*.{js,ts,jsx,tsx}"],
content: [
"./src/**/*.{js,ts,jsx,tsx}",
"./node_modules/@bleu/ui/dist/**/*",
"../../packages/hooks-ui/src/**/*.{js,ts,jsx,tsx}",
],
};
31 changes: 31 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.2/schema.json",
"vcs": {
"enabled": false,
"clientKind": "git",
"useIgnoreFile": true
},
"files": {
"ignoreUnknown": true,
"ignore": [".next/**/*", "**/node_modules/**", "node_modules/**"]
},
"formatter": {
"enabled": true,
"indentStyle": "space",
"indentWidth": 2
},
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
}
},
"javascript": {
"formatter": {
"quoteStyle": "double"
}
}
}
43 changes: 0 additions & 43 deletions cache.config.js

This file was deleted.

58 changes: 29 additions & 29 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
module.exports = {
extends: ['@commitlint/config-conventional'],
extends: ["@commitlint/config-conventional"],
rules: {
'body-leading-blank': [1, 'always'],
'body-max-line-length': [2, 'always', 100],
'footer-leading-blank': [1, 'always'],
'footer-max-line-length': [2, 'always', 100],
'header-max-length': [2, 'always', 100],
'scope-case': [2, 'always', 'lower-case'],
'subject-case': [
"body-leading-blank": [1, "always"],
"body-max-line-length": [2, "always", 100],
"footer-leading-blank": [1, "always"],
"footer-max-line-length": [2, "always", 100],
"header-max-length": [2, "always", 100],
"scope-case": [2, "always", "lower-case"],
"subject-case": [
2,
'never',
['sentence-case', 'start-case', 'pascal-case', 'upper-case'],
"never",
["sentence-case", "start-case", "pascal-case", "upper-case"],
],
'subject-empty': [2, 'never'],
'subject-full-stop': [2, 'never', '.'],
'type-case': [2, 'always', 'lower-case'],
'type-empty': [2, 'never'],
'type-enum': [
"subject-empty": [2, "never"],
"subject-full-stop": [2, "never", "."],
"type-case": [2, "always", "lower-case"],
"type-empty": [2, "never"],
"type-enum": [
2,
'always',
"always",
[
'build',
'chore',
'ci',
'docs',
'feat',
'fix',
'perf',
'refactor',
'revert',
'style',
'test',
'translation',
'security',
"build",
"chore",
"ci",
"docs",
"feat",
"fix",
"perf",
"refactor",
"revert",
"style",
"test",
"translation",
"security",
],
],
},
Expand Down
70 changes: 4 additions & 66 deletions lint-staged.common.js
Original file line number Diff line number Diff line change
@@ -1,69 +1,8 @@
// @ts-check
// biome-ignore lint:
const escape = require("shell-quote").quote;

const path = require('path');
const escape = require('shell-quote').quote;

const isWin = process.platform === 'win32';

const eslintGlobalRulesForFix = [
// react-hooks/eslint and react in general is very strict about exhaustively
// declaring the dependencies when using the useEffect, useCallback... hooks.
//
// In some specific scenarios declaring the deps seems 'less' wanted or 'less' applicable
// by the developer, leading to some exceptions in the code. That said it should be avoided.
//
// While the 'react-hooks/exhaustive-deps' rule is a good rule of thumb, it's not recommended to
// automatically fix it from lint-staged as it can potentially break a legit intent.
//
// Reminder that a good practice is to always declare the dependencies when using the hooks,
// and if not applicable, add an eslint disable comment to the useEffect, useCallback... such as:
//
// // eslint-disable-next-line react-hooks/exhaustive-deps
//
// Another approach can be to use hooks such as https://github.com/kentcdodds/use-deep-compare-effect to quickly bypass
// shallow rendering limitations.
//
// @see https://reactjs.org/docs/hooks-rules.html
// @see https://eslint.org/docs/2.13.1/user-guide/configuring#disabling-rules-with-inline-comments
'react-hooks/exhaustive-deps: off',
];

/**
* Lint-staged command for running eslint in packages or apps.
* @param {{cwd: string, files: string[], fix: boolean, fixType?: ('problem'|'suggestion'|'layout'|'directive')[], cache: boolean, rules?: string[], maxWarnings?: number}} params
*/
const getEslintFixCmd = ({
cwd,
files,
rules,
fix,
fixType,
cache,
maxWarnings,
}) => {
const cliRules = [...(rules ?? []), ...eslintGlobalRulesForFix]
.filter((rule) => rule.trim().length > 0)
.map((r) => `"${r.trim()}"`);

// For lint-staged it's safer to not apply the fix command if it changes the AST
// @see https://eslint.org/docs/user-guide/command-line-interface#--fix-type
const cliFixType = [...(fixType ?? ['layout'])].filter(
(type) => type.trim().length > 0
);

const args = [
cache ? '--cache' : '',
fix ? '--fix' : '',
cliFixType.length > 0 ? `--fix-type ${cliFixType.join(',')}` : '',
maxWarnings !== undefined ? `--max-warnings=${maxWarnings}` : '',
cliRules.length > 0 ? `--rule ${cliRules.join('--rule ')}` : '',
files
// makes output cleaner by removing absolute paths from filenames
.map((f) => `"./${path.relative(cwd, f)}"`)
.join(' '),
].join(' ');
return `eslint ${args}`;
};
const isWin = process.platform === "win32";

/**
* Concatenate and escape a list of filenames that can be passed as args to prettier cli
Expand All @@ -79,12 +18,11 @@ const getEslintFixCmd = ({
const concatFilesForPrettier = (filenames) =>
filenames
.map((filename) => `"${isWin ? filename : escape([filename])}"`)
.join(' ');
.join(" ");

const concatFilesForStylelint = concatFilesForPrettier;

module.exports = {
concatFilesForPrettier,
concatFilesForStylelint,
getEslintFixCmd,
};
8 changes: 4 additions & 4 deletions lint-staged.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@
* {@link https://github.com/belgattitude/nextjs-monorepo-example/blob/main/docs/about-lint-staged.md}
*/

const { concatFilesForPrettier } = require('./lint-staged.common.js');
const { concatFilesForPrettier } = require("./lint-staged.common.js");

/**
* @type {Record<string, (filenames: string[]) => string | string[] | Promise<string | string[]>>}
*/
const rules = {
'**/*.{json,md,mdx,css,html,yml,yaml,scss,ts,js,tsx,jsx,mjs}': (
filenames
"**/*.{json,md,mdx,css,html,yml,yaml,scss,ts,js,tsx,jsx,mjs}": (
filenames,
) => {
return [`yarn prettier --write ${concatFilesForPrettier(filenames)}`];
return [`yarn biome check --write ${concatFilesForPrettier(filenames)}`];
},
};

Expand Down
Loading

0 comments on commit 74e60e8

Please sign in to comment.