Skip to content

Commit

Permalink
🛠️ [Eslint] Switch to flat config (#84)
Browse files Browse the repository at this point in the history
  • Loading branch information
beefchimi authored Jul 31, 2024
1 parent 069c6ba commit fba1989
Show file tree
Hide file tree
Showing 87 changed files with 2,796 additions and 2,078 deletions.
6 changes: 6 additions & 0 deletions .changeset/small-seahorses-enjoy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"website": minor
"earwurm": minor
---

Bumped required node and pnpm versions. Also overhauled linting/formatting.
5 changes: 0 additions & 5 deletions .eslintignore

This file was deleted.

17 changes: 0 additions & 17 deletions .eslintrc

This file was deleted.

46 changes: 22 additions & 24 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
🧰 Dependency:
- changed-files:
- any-glob-to-any-file: 'pnpm-lock.yaml'
- any-glob-to-any-file: pnpm-lock.yaml

📚 Documentation:
- changed-files:
- any-glob-to-any-file: ['README.md', 'docs/**']
- any-glob-to-any-file: [README.md, 'docs/**']

⚖️ Legal:
- changed-files:
- any-glob-to-any-file: 'LICENSE'
- any-glob-to-any-file: LICENSE

🔖 Release:
- changed-files:
- any-glob-to-any-file: 'CHANGELOG.md'
- any-glob-to-any-file: CHANGELOG.md

🧪 Testing:
- changed-files:
Expand All @@ -21,23 +21,21 @@
🛠️ Tooling:
- changed-files:
- any-glob-to-any-file:
[
'.github/**',
'.vscode/**',
'.editorconfig',
'.eslintignore',
'.eslintrc',
'.eslintrc.cjs',
'.gitignore',
'.npmignore',
'.nvmrc',
'.prettierignore',
'.prettierrc',
'config/**',
'package.json',
'tsconfig.json',
'tsconfig.*.json',
'vite.config.ts',
'**/*/env.d.ts',
'**/*/lightningcss-plugins.ts',
]
- '.github/**'
- '.vscode/**'
- .editorconfig
- .eslintignore
- .eslintrc
- .eslintrc.cjs
- .gitignore
- .npmignore
- .nvmrc
- .prettierignore
- .prettierrc
- 'config/**'
- package.json
- tsconfig.json
- 'tsconfig.*.json'
- vite.config.ts
- '**/*/env.d.ts'
- '**/*/lightningcss-plugins.ts'
8 changes: 4 additions & 4 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ permissions:

# Allow one concurrent deployment.
concurrency:
group: 'pages'
group: pages
cancel-in-progress: true

# This workflow is adapted from:
Expand All @@ -37,8 +37,8 @@ jobs:
- name: 🔧 Setup Node 20.x
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'pnpm'
node-version-file: .nvmrc
cache: pnpm

- name: 📦 Install dependencies
run: pnpm i
Expand All @@ -52,7 +52,7 @@ jobs:
- name: 📈 Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: './app/website/dist'
path: ./app/website/dist

- name: 📱 Deploy to GitHub Pages
id: deployment
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ jobs:
- name: 🔧 Setup Node 20.x
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'pnpm'
node-version-file: .nvmrc
cache: pnpm

- name: 📦 Install dependencies
run: pnpm i
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ jobs:
- name: 🔧 Setup Node 20.x
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'pnpm'
node-version-file: .nvmrc
cache: pnpm

- name: 📦 Install dependencies
run: pnpm i
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ jobs:
- name: 🔧 Setup Node 20.x
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'pnpm'
node-version-file: .nvmrc
cache: pnpm

- name: 📦 Install dependencies
run: pnpm i
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20.12
22.4
5 changes: 0 additions & 5 deletions .prettierignore

This file was deleted.

4 changes: 0 additions & 4 deletions .prettierrc

This file was deleted.

6 changes: 3 additions & 3 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"vue.volar",
"csstools.postcss",
"stylelint.vscode-stylelint"
]
"csstools.postcss"
],
"unwantedRecommendations": []
}
60 changes: 57 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
{
"editor.defaultFormatter": "esbenp.prettier-vscode",

/*
"editor.codeActionsOnSave": {
"source.fixAll": "explicit"
},
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"eslint.validate": ["javascript", "typescript", "vue"],
"stylelint.enable": true,
*/

"eslint.useFlatConfig": true,
"typescript.tsdk": "./node_modules/typescript/lib",
"typescript.enablePromptUseWorkspaceTsdk": true,
"files.exclude": {
Expand All @@ -17,5 +21,55 @@
"**/node_modules": true,
"lib": true,
"dist/": true
}
},

// Ant-fu
// https://github.com/antfu/eslint-config

// Disable the default formatter, use eslint instead
"prettier.enable": false,
"editor.formatOnSave": false,

// Auto fix
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit",
"source.organizeImports": "never"
},

// Silence the stylistic rules in you IDE, but still auto fix them
"eslint.rules.customizations": [
{ "rule": "style/*", "severity": "off", "fixable": true },
{ "rule": "format/*", "severity": "off", "fixable": true },
{ "rule": "*-indent", "severity": "off", "fixable": true },
{ "rule": "*-spacing", "severity": "off", "fixable": true },
{ "rule": "*-spaces", "severity": "off", "fixable": true },
{ "rule": "*-order", "severity": "off", "fixable": true },
{ "rule": "*-dangle", "severity": "off", "fixable": true },
{ "rule": "*-newline", "severity": "off", "fixable": true },
{ "rule": "*quotes", "severity": "off", "fixable": true },
{ "rule": "*semi", "severity": "off", "fixable": true }
],

// Enable eslint for all supported languages
"eslint.validate": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact",
"vue",
"html",
"markdown",
"json",
"jsonc",
"yaml",
"toml",
"xml",
"gql",
"graphql",
"astro",
"css",
"scss",
"pcss",
"postcss"
]
}
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Earwurm

[![License: ISC](https://img.shields.io/badge/License-ISC-blue.svg)](https://opensource.org/licenses/ISC)
[![Mutable.ai Auto Wiki](https://img.shields.io/badge/Auto_Wiki-Mutable.ai-blue)](https://wiki.mutable.ai/beefchimi/earwurm)

> `Earwurm` is a minimal-scope library for managing `webm` audio files using the [`Web Audio API`](https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API).
Expand All @@ -25,6 +26,8 @@ pnpm add earwurm

**Initializing a global instance:**

<!-- eslint-skip -->

```ts
import {Earwurm, type ManagerConfig} from 'earwurm';

Expand Down
19 changes: 1 addition & 18 deletions app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,4 @@ All marketing and demo apps are located in this folder.

## Eslint

At the moment, we are allowing each `app` to manage their own `eslint` config. We may later decide to move this to the root level `.eslintrc`. If so, we should be able to clearly specify `Vue` config like so:

```json
"overrides": [
{
"files": "*.vue",
"parser": "vue-eslint-parser",
"extends": [
"plugin:vue/vue3-essential",
"eslint:recommended",
"@vue/eslint-config-typescript",
"@vue/eslint-config-prettier/skip-formatting",
],
"plugins": [],
"rules": {}
}
],
```
At the moment, we are linting/formatting the entire monorepo from the root `eslint.config.mjs`. In the future, we may use a dedicated `/websites/eslint.config.mjs`.
34 changes: 0 additions & 34 deletions app/website/.eslintrc.cjs

This file was deleted.

60 changes: 60 additions & 0 deletions app/website/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,63 @@
# 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": []
}
```
Loading

0 comments on commit fba1989

Please sign in to comment.