Skip to content

Commit

Permalink
chore: lint with @antfu/eslint-config but format with Prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
johannschopplich committed Nov 24, 2023
1 parent e5988a4 commit f00f9a0
Show file tree
Hide file tree
Showing 6 changed files with 561 additions and 648 deletions.
30 changes: 26 additions & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,31 @@
{
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
// Enable ESLint flat config support
"eslint.experimental.useFlatConfig": true,

// Use Pretter as the default formatter
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"eslint.validate": ["javascript", "javascriptreact", "vue"],

// Auto-fix ESLint errors on save
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit",
"source.organizeImports": "never"
},

// Enable ESLint for all supported languages
"eslint.validate": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact",
"vue",
"html",
"markdown",
"json",
"jsonc",
"yaml"
],

// Translations
"i18n-ally.localesPaths": ["locales"]
}
2 changes: 1 addition & 1 deletion components/Kirby/UuidResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default defineComponent({
},
setup(props, { slots }) {
if (!Array.isArray(props.collection)) {
throw new Error('Invalid prop: "collection" must be an array.')
throw new TypeError('Invalid prop: "collection" must be an array.')
}

const data = reactive({
Expand Down
23 changes: 23 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import antfu from '@antfu/eslint-config'
import unocss from '@unocss/eslint-config/flat'

export default [
unocss,
...(await antfu(
{
stylistic: false,
ignores: ['tsconfig.json'],
},
{
rules: {
'node/prefer-global/buffer': 'off',
'node/prefer-global/process': 'off',
// Ignore rules clashing with Prettier
'vue/html-closing-bracket-newline': 'off',
'vue/html-indent': 'off',
'vue/html-self-closing': 'off',
'vue/singleline-html-element-content-newline': 'off',
},
},
)),
]
22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,22 @@
{
"private": true,
"type": "module",
"packageManager": "pnpm@8.10.5",
"private": true,
"packageManager": "pnpm@8.11.0",
"scripts": {
"dev": "nuxi dev",
"dev:tunnel": "nuxi dev --tunnel",
"build": "nuxi build",
"generate": "nuxi generate",
"preview": "nuxi preview",
"lint": "eslint . --ignore-path .gitignore",
"lint:fix": "eslint . --fix --ignore-path .gitignore",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"format": "prettier \"**/*.{css,html,json,md,mjs,ts,vue,yml}\" --write",
"format:check": "prettier \"**/*.{css,html,json,md,mjs,ts,vue,yml}\" --check",
"test:types": "vue-tsc --noEmit",
"prepare": "simple-git-hooks && nuxi prepare"
},
"lint-staged": {
"**/*.{ts,vue}": "eslint --cache --ignore-path .gitignore"
},
"simple-git-hooks": {
"pre-commit": "npx lint-staged"
},
"devDependencies": {
"@byjohann/eslint-config": "^0.3.0",
"@antfu/eslint-config": "^2.1.0",
"@nuxtjs/i18n": "8.0.0-rc.5",
"@sindresorhus/slugify": "^2.2.1",
"@types/node": "^20.9.4",
Expand All @@ -37,5 +31,11 @@
"simple-git-hooks": "^2.9.0",
"typescript": "^5.2.2",
"vue-tsc": "^1.8.22"
},
"simple-git-hooks": {
"pre-commit": "npx lint-staged"
},
"lint-staged": {
"**/*.{ts,vue}": "eslint --cache"
}
}
1 change: 1 addition & 0 deletions plugins/site.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export default defineNuxtPlugin(async (nuxtApp) => {
) => {
if (oldLocale !== newLocale) {
if (import.meta.dev)
// eslint-disable-next-line no-console
console.log('Locale changed:', oldLocale, '->', newLocale)

await updateSite(newLocale)
Expand Down
Loading

0 comments on commit f00f9a0

Please sign in to comment.