Skip to content

Commit

Permalink
feat: add eslint verification configuration, add lint CI workflows (#284
Browse files Browse the repository at this point in the history
)

* feat: add eslint configuration

* chore: update pnpm version
  • Loading branch information
yzh990918 committed Mar 17, 2023
1 parent ccd4c97 commit 0e69a11
Show file tree
Hide file tree
Showing 29 changed files with 2,392 additions and 373 deletions.
7 changes: 7 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
dist
public
node_modules
.netlify
.vercel
.github
.changeset
31 changes: 31 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
module.exports = {
extends: ['@evan-yang', 'plugin:astro/recommended'],
rules: {
'no-console': ['error', { allow: ['error'] }],
'react/display-name': 'off',
'react-hooks/rules-of-hooks': 'off',
'@typescript-eslint/no-use-before-define': 'off',
},
overrides: [
{
files: ['*.astro'],
parser: 'astro-eslint-parser',
parserOptions: {
parser: '@typescript-eslint/parser',
extraFileExtensions: ['.astro'],
},
rules: {
'no-mixed-spaces-and-tabs': ['error', 'smart-tabs'],
},
},
{
// Define the configuration for `<script>` tag.
// Script in `<script>` is assigned a virtual file name with the `.js` extension.
files: ['**/*.astro/*.js', '*.astro/*.js'],
parser: '@typescript-eslint/parser',
rules: {
'prettier/prettier': 'off',
},
},
],
}
31 changes: 31 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Lint CI

on:
push:
branches:
- main

pull_request:
branches:
- main

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Install pnpm
uses: pnpm/action-setup@v2

- name: Set node
uses: actions/setup-node@v3
with:
node-version: 18.x
cache: pnpm

- name: Install
run: pnpm install --no-frozen-lockfile

- name: Lint
run: pnpm run lint
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
registry=https://registry.npmjs.org/
strict-peer-dependencies=false
auto-install-peers=true
shamefully-hoist=true
2 changes: 1 addition & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"recommendations": ["astro-build.astro-vscode"],
"recommendations": ["astro-build.astro-vscode","dbaeumer.vscode-eslint","antfu.unocss"],
"unwantedRecommendations": [],
}
13 changes: 13 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"editor.formatOnSave": false,
"eslint.validate": [
"javascript",
"javascriptreact",
"astro", // Enable .astro
"typescript", // Enable .ts
"typescriptreact" // Enable .tsx
]
}
12 changes: 9 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
{
"name": "chatgpt-api-demo",
"type": "module",
"version": "0.0.1",
"packageManager": "[email protected]",
"scripts": {
"dev": "astro dev",
"start": "astro dev",
"build": "astro build",
"build:vercel": "OUTPUT=vercel astro build",
"build:netlify": "OUTPUT=netlify astro build",
"preview": "astro preview",
"astro": "astro"
"astro": "astro",
"lint": "eslint . --ext .js,.jsx,.ts,.tsx,.astro",
"lint:fix": "eslint . --ext .js,.jsx,.ts,.tsx,.astro --fix"
},
"dependencies": {
"@astrojs/netlify": "2.0.0",
Expand All @@ -18,6 +20,7 @@
"@astrojs/vercel": "^3.1.3",
"@unocss/reset": "^0.50.1",
"astro": "^2.0.15",
"eslint": "^8.36.0",
"eventsource-parser": "^0.1.0",
"highlight.js": "^11.7.0",
"js-sha256": "^0.9.0",
Expand All @@ -32,10 +35,13 @@
"devDependencies": {
"@iconify-json/carbon": "^1.1.16",
"@types/markdown-it": "^12.2.3",
"@typescript-eslint/parser": "^5.54.1",
"@unocss/preset-attributify": "^0.50.1",
"@unocss/preset-icons": "^0.50.4",
"@unocss/preset-typography": "^0.50.3",
"eslint-plugin-astro": "^0.24.0",
"punycode": "^2.3.0",
"unocss": "^0.50.1"
"unocss": "^0.50.1",
"@evan-yang/eslint-config": "^1.0.1"
}
}
4 changes: 2 additions & 2 deletions plugins/vercelDisableBlocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export default function plugin() {
if (id.includes('pages/api/generate.ts')) {
return {
code: code.replace(/^.*?#vercel-disable-blocks([\s\S]+?)#vercel-end.*?$/gm, ''),
map: null
map: null,
}
}
}
Expand All @@ -13,4 +13,4 @@ export default function plugin() {
enforce: 'pre',
transform,
}
}
}
Loading

1 comment on commit 0e69a11

@vercel
Copy link

@vercel vercel bot commented on 0e69a11 Mar 17, 2023

Choose a reason for hiding this comment

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

Please sign in to comment.