Skip to content

Commit

Permalink
♻️ refactor(formatting): replace eslint and prettier with biome (#326)
Browse files Browse the repository at this point in the history
* chore: replace eslint and prettier with biomejs

* chore: use biome vcs integration

* chore: add newline at eof

* chore: remove unintended additions

* chore: re-add accidentally removed permission check

* chore: ignore gitignore for post-generate hooks

* chore: clean up commands

* chore: temporarily use spaces for smaller diff

* chore: temporarily use 120 line width

* chore: manually add ignored files

* chore: format non-src code
  • Loading branch information
larwaa authored Dec 21, 2023
1 parent 130ea66 commit 7e35534
Show file tree
Hide file tree
Showing 158 changed files with 1,491 additions and 2,761 deletions.
102 changes: 0 additions & 102 deletions .eslintrc.yaml

This file was deleted.

63 changes: 31 additions & 32 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ name: "CodeQL"

on:
push:
branches: [ "main" ]
branches: ["main"]
pull_request:
branches: [ "main" ]
branches: ["main"]
schedule:
- cron: '25 4 * * 1'
- cron: "25 4 * * 1"

jobs:
analyze:
Expand All @@ -37,45 +37,44 @@ jobs:
strategy:
fail-fast: false
matrix:
language: [ 'javascript-typescript' ]
language: ["javascript-typescript"]
# CodeQL supports [ 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift' ]
# Use only 'java-kotlin' to analyze code written in Java, Kotlin or both
# Use only 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support

steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Checkout repository
uses: actions/checkout@v4

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality
# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality

# Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v3

# Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v3
# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.

# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh

# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -218,3 +218,8 @@ $RECYCLE.BIN/
# End of https://www.toptal.com/developers/gitignore/api/node,macos,windows,linux

dump.rdb

# GraphQL Codegen
src/graphql/test-clients/integration/**
src/graphql/test-clients/unit/**
*.generated.ts
3 changes: 0 additions & 3 deletions .prettierignore

This file was deleted.

7 changes: 0 additions & 7 deletions .prettierrc

This file was deleted.

2 changes: 1 addition & 1 deletion .swcrc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
},

"paths": {
"@/*": ["./src/*"]
"~/*": ["./src/*"]
},
"baseUrl": "."
}
Expand Down
3 changes: 3 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["GraphQL.vscode-graphql-syntax", "GraphQL.vscode-graphql", "biomejs.biome", "redhat.vscode-yaml"]
}
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"editor.defaultFormatter": "biomejs.biome",
"editor.codeActionsOnSave": {
"source.organizeImports.biome": true
}
}
32 changes: 32 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"$schema": "https://biomejs.dev/schemas/1.4.1/schema.json",
"vcs": {
"enabled": true,
"useIgnoreFile": true,
"clientKind": "git"
},
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
}
},
"formatter": {
"indentWidth": 2,
"indentStyle": "space",
"lineWidth": 120
},
"files": {
"ignore": [
"node_modules",
"dist",
"pnpm-lock.yaml",
"src/graphql/test-clients/integration/**/*.ts",
"src/graphql/test-clients/unit/**/*.ts",
"*.generated.ts"
]
}
}
9 changes: 4 additions & 5 deletions codegen.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
const { defineConfig } = require("@eddeee888/gcg-typescript-resolver-files");

const generatedPrefix = `
/* eslint-disable */
/* prettier-ignore */
// biome-ignore
/**
* This file was automatically generated by 'graphql-codegen'.
Expand All @@ -26,7 +25,7 @@ const config = {
schema: "src/graphql/**/schema.graphql",
emitLegacyCommonJSImports: false,
hooks: {
afterAllFileWrite: ["prettier --write"],
afterAllFileWrite: ["pnpm exec biome check --apply"],
},
ignoreNoDocuments: true,
generates: {
Expand Down Expand Up @@ -110,10 +109,10 @@ const config = {
"./types.generated.ts": { content: generatedPrefix },
},
typesPluginsConfig: {
contextType: "@/lib/apollo-server.js#ApolloContext",
contextType: "~/lib/apollo-server.js#ApolloContext",
},
},
{ schema: "src/graphql/**/*.{graphql}" }
{ schema: "src/graphql/**/*.{graphql}" },
),
},
};
Expand Down
18 changes: 7 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@
"generate:prisma": "prisma generate",
"generate": "run-p generate:*",
"integration-test": "dotenv -e .env.test -- pnpm db:push && dotenv -e .env.test -- node --experimental-vm-modules --no-warnings=ExperimentalWarning ./node_modules/jest/bin/jest.js --config jest.integration.config.cjs",
"lint:fix": "pnpm lint --fix",
"lint": "eslint .",
"lint:ci": "run-s setup 'lint {@}' --",
"format": "biome format src",
"format:write": "biome format --write src",
"lint": "biome check src",
"lint:apply": "biome check --apply src",
"biome:ci": "biome ci src",
"lint:ci": "run-s setup biome:ci",
"setup-integration-test": "run-s docker:up && wait-on tcp:5433 -t 20000",
"swc": "swc src -d dist",
"test:integration:ci": "run-s setup 'integration-test {@}' --",
Expand All @@ -38,6 +41,7 @@
"check": "run-s setup tsc lint test"
},
"devDependencies": {
"@biomejs/biome": "1.4.1",
"@eddeee888/gcg-typescript-resolver-files": "^0.7.2",
"@faker-js/faker": "^8.3.1",
"@graphql-codegen/add": "^5.0.0",
Expand All @@ -46,7 +50,6 @@
"@graphql-codegen/schema-ast": "^4.0.0",
"@graphql-codegen/typescript": "^4.0.1",
"@graphql-codegen/typescript-resolvers": "^4.0.1",
"@graphql-eslint/eslint-plugin": "^3.20.1",
"@graphql-typed-document-node/core": "^3.2.0",
"@jest/globals": "^29.7.0",
"@parcel/watcher": "^2.3.0",
Expand All @@ -59,15 +62,8 @@
"@types/lodash-es": "^4.17.12",
"@types/luxon": "^3.3.7",
"@types/node": "^20.10.5",
"@typescript-eslint/eslint-plugin": "^6.15.0",
"@typescript-eslint/parser": "^6.15.0",
"concurrently": "^8.2.2",
"dotenv-cli": "^7.3.0",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-prettier": "^5.1.0",
"jest": "^29.7.0",
"jest-mock-extended": "^3.0.5",
"nodemon": "^3.0.2",
Expand Down
Loading

0 comments on commit 7e35534

Please sign in to comment.