Skip to content

Commit

Permalink
🐛 [Vue] Restore the vue TS config
Browse files Browse the repository at this point in the history
  • Loading branch information
beefchimi committed Dec 7, 2024
1 parent 9cf1595 commit 5223181
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 108 deletions.
60 changes: 0 additions & 60 deletions app/website/README.md
Original file line number Diff line number Diff line change
@@ -1,63 +1,3 @@
# Earwurm app

This repo hosts the website for the `earwurm` project.

## TsConfig

Originally, we isolated the `app` vs `node` configs. This had to be changed however because of the following bug: <https://github.com/antfu/eslint-config/issues/564>

As a result, the following packages were removed:

```json
{
"@tsconfig/node20": "^20.1.4",
"@vue/tsconfig": "^0.5.1"
}
```

### Record keeping

In case we ever restore the original `tsconfig`:

#### tsconfig.app.json

```json
{
"extends": "@vue/tsconfig/tsconfig.dom.json",
"compilerOptions": {
"composite": true,
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
}
},
"include": ["env.d.ts", "src/**/*", "src/**/*.vue"]
}
```

#### tsconfig.node.json

```json
{
"extends": "@tsconfig/node20/tsconfig.json",
"compilerOptions": {
"composite": true,
"module": "esnext",
"moduleResolution": "bundler",
"types": ["node"]
},
"include": ["lightningcss-plugins.ts", "vite.config.ts"]
}
```

#### tsconfig.json

```json
{
"references": [
{ "path": "./tsconfig.node.json" },
{ "path": "./tsconfig.app.json" }
],
"files": []
}
```
22 changes: 8 additions & 14 deletions app/website/eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import antfu from '@antfu/eslint-config';
export default antfu(
// Websites config
{
name: 'website',
type: 'app',
// ignores: [],
formatters: {
// Formats .css and .scss files, but also the `<style>` blocks in Vue.
css: true,
Expand Down Expand Up @@ -33,34 +33,28 @@ export default antfu(
},
},
},

// General config
{
// Without a `files` scope, these rules will apply to everything.
name: 'Websites general',
rules: {
// General
'no-console': 'warn',

// Antfu
'antfu/if-newline': 'off',
'perfectionist/sort-exports': 'off',
'perfectionist/sort-named-exports': 'off',
'perfectionist/sort-imports': 'off',
'style/arrow-parens': ['error', 'always'],
'style/object-curly-spacing': ['error', 'never'],
'test/prefer-lowercase-title': 'off',
'ts/explicit-function-return-type': 'off',
'ts/strict-boolean-expressions': 'off',

// Would like this if I could differentiate between ternary and if conditions.
// 'style/operator-linebreak': ['error', 'after'],

// TODO: Try and solve broken if/else statements.
/*
'style/padding-line-between-statements': [
'error',
{blankLine: 'never', prev: 'if', next: 'block-like'},
],
*/
// I like sorted imports/exports... but the Antfu config doesn't
// quite order things the way I'd like, so I'm disabling it for now.
'perfectionist/sort-exports': 'off',
'perfectionist/sort-named-exports': 'off',
'perfectionist/sort-imports': 'off',
},
},
);
2 changes: 2 additions & 0 deletions app/website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@
"devDependencies": {
"@antfu/eslint-config": "^3.11.2",
"@earwurm/types": "workspace:*",
"@tsconfig/node22": "^22.0.0",
"@vitejs/plugin-vue": "^5.2.1",
"@vue/tsconfig": "^0.7.0",
"eslint": "^9.16.0",
"eslint-plugin-format": "^0.1.3",
"lightningcss": "^1.28.2",
Expand Down
11 changes: 11 additions & 0 deletions app/website/tsconfig.app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "@vue/tsconfig/tsconfig.dom.json",
"compilerOptions": {
"composite": true,
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
}
},
"include": ["env.d.ts", "src/**/*", "src/**/*.vue"]
}
34 changes: 5 additions & 29 deletions app/website/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,31 +1,7 @@
{
"compilerOptions": {
// "types": ["node"],
"composite": true,
"target": "esnext",
"jsx": "preserve",
"jsxImportSource": "vue",
"lib": [
"es2020",
"dom",
"dom.iterable"
],
"useDefineForClassFields": true,
"baseUrl": ".",
"module": "esnext",
"moduleResolution": "bundler",
"paths": {
"@/*": ["./src/*"]
},
"resolveJsonModule": true,
"types": [],
"strict": true,
"noImplicitThis": true,
"noEmit": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"verbatimModuleSyntax": true,
"skipLibCheck": true
},
"include": ["env.d.ts", "lightningcss-plugins.ts", "vite.config.ts", "src/**/*", "src/**/*.vue"]
"references": [
{ "path": "./tsconfig.node.json" },
{ "path": "./tsconfig.app.json" }
],
"files": []
}
10 changes: 10 additions & 0 deletions app/website/tsconfig.node.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "@tsconfig/node22/tsconfig.json",
"compilerOptions": {
"composite": true,
"module": "esnext",
"moduleResolution": "bundler",
"types": ["node"]
},
"include": ["lightningcss-plugins.ts", "vite.config.ts"]
}
17 changes: 12 additions & 5 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import antfu from '@antfu/eslint-config';
// 2. https://github.com/antfu/eslint-plugin-antfu
// 3. https://github.com/antfu/eslint-plugin-format
export default antfu(
// Library config
// Packages config
{
name: 'Packages',
type: 'lib',
// Antfu respects `gitignore`, so we don't need to repeat those directories.
ignores: ['app/**'],
formatters: {
markdown: true,
Expand All @@ -21,24 +21,31 @@ export default antfu(
},
vue: false,
},

// TODO: Is there not a way to have a separate entry for `/websites`?

// General config
{
// Without a `files` scope, these rules will apply to everything.
name: 'Packages general',
rules: {
// General
'no-console': 'warn',

// Antfu
'antfu/if-newline': 'off',
'perfectionist/sort-exports': 'off',
'perfectionist/sort-named-exports': 'off',
'perfectionist/sort-imports': 'off',
'style/arrow-parens': ['error', 'always'],
'style/object-curly-spacing': ['error', 'never'],
'test/prefer-lowercase-title': 'off',
'ts/explicit-function-return-type': 'off',
'ts/strict-boolean-expressions': 'off',

// I like sorted imports/exports... but the Antfu config doesn't
// quite order things the way I'd like, so I'm disabling it for now.
'perfectionist/sort-exports': 'off',
'perfectionist/sort-named-exports': 'off',
'perfectionist/sort-imports': 'off',

// Would like this if I could differentiate between ternary and if conditions.
// 'style/operator-linebreak': ['error', 'after'],

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"clean": "pnpm -r clean && rm -rf coverage",
"nuke": "pnpm clean && ./scripts/nuke.sh",
"start": "pnpm --filter earwurm build && pnpm -r --parallel --stream start",
"preview": "pnpm --filter website preview",
"build": "pnpm -r build",
"lint": "pnpm -r build:only && pnpm -r lint && eslint .",
"lint:fix": "pnpm -r build:only && pnpm -r lint:fix && eslint . --fix",
Expand Down
27 changes: 27 additions & 0 deletions pnpm-lock.yaml

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

0 comments on commit 5223181

Please sign in to comment.