Skip to content

Commit

Permalink
chore: migrate to antfu eslint config and drop prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Mar 7, 2024
1 parent 65297b3 commit 6738dac
Show file tree
Hide file tree
Showing 20 changed files with 1,128 additions and 211 deletions.
16 changes: 0 additions & 16 deletions .eslintrc.cjs

This file was deleted.

4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/---bug-report.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: "\U0001F41B Bug report"
name: 🐛 Bug report
description: Something's not working
labels: ["bug"]
labels: [bug]
body:
- type: textarea
validations:
Expand Down
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/---documentation.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: "\U0001F4DA Documentation"
name: 📚 Documentation
description: How do I ... ?
labels: ["documentation"]
labels: [documentation]
body:
- type: textarea
validations:
Expand Down
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/---feature-suggestion.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: "\U0001F195 Feature suggestion"
name: 🆕 Feature suggestion
description: Suggest an idea
labels: ["enhancement"]
labels: [enhancement]
body:
- type: textarea
validations:
Expand Down
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/---help-wanted.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: "\U0001F198 Help"
name: 🆘 Help
description: I need help with ...
labels: ["help"]
labels: [help]
body:
- type: textarea
validations:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: 18
cache: 'pnpm'
cache: pnpm

- name: 📦 Install dependencies
run: pnpm install
Expand All @@ -35,7 +35,7 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: 18
cache: 'pnpm'
cache: pnpm

- name: 📦 Install dependencies
run: pnpm install
Expand Down
15 changes: 7 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,13 @@ yarn add -D fontaine
```js
import { FontaineTransform } from 'fontaine'

// Astro config - astro.config.mjs
import { defineConfig } from 'astro/config'

const options = {
fallbacks: ['BlinkMacSystemFont', 'Segoe UI', 'Helvetica Neue', 'Arial', 'Noto Sans'],
// You may need to resolve assets like `/fonts/Roboto.woff2` to a particular directory
resolvePath: (id) => 'file:///path/to/public/dir' + id,
resolvePath: id => `file:///path/to/public/dir${id}`,
// overrideName: (originalName) => `${name} override`
// sourcemap: false
// skipFontFaceGeneration: (fallbackName) => fallbackName === 'Roboto override'
Expand Down Expand Up @@ -83,9 +86,9 @@ function fontainePlugin(_context, _options) {
plugins: [
fontaine.FontaineTransform.webpack(options),
],
};
}
},
};
}
}

// Gatsby config - gatsby-node.js
Expand All @@ -97,17 +100,13 @@ exports.onCreateWebpackConfig = ({ stage, actions, getConfig }) => {
actions.replaceWebpackConfig(config)
}

// Astro config - astro.config.mjs
import { defineConfig } from 'astro/config'
import { FontaineTransform } from 'fontaine'

export default defineConfig({
integrations: [],
vite: {
plugins: [
FontaineTransform.vite({
fallbacks: ['Arial'],
resolvePath: (id) => new URL(`./public${id}`, import.meta.url), // id is the font src value in the CSS
resolvePath: id => new URL(`./public${id}`, import.meta.url), // id is the font src value in the CSS
}),
],
},
Expand Down
3 changes: 3 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import antfu from '@antfu/eslint-config'

export default antfu()
7 changes: 0 additions & 7 deletions lint-staged.config.cjs

This file was deleted.

33 changes: 19 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
{
"name": "fontaine",
"type": "module",
"version": "0.4.1",
"packageManager": "[email protected]",
"description": "Automatic font fallback based on font metrics",
"author": {
"name": "Daniel Roe <[email protected]>",
"url": "https://github.com/danielroe"
},
"license": "MIT",
"repository": "unjs/fontaine",
"keywords": [
"fonts",
"cls",
"web-vitals",
"performance"
],
"author": {
"name": "Daniel Roe <[email protected]>",
"url": "https://github.com/danielroe"
},
"license": "MIT",
"sideEffects": false,
"type": "module",
"exports": {
".": {
"import": "./dist/index.mjs",
Expand All @@ -33,12 +34,8 @@
"dev": "vitest",
"demo": "vite dev playground",
"demo:dev": "pnpm demo --config test/vite.config.mjs",
"lint": "pnpm lint:all:eslint && pnpm lint:all:prettier",
"lint:all:eslint": "pnpm lint:eslint --ext .ts,.js,.mjs,.cjs .",
"lint:all:prettier": "pnpm lint:prettier \"{src,test}/**/*.{js,json,ts}\"",
"lint:eslint": "eslint --fix",
"lint:prettier": "prettier --write --log-level warn",
"prepare": "husky install && pnpm build",
"lint": "eslint --fix .",
"prepare": "simple-git-hooks install && pnpm build",
"prepublishOnly": "pnpm lint && pnpm test",
"release": "pnpm test && bumpp && npm publish",
"test": "vitest run"
Expand All @@ -53,6 +50,7 @@
"unplugin": "^1.8.3"
},
"devDependencies": {
"@antfu/eslint-config": "^2.8.0",
"@nuxtjs/eslint-config-typescript": "latest",
"@types/node": "20.11.25",
"@types/serve-handler": "6.1.4",
Expand All @@ -65,10 +63,10 @@
"eslint-plugin-prettier": "latest",
"execa": "8.0.1",
"get-port-please": "3.1.2",
"husky": "latest",
"lint-staged": "15.2.2",
"prettier": "latest",
"serve-handler": "6.1.5",
"simple-git-hooks": "^2.10.0",
"typescript": "5.4.2",
"unbuild": "latest",
"vite": "5.1.5",
Expand All @@ -77,5 +75,12 @@
"resolutions": {
"fontaine": "link:."
},
"packageManager": "[email protected]"
"simple-git-hooks": {
"pre-commit": "npx lint-staged"
},
"lint-staged": {
"*.{js,ts,mjs,cjs,json,.*rc}": [
"pnpm eslint --fix"
]
}
}
2 changes: 1 addition & 1 deletion playground/vite.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default defineConfig({
FontaineTransform.vite({
fallbacks: ['Arial'],
// resolve absolute URL -> file
resolvePath: id => new URL('.' + id, import.meta.url),
resolvePath: id => new URL(`.${id}`, import.meta.url),
}),
],
})
Loading

0 comments on commit 6738dac

Please sign in to comment.